KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > util > threadpool > TestThreadPool


1 package org.apache.axis2.util.threadpool;
2
3 import org.apache.axis2.AbstractTestCase;
4 import org.apache.axis2.engine.AxisFault;
5
6 import java.util.ArrayList JavaDoc;
7 import java.util.List JavaDoc;
8
9 /**
10  * Created by IntelliJ IDEA.
11  * User: Jaliya
12  * Date: Jun 23, 2005
13  * Time: 3:58:45 PM
14  * To change this template use File | Settings | File Templates.
15  */

16 public class TestThreadPool extends AbstractTestCase {
17     /**
18      * @param testName
19      */

20     public TestThreadPool(String JavaDoc testName) {
21         super(testName);
22     }
23
24     class TestWorker implements AxisWorker {
25         private boolean workDone;
26
27         public void doWork() {
28             workDone = true;
29         }
30
31         public boolean isWorkDone() {
32             return workDone;
33         }
34     }
35
36
37     public void testPool() throws AxisFault {
38         ThreadPool tPool = new ThreadPool();
39         List JavaDoc workerList = new ArrayList JavaDoc();
40
41         for (int i = 0; i < 5; i++) {
42             TestWorker worker = new TestWorker();
43             workerList.add(worker);
44             tPool.addWorker(worker);
45         }
46
47         tPool.safeShutDown();
48
49         for (int i = 0; i < 5; i++) {
50             assertEquals(true, ((TestWorker) workerList.get(i)).isWorkDone());
51         }
52
53     }
54
55 }
56
Popular Tags