|
Lines 110-120
Link Here
|
| 110 |
assertFalse( manager.isCallBackRequestBlocked() ); |
110 |
assertFalse( manager.isCallBackRequestBlocked() ); |
| 111 |
assertFalse( thread.isAlive() ); |
111 |
assertFalse( thread.isAlive() ); |
| 112 |
} |
112 |
} |
|
|
113 |
|
| 114 |
public void testWakeWithoutPendingUICallbackReleasesNextUICallback() throws Exception { |
| 115 |
Throwable[] uiCallBackServiceHandlerThrowable = { null }; |
| 116 |
ServiceContext context = ContextProvider.getContext(); |
| 113 |
|
117 |
|
|
|
118 |
manager.forceWakeClient(); |
| 119 |
simulateUiCallBackRequest( uiCallBackServiceHandlerThrowable, context ); |
| 120 |
|
| 121 |
assertNull( uiCallBackServiceHandlerThrowable[ 0 ] ); |
| 122 |
assertFalse( manager.isCallBackRequestBlocked() ); |
| 123 |
} |
| 124 |
|
| 114 |
public void testWaitOnUIThread() throws Exception { |
125 |
public void testWaitOnUIThread() throws Exception { |
| 115 |
final Throwable[] uiCallBackServiceHandlerThrowable = { null }; |
126 |
final Throwable[] uiCallBackServiceHandlerThrowable = { null }; |
| 116 |
ServiceContext context = ContextProvider.getContext(); |
127 |
ServiceContext context = ContextProvider.getContext(); |
| 117 |
simulateUiCallBackThread( uiCallBackServiceHandlerThrowable, context ); |
128 |
simulateUiCallBackRequest( uiCallBackServiceHandlerThrowable, context ); |
| 118 |
assertNull( uiCallBackServiceHandlerThrowable[ 0 ] ); |
129 |
assertNull( uiCallBackServiceHandlerThrowable[ 0 ] ); |
| 119 |
display.wake(); |
130 |
display.wake(); |
| 120 |
assertTrue( manager.isCallBackRequestBlocked() ); |
131 |
assertTrue( manager.isCallBackRequestBlocked() ); |
|
Lines 124-130
Link Here
|
| 124 |
public void testWaitOnBackgroundThread() throws Throwable { |
135 |
public void testWaitOnBackgroundThread() throws Throwable { |
| 125 |
final Throwable[] uiCallBackServiceHandlerThrowable = { null }; |
136 |
final Throwable[] uiCallBackServiceHandlerThrowable = { null }; |
| 126 |
ServiceContext context = ContextProvider.getContext(); |
137 |
ServiceContext context = ContextProvider.getContext(); |
| 127 |
simulateUiCallBackThread( uiCallBackServiceHandlerThrowable, context ); |
138 |
simulateUiCallBackRequest( uiCallBackServiceHandlerThrowable, context ); |
| 128 |
assertNull( uiCallBackServiceHandlerThrowable[ 0 ] ); |
139 |
assertNull( uiCallBackServiceHandlerThrowable[ 0 ] ); |
| 129 |
assertTrue( manager.isCallBackRequestBlocked() ); |
140 |
assertTrue( manager.isCallBackRequestBlocked() ); |
| 130 |
Runnable runnable = new Runnable() { |
141 |
Runnable runnable = new Runnable() { |
|
Lines 141-147
Link Here
|
| 141 |
public void testWaitOnBackgroundThread_DuringLifecycle() throws Exception { |
152 |
public void testWaitOnBackgroundThread_DuringLifecycle() throws Exception { |
| 142 |
final Throwable[] uiCallBackServiceHandlerThrowable = { null }; |
153 |
final Throwable[] uiCallBackServiceHandlerThrowable = { null }; |
| 143 |
ServiceContext context = ContextProvider.getContext(); |
154 |
ServiceContext context = ContextProvider.getContext(); |
| 144 |
simulateUiCallBackThread( uiCallBackServiceHandlerThrowable, context ); |
155 |
simulateUiCallBackRequest( uiCallBackServiceHandlerThrowable, context ); |
| 145 |
assertNull( uiCallBackServiceHandlerThrowable[ 0 ] ); |
156 |
assertNull( uiCallBackServiceHandlerThrowable[ 0 ] ); |
| 146 |
assertTrue( manager.isCallBackRequestBlocked() ); |
157 |
assertTrue( manager.isCallBackRequestBlocked() ); |
| 147 |
Thread thread = new Thread( new Runnable() { |
158 |
Thread thread = new Thread( new Runnable() { |
|
Lines 185-191
Link Here
|
| 185 |
public void testCallBackRequestBlocking() throws Exception { |
196 |
public void testCallBackRequestBlocking() throws Exception { |
| 186 |
final Throwable[] uiCallBackServiceHandlerThrowable = { null }; |
197 |
final Throwable[] uiCallBackServiceHandlerThrowable = { null }; |
| 187 |
ServiceContext context = ContextProvider.getContext(); |
198 |
ServiceContext context = ContextProvider.getContext(); |
| 188 |
simulateUiCallBackThread( uiCallBackServiceHandlerThrowable, context ); |
199 |
simulateUiCallBackRequest( uiCallBackServiceHandlerThrowable, context ); |
| 189 |
assertNull( uiCallBackServiceHandlerThrowable[ 0 ] ); |
200 |
assertNull( uiCallBackServiceHandlerThrowable[ 0 ] ); |
| 190 |
assertTrue( manager.isCallBackRequestBlocked() ); |
201 |
assertTrue( manager.isCallBackRequestBlocked() ); |
| 191 |
} |
202 |
} |
|
Lines 194-200
Link Here
|
| 194 |
final Throwable[] uiCallBackServiceHandlerThrowable = { null }; |
205 |
final Throwable[] uiCallBackServiceHandlerThrowable = { null }; |
| 195 |
ServiceContext context = ContextProvider.getContext(); |
206 |
ServiceContext context = ContextProvider.getContext(); |
| 196 |
Thread uiCallBackThread |
207 |
Thread uiCallBackThread |
| 197 |
= simulateUiCallBackThread( uiCallBackServiceHandlerThrowable, context ); |
208 |
= simulateUiCallBackRequest( uiCallBackServiceHandlerThrowable, context ); |
| 198 |
simulateBackgroundAddition( context ); |
209 |
simulateBackgroundAddition( context ); |
| 199 |
assertFalse( manager.isCallBackRequestBlocked() ); |
210 |
assertFalse( manager.isCallBackRequestBlocked() ); |
| 200 |
assertFalse( uiCallBackThread.isAlive() ); |
211 |
assertFalse( uiCallBackThread.isAlive() ); |
|
Lines 204-210
Link Here
|
| 204 |
public void testCallBackRequestIsReleasedOnSessionInvalidate() throws Exception { |
215 |
public void testCallBackRequestIsReleasedOnSessionInvalidate() throws Exception { |
| 205 |
Throwable[] uiCallBackHandlerThrowable = { null }; |
216 |
Throwable[] uiCallBackHandlerThrowable = { null }; |
| 206 |
ServiceContext context = ContextProvider.getContext(); |
217 |
ServiceContext context = ContextProvider.getContext(); |
| 207 |
Thread uiCallBackThread = simulateUiCallBackThread( uiCallBackHandlerThrowable, context ); |
218 |
Thread uiCallBackThread = simulateUiCallBackRequest( uiCallBackHandlerThrowable, context ); |
| 208 |
|
219 |
|
| 209 |
context.getSessionStore().getHttpSession().invalidate(); |
220 |
context.getSessionStore().getHttpSession().invalidate(); |
| 210 |
uiCallBackThread.join(); |
221 |
uiCallBackThread.join(); |
|
Lines 233-242
Link Here
|
| 233 |
manager.setRequestCheckInterval( 20 ); |
244 |
manager.setRequestCheckInterval( 20 ); |
| 234 |
ServiceContext context1 = ContextProvider.getContext(); |
245 |
ServiceContext context1 = ContextProvider.getContext(); |
| 235 |
Throwable[] uiCallBackHandlerThrowable1 = { null }; |
246 |
Throwable[] uiCallBackHandlerThrowable1 = { null }; |
| 236 |
Thread uiCallBackThread1 = simulateUiCallBackThread( uiCallBackHandlerThrowable1, context1 ); |
247 |
Thread uiCallBackThread1 = simulateUiCallBackRequest( uiCallBackHandlerThrowable1, context1 ); |
| 237 |
ServiceContext context2 = createServiceContext( context1.getSessionStore().getHttpSession() ); |
248 |
ServiceContext context2 = createServiceContext( context1.getSessionStore().getHttpSession() ); |
| 238 |
Throwable[] uiCallBackHandlerThrowable2 = { null }; |
249 |
Throwable[] uiCallBackHandlerThrowable2 = { null }; |
| 239 |
Thread uiCallBackThread2 = simulateUiCallBackThread( uiCallBackHandlerThrowable2, context2 ); |
250 |
Thread uiCallBackThread2 = simulateUiCallBackRequest( uiCallBackHandlerThrowable2, context2 ); |
| 240 |
|
251 |
|
| 241 |
Thread.sleep( SLEEP_TIME ); |
252 |
Thread.sleep( SLEEP_TIME ); |
| 242 |
|
253 |
|
|
Lines 261-267
Link Here
|
| 261 |
}; |
272 |
}; |
| 262 |
ServiceContext context2 = createServiceContext( httpSession, response ); |
273 |
ServiceContext context2 = createServiceContext( httpSession, response ); |
| 263 |
Throwable[] uiCallBackHandlerThrowable = { null }; |
274 |
Throwable[] uiCallBackHandlerThrowable = { null }; |
| 264 |
Thread uiCallBackThread = simulateUiCallBackThread( uiCallBackHandlerThrowable, context2 ); |
275 |
Thread uiCallBackThread = simulateUiCallBackRequest( uiCallBackHandlerThrowable, context2 ); |
| 265 |
|
276 |
|
| 266 |
Thread.sleep( SLEEP_TIME ); |
277 |
Thread.sleep( SLEEP_TIME ); |
| 267 |
|
278 |
|
|
Lines 275-281
Link Here
|
| 275 |
ServiceContext context = ContextProvider.getContext(); |
286 |
ServiceContext context = ContextProvider.getContext(); |
| 276 |
// test runnables addition while no uiCallBack thread is not blocked |
287 |
// test runnables addition while no uiCallBack thread is not blocked |
| 277 |
Thread uiCallBackThread |
288 |
Thread uiCallBackThread |
| 278 |
= simulateUiCallBackThread( uiCallBackServiceHandlerThrowable, context ); |
289 |
= simulateUiCallBackRequest( uiCallBackServiceHandlerThrowable, context ); |
| 279 |
manager.notifyUIThreadEnd(); |
290 |
manager.notifyUIThreadEnd(); |
| 280 |
simulateBackgroundAddition( context ); |
291 |
simulateBackgroundAddition( context ); |
| 281 |
fakeRequestParam( display ); |
292 |
fakeRequestParam( display ); |
|
Lines 564-570
Link Here
|
| 564 |
} |
575 |
} |
| 565 |
} |
576 |
} |
| 566 |
|
577 |
|
| 567 |
private Thread simulateUiCallBackThread( |
578 |
private Thread simulateUiCallBackRequest( |
| 568 |
final Throwable[] uiCallBackServiceHandlerThrowable, |
579 |
final Throwable[] uiCallBackServiceHandlerThrowable, |
| 569 |
final ServiceContext context ) |
580 |
final ServiceContext context ) |
| 570 |
throws InterruptedException |
581 |
throws InterruptedException |