@Test public void whenAborted() throws InterruptedException { barrier = new VetoCommitBarrier(); barrier.abort(); boolean success = barrier.tryAwaitOpen(1, TimeUnit.DAYS); assertTrue(barrier.isAborted()); assertTrue(success); }
@Test public void whenBarrierAborted_thenCommitBarrierOpenException() { VetoCommitBarrier barrier = new VetoCommitBarrier(); barrier.abort(); try { barrier.vetoCommit(); fail(); } catch (CommitBarrierOpenException expected) { } assertTrue(barrier.isAborted()); }
@Test public void whenAbortedWhileWaiting() throws InterruptedException { barrier = new VetoCommitBarrier(); TestThread thread = new TestThread() { @Override public void doRun() throws Exception { boolean result = barrier.tryAwaitOpen(1, TimeUnit.DAYS); assertTrue(result); } }; thread.setPrintStackTrace(false); thread.start(); sleepMs(500); barrier.abort(); joinAll(thread); }