@Test public void refreshSchedulerForJobTest() { final String beanName = "schedulerBean"; final JobSchedulerConfiguration jobSchedulerConfiguration = DomainTestHelper.createJobSchedulerConfiguration(null, 10L, 10L, JobSchedulerType.PERIOD); jobSchedulerConfiguration.setBeanName(beanName); jobSchedulerConfiguration.setTaskExecutorType(TaskExecutorType.ASYNCHRONOUS); final JobConfiguration jobConfiguration = DomainTestHelper.createJobConfiguration(jobSchedulerConfiguration); final Map<String, Object> jobParameters = new HashMap<>(); jobParameters.put("LONG", 10L); jobParameters.put("DOUBLE", 20.2); jobParameters.put("STRING", "test"); jobParameters.put("DATE", "2015/03/27 23:19:24:120"); jobParameters.put("DATE", "2015/03/27"); jobConfiguration.setJobParameters(jobParameters); final SchedulerConstructorWrapper schedulerConstructorWrapper = new SchedulerConstructorWrapper(); schedulerConstructorWrapper.setJob(DomainTestHelper.createJob("sampleJob")); schedulerConstructorWrapper.setJobConfiguration(jobConfiguration); schedulerConstructorWrapper.setJobIncrementer(JobIncrementer.NONE); schedulerConstructorWrapper.setJobLauncher(new SimpleJobLauncher()); schedulerConstructorWrapper.setJobParameters(new JobParametersBuilder().toJobParameters()); when(this.applicationContext.containsBean(beanName)).thenReturn(Boolean.TRUE); when(this.applicationContext.getBean(beanName, Scheduler.class)).thenReturn(this.scheduler); when(this.scheduler.getSchedulerStatus()).thenReturn(SchedulerStatus.INITIALIZED); this.schedulerService.refreshSchedulerForJob(jobConfiguration); verify(this.scheduler, times(1)).terminate(); }
@Override public void refreshSchedulerForJob(final JobConfiguration jobConfiguration) { this.terminate(jobConfiguration.getJobSchedulerConfiguration().getBeanName()); this.unregisterSchedulerForJob(jobConfiguration.getJobSchedulerConfiguration().getBeanName()); this.registerSchedulerForJob(jobConfiguration); }
DefaultSchedulerService implements SchedulerService { @Override public void refreshSchedulerForJob(final JobConfiguration jobConfiguration) { this.terminate(jobConfiguration.getJobSchedulerConfiguration().getBeanName()); this.unregisterSchedulerForJob(jobConfiguration.getJobSchedulerConfiguration().getBeanName()); this.registerSchedulerForJob(jobConfiguration); } }
DefaultSchedulerService implements SchedulerService { @Override public void refreshSchedulerForJob(final JobConfiguration jobConfiguration) { this.terminate(jobConfiguration.getJobSchedulerConfiguration().getBeanName()); this.unregisterSchedulerForJob(jobConfiguration.getJobSchedulerConfiguration().getBeanName()); this.registerSchedulerForJob(jobConfiguration); } DefaultSchedulerService(final BeanRegistrar beanRegistrar,
                                   final JobRepository jobRepository,
                                   final JobRegistry jobRegistry); }
DefaultSchedulerService implements SchedulerService { @Override public void refreshSchedulerForJob(final JobConfiguration jobConfiguration) { this.terminate(jobConfiguration.getJobSchedulerConfiguration().getBeanName()); this.unregisterSchedulerForJob(jobConfiguration.getJobSchedulerConfiguration().getBeanName()); this.registerSchedulerForJob(jobConfiguration); } DefaultSchedulerService(final BeanRegistrar beanRegistrar,
                                   final JobRepository jobRepository,
                                   final JobRegistry jobRegistry); @Autowired void setApplicationContext(final ApplicationContext applicationContext); @Override String registerSchedulerForJob(final JobConfiguration jobConfiguration); @Override void unregisterSchedulerForJob(final String beanName); @Override void refreshSchedulerForJob(final JobConfiguration jobConfiguration); @Override void schedule(final String beanName, final Boolean forceScheduling); @Override void terminate(final String beanName); @Override SchedulerStatus getSchedulerStatus(final String beanName); @Override void afterPropertiesSet(); @Override JobLauncher createLobLauncher(final TaskExecutorType taskExecutorType, final JobRepository jobRepository); }
DefaultSchedulerService implements SchedulerService { @Override public void refreshSchedulerForJob(final JobConfiguration jobConfiguration) { this.terminate(jobConfiguration.getJobSchedulerConfiguration().getBeanName()); this.unregisterSchedulerForJob(jobConfiguration.getJobSchedulerConfiguration().getBeanName()); this.registerSchedulerForJob(jobConfiguration); } DefaultSchedulerService(final BeanRegistrar beanRegistrar,
                                   final JobRepository jobRepository,
                                   final JobRegistry jobRegistry); @Autowired void setApplicationContext(final ApplicationContext applicationContext); @Override String registerSchedulerForJob(final JobConfiguration jobConfiguration); @Override void unregisterSchedulerForJob(final String beanName); @Override void refreshSchedulerForJob(final JobConfiguration jobConfiguration); @Override void schedule(final String beanName, final Boolean forceScheduling); @Override void terminate(final String beanName); @Override SchedulerStatus getSchedulerStatus(final String beanName); @Override void afterPropertiesSet(); @Override JobLauncher createLobLauncher(final TaskExecutorType taskExecutorType, final JobRepository jobRepository);  }