Skip to content

Commit

Permalink
Merge pull request #497 from aubi/remove-asynchronous-context-switch-…
Browse files Browse the repository at this point in the history
…tests

Removing Tests of Context Switch from Asynchronous Tests
  • Loading branch information
aubi authored May 18, 2024
2 parents d2fc015 + a06b655 commit e5f5e61
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -663,20 +664,17 @@ public void testScheduledAsynchIgnoresMaxAsync() throws Throwable {
AtomicInteger counter = new AtomicInteger();

try {
IntContext.set(22); //Context should be cleared

executor.runAsync(task);
executor.runAsync(task);
CompletableFuture<Integer> future = appBean.scheduledEvery3Seconds(1, counter);


assertEquals(Integer.valueOf(0), results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS),
"ManagedExecutorService with maxAsync=1 must be able to run an async task.");

assertEquals(null, results.poll(1, TimeUnit.SECONDS),
"ManagedExecutorService with maxAsync=1 must not run 2 async tasks concurrently.");

assertEquals(Integer.valueOf(0), future.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS),
assertNotNull(future.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS),
"ManagedExecutorService with maxAsync=1 must be able to run scheduled async methods concurrently.");
} finally {
IntContext.set(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,15 +763,13 @@ public void testScheduledAsynchIgnoresMaxAsync() throws Throwable {
AtomicInteger counter = new AtomicInteger();

try {
IntContext.set(22); //Context should be cleared

executor.runAsync(task);
executor.runAsync(task);
executor.runAsync(task);
executor.runAsync(task);
executor.runAsync(task);

CompletableFuture<Integer> future = reqBean.scheduledEvery3Seconds(1, counter);


assertEquals(Integer.valueOf(0), results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS),
"ManagedScheduledExecutorService with maxAsync=4 must be able to run one async task.");
Expand All @@ -788,7 +786,7 @@ public void testScheduledAsynchIgnoresMaxAsync() throws Throwable {
assertEquals(null, results.poll(1, TimeUnit.SECONDS),
"ManagedScheduledExecutorService with maxAsync=4 must not run 5 async tasks concurrently.");

assertEquals(Integer.valueOf(0), future.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS),
assertNotNull(future.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS),
"ManagedScheduledExecutorService with maxAsync=4 must be able to run scheduled async methods concurrently.");
} finally {
IntContext.set(0);
Expand Down

0 comments on commit e5f5e61

Please sign in to comment.