public void testOnRemoveCallsDispose() throws Exception { MuleDescriptor descriptor = getTestDescriptor("test", "java.lang.Object"); UMOModel model = new SedaModel(); CommonsPoolProxyFactory factory = new CommonsPoolProxyFactory(descriptor, model); CommonsPoolProxyPool pool = new CommonsPoolProxyPool(descriptor, model, factory, new PoolingProfile()); factory.setPool(pool); Object obj = factory.makeObject(); factory.destroyObject(obj); // if calling dispose throws an IllegalStateException it means // the component has already been disposed by the pool. boolean exceptionWasThrown = false; try { ((MuleProxy) obj).dispose(); } catch (IllegalStateException isex) { assertEquals("Component has already been disposed of", isex.getMessage()); exceptionWasThrown = true; } if (!exceptionWasThrown) { fail("Expected exception has never been thrown. Was the component disposed before?"); } }
public ObjectFactory getProxyFactory(MuleDescriptor descriptor, ObjectPool pool) { CommonsPoolProxyFactory factory = new CommonsPoolProxyFactory(descriptor); factory.setPool(pool); return factory; }