KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > threadpool > test > TestSimpleThreadPoolService


1 package org.exoplatform.services.threadpool.test;
2
3 import org.exoplatform.container.PortalContainer;
4 import org.exoplatform.services.threadpool.impl.ThreadPoolServiceImpl;
5 import org.exoplatform.test.BasicTestCase;
6
7 /**
8  * Created by the Exo Development team.
9  * Author : Mestrallet Benjamin
10  * benjamin.mestrallet@exoplatform.com
11  */

12 public class TestSimpleThreadPoolService extends BasicTestCase{
13   private ThreadPoolServiceImpl service_;
14
15   private static int counter = 0;
16
17   public TestSimpleThreadPoolService(String JavaDoc name) {
18     super(name);
19   }
20
21   protected String JavaDoc getDescription() {
22     return "Test the Thread pool service";
23   }
24
25     public void setUp() throws Exception JavaDoc {
26       PortalContainer manager = PortalContainer.getInstance();
27         service_ =
28             (ThreadPoolServiceImpl) manager.getComponentInstanceOfType(ThreadPoolServiceImpl.class) ;
29     }
30
31   public void testSimpleThreadPoolService() throws InterruptedException JavaDoc {
32     service_.setMaximumPoolSize(10);
33     for(int i= 0; i < 20; i++){
34       Runnable JavaDoc r = new SimpleRunnable();
35       service_.execute(r);
36     }
37   }
38
39   public class SimpleRunnable implements Runnable JavaDoc {
40     public void run() {
41       System.out.println("In run method of for threads number : " + counter);
42       counter++;
43     }
44   }
45 }
46
Popular Tags