Author: david.lloyd(a)jboss.com
Date: 2008-11-19 15:23:47 -0500 (Wed, 19 Nov 2008)
New Revision: 4712
Modified:
remoting3/trunk/api/src/test/java/org/jboss/remoting/spi/CloseableTestCase.java
Log:
Implement testHandlerRemoval() test
Modified: remoting3/trunk/api/src/test/java/org/jboss/remoting/spi/CloseableTestCase.java
===================================================================
---
remoting3/trunk/api/src/test/java/org/jboss/remoting/spi/CloseableTestCase.java 2008-11-19
20:07:11 UTC (rev 4711)
+++
remoting3/trunk/api/src/test/java/org/jboss/remoting/spi/CloseableTestCase.java 2008-11-19
20:23:47 UTC (rev 4712)
@@ -32,6 +32,7 @@
import org.jboss.xnio.IoUtils;
import org.jboss.xnio.log.Logger;
import org.jboss.remoting.CloseHandler;
+import org.jboss.remoting.HandleableCloseable;
import org.jboss.remoting.test.support.LoggingHelper;
/**
@@ -184,13 +185,21 @@
}
public void testHandlerRemoval() throws Throwable {
+ final AtomicBoolean handlerCalled = new AtomicBoolean();
final Executor executor = IoUtils.directExecutor();
final AbstractAutoCloseable<Object> closeable = new
AbstractAutoCloseable<Object>(executor) {
// empty
};
final Handle<Object> rootHandle = closeable.getHandle();
try {
- // todo - something with that rootHandle
+ final HandleableCloseable.Key key = closeable.addCloseHandler(new
CloseHandler<Object>() {
+ public void handleClose(final Object closed) {
+ handlerCalled.set(true);
+ }
+ });
+ key.remove();
+ closeable.close();
+ assertFalse(handlerCalled.get());
} finally {
IoUtils.safeClose(closeable);
}