@Test public void testWithStepExecutionFactory() throws Exception { testExecutionContext(new WithStepExecutionFactory()); }
@Test public void testWithParameters() throws Exception { testJobParameters(new WithStepExecutionFactory()); }
@Test public void testDefaultStepContext() throws Exception { TestContext testContext = getTestContext(new Object()); listener.prepareTestInstance(testContext); listener.beforeTestMethod(testContext); StepContext context = StepSynchronizationManager.getContext(); assertNotNull(context); listener.afterTestMethod(testContext); assertNull(StepSynchronizationManager.getContext()); }
private void testExecutionContext(Object target) throws Exception { TestContext testContext = getTestContext(target); listener.prepareTestInstance(testContext); try { listener.beforeTestMethod(testContext); StepContext context = StepSynchronizationManager.getContext(); assertNotNull(context); assertEquals("bar", context.getStepExecutionContext().get("foo")); } finally { listener.afterTestMethod(testContext); } assertNull(StepSynchronizationManager.getContext()); }
private void testJobParameters(Object target) throws Exception { TestContext testContext = getTestContext(target); listener.prepareTestInstance(testContext); try { listener.beforeTestMethod(testContext); StepContext context = StepSynchronizationManager.getContext(); assertNotNull(context); assertEquals("spam", context.getJobParameters().get("foo")); } finally { listener.afterTestMethod(testContext); } assertNull(StepSynchronizationManager.getContext()); }