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 12 13 20 public class TestTaskService extends BasicTestCase { 21 22 TaskService service_ ; 23 24 public TestTaskService(String name) { 25 super(name); 26 } 27 28 protected String getDescription() { 29 return "Log service test"; 30 } 31 32 public void setUp() throws Exception { 33 setTestNumber(1) ; 34 PortalContainer manager = PortalContainer.getInstance(); 35 service_ = (TaskService) manager.getComponentInstanceOfType(TaskService.class) ; 36 } 37 38 public void tearDown() throws Exception { } 39 40 public void testTaskService() throws Exception { 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 task_ ; 54 55 public MockTask(String task) { task_ = task ; } 56 57 public void execute() { 58 System.out.println("execute mock task : " + task_) ; 59 } 60 61 public String getName() { return "Mock task"; } 62 63 public String getDescription() { return "A mock task"; } 64 65 } 66 } | Popular Tags |