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);
}
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");
}
}
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());
}
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 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!!!");
}
}
Aggregations