use of org.pentaho.platform.scheduler2.quartz.QuartzScheduler in project pentaho-platform by pentaho.
the class QuartzSchedulerIT method testGetJobs.
@Test
public void testGetJobs() throws SchedulerException {
QuartzScheduler testGetJobsSchduler = new QuartzScheduler();
Assert.assertEquals(0, testGetJobsSchduler.getJobs(null).size());
String PARAM_KEY = "testGetJobsKey";
jobParams.put(PARAM_KEY, "testParam1-value");
Calendar calendar = Calendar.getInstance();
int startingMin = calendar.get(Calendar.MINUTE);
int startingSec = calendar.get(Calendar.SECOND) + 10;
if (startingSec > 59) {
startingSec = startingSec % 60;
startingMin++;
if (startingMin > 59) {
startingMin = startingMin % 60;
}
}
calendar.set(Calendar.MINUTE, startingMin);
calendar.set(Calendar.SECOND, startingSec);
SimpleJobTrigger jobTrigger = new SimpleJobTrigger(calendar.getTime(), null, 0, 0);
testGetJobsSchduler.createJob("getJobsTestJob", TestAction.class, jobParams, jobTrigger);
List<Job> jobs = testGetJobsSchduler.getJobs(null);
Assert.assertEquals(1, jobs.size());
Job theJob = jobs.get(0);
Assert.assertTrue(theJob.getJobParams().containsKey(PARAM_KEY));
Assert.assertTrue(theJob.getJobName().contains("getJobsTestJob"));
}
use of org.pentaho.platform.scheduler2.quartz.QuartzScheduler in project pentaho-platform by pentaho.
the class JaxWsSchedulerServiceIT method testUpdateComplexJob.
/*
public static class TestQuartzScheduler extends QuartzScheduler {
@Override
protected String getCurrentUser() {
SecurityHelper.getInstance().becomeUser( TEST_USER );
return super.getCurrentUser();
}
}
*/
@Test(timeout = 1000 * 5 * 60)
public void testUpdateComplexJob() throws SchedulerException {
long start = System.currentTimeMillis() + 1000;
long end = System.currentTimeMillis() + 1000 + 5 * 60 * 60 * 100;
int startingMinute = (Calendar.getInstance().get(Calendar.MINUTE) + 10) % 60;
ComplexJobTrigger jobTrigger = new ComplexJobTrigger();
jobTrigger.setStartTime(new Date(start));
jobTrigger.setEndTime(new Date(end));
jobTrigger.setMinuteRecurrence(new IncrementalRecurrence(startingMinute, 1));
jobTrigger.setHourlyRecurrence((ITimeRecurrence) null);
System.out.println(jobTrigger.toString());
String jobId = schedulerSvc.createComplexJob("test job", jobParams, jobTrigger);
Assert.assertEquals(1, schedulerSvc.getJobs().length);
jobTrigger = new ComplexJobTrigger();
start = System.currentTimeMillis() + 2 * 1000;
end = System.currentTimeMillis() + 1000 + 7 * 60 * 60 * 100;
jobTrigger.setStartTime(new Date(start));
jobTrigger.setEndTime(new Date(end));
startingMinute = (Calendar.getInstance().get(Calendar.MINUTE) + 20) % 60;
jobTrigger.setMinuteRecurrence(new IncrementalRecurrence(startingMinute, 5));
jobTrigger.setHourlyRecurrence((ITimeRecurrence) null);
System.out.println(jobTrigger.toString());
HashMap<String, ParamValue> newJobParams = new HashMap<String, ParamValue>(jobParams);
newJobParams.put("newKey", new StringParamValue(""));
schedulerSvc.updateJobToUseComplexTrigger(jobId, newJobParams, jobTrigger);
Assert.assertEquals(1, schedulerSvc.getJobs().length);
Job job = schedulerSvc.getJobs()[0];
jobTrigger = (ComplexJobTrigger) job.getJobTrigger();
Assert.assertEquals((Integer) startingMinute, ((IncrementalRecurrence) jobTrigger.getMinuteRecurrences().get(0)).getStartingValue());
Assert.assertEquals((Integer) 5, ((IncrementalRecurrence) jobTrigger.getMinuteRecurrences().get(0)).getIncrement());
Assert.assertTrue(job.getJobParams().containsKey("newKey"));
Assert.assertEquals(new Date(start), jobTrigger.getStartTime());
Assert.assertEquals(new Date(end), jobTrigger.getEndTime());
}
use of org.pentaho.platform.scheduler2.quartz.QuartzScheduler in project pdi-platform-plugin by pentaho.
the class PdiActionTest method init.
@Before
public void init() throws SchedulerException, PlatformInitializationException {
// $NON-NLS-1$ //$NON-NLS-2$
System.setProperty("java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory");
// $NON-NLS-1$ //$NON-NLS-2$
System.setProperty("org.osjava.sj.root", SOLUTION_REPOSITORY);
// $NON-NLS-1$ //$NON-NLS-2$
System.setProperty("org.osjava.sj.delimiter", "/");
// $NON-NLS-2$
System.setProperty("PENTAHO_SYS_CFG_PATH", new File(SOLUTION_REPOSITORY + "/pentaho.xml").getAbsolutePath());
IPentahoSession session = new StandaloneSession();
PentahoSessionHolder.setSession(session);
scheduler = new QuartzScheduler();
scheduler.start();
mp.define(IUserRoleListService.class, StubUserRoleListService.class);
mp.define(UserDetailsService.class, StubUserDetailService.class);
mp.defineInstance(IAuthorizationPolicy.class, new TestAuthorizationPolicy());
mp.setSettingsProvider(new PathBasedSystemSettings());
mp.defineInstance(IScheduler.class, scheduler);
mp.define(ISolutionEngine.class, SolutionEngine.class);
FileSystemBackedUnifiedRepository repo = new FileSystemBackedUnifiedRepository(SOLUTION_REPOSITORY);
mp.defineInstance(IUnifiedRepository.class, repo);
mp.start();
SecurityHelper.getInstance().becomeUser(TEST_USER);
}
use of org.pentaho.platform.scheduler2.quartz.QuartzScheduler in project pdi-platform-plugin by pentaho.
the class PdiContentGeneratorTest method setUp.
@Before
public void setUp() throws Exception {
// $NON-NLS-1$ //$NON-NLS-2$
System.setProperty("java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory");
// $NON-NLS-1$ //$NON-NLS-2$
System.setProperty("org.osjava.sj.root", SOLUTION_REPOSITORY);
// $NON-NLS-1$ //$NON-NLS-2$
System.setProperty("org.osjava.sj.delimiter", "/");
// $NON-NLS-2$
System.setProperty("PENTAHO_SYS_CFG_PATH", new File(SOLUTION_REPOSITORY + "/pentaho.xml").getAbsolutePath());
IPentahoSession session = new StandaloneSession();
PentahoSessionHolder.setSession(session);
pdiContentGenerator = new PdiContentGenerator();
pdiAction = new PdiAction();
pdiAction.setRepositoryName(KettleFileRepositoryMeta.REPOSITORY_TYPE_ID);
pdiContentGenerator.setPdiAction(pdiAction);
outputStream = mock(OutputStream.class);
repositoryFile = mock(RepositoryFile.class);
pdiContentGenerator.setOutputStream(outputStream);
pdiContentGenerator.setRepositoryFile(repositoryFile);
scheduler = new QuartzScheduler();
scheduler.start();
mp.define(IUserRoleListService.class, StubUserRoleListService.class);
mp.define(UserDetailsService.class, StubUserDetailService.class);
mp.defineInstance(IAuthorizationPolicy.class, new TestAuthorizationPolicy());
mp.defineInstance(IScheduler.class, scheduler);
mp.define(ISolutionEngine.class, SolutionEngine.class);
FileSystemBackedUnifiedRepository repo = new FileSystemBackedUnifiedRepository(SOLUTION_REPOSITORY);
mp.defineInstance(IUnifiedRepository.class, repo);
mp.start();
}
use of org.pentaho.platform.scheduler2.quartz.QuartzScheduler in project pentaho-platform by pentaho.
the class QuartzSchedulerIT method init.
@Before
public void init() throws SchedulerException, PlatformInitializationException {
scheduler = new QuartzScheduler();
scheduler.start();
TestAction.reset();
TestAction2.reset();
TestAction3.reset();
TestActionCustomParam.reset();
MicroPlatform mp = new MicroPlatform();
// $NON-NLS-1$
mp.define("IScheduler2", TestQuartzScheduler.class);
mp.define(IUserRoleListService.class, StubUserRoleListService.class);
mp.define(UserDetailsService.class, StubUserDetailsService.class);
mp.define(IAuditEntry.class, TestAuditEntry.class);
mp.start();
SecurityHelper.getInstance().becomeUser(TEST_USER);
jobParams = new HashMap<String, Serializable>();
}
Aggregations