@Test
  public void whenBarrierCommitted_thenIgnored() {
    VetoCommitBarrier barrier = new VetoCommitBarrier();
    barrier.vetoCommit();

    barrier.vetoCommit();
    assertTrue(barrier.isCommitted());
  }
  @Test
  public void whenPendingTransactions() {
    VetoCommitBarrier barrier = new VetoCommitBarrier();

    IntRef ref1 = new IntRef();
    IntRef ref2 = new IntRef();
    IntRef ref3 = new IntRef();

    IncThread thread1 = new IncThread(ref1, barrier);
    IncThread thread2 = new IncThread(ref2, barrier);
    IncThread thread3 = new IncThread(ref3, barrier);

    startAll(thread1, thread2, thread3);

    sleepMs(500);
    barrier.vetoCommit();
    joinAll(thread1, thread2, thread3);

    assertIsCommitted(thread1.tx);
    assertIsCommitted(thread2.tx);
    assertIsCommitted(thread3.tx);

    assertEquals(1, ref1.get());
    assertEquals(1, ref2.get());
    assertEquals(1, ref3.get());
  }
  @Test
  public void whenNoPendingTransactions() {
    VetoCommitBarrier barrier = new VetoCommitBarrier();
    barrier.vetoCommit();

    assertTrue(barrier.isCommitted());
  }
  @Test
  public void whenBarrierAborted_thenCommitBarrierOpenException() {
    VetoCommitBarrier barrier = new VetoCommitBarrier();
    barrier.abort();

    try {
      barrier.vetoCommit();
      fail();
    } catch (CommitBarrierOpenException expected) {
    }
    assertTrue(barrier.isAborted());
  }