@Test public void testSaveStepExecutions() { List<StepExecution> stepExecutions = new ArrayList<>(); for (int i = 0; i < 3; i++) { StepExecution stepExecution = new StepExecution("stepName" + i, jobExecution); stepExecutions.add(stepExecution); } jobRepository.addAll(stepExecutions); verify(stepExecutionDao).saveStepExecutions(stepExecutions); verify(ecDao).saveExecutionContexts(stepExecutions); }
@Test public void testSetStepExecutions() throws Exception { assertEquals(0, execution.getStepExecutions().size()); execution.addStepExecutions(Arrays.asList(new StepExecution("step", execution))); assertEquals(1, execution.getStepExecutions().size()); }
@Test public void testSaveOrUpdateStepExecutionException() { StepExecution stepExecution = new StepExecution("stepName", null); // failure scenario -- no step id set. try { jobRepository.add(stepExecution); fail(); } catch (Exception ex) { // expected } }
protected void runStep(Step step) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException, JobInterruptedException { JobExecution jobExecution = repository.createJobExecution("job1", new JobParameters()); stepExecution = new StepExecution("step1", jobExecution); repository.add(stepExecution); step.execute(stepExecution); }
@Before public void start() throws Exception { int count = doTest("vanilla", "warmup"); logger.info("Item count: "+count); StepSynchronizationManager.close(); StepSynchronizationManager.register(new StepExecution("step", new JobExecution(0L),1L)); }
@Test public void testProxiedScopedProxy() throws Exception { assertNotNull(nested); nested.execute(new StepExecution("step", new JobExecution(0L), 1L)); assertEquals(4, TestAdvice.names.size()); assertEquals("bar", TestAdvice.names.get(0)); assertEquals(1, StringUtils.countOccurrencesOf(TestDisposableCollaborator.message, "destroyed")); }
@Test public void testNestedProxyTargetClassTrue() throws Exception { nestedProxyTargetClassTrue.execute(new StepExecution("foo", new JobExecution(11L), 31L)); String parent = (String) TestStep.getContext().getAttribute("parent"); assertEquals("bar", parent); assertTrue("Scoped proxy not created", ((String) TestStep.getContext().getAttribute("parent.class")) .matches(CGLIB_PROXY_TO_STRING_REGEX)); }
@Test public void testNullNameIsIllegal() throws Exception { try { new StepExecution(null, new JobExecution(new JobInstance(null, "job"), null)); fail(); } catch (IllegalArgumentException e) { // expected } }
@Test public void testStepToCompletion() throws Exception { RepeatTemplate template = new RepeatTemplate(); // process all items: template.setCompletionPolicy(new DefaultResultCompletionPolicy()); step.setStepOperations(template); JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters); StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); step.execute(stepExecution); assertEquals(3, processed.size()); assertEquals(3, stepExecution.getReadCount()); }
/** * @param parameters * @return */ private StepExecution getStepExecution(String parameters) { JobParameters jobParameters = new DefaultJobParametersConverter().getJobParameters(PropertiesConverter.stringToProperties(parameters)); return new StepExecution("step", new JobExecution(new JobInstance(1L, "job"), jobParameters)); }
@Before public void onSetUp() throws Exception { repository = getJobRepository(); jobExecution = repository.createJobExecution("job", new JobParameters()); jobInstance = jobExecution.getJobInstance(); step = new StepSupport("foo"); stepExecution = new StepExecution(step.getName(), jobExecution); dao = getStepExecutionDao(); }
@BeforeTransaction public void onSetUpBeforeTransaction() throws Exception { StepExecution stepExecution = new StepExecution("stepName", new JobExecution(new JobInstance(jobId, "testJob"), new JobParameters())); writer.beforeStep(stepExecution); writer.write(Arrays.asList("FOO", "BAR", "SPAM", "BUCKET")); reader.beforeStep(stepExecution); }
@Test public void testCommitCount_Uneven() throws Exception { JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters); step = getStep(new String[] { "foo", "bar", "spam" }, 2); step.setTransactionManager(transactionManager); StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); step.execute(stepExecution); assertEquals(3, processed.size()); assertEquals(3, stepExecution.getReadCount()); assertEquals(3, stepExecution.getWriteCount()); assertEquals(2, stepExecution.getCommitCount()); }
private void start(String foo) { StepSynchronizationManager.close(); stepExecution = new StepExecution("foo", new JobExecution(11L), 123L); ExecutionContext executionContext = new ExecutionContext(); executionContext.put("foo", foo); executionContext.put("parent", bar); stepExecution.setExecutionContext(executionContext); StepSynchronizationManager.register(stepExecution); beanCount = beanFactory.getBeanDefinitionCount(); }
@Before public void start() { StepSynchronizationManager.close(); TestStep.reset(); stepExecution = new StepExecution("foo", new JobExecution(11L), 123L); ExecutionContext executionContext = new ExecutionContext(); executionContext.put("foo", "bar"); stepExecution.setExecutionContext(executionContext); StepSynchronizationManager.register(stepExecution); beanCount = beanFactory.getBeanDefinitionCount(); }
@Test public void testRepository() throws Exception { SimpleJobRepository repository = new SimpleJobRepository(new MapJobInstanceDao(), new MapJobExecutionDao(), new MapStepExecutionDao(), new MapExecutionContextDao()); step.setJobRepository(repository); JobExecution jobExecution = repository.createJobExecution(job.getName(), jobParameters); StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); repository.add(stepExecution); step.execute(stepExecution); assertEquals(1, processed.size()); }
@Test public void testNonRestartedJob() throws Exception { MockRestartableItemReader tasklet = new MockRestartableItemReader(); step.setTasklet(new TestingChunkOrientedTasklet<>(tasklet, itemWriter)); step.registerStream(tasklet); JobExecution jobExecutionContext = new JobExecution(jobInstance, jobParameters); StepExecution stepExecution = new StepExecution(step.getName(), jobExecutionContext); step.execute(stepExecution); assertFalse(tasklet.isRestoreFromCalled()); assertTrue(tasklet.isGetExecutionAttributesCalled()); }
@Test public void workDone() { StepExecution stepExecution = new StepExecution("NoProcessingStep", new JobExecution(new JobInstance(1L, "NoProcessingJob"), new JobParameters())); stepExecution.setReadCount(1); ExitStatus exitStatus = tested.afterStep(stepExecution); assertNull(exitStatus); } }
@Test public void testCompoundPropertyTwice() throws Exception { assertEquals("bar-bar", compound.getName()); StepSynchronizationManager.close(); stepExecution = new StepExecution("foo", new JobExecution(11L), 123L); ExecutionContext executionContext = new ExecutionContext(); executionContext.put("foo", "spam"); stepExecution.setExecutionContext(executionContext); StepSynchronizationManager.register(stepExecution); assertEquals("spam-bar", compound.getName()); }
@Before public void init() { taskletStep = new TaskletStep(); taskletStep.setTasklet(new ExceptionTasklet()); jobRepository = new UpdateCountingJobRepository(); taskletStep.setJobRepository(jobRepository); taskletStep.setTransactionManager(new ResourcelessTransactionManager()); JobInstance jobInstance = new JobInstance(1L, "testJob"); JobExecution jobExecution = new JobExecution(jobInstance, new JobParameters()); stepExecution = new StepExecution("testStep", jobExecution); }