|
39 | 39 | import software.aws.solution.clickstream.client.ClickstreamContext; |
40 | 40 | import software.aws.solution.clickstream.client.ClickstreamManager; |
41 | 41 | import software.aws.solution.clickstream.client.Event; |
| 42 | +import software.aws.solution.clickstream.client.EventRecorder; |
42 | 43 | import software.aws.solution.clickstream.client.ScreenRefererTool; |
43 | 44 | import software.aws.solution.clickstream.client.db.ClickstreamDBUtil; |
44 | 45 | import software.aws.solution.clickstream.client.util.StringUtil; |
45 | 46 | import software.aws.solution.clickstream.util.ReflectUtil; |
46 | 47 |
|
47 | 48 | import java.util.ArrayList; |
48 | 49 | import java.util.List; |
| 50 | +import java.util.concurrent.ExecutorService; |
| 51 | +import java.util.concurrent.ThreadPoolExecutor; |
49 | 52 |
|
50 | 53 | import static org.junit.Assert.assertEquals; |
51 | 54 | import static org.junit.Assert.assertFalse; |
@@ -411,6 +414,23 @@ public void testHandleAppStart() throws Exception { |
411 | 414 | } |
412 | 415 | } |
413 | 416 |
|
| 417 | + /** |
| 418 | + * test case for app move to background with flush event. |
| 419 | + * |
| 420 | + * @throws Exception exception. |
| 421 | + */ |
| 422 | + @Test |
| 423 | + public void testBackgroundRequest() throws Exception { |
| 424 | + lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_START); |
| 425 | + Thread.sleep(1100); |
| 426 | + lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_STOP); |
| 427 | + EventRecorder eventRecorder = |
| 428 | + (EventRecorder) ReflectUtil.getFiled(clickstreamContext.getAnalyticsClient(), "eventRecorder"); |
| 429 | + ExecutorService executorService = |
| 430 | + (ExecutorService) ReflectUtil.getFiled(eventRecorder, "submissionRunnableQueue"); |
| 431 | + assertEquals(1, ((ThreadPoolExecutor) executorService).getActiveCount()); |
| 432 | + } |
| 433 | + |
414 | 434 | /** |
415 | 435 | * test init autoRecordEventClient with null analyticsClient. |
416 | 436 | */ |
|
0 commit comments