/** * Add a Double value to the context. * * @param key Key to add to context * @param value Value to associate with key */ public void putDouble(String key, double value) { put(key, value); }
@Override public Map<String, ExecutionContext> partition(int gridSize) { Map<String, ExecutionContext> partitions = super.partition(gridSize); int i = 0; for (ExecutionContext context : partitions.values()) { context.put(PARTITION_KEY, PARTITION_KEY + (i++)); } return partitions; }
@Override public void beforeJob(JobExecution jobExecution) { ExecutionContext jobContext = jobExecution.getExecutionContext(); for (Map.Entry<String, Object> entry : jobExecutionContext.entrySet()) { jobContext.put(entry.getKey(), entry.getValue()); } } } });
public void open(ExecutionContext executionContext) { this.isClosed = false; executionContext.put(HAS_BEEN_OPENED, true); executionContext.remove(UPDATE_COUNT_KEY); }
@Test public void testUpdate() throws Exception { when(delegate.checkpointInfo()).thenReturn("checkpoint"); adapter.update(executionContext); verify(executionContext).put("jsrReader.reader.checkpoint", "checkpoint"); }
@Test public void testUpdate() throws Exception { when(delegate.checkpointInfo()).thenReturn("checkpoint"); adapter.update(executionContext); verify(executionContext).put("jsrWriter.writer.checkpoint", "checkpoint"); }
@Override public Void doInTransaction(TransactionStatus status) { stepExecution.getExecutionContext().put("foo", "bar"); dao.saveExecutionContext(stepExecution); return null; } });
@Override @Test public void testReadAfterJumpSecondPage() throws Exception { executionContext.put(getName() + ".start.after", Collections.<String, Object>singletonMap("ID", 4)); super.testReadAfterJumpSecondPage(); }
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("type", TestCollaborator.class.getName()); stepExecution.setExecutionContext(executionContext); StepSynchronizationManager.register(stepExecution); beanCount = beanFactory.getBeanDefinitionCount(); }
@Test public void testFromStepInJob() throws Exception { Date date = new Date(); JobExecution jobExecution = MetaDataInstanceFactory.createJobExecutionWithStepExecutions(123L, Arrays.asList("foo", "bar")); StepExecution stepExecution = jobExecution.createStepExecution("spam"); stepExecution.getExecutionContext().put("foo", date); Date result = ExecutionContextTestUtils.getValueFromStepInJob(jobExecution, "spam", "foo"); assertEquals(date, result); }
@Test public void testJobExecutionContext() throws Exception { ExecutionContext executionContext = stepExecution.getJobExecution().getExecutionContext(); executionContext.put("foo", "bar"); assertEquals("bar", context.getJobExecutionContext().get("foo")); }
@Test public void testCopyConstructor() throws Exception { ExecutionContext context = new ExecutionContext(); context.put("foo", "bar"); ExecutionContext copy = new ExecutionContext(context); assertEquals(copy, context); }
@Test public void testGetNamedJobParameters() throws Exception { stepExecution.getExecutionContext().put("foo", "bar"); extractor.setKeys(new String[] {"foo", "bar"}); JobParameters jobParameters = extractor.getJobParameters(null, stepExecution); assertEquals("{foo=bar}", jobParameters.toString()); }
@Before public void start() { JobSynchronizationManager.close(); jobExecution = new JobExecution(123L); ExecutionContext executionContext = new ExecutionContext(); executionContext.put("foo", "bar"); jobExecution.setExecutionContext(executionContext); JobSynchronizationManager.register(jobExecution); beanCount = beanFactory.getBeanDefinitionCount(); }
@Override public void execute(StepExecution stepExecution) throws JobInterruptedException { if (!stepExecution.getJobExecution().getExecutionContext().containsKey("STOPPED")) { stepExecution.getJobExecution().getExecutionContext().put("STOPPED", true); stepExecution.setStatus(BatchStatus.STOPPED); jobRepository.update(stepExecution); } else { fail("The Job should have stopped by now"); } } }), "end0"));
@Test public void testSimpleProperty() throws Exception { StepExecution stepExecution = new StepExecution("step", new JobExecution(0L), 123L); ExecutionContext executionContext = stepExecution.getExecutionContext(); executionContext.put("foo", "bar"); StepSynchronizationManager.register(stepExecution); assertEquals("bar", simple.getName()); }
@Before public void start() { StepSynchronizationManager.close(); 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 testSaveUpdate() throws Exception { StepExecution stepExecution = new StepExecution("step", new JobExecution(11L)); stepExecution.setId(123L); stepExecution.getExecutionContext().put("foo", "bar"); dao.saveExecutionContext(stepExecution); ExecutionContext executionContext = dao.getExecutionContext(stepExecution); assertEquals("bar", executionContext.get("foo")); }
@Test public void testCycle() throws Exception { StepExecution stepExecution = new StepExecution("step", new JobExecution(new JobInstance(123L, "job"), 321L, new JobParameters(), null), 11L); stepExecution.getExecutionContext().put("foo.bar.spam", 123); StepExecution result = getCopy(stepExecution); assertEquals(stepExecution, result); }
@Test public void testExecutionContext() throws Exception { StepExecution stepExecution = new StepExecution("foo", new JobExecution(11L), 1L); ExecutionContext executionContext = new ExecutionContext(); executionContext.put("name", "spam"); stepExecution.setExecutionContext(executionContext); proxied.execute(stepExecution); assertTrue(TestStep.getContext().attributeNames().length > 0); String collaborator = (String) TestStep.getContext().getAttribute("collaborator"); assertNotNull(collaborator); assertEquals("bar", collaborator); }