Fixes for TCK tests: testDeciderNextNormal, testDeciderNextSpecial, testFlowTransitionToDecision, testFlowTransitionToStep, testFlowTransitionToStepOutOfScope, testFlowTransitionWithinFlow, testOneArtifactIsJobAndStepListener, testSimpleFlow, testStartLimitVariation1, testStepInFlowStepExecution
Tests blocked by TCK issues: testOneArtifactIsJobAndStepListener, testStartLimitVariation1 * Expose job level properties to step artifacts and update tests * Make JobParameterResolvingBeanFactoryPostProcessor HIGHEST_PRECEDENCE to avoid other BFPP's creating bean defs first * General cleanup and renaming * Register a bean definition for the JobContext prior to refreshing the beanfactory so it becomes injectable. Set properties and the jobExecution on the JobContext bean after they are initalized. * Only step scope non-step scoped listeners * Parse flow elements and transitions
This commit is contained in:
committed by
Michael Minella
parent
416033299f
commit
1ef21104ac
@@ -44,16 +44,20 @@ public class JobContextTests {
|
||||
public void setUp() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.put("jobLevelProperty1", "jobLevelValue1");
|
||||
Properties properties = new Properties();
|
||||
properties.put("jobLevelProperty1", "jobLevelValue1");
|
||||
|
||||
context = new JobContext();
|
||||
context.setProperties(properties);
|
||||
context.setJobExecution(execution);
|
||||
|
||||
context = new JobContext(execution, properties);
|
||||
when(execution.getJobInstance()).thenReturn(instance);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testCreateWithNull() {
|
||||
context = new JobContext(null, null);
|
||||
context = new JobContext();
|
||||
context.setJobExecution(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -91,12 +95,12 @@ public class JobContextTests {
|
||||
|
||||
when(execution.getJobParameters()).thenReturn(params);
|
||||
|
||||
assertEquals("value1", execution.getJobParameters().getString("key1"));
|
||||
assertEquals("value1", execution.getJobParameters().getString("key1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJobProperties() {
|
||||
assertEquals("jobLevelValue1", context.getProperties().get("jobLevelProperty1"));
|
||||
assertEquals("jobLevelValue1", context.getProperties().get("jobLevelProperty1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -108,12 +112,16 @@ public class JobContextTests {
|
||||
|
||||
@Test
|
||||
public void testExitStatus() {
|
||||
when(execution.getExitStatus()).thenReturn(new ExitStatus("exit"));
|
||||
|
||||
assertEquals("exit", context.getExitStatus());
|
||||
|
||||
context.setExitStatus("my exit status");
|
||||
|
||||
verify(execution).setExitStatus(new ExitStatus("my exit status"));
|
||||
|
||||
when(execution.getExitStatus()).thenReturn(new ExitStatus("exit"));
|
||||
assertEquals("exit", context.getExitStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitialNullExitStatus() {
|
||||
when(execution.getExitStatus()).thenReturn(new ExitStatus("exit"));
|
||||
assertEquals(null, context.getExitStatus());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,11 +170,13 @@ public class BatchPropertyContextTests {
|
||||
batchPropertyContext.setStepArtifactPropertiesContextEntry(stepArtifactProperties);
|
||||
|
||||
Properties artifactProperties = batchPropertyContext.getStepArtifactProperties("step1", "reader");
|
||||
assertEquals(4, artifactProperties.size());
|
||||
assertEquals(6, artifactProperties.size());
|
||||
assertEquals("readerProperty1value", artifactProperties.getProperty("readerProperty1"));
|
||||
assertEquals("readerProperty2value", artifactProperties.getProperty("readerProperty2"));
|
||||
assertEquals("step1PropertyValue1", artifactProperties.getProperty("step1PropertyName1"));
|
||||
assertEquals("step1PropertyValue2", artifactProperties.getProperty("step1PropertyName2"));
|
||||
assertEquals("jobProperty1value", artifactProperties.getProperty("jobProperty1"));
|
||||
assertEquals("jobProperty2value", artifactProperties.getProperty("jobProperty2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -213,12 +215,14 @@ public class BatchPropertyContextTests {
|
||||
batchPropertyContext.setStepArtifactPropertiesContextEntry(partitionProperties);
|
||||
|
||||
Properties artifactProperties = batchPropertyContext.getStepArtifactProperties("step2:partition0", "writer");
|
||||
assertEquals(6, artifactProperties.size());
|
||||
assertEquals(8, artifactProperties.size());
|
||||
assertEquals("writerProperty1", artifactProperties.getProperty("writerProperty1Step"));
|
||||
assertEquals("writerProperty2", artifactProperties.getProperty("writerProperty2Step"));
|
||||
assertEquals("writerProperty1valuePartition0", artifactProperties.getProperty("writerProperty1"));
|
||||
assertEquals("writerProperty2valuePartition0", artifactProperties.getProperty("writerProperty2"));
|
||||
assertEquals("step2PropertyValue1", artifactProperties.getProperty("step2PropertyName1"));
|
||||
assertEquals("step2PropertyValue2", artifactProperties.getProperty("step2PropertyName2"));
|
||||
assertEquals("jobProperty1value", artifactProperties.getProperty("jobProperty1"));
|
||||
assertEquals("jobProperty2value", artifactProperties.getProperty("jobProperty2"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core.jsr.configuration.xml;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.listener.StepListenerFactoryBean;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Test cases around scoping of job/step listeners when building their bean definitions.
|
||||
* </p>
|
||||
*
|
||||
* @author Chris Schaefer
|
||||
*/
|
||||
public class ListenerParserTests {
|
||||
@Test
|
||||
public void testStepListenerStepScoped() {
|
||||
GenericApplicationContext applicationContext = new GenericApplicationContext();
|
||||
|
||||
AbstractBeanDefinition newBeanDefinition = BeanDefinitionBuilder.genericBeanDefinition("stepListener").getBeanDefinition();
|
||||
newBeanDefinition.setScope("step");
|
||||
|
||||
applicationContext.registerBeanDefinition("stepListener", newBeanDefinition);
|
||||
|
||||
ListenerParser listenerParser = new ListenerParser(StepListenerFactoryBean.class, "listeners");
|
||||
listenerParser.applyListenerScope("stepListener", applicationContext);
|
||||
|
||||
BeanDefinition beanDefinition = applicationContext.getBeanDefinition("stepListener");
|
||||
assertEquals("step", beanDefinition.getScope());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJobListenerSingletonScoped() {
|
||||
GenericApplicationContext applicationContext = new GenericApplicationContext();
|
||||
|
||||
AbstractBeanDefinition newBeanDefinition = BeanDefinitionBuilder.genericBeanDefinition("jobListener").getBeanDefinition();
|
||||
newBeanDefinition.setScope("step");
|
||||
|
||||
applicationContext.registerBeanDefinition("jobListener", newBeanDefinition);
|
||||
|
||||
ListenerParser listenerParser = new ListenerParser(JobListenerFactoryBean.class, "jobExecutionListeners");
|
||||
listenerParser.applyListenerScope("jobListener", applicationContext);
|
||||
|
||||
BeanDefinition beanDefinition = applicationContext.getBeanDefinition("jobListener");
|
||||
assertEquals("singleton", beanDefinition.getScope());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user