CloseableReferenceCount { public void unreferenceCheckClosed() throws ClosedChannelException { int newVal = status.decrementAndGet(); if ((newVal & STATUS_CLOSED_MASK) != 0) { throw new AsynchronousCloseException(); } } CloseableReferenceCount(); void reference(); boolean unreference(); void unreferenceCheckClosed(); boolean isOpen(); int setClosed(); int getReferenceCount();  }
@Test public void testUnreferenceCheckClosed() throws ClosedChannelException { CloseableReferenceCount clr = new CloseableReferenceCount(); clr.reference(); clr.reference(); clr.unreferenceCheckClosed(); assertEquals("Incorrect reference count", 1, clr.getReferenceCount()); }