Merge pull request #8252 from kwoyke/BAEL-19699
BAEL-19699: Fix core-java-concurrency-basic unit tests
This commit is contained in:
commit
fc27da10b9
|
@ -19,7 +19,10 @@ public class CounterUnitTest {
|
|||
Future<Integer> future1 = (Future<Integer>) executorService.submit(new CounterCallable(counter));
|
||||
Future<Integer> future2 = (Future<Integer>) executorService.submit(new CounterCallable(counter));
|
||||
|
||||
assertThat(future1.get()).isEqualTo(1);
|
||||
assertThat(future2.get()).isEqualTo(2);
|
||||
// Just to make sure both are completed
|
||||
future1.get();
|
||||
future2.get();
|
||||
|
||||
assertThat(counter.getCounter()).isEqualTo(2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,10 @@ public class ExtrinsicLockCounterUnitTest {
|
|||
Future<Integer> future1 = (Future<Integer>) executorService.submit(new ExtrinsicLockCounterCallable(counter));
|
||||
Future<Integer> future2 = (Future<Integer>) executorService.submit(new ExtrinsicLockCounterCallable(counter));
|
||||
|
||||
assertThat(future1.get()).isEqualTo(1);
|
||||
assertThat(future2.get()).isEqualTo(2);
|
||||
// Just to make sure both are completed
|
||||
future1.get();
|
||||
future2.get();
|
||||
|
||||
assertThat(counter.getCounter()).isEqualTo(2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,10 @@ public class ReentrantLockCounterUnitTest {
|
|||
Future<Integer> future1 = (Future<Integer>) executorService.submit(new ReentrantLockCounterCallable(counter));
|
||||
Future<Integer> future2 = (Future<Integer>) executorService.submit(new ReentrantLockCounterCallable(counter));
|
||||
|
||||
assertThat(future1.get()).isEqualTo(1);
|
||||
assertThat(future2.get()).isEqualTo(2);
|
||||
// Just to make sure both are completed
|
||||
future1.get();
|
||||
future2.get();
|
||||
|
||||
assertThat(counter.getCounter()).isEqualTo(2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,14 @@ public class ReentrantReadWriteLockCounterUnitTest {
|
|||
public void whenCalledIncrementCounter_thenCorrect() throws Exception {
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(2);
|
||||
ReentrantReadWriteLockCounter counter = new ReentrantReadWriteLockCounter();
|
||||
Future<Integer> future1 = (Future<Integer>) executorService.submit(new ReentranReadWriteLockCounterCallable(counter));
|
||||
Future<Integer> future2 = (Future<Integer>) executorService.submit(new ReentranReadWriteLockCounterCallable(counter));
|
||||
Future<Integer> future1 = (Future<Integer>) executorService.submit(new ReentranReadWriteLockCounterCallable(counter));
|
||||
Future<Integer> future2 = (Future<Integer>) executorService.submit(new ReentranReadWriteLockCounterCallable(counter));
|
||||
|
||||
assertThat(future2.get()).isEqualTo(2);
|
||||
assertThat(future1.get()).isEqualTo(1);
|
||||
// Just to make sure both are completed
|
||||
future1.get();
|
||||
future2.get();
|
||||
|
||||
assertThat(counter.getCounter()).isEqualTo(2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue