BAEL-20599: Increase blocking operations' time
This commit is contained in:
parent
7d88ce8e4a
commit
0dc6b27fa6
|
@ -31,7 +31,7 @@ public class SaturationPolicyUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void givenAbortPolicy_WhenSaturated_ThenShouldThrowRejectedExecutionException() {
|
public void givenAbortPolicy_WhenSaturated_ThenShouldThrowRejectedExecutionException() {
|
||||||
executor = new ThreadPoolExecutor(1, 1, 0, MILLISECONDS, new SynchronousQueue<>(), new AbortPolicy());
|
executor = new ThreadPoolExecutor(1, 1, 0, MILLISECONDS, new SynchronousQueue<>(), new AbortPolicy());
|
||||||
executor.execute(() -> waitFor(100));
|
executor.execute(() -> waitFor(250));
|
||||||
|
|
||||||
assertThatThrownBy(() -> executor.execute(() -> System.out.println("Will be rejected"))).isInstanceOf(RejectedExecutionException.class);
|
assertThatThrownBy(() -> executor.execute(() -> System.out.println("Will be rejected"))).isInstanceOf(RejectedExecutionException.class);
|
||||||
}
|
}
|
||||||
|
@ -39,13 +39,13 @@ public class SaturationPolicyUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void givenCallerRunsPolicy_WhenSaturated_ThenTheCallerThreadRunsTheTask() {
|
public void givenCallerRunsPolicy_WhenSaturated_ThenTheCallerThreadRunsTheTask() {
|
||||||
executor = new ThreadPoolExecutor(1, 1, 0, MILLISECONDS, new SynchronousQueue<>(), new CallerRunsPolicy());
|
executor = new ThreadPoolExecutor(1, 1, 0, MILLISECONDS, new SynchronousQueue<>(), new CallerRunsPolicy());
|
||||||
executor.execute(() -> waitFor(100));
|
executor.execute(() -> waitFor(250));
|
||||||
|
|
||||||
long startTime = System.nanoTime();
|
long startTime = System.currentTimeMillis();
|
||||||
executor.execute(() -> waitFor(100));
|
executor.execute(() -> waitFor(500));
|
||||||
double blockedDuration = (System.nanoTime() - startTime) / 1_000_000.0;
|
long blockedDuration = System.currentTimeMillis() - startTime;
|
||||||
|
|
||||||
assertThat(blockedDuration).isGreaterThanOrEqualTo(100);
|
assertThat(blockedDuration).isGreaterThanOrEqualTo(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue