|
50 | 50 | import java.util.concurrent.TimeUnit; |
51 | 51 | import java.util.stream.Collectors; |
52 | 52 |
|
53 | | -import static com.exactpro.th2.common.utils.ExecutorServiceUtilsKt.shutdownGracefully; |
54 | 53 | import static org.junit.jupiter.api.Assertions.assertArrayEquals; |
55 | 54 | import static org.junit.jupiter.api.Assertions.assertEquals; |
56 | 55 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
57 | 56 | import static org.junit.jupiter.api.Assertions.assertNull; |
| 57 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
58 | 58 | import static org.mockito.ArgumentMatchers.any; |
59 | 59 | import static org.mockito.Mockito.after; |
60 | 60 | import static org.mockito.Mockito.doReturn; |
@@ -206,7 +206,7 @@ public void testEventResubmittedLimitedTimes() throws IOException, CradleStorage |
206 | 206 |
|
207 | 207 | @Test |
208 | 208 | @DisplayName("Event persistence is queued by count") |
209 | | - public void testEventCountQueueing() throws IOException, CradleStorageException { |
| 209 | + public void testEventCountQueueing() throws IOException, CradleStorageException, InterruptedException { |
210 | 210 |
|
211 | 211 | final long storeExecutionTime = EVENT_PERSIST_TIMEOUT * 3; |
212 | 212 | final long totalExecutionTime = EVENT_PERSIST_TIMEOUT * 5; |
@@ -236,13 +236,14 @@ public void testEventCountQueueing() throws IOException, CradleStorageException |
236 | 236 | verify(callback, after(totalExecutionTime).times(totalEvents)).onSuccess(any()); |
237 | 237 | verify(callback, after(totalExecutionTime).times(0)).onFail(any()); |
238 | 238 |
|
239 | | - shutdownGracefully(executor, 1, TimeUnit.SECONDS); |
| 239 | + executor.shutdown(); |
| 240 | + assertTrue(executor.awaitTermination(1, TimeUnit.SECONDS), "Executor didn't terminate according to a timeout"); |
240 | 241 | } |
241 | 242 |
|
242 | 243 |
|
243 | 244 | @Test |
244 | 245 | @DisplayName("Event persistence is queued by event sizes") |
245 | | - public void testEventSizeQueueing() throws IOException, CradleStorageException { |
| 246 | + public void testEventSizeQueueing() throws IOException, CradleStorageException, InterruptedException { |
246 | 247 |
|
247 | 248 | final long storeExecutionTime = EVENT_PERSIST_TIMEOUT * 3; |
248 | 249 | final long totalExecutionTime = EVENT_PERSIST_TIMEOUT * 6; |
@@ -283,7 +284,8 @@ public void testEventSizeQueueing() throws IOException, CradleStorageException { |
283 | 284 | verify(callback, after(totalExecutionTime).times(totalEvents)).onSuccess(any()); |
284 | 285 | verify(callback, after(totalExecutionTime).times(0)).onFail(any()); |
285 | 286 |
|
286 | | - shutdownGracefully(executor, 1, TimeUnit.SECONDS); |
| 287 | + executor.shutdown(); |
| 288 | + assertTrue(executor.awaitTermination(1, TimeUnit.SECONDS), "Executor didn't terminate according to a timeout"); |
287 | 289 | } |
288 | 290 |
|
289 | 291 |
|
|
0 commit comments