1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.config;
12
13 import org.mule.config.PoolingProfile;
14 import org.mule.config.pool.CommonsPoolProxyFactory;
15 import org.mule.config.pool.CommonsPoolProxyPool;
16 import org.mule.impl.MuleDescriptor;
17 import org.mule.impl.model.MuleProxy;
18 import org.mule.impl.model.seda.SedaModel;
19 import org.mule.tck.AbstractMuleTestCase;
20 import org.mule.umo.model.UMOModel;
21
22 public class CommonsPoolProxyPoolTestCase extends AbstractMuleTestCase
23 {
24
25 public void testOnRemoveCallsDispose() throws Exception
26 {
27 MuleDescriptor descriptor = getTestDescriptor("test", "java.lang.Object");
28 UMOModel model = new SedaModel();
29 CommonsPoolProxyFactory factory = new CommonsPoolProxyFactory(descriptor, model);
30 CommonsPoolProxyPool pool = new CommonsPoolProxyPool(descriptor, model, factory, new PoolingProfile());
31 factory.setPool(pool);
32
33 Object obj = factory.makeObject();
34 factory.destroyObject(obj);
35
36
37
38 boolean exceptionWasThrown = false;
39 try
40 {
41 ((MuleProxy)obj).dispose();
42 }
43 catch (IllegalStateException isex)
44 {
45 assertEquals("Component has already been disposed of", isex.getMessage());
46 exceptionWasThrown = true;
47 }
48
49 if (!exceptionWasThrown)
50 {
51 fail("Expected exception has never been thrown. Was the component disposed before?");
52 }
53 }
54 }