1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.config;
12
13 import org.mule.config.ThreadingProfile;
14 import org.mule.tck.AbstractMuleTestCase;
15
16 import edu.emory.mathcs.backport.java.util.concurrent.RejectedExecutionHandler;
17 import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor;
18
19 public class ThreadingProfileTestCase extends AbstractMuleTestCase
20 {
21
22 public void testCustomRejectedExecutionHandler()
23 {
24 RejectedExecutionHandler handler = new RejectedExecutionHandler()
25 {
26 public void rejectedExecution(Runnable arg0, ThreadPoolExecutor arg1)
27 {
28
29 }
30 };
31
32 ThreadingProfile profile = new ThreadingProfile();
33 profile.setRejectedExecutionHandler(handler);
34 ThreadPoolExecutor pool = profile.createPool("testPool");
35 assertSame(handler, pool.getRejectedExecutionHandler());
36 }
37
38 public void testPoolExhaustedActionStrings()
39 {
40 ThreadingProfile tp = new ThreadingProfile();
41
42 tp.setPoolExhaustedActionString(null);
43 assertEquals(ThreadingProfile.DEFAULT_POOL_EXHAUST_ACTION, tp.getPoolExhaustedAction());
44
45 tp.setPoolExhaustedActionString("BAZ");
46 assertEquals(ThreadingProfile.DEFAULT_POOL_EXHAUST_ACTION, tp.getPoolExhaustedAction());
47
48 tp.setPoolExhaustedActionString("WHEN_EXHAUSTED_WAIT");
49 assertEquals(ThreadingProfile.WHEN_EXHAUSTED_WAIT, tp.getPoolExhaustedAction());
50 tp.setPoolExhaustedActionString("WAIT");
51 assertEquals(ThreadingProfile.WHEN_EXHAUSTED_WAIT, tp.getPoolExhaustedAction());
52
53 tp.setPoolExhaustedActionString("WHEN_EXHAUSTED_DISCARD");
54 assertEquals(ThreadingProfile.WHEN_EXHAUSTED_DISCARD, tp.getPoolExhaustedAction());
55 tp.setPoolExhaustedActionString("DISCARD");
56 assertEquals(ThreadingProfile.WHEN_EXHAUSTED_DISCARD, tp.getPoolExhaustedAction());
57
58 tp.setPoolExhaustedActionString("WHEN_EXHAUSTED_DISCARD_OLDEST");
59 assertEquals(ThreadingProfile.WHEN_EXHAUSTED_DISCARD_OLDEST, tp.getPoolExhaustedAction());
60 tp.setPoolExhaustedActionString("DISCARD_OLDEST");
61 assertEquals(ThreadingProfile.WHEN_EXHAUSTED_DISCARD_OLDEST, tp.getPoolExhaustedAction());
62
63 tp.setPoolExhaustedActionString("WHEN_EXHAUSTED_ABORT");
64 assertEquals(ThreadingProfile.WHEN_EXHAUSTED_ABORT, tp.getPoolExhaustedAction());
65 tp.setPoolExhaustedActionString("ABORT");
66 assertEquals(ThreadingProfile.WHEN_EXHAUSTED_ABORT, tp.getPoolExhaustedAction());
67
68 tp.setPoolExhaustedActionString("WHEN_EXHAUSTED_RUN");
69 assertEquals(ThreadingProfile.WHEN_EXHAUSTED_RUN, tp.getPoolExhaustedAction());
70 tp.setPoolExhaustedActionString("RUN");
71 assertEquals(ThreadingProfile.WHEN_EXHAUSTED_RUN, tp.getPoolExhaustedAction());
72 }
73
74 }