public static <T> T doInStepScope(StepExecution stepExecution, Callable<T> callable) throws Exception { try { StepSynchronizationManager.register(stepExecution); return callable.call(); } finally { StepSynchronizationManager.close(); } }
/** * Added to clean up left overs from other tests. * @throws Exception */ @BeforeClass public static void setUpClass() throws Exception { StepSynchronizationManager.close(); }
@After public void cleanUpStepContext() { StepSynchronizationManager.close(); }
@Before @After public void start() { while (StepSynchronizationManager.getContext() != null) { StepSynchronizationManager.close(); } }
@Before @After public void start() { StepSynchronizationManager.close(); TestStep.reset(); }
@After public void cleanUp() { StepSynchronizationManager.close(); // Check that all temporary bean definitions are cleaned up assertEquals(beanCount, beanFactory.getBeanDefinitionCount()); }
@After public void stop() { StepSynchronizationManager.close(); // Check that all temporary bean definitions are cleaned up assertEquals(beanCount, beanFactory.getBeanDefinitionCount()); }
@After public void stop() { StepSynchronizationManager.close(); // Check that all temporary bean definitions are cleaned up assertEquals(beanCount, beanFactory.getBeanDefinitionCount()); }
@Before public void setUp() throws Exception { StepSynchronizationManager.close(); propertyContext = new BatchPropertyContext(); factoryBean = new JsrJobContextFactoryBean(); }
@Test public void testRegisterTwice() { StepSynchronizationManager.register(stepExecution); StepSynchronizationManager.register(stepExecution); StepSynchronizationManager.close(); // if someone registers you have to assume they are going to close, so // the last thing you want is for the close to remove another context // that someone else has registered assertNotNull(StepSynchronizationManager.getContext()); StepSynchronizationManager.close(); assertNull(StepSynchronizationManager.getContext()); }
@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)); }
@Override protected void pointReaderToOutput(ItemReader<CustomerCredit> reader) { JobParameters jobParameters = new JobParametersBuilder(super.getUniqueJobParameters()).addString("inputFile", "file:./build/test-outputs/fixedLengthOutput.txt").toJobParameters(); StepExecution stepExecution = MetaDataInstanceFactory.createStepExecution(jobParameters); StepSynchronizationManager.close(); StepSynchronizationManager.register(stepExecution); }
@Override protected void pointReaderToOutput(ItemReader<CustomerCredit> reader) { JobParameters jobParameters = new JobParametersBuilder(super.getUniqueJobParameters()).addString("inputFile", "file:./build/test-outputs/delimitedOutput.csv").toJobParameters(); StepExecution stepExecution = MetaDataInstanceFactory.createStepExecution(jobParameters); StepSynchronizationManager.close(); StepSynchronizationManager.register(stepExecution); }
@Override protected void pointReaderToOutput(ItemReader<CustomerCredit> reader) { JobParameters jobParameters = new JobParametersBuilder(super.getUniqueJobParameters()).addString( "input.file.path", "file:build/test-outputs/multiResourceOutput.csv.*").toJobParameters(); StepExecution stepExecution = MetaDataInstanceFactory.createStepExecution(jobParameters); StepSynchronizationManager.close(); StepSynchronizationManager.register(stepExecution); }
@Override protected void pointReaderToOutput(ItemReader<CustomerCredit> reader) { JobParameters jobParameters = new JobParametersBuilder(super.getUniqueJobParameters()).addDouble("credit", 0.) .toJobParameters(); StepExecution stepExecution = MetaDataInstanceFactory.createStepExecution(jobParameters); StepSynchronizationManager.close(); StepSynchronizationManager.register(stepExecution); }
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(); }
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(); }
@Test public void testInitialCreationSingleThreadUsingStepScope() throws Exception { factoryBean.setBatchPropertyContext(propertyContext); StepSynchronizationManager.register(new StepExecution("step1", new JobExecution(5L))); JobContext jobContext = factoryBean.getObject(); assertEquals(5L, jobContext.getExecutionId()); StepSynchronizationManager.close(); }
@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 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()); }