@Test public void testGetNextJobParametersRestartable(){ this.job.setRestartable(true); this.job.setJobParametersIncrementer(new RunIdIncrementer()); this.jobInstanceList.add(new JobInstance(1L, "simpleJobInstance")); this.jobExecutionList.add(getJobExecution(this.jobInstanceList.get(0), BatchStatus.FAILED)); when(this.jobExplorer.getJobInstances("simpleJob",0,1)).thenReturn(this.jobInstanceList); when(this.jobExplorer.getJobExecutions(any())).thenReturn(this.jobExecutionList); initializeForNextJobParameters(); this.parametersBuilder.addLong("NON_IDENTIFYING_LONG", new Long(1), false); this.parametersBuilder.getNextJobParameters(this.job); baseJobParametersVerify(this.parametersBuilder.toJobParameters(), 5); }
/** * Execution context should be restored on restart. */ @Test public void testRestartAndExecutionContextRestored() throws Exception { job.setRestartable(true); step1.setAllowStartIfComplete(true); final RuntimeException exception = new RuntimeException("Foo!"); step2.setProcessException(exception); job.execute(jobExecution); assertEquals(1, jobExecution.getAllFailureExceptions().size()); Throwable e = jobExecution.getAllFailureExceptions().get(0); assertSame(exception, e); assertTrue(step1.passedInJobContext.isEmpty()); assertFalse(step2.passedInJobContext.isEmpty()); assertFalse(jobExecution.getExecutionContext().isEmpty()); jobExecution = jobRepository.createJobExecution(job.getName(), jobParameters); job.execute(jobExecution); assertEquals(1, jobExecution.getAllFailureExceptions().size()); e = jobExecution.getAllFailureExceptions().get(0); assertSame(exception, e); assertFalse(step1.passedInJobContext.isEmpty()); assertFalse(step2.passedInJobContext.isEmpty()); }