@Test
public void testLockingOptimisticUpdateAndRead() throws Exception {
resetCountDownLatches();
List<Movie> movies = movieBean.listMovies();
assertFalse(movies.isEmpty());
final CountDownLatch testCountDownLatch = new CountDownLatch(1);
executor.execute(new Runnable() {
@Override
public void run() {
movieBean.updateMovie(3, "INCEPTION UR");
testCountDownLatch.countDown();
}
});
executor.execute(new Runnable() {
@Override
public void run() {
movieBean.findMovie(3);
MovieBeanAlternative.lockCountDownLatch.countDown();
}
});
assertTrue(testCountDownLatch.await(10, TimeUnit.SECONDS));
assertEquals("INCEPTION UR", movieBean.findMovie(3).getName());
}