/** * Checks whether any of the data buffers created by {@link #bufferFactory} have not been * released, throwing an assertion error if so. */ @After public final void checkForLeaks() { this.bufferFactory.checkForLeaks(); }
@Test public void noLeak() { DataBuffer dataBuffer = this.bufferFactory.allocateBuffer(); release(dataBuffer); this.bufferFactory.checkForLeaks(); }
@Test public void leak() { DataBuffer dataBuffer = this.bufferFactory.allocateBuffer(); try { this.bufferFactory.checkForLeaks(); fail("AssertionError expected"); } catch (AssertionError expected) { // ignore } finally { release(dataBuffer); } }