use of org.springframework.batch.core.JobExecution in project head by mifos.
the class BatchJobCatchUpIntegrationTest method testIncompleteTaskHandling.
@Test
public void testIncompleteTaskHandling() throws Exception {
mifosScheduler = getMifosScheduler("org/mifos/framework/components/batchjobs/catchUpTask2.xml");
JobLauncher jobLauncher = mifosScheduler.getBatchJobLauncher();
JobLocator jobLocator = mifosScheduler.getBatchJobLocator();
for (int i = 0; i < 3; i++) {
jobLauncher.run(jobLocator.getJob(jobName), MifosBatchJob.createJobParameters(new Date().getTime()));
Thread.sleep(1500);
}
JobExplorer explorer = mifosScheduler.getBatchJobExplorer();
List<JobInstance> jobInstances = explorer.getJobInstances(jobName, 0, 10);
Assert.assertEquals(3, jobInstances.size());
for (JobInstance jobInstance : jobInstances) {
List<JobExecution> jobExecutions = explorer.getJobExecutions(jobInstance);
Assert.assertEquals(1, jobExecutions.size());
Assert.assertEquals(BatchStatus.FAILED, jobExecutions.get(0).getStatus());
}
mifosScheduler.runIndividualTask(jobName);
Thread.sleep(5000);
jobInstances = explorer.getJobInstances(jobName, 0, 10);
Assert.assertEquals(4, jobInstances.size());
for (JobInstance jobInstance : jobInstances) {
List<JobExecution> jobExecutions = explorer.getJobExecutions(jobInstance);
Assert.assertEquals(BatchStatus.COMPLETED, jobExecutions.get(0).getStatus());
}
}
use of org.springframework.batch.core.JobExecution in project head by mifos.
the class ProductStatusHelperIntegrationTest method testExecuteTaskFailure.
@Test
public void testExecuteTaskFailure() throws Exception {
createInactiveLoanOffering();
mifosScheduler = getMifosScheduler("org/mifos/framework/components/batchjobs/productStatusTestTask2.xml");
mifosScheduler.runIndividualTask(jobName);
Thread.sleep(1000);
JobExplorer explorer = mifosScheduler.getBatchJobExplorer();
List<JobInstance> jobInstances = explorer.getJobInstances(jobName, 0, 10);
Assert.assertTrue(jobInstances.size() > 0);
JobInstance lastInstance = jobInstances.get(0);
List<JobExecution> jobExecutions = explorer.getJobExecutions(lastInstance);
Assert.assertEquals(1, jobExecutions.size());
JobExecution lastExecution = jobExecutions.get(0);
Assert.assertEquals(BatchStatus.FAILED, lastExecution.getStatus());
product = (LoanOfferingBO) TestObjectFactory.getObject(LoanOfferingBO.class, product.getPrdOfferingId());
Assert.assertEquals(PrdStatus.LOAN_INACTIVE, product.getStatus());
}
use of org.springframework.batch.core.JobExecution in project pinpoint by naver.
the class AlarmJobTest method main.
public static void main(String[] args) throws Exception {
GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext("/applicationContext-test.xml");
JobLauncherTestUtils testLauncher = applicationContext.getBean(JobLauncherTestUtils.class);
JobExecution jobExecution = testLauncher.launchJob(getParameters());
BatchStatus status = jobExecution.getStatus();
assertEquals(BatchStatus.COMPLETED, status);
applicationContext.close();
}
use of org.springframework.batch.core.JobExecution in project spring-boot by spring-projects.
the class JobExecutionExitCodeGeneratorTests method testExitCodeForCompleted.
@Test
public void testExitCodeForCompleted() {
JobExecution execution = new JobExecution(0L);
execution.setStatus(BatchStatus.COMPLETED);
this.generator.onApplicationEvent(new JobExecutionEvent(execution));
assertThat(this.generator.getExitCode()).isEqualTo(0);
}
use of org.springframework.batch.core.JobExecution in project camel by apache.
the class SpringBatchProducer method process.
@Override
public void process(Exchange exchange) throws Exception {
JobParameters jobParameters = prepareJobParameters(exchange.getIn().getHeaders());
String messageJobName = jobParameters.getString(SpringBatchConstants.JOB_NAME);
Job job2run = this.job;
if (messageJobName != null) {
if (jobRegistry != null) {
job2run = jobRegistry.getJob(messageJobName);
} else {
job2run = CamelContextHelper.mandatoryLookup(getEndpoint().getCamelContext(), messageJobName, Job.class);
}
}
if (job2run == null) {
exchange.setException(new CamelExchangeException("jobName was not specified in the endpoint construction " + " and header " + SpringBatchConstants.JOB_NAME + " could not be found", exchange));
return;
}
JobExecution jobExecution = jobLauncher.run(job2run, jobParameters);
exchange.getOut().getHeaders().putAll(exchange.getIn().getHeaders());
exchange.getOut().setBody(jobExecution);
}
Aggregations