use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.
the class QuartzJobKey method parse.
/**
* Parses an existing jobId into a {@link QuartzJobKey}
*
* @param jobId
* an existing jobId
* @return a quartz job key
* @throws SchedulerException
*/
public static QuartzJobKey parse(String jobId) throws SchedulerException {
String delimiter = jobId.contains("\t") || jobId.isEmpty() ? "\t" : ":";
// $NON-NLS-1$
String[] elements = jobId.split(delimiter);
if (elements == null || elements.length < 3) {
throw new SchedulerException(MessageFormat.format(Messages.getInstance().getErrorString("QuartzJobKey.ERROR_0002"), // $NON-NLS-1$
jobId));
}
QuartzJobKey key = new QuartzJobKey();
key.userName = elements[0];
key.jobName = elements[1];
try {
key.timeInMillis = Long.parseLong(elements[2]);
} catch (NumberFormatException ex) {
throw new SchedulerException(MessageFormat.format(Messages.getInstance().getErrorString("QuartzJobKey.ERROR_0002"), // $NON-NLS-1$
jobId));
}
return key;
}
use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.
the class RepositoryCleanerSystemListenerTest method returnsTrue_EvenGetsExceptions.
@Test
public void returnsTrue_EvenGetsExceptions() throws Exception {
when(scheduler.getJobs(any(IJobFilter.class))).thenThrow(new SchedulerException("test exception"));
prepareMp();
assertTrue("The listener should not return false to let the system continue working", listener.startup(null));
}
use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.
the class SchedulerServiceTest method testPauseException.
@Test
public void testPauseException() throws SchedulerException {
doReturn(true).when(schedulerService.policy).isAllowed(SchedulerAction.NAME);
doThrow(new SchedulerException("")).when(schedulerService.scheduler).pause();
try {
schedulerService.pause();
fail();
} catch (SchedulerException e) {
// Should go here
}
verify(schedulerService.policy).isAllowed(SchedulerAction.NAME);
verify(schedulerService.scheduler).pause();
}
use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.
the class SchedulerServiceTest method testResumeJobException.
@Test
public void testResumeJobException() throws SchedulerException {
Job job = mock(Job.class);
doReturn(job).when(schedulerService).getJob(nullable(String.class));
doReturn(true).when(schedulerService).isScheduleAllowed();
doThrow(new SchedulerException("pause-exception")).when(schedulerService.scheduler).resumeJob(nullable(String.class));
try {
schedulerService.resumeJob("job-id");
} catch (SchedulerException e) {
assertEquals("pause-exception", e.getMessage());
}
}
use of org.pentaho.platform.api.scheduler2.SchedulerException in project pentaho-platform by pentaho.
the class SchedulerServiceTest method testResumeJob.
@Test
public void testResumeJob() throws SchedulerException {
Job job = mock(Job.class);
doReturn(job).when(schedulerService).getJob(nullable(String.class));
doReturn(true).when(schedulerService).isScheduleAllowed();
doNothing().when(schedulerService.scheduler).resumeJob(nullable(String.class));
schedulerService.resumeJob("job-id");
}
Aggregations