BAEL-19699: Fix core-java-concurrency-basic unit tests

This commit is contained in:
Krzysiek 2019-11-25 21:34:15 +01:00
parent e827db3db2
commit d5359a58e1
4 changed files with 28 additions and 16 deletions

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -19,8 +19,11 @@ public class ReentrantReadWriteLockCounterUnitTest {
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);
}
}