1
2
3
4
5
6
7
8
9
10
11 package org.mule.mule.commonspool;
12
13 import org.mule.config.pool.CommonsPoolFactory;
14 import org.mule.config.pool.CommonsPoolProxyPool;
15 import org.mule.impl.MuleDescriptor;
16 import org.mule.impl.model.seda.SedaModel;
17 import org.mule.tck.model.AbstractPoolTestCase;
18 import org.mule.umo.lifecycle.InitialisationException;
19 import org.mule.umo.model.UMOPoolFactory;
20 import org.mule.util.ObjectPool;
21
22 import org.apache.commons.pool.impl.GenericObjectPool;
23
24 public class CommonsPoolTestCase extends AbstractPoolTestCase
25 {
26
27
28
29
30
31
32
33 public ObjectPool createPool(MuleDescriptor descriptor, byte action) throws InitialisationException
34 {
35 GenericObjectPool.Config config = new GenericObjectPool.Config();
36 config.maxActive = DEFAULT_POOL_SIZE;
37 config.maxWait = DEFAULT_WAIT;
38
39 if (action == FAIL_WHEN_EXHAUSTED)
40 {
41 config.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_FAIL;
42 }
43 else if (action == GROW_WHEN_EXHAUSTED)
44 {
45 config.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW;
46 }
47 else if (action == BLOCK_WHEN_EXHAUSTED)
48 {
49 config.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_BLOCK;
50 }
51 else
52 {
53 fail("Action type for pool not recognised. Type is: " + action);
54 }
55 return new CommonsPoolProxyPool(descriptor, new SedaModel(), config);
56 }
57
58 public UMOPoolFactory getPoolFactory()
59 {
60 return new CommonsPoolFactory();
61 }
62
63 }