Search in sources :

Example 71 with JobExecution

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

the class JobExecutionExitCodeGeneratorTests method testExitCodeForFailed.

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

Example 72 with JobExecution

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

the class App method main.

public static void main(final String[] args) {
    // Spring Java config
    final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.register(SpringConfig.class);
    context.register(SpringBatchConfig.class);
    context.refresh();
    // Spring xml config
    // ApplicationContext context = new ClassPathXmlApplicationContext("spring-batch.xml");
    final JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
    final Job job = (Job) context.getBean("firstBatchJob");
    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 73 with JobExecution

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

the class TaskletsTest method givenTaskletsJob_WhenJobEnds_ThenStatusCompleted.

@Test
public void givenTaskletsJob_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 74 with JobExecution

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();
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) BatchStatus(org.springframework.batch.core.BatchStatus) JobLauncherTestUtils(org.springframework.batch.test.JobLauncherTestUtils) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext)

Example 75 with JobExecution

use of org.springframework.batch.core.JobExecution in project nixmash-blog by mintster.

the class GithubJobRunner method runGithubJob.

@Scheduled(fixedRateString = "${github.job.fixed.delay.seconds:60}000")
public void runGithubJob() {
    SimpleDateFormat format = new SimpleDateFormat("M-dd-yy hh:mm:ss");
    String startDateTime = format.format(new Date());
    JobParameters jobParameters = new JobParametersBuilder().addLong("time", System.currentTimeMillis()).toJobParameters();
    try {
        logger.info("");
        logger.info("STARTING GITHUB BATCH JOB : " + startDateTime);
        JobExecution execution = jobLauncher.run(githubJob, jobParameters);
        logger.info("JOB STATUS  : " + execution.getStatus());
    } catch (Exception e) {
        e.printStackTrace();
        logger.info("JOB FAILED!!!");
    }
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) JobParametersBuilder(org.springframework.batch.core.JobParametersBuilder) JobParameters(org.springframework.batch.core.JobParameters) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Scheduled(org.springframework.scheduling.annotation.Scheduled)

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