Search in sources :

Example 31 with JobExecution

use of org.springframework.batch.core.JobExecution in project tutorials by eugenp.

the class SpringbatchPartitionerApp method main.

public static void main(final String[] args) {
    // Spring Java config
    final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.register(SpringbatchPartitionConfig.class);
    context.refresh();
    final JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
    final Job job = (Job) context.getBean("partitionerJob");
    System.out.println("Starting the batch job");
    try {
        final JobExecution execution = jobLauncher.run(job, new JobParameters());
        System.out.println("Job Status : " + execution.getStatus());
        System.out.println("Job succeeded");
    } catch (final Exception e) {
        e.printStackTrace();
        System.out.println("Job failed");
    }
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) JobLauncher(org.springframework.batch.core.launch.JobLauncher) JobParameters(org.springframework.batch.core.JobParameters) Job(org.springframework.batch.core.Job)

Example 32 with JobExecution

use of org.springframework.batch.core.JobExecution in project tutorials by eugenp.

the class ChunksTest method givenChunksJob_WhenJobEnds_ThenStatusCompleted.

@Test
public void givenChunksJob_WhenJobEnds_ThenStatusCompleted() throws Exception {
    JobExecution jobExecution = jobLauncherTestUtils.launchJob();
    Assert.assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus());
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) Test(org.junit.Test)

Example 33 with JobExecution

use of org.springframework.batch.core.JobExecution in project spring-boot by spring-projects.

the class JobExecutionExitCodeGeneratorTests method testExitCodeForCompleted.

@Test
void testExitCodeForCompleted() {
    JobExecution execution = new JobExecution(0L);
    execution.setStatus(BatchStatus.COMPLETED);
    this.generator.onApplicationEvent(new JobExecutionEvent(execution));
    assertThat(this.generator.getExitCode()).isEqualTo(0);
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) Test(org.junit.jupiter.api.Test)

Example 34 with JobExecution

use of org.springframework.batch.core.JobExecution in project head by mifos.

the class LoanArrearsTaskIntegrationTest method testExecute.

@Test
public void testExecute() throws Exception {
    int statusChangeHistorySize = loanAccount.getAccountStatusChangeHistory().size();
    mifosScheduler.runIndividualTask(jobName);
    Thread.sleep(1500);
    JobExplorer explorer = mifosScheduler.getBatchJobExplorer();
    List<JobInstance> jobInstances = explorer.getJobInstances(jobName, 0, 10);
    Assert.assertEquals(1, jobInstances.size());
    JobInstance lastInstance = jobInstances.get(0);
    List<JobExecution> jobExecutions = explorer.getJobExecutions(lastInstance);
    Assert.assertEquals(1, jobExecutions.size());
    JobExecution lastExecution = jobExecutions.get(0);
    Assert.assertEquals(BatchStatus.COMPLETED, lastExecution.getStatus());
    StaticHibernateUtil.getSessionTL().refresh(loanAccount);
    loanAccount = legacyAccountDao.getAccount(loanAccount.getAccountId());
    Assert.assertEquals(AccountState.LOAN_ACTIVE_IN_BAD_STANDING, loanAccount.getState());
    Assert.assertEquals(statusChangeHistorySize + 1, loanAccount.getAccountStatusChangeHistory().size());
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) JobInstance(org.springframework.batch.core.JobInstance) JobExplorer(org.springframework.batch.core.explore.JobExplorer) Test(org.junit.Test)

Example 35 with JobExecution

use of org.springframework.batch.core.JobExecution in project head by mifos.

the class ProductStatusHelperIntegrationTest method testExecuteTask.

@Test
public void testExecuteTask() throws Exception {
    createInactiveLoanOffering();
    mifosScheduler = getMifosScheduler("org/mifos/framework/components/batchjobs/productStatusTestTask.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.COMPLETED, lastExecution.getStatus());
    product = (LoanOfferingBO) TestObjectFactory.getObject(LoanOfferingBO.class, product.getPrdOfferingId());
    Assert.assertEquals(PrdStatus.LOAN_ACTIVE, product.getStatus());
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) JobInstance(org.springframework.batch.core.JobInstance) JobExplorer(org.springframework.batch.core.explore.JobExplorer) Test(org.junit.Test)

Aggregations

JobExecution (org.springframework.batch.core.JobExecution)75 JobParameters (org.springframework.batch.core.JobParameters)52 JobParameter (org.springframework.batch.core.JobParameter)42 HashMap (java.util.HashMap)41 Test (org.testng.annotations.Test)36 AbstractTest (cz.mzk.recordmanager.server.AbstractTest)30 InputStream (java.io.InputStream)25 Job (org.springframework.batch.core.Job)16 Date (java.util.Date)15 JobInstance (org.springframework.batch.core.JobInstance)14 Test (org.junit.Test)12 ByteArrayInputStream (java.io.ByteArrayInputStream)11 JobExplorer (org.springframework.batch.core.explore.JobExplorer)11 HarvestedRecord (cz.mzk.recordmanager.server.model.HarvestedRecord)9 OAIHarvestConfiguration (cz.mzk.recordmanager.server.model.OAIHarvestConfiguration)9 JobExecutionFailure (cz.mzk.recordmanager.server.facade.exception.JobExecutionFailure)6 MarcRecord (cz.mzk.recordmanager.server.marc.MarcRecord)5 MarcRecordImpl (cz.mzk.recordmanager.server.marc.MarcRecordImpl)5 Record (org.marc4j.marc.Record)5 JobLauncher (org.springframework.batch.core.launch.JobLauncher)5