1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.spring;
12
13 import org.mule.api.service.Service;
14 import org.mule.component.PooledJavaComponent;
15 import org.mule.config.PoolingProfile;
16 import org.mule.tck.FunctionalTestCase;
17
18 public class PoolingProfileTestCase extends FunctionalTestCase
19 {
20 protected String getConfigResources()
21 {
22 return "pooling-profile-test.xml";
23 }
24
25 public void testDefault()
26 {
27 doTest("default", PoolingProfile.DEFAULT_POOL_EXHAUSTED_ACTION,
28 PoolingProfile.DEFAULT_POOL_INITIALISATION_POLICY,
29 PoolingProfile.DEFAULT_MAX_POOL_ACTIVE,
30 PoolingProfile.DEFAULT_MAX_POOL_IDLE,
31 PoolingProfile.DEFAULT_MAX_POOL_WAIT);
32 }
33
34 public void testFailAll()
35 {
36 doTest("fail_all", PoolingProfile.WHEN_EXHAUSTED_FAIL,
37 PoolingProfile.INITIALISE_ALL, 1, 2, 3);
38 }
39
40 public void testGrowOne()
41 {
42 doTest("grow_one", PoolingProfile.WHEN_EXHAUSTED_GROW,
43 PoolingProfile.INITIALISE_ONE, 2, 3, 4);
44 }
45
46 public void testWaitNone()
47 {
48 doTest("wait_none", PoolingProfile.WHEN_EXHAUSTED_WAIT,
49 PoolingProfile.INITIALISE_NONE, 3, 4, 5);
50 }
51
52 protected void doTest(String service, int exhausted, int initialisation,
53 int active, int idle, long wait)
54 {
55 Service c = muleContext.getRegistry().lookupService(service);
56 assertNotNull(service, c);
57 assertTrue(c.getComponent() instanceof PooledJavaComponent);
58 PooledJavaComponent pjc = (PooledJavaComponent)c.getComponent();
59 PoolingProfile profile = pjc.getPoolingProfile();
60 assertNotNull(profile);
61 assertEquals("exhausted:", exhausted, profile.getExhaustedAction());
62 assertEquals("initialisation:", initialisation, profile.getInitialisationPolicy());
63 assertEquals("active:", active, profile.getMaxActive());
64 assertEquals("idle:", idle, profile.getMaxIdle());
65 assertEquals("wait:", wait, profile.getMaxWait());
66 }
67 }