KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > task > test > TestTaskService


1 package org.exoplatform.services.task.test;
2
3 import org.exoplatform.container.PortalContainer;
4 import org.exoplatform.services.task.TaskService;
5 import org.exoplatform.services.task.BaseTask;
6 import org.exoplatform.test.BasicTestCase;
7
8 /**
9  * Copyright 2001-2003 The eXo platform SARL All rights reserved.
10  * Please look at license.txt in info directory for more license detail.
11  **/

12
13 /**
14  * Created by the Exo Development team.
15  * Author : Mestrallet Benjamin
16  * benjmestrallet@users.sourceforge.net
17  * Date: 14 nov. 2003
18  * Time: 22:31:20
19  */

20 public class TestTaskService extends BasicTestCase {
21
22   TaskService service_ ;
23
24   public TestTaskService(String JavaDoc name) {
25     super(name);
26   }
27
28     protected String JavaDoc getDescription() {
29         return "Log service test";
30     }
31
32     public void setUp() throws Exception JavaDoc {
33     setTestNumber(1) ;
34     PortalContainer manager = PortalContainer.getInstance();
35     service_ = (TaskService) manager.getComponentInstanceOfType(TaskService.class) ;
36   }
37
38   public void tearDown() throws Exception JavaDoc { }
39
40     public void testTaskService() throws Exception JavaDoc {
41     for(int i = 0; i < 10 ; i++) {
42       service_.queueTask(new MockTask("task - " + i)) ;
43     }
44     
45     for(int i = 0; i < 5 ; i++) {
46       service_.queueRepeatTask(new MockTask("repeast task - " + i)) ;
47     }
48     
49     Thread.sleep(6500) ;
50     }
51   
52   static class MockTask extends BaseTask {
53     private String JavaDoc task_ ;
54     
55     public MockTask(String JavaDoc task) { task_ = task ; }
56     
57     public void execute() {
58       System.out.println("execute mock task : " + task_) ;
59     }
60
61     public String JavaDoc getName() { return "Mock task"; }
62
63     public String JavaDoc getDescription() { return "A mock task"; }
64     
65   }
66 }
Popular Tags