CommitRateLimiter implements CommitHook { public void blockCommits() { blockCommits = true; }  void blockCommits(); void unblockCommits(); boolean getBlockCommits(); void setDelay(long delay); @NotNull @Override NodeState processCommit(NodeState before, NodeState after, CommitInfo info); void blockCommit(); void beforeNonBlocking(); void afterNonBlocking(); boolean isThreadBlocking();  }
@Test(expected = CommitFailedException.class) public void blockCommits() throws CommitFailedException, InterruptedException { final CountDownLatch latch = new CountDownLatch(1); CommitRateLimiter limiter = new CommitRateLimiter() { @Override public boolean getBlockCommits() { latch.countDown(); return super.getBlockCommits(); } }; limiter.blockCommits(); final Thread mainThread = Thread.currentThread(); Thread t = new Thread() { @Override public void run() { try { latch.await(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } mainThread.interrupt(); } }; t.start(); try { limiter.processCommit(EMPTY_NODE, AFTER, null); } finally { try { t.join(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } assertTrue(Thread.interrupted()); } }