Search in sources :

Example 1 with SchedulerException

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;
}
Also used : SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException)

Example 2 with SchedulerException

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));
}
Also used : IJobFilter(org.pentaho.platform.api.scheduler2.IJobFilter) SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) Test(org.junit.Test)

Example 3 with SchedulerException

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();
}
Also used : SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) Test(org.junit.Test)

Example 4 with SchedulerException

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());
    }
}
Also used : SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) Job(org.pentaho.platform.api.scheduler2.Job) Test(org.junit.Test)

Example 5 with SchedulerException

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");
}
Also used : Job(org.pentaho.platform.api.scheduler2.Job) Test(org.junit.Test)

Aggregations

SchedulerException (org.pentaho.platform.api.scheduler2.SchedulerException)53 Test (org.junit.Test)49 Job (org.pentaho.platform.api.scheduler2.Job)43 IScheduler (org.pentaho.platform.api.scheduler2.IScheduler)22 ComplexJobTrigger (org.pentaho.platform.api.scheduler2.ComplexJobTrigger)18 Serializable (java.io.Serializable)16 SimpleJobTrigger (org.pentaho.platform.api.scheduler2.SimpleJobTrigger)16 IJobTrigger (org.pentaho.platform.api.scheduler2.IJobTrigger)11 Date (java.util.Date)9 JobTrigger (org.pentaho.platform.api.scheduler2.JobTrigger)9 ArrayList (java.util.ArrayList)8 Scheduler (org.quartz.Scheduler)8 IJobFilter (org.pentaho.platform.api.scheduler2.IJobFilter)7 IOException (java.io.IOException)6 Calendar (java.util.Calendar)6 HashMap (java.util.HashMap)6 CronTrigger (org.quartz.CronTrigger)6 SimpleTrigger (org.quartz.SimpleTrigger)6 Trigger (org.quartz.Trigger)6 Response (javax.ws.rs.core.Response)5