开发者

Junit for Quartz Scheduler

I have created a simple Job using SchedulerFactoryBean for my application. Can anyone please let me know how do I test this Job using Junit and make sure that is working fine for the interval given and the job should be stopped after that. I have created a sample class and have tested its working fine, for stopping this I have to stop/kill the application.

What I want to try using Junit is: The Job call's a method after a required interval, 开发者_运维百科I want to test the return value of the method and other functionalities associated with this method and then the job should be stopped.

 public class First {
   private HashMap myData = null;

   public void reload(){
     myData = calling some method;
   }
}

I will create an instance of First in Junit then sleep for some interval. In between the sleep the reload will be called by the Job and that will fill the myData. Now I need to test the value in myData with Junit.

I created this Job using the below link: http://www.mkyong.com/spring/spring-...duler-example/

Thanks in Advance.

Khan


You can add a code section :while (true) {} to avoid JUnit thread ends. But it's not an recommend method. Because if you use maven or hudson the process will blocked by this method, and the build will failed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜