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 ; 7 import java.util.List ; 8 9 16 public class TestThreadPool extends AbstractTestCase { 17 20 public TestThreadPool(String 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 workerList = new ArrayList (); 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 |