1 package org.apache.commons.jcs3.utils.threadpool;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Properties;
23 import java.util.Set;
24 import java.util.concurrent.ExecutorService;
25
26 import org.apache.commons.jcs3.utils.props.PropertyLoader;
27 import junit.framework.TestCase;
28
29
30
31
32
33 public class ThreadPoolManagerUnitTest
34 extends TestCase
35 {
36
37
38
39
40 public void testDefaultConfig()
41 {
42 final Properties props = PropertyLoader.loadProperties( "thread_pool.properties" );
43 ThreadPoolManager.setProps( props );
44 final ThreadPoolManager mgr = ThreadPoolManager.getInstance();
45 assertNotNull( mgr );
46
47 final ExecutorService pool = mgr.getExecutorService( "test1" );
48 assertNotNull( pool );
49 }
50
51
52
53
54 public void testSpecialConfig()
55 {
56 final Properties props = PropertyLoader.loadProperties( "thread_pool.properties" );
57 ThreadPoolManager.setProps( props );
58 final ThreadPoolManager mgr = ThreadPoolManager.getInstance();
59 assertNotNull( mgr );
60
61 final ExecutorService pool = mgr.getExecutorService( "aborttest" );
62 assertNotNull( pool );
63 }
64
65
66
67
68
69 public void testGetPoolNames()
70 {
71 final ThreadPoolManager mgr = ThreadPoolManager.getInstance();
72 assertNotNull( mgr );
73
74 final String poolName1 = "testGetPoolNames1";
75 mgr.getExecutorService( poolName1 );
76
77 final String poolName2 = "testGetPoolNames2";
78 mgr.getExecutorService( poolName2 );
79
80 final Set<String> names = mgr.getPoolNames();
81 assertTrue( "Should have name in list.", names.contains( poolName1 ) );
82 assertTrue( "Should have name in list.", names.contains( poolName2 ) );
83 }
84 }