单元测试用例
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
*
|
||||
*/
|
||||
package org.redkale.test.scheduling;
|
||||
|
||||
import org.redkale.annotation.Scheduled;
|
||||
import org.redkale.service.Service;
|
||||
import org.redkale.util.Times;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
public class ScheduleService implements Service {
|
||||
|
||||
@Scheduled(cron = "0/1 * * * * ?")
|
||||
public void task1() {
|
||||
System.out.println(Times.nowMillis() + "每秒-----------执行task1");
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0/1 * * * * ?")
|
||||
public String task2() {
|
||||
System.out.println(Times.nowMillis() + "每秒*****执行task2");
|
||||
return "";
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0/1 * * * * ?")
|
||||
private void task3() {
|
||||
System.out.println(Times.nowMillis() + "每秒执行task3");
|
||||
}
|
||||
}
|
||||
31
src/test/java/org/redkale/test/scheduling/ScheduleTest.java
Normal file
31
src/test/java/org/redkale/test/scheduling/ScheduleTest.java
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
*
|
||||
*/
|
||||
package org.redkale.test.scheduling;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.redkale.scheduling.ScheduledFactory;
|
||||
import org.redkale.util.Utility;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
public class ScheduleTest {
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
ScheduleTest test = new ScheduleTest();
|
||||
test.run();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void run() throws Exception {
|
||||
ScheduledFactory factory = ScheduledFactory.create(null);
|
||||
ScheduleService service = new ScheduleService();
|
||||
factory.schedule(service);
|
||||
Utility.sleep(3000);
|
||||
factory.unschedule(service);
|
||||
factory.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user