Junit for Quartz Scheduler

给你一囗甜甜゛ 提交于 2020-02-23 04:35:48

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/5321044/junit-for-quartz-scheduler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!