add spring3 profile

This commit is contained in:
dsyer
2009-07-07 12:56:53 +00:00
parent abd28fe07a
commit b0d6e0e2b9
53 changed files with 142 additions and 2629 deletions

View File

@@ -111,6 +111,12 @@ public class StepScope implements Scope, BeanFactoryPostProcessor, Ordered {
public void setProxyTargetClass(boolean proxyTargetClass) {
this.proxyTargetClass = proxyTargetClass;
}
// Implement missing method from Spring 3.0 SPI.
public Object resolveContextualObject(String key) {
StepContext context = getContext();
return context.getAttribute(key);
}
/**
* @see Scope#get(String, ObjectFactory)

View File

@@ -30,21 +30,21 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
*/
public class AutoRegisteringStepScopeTests {
@SuppressWarnings("unchecked")
@Test
public void testJobElement() throws Exception {
ConfigurableApplicationContext ctx =
new ClassPathXmlApplicationContext("org/springframework/batch/core/configuration/xml/AutoRegisteringStepScopeForJobElementTests-context.xml");
Map<String, Object> beans = ctx.getBeansOfType(StepScope.class);
@SuppressWarnings("unchecked")
Map<String, StepScope> beans = ctx.getBeansOfType(StepScope.class);
assertTrue("StepScope not defined properly", beans.size() == 1);
}
@SuppressWarnings("unchecked")
@Test
public void testStepElement() throws Exception {
ConfigurableApplicationContext ctx =
new ClassPathXmlApplicationContext("org/springframework/batch/core/configuration/xml/AutoRegisteringStepScopeForStepElementTests-context.xml");
Map<String, Object> beans = ctx.getBeansOfType(StepScope.class);
@SuppressWarnings("unchecked")
Map<String, StepScope> beans = ctx.getBeansOfType(StepScope.class);
assertTrue("StepScope not defined properly", beans.size() == 1);
}

View File

@@ -174,7 +174,7 @@ public class ChunkElementParserTests {
@SuppressWarnings("unchecked")
private Set<Class<?>> getExceptionClasses(String stepName, String type, ApplicationContext ctx) throws Exception {
Map<String, Object> beans = ctx.getBeansOfType(Step.class);
Map<String, Step> beans = ctx.getBeansOfType(Step.class);
assertTrue(beans.containsKey(stepName));
Object step = ctx.getBean(stepName);
assertTrue(step instanceof TaskletStep);
@@ -190,7 +190,7 @@ public class ChunkElementParserTests {
@SuppressWarnings("unchecked")
private Collection<ItemStream> getStreams(String stepName, ApplicationContext ctx) throws Exception {
Map<String, Object> beans = ctx.getBeansOfType(Step.class);
Map<String, Step> beans = ctx.getBeansOfType(Step.class);
assertTrue(beans.containsKey(stepName));
Object step = ctx.getBean(stepName);
assertTrue(step instanceof TaskletStep);
@@ -201,7 +201,7 @@ public class ChunkElementParserTests {
@SuppressWarnings("unchecked")
private Collection<RetryListener> getRetryListeners(String stepName, ApplicationContext ctx) throws Exception {
Map<String, Object> beans = ctx.getBeansOfType(Step.class);
Map<String, Step> beans = ctx.getBeansOfType(Step.class);
assertTrue(beans.containsKey(stepName));
Object step = ctx.getBean(stepName);
assertTrue(step instanceof TaskletStep);

View File

@@ -89,7 +89,7 @@ public class StepListenerParserTests {
@SuppressWarnings("unchecked")
private List<?> getListeners(String stepName, ApplicationContext ctx) throws Exception {
Map<String, Object> beans = ctx.getBeansOfType(Step.class);
Map<String, Step> beans = ctx.getBeansOfType(Step.class);
assertTrue(beans.containsKey(stepName));
Object step = ctx.getBean(stepName);
assertTrue(step instanceof TaskletStep);

View File

@@ -61,25 +61,26 @@ public class StepParserTests {
"org/springframework/batch/core/configuration/xml/StepParserParentAttributeTests-context.xml");
}
@SuppressWarnings("unchecked")
@Test
public void testTaskletStepAttributes() throws Exception {
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext(
"org/springframework/batch/core/configuration/xml/StepParserTaskletAttributesTests-context.xml");
Map<String, Object> beans = ctx.getBeansOfType(StepParserStepFactoryBean.class);
@SuppressWarnings("unchecked")
Map<String, StepParserStepFactoryBean> beans = ctx.getBeansOfType(StepParserStepFactoryBean.class);
String factoryName = (String) beans.keySet().toArray()[0];
@SuppressWarnings("unchecked")
StepParserStepFactoryBean<Object, Object> factory = (StepParserStepFactoryBean<Object, Object>) beans
.get(factoryName);
TaskletStep bean = (TaskletStep) factory.getObject();
assertEquals("wrong start-limit:", 25, bean.getStartLimit());
}
@SuppressWarnings("unchecked")
@Test
public void testStepParserBeanName() throws Exception {
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext(
"org/springframework/batch/core/configuration/xml/StepParserBeanNameTests-context.xml");
Map<String, Object> beans = ctx.getBeansOfType(Step.class);
@SuppressWarnings("unchecked")
Map<String, Step> beans = ctx.getBeansOfType(Step.class);
assertTrue("'s1' bean not found", beans.containsKey("s1"));
Step s1 = (Step) ctx.getBean("s1");
assertEquals("wrong name", "s1", s1.getName());
@@ -91,12 +92,12 @@ public class StepParserTests {
"org/springframework/batch/core/configuration/xml/StepParserCommitIntervalCompletionPolicyTests-context.xml");
}
@SuppressWarnings("unchecked")
@Test
public void testStepParserCommitInterval() throws Exception {
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext(
"org/springframework/batch/core/configuration/xml/StepParserCommitIntervalTests-context.xml");
Map<String, Object> beans = ctx.getBeansOfType(Step.class);
@SuppressWarnings("unchecked")
Map<String, Step> beans = ctx.getBeansOfType(Step.class);
assertTrue("'s1' bean not found", beans.containsKey("s1"));
Step s1 = (Step) ctx.getBean("s1");
CompletionPolicy completionPolicy = getCompletionPolicy(s1);
@@ -104,12 +105,12 @@ public class StepParserTests {
assertEquals(25, ReflectionTestUtils.getField(completionPolicy, "chunkSize"));
}
@SuppressWarnings("unchecked")
@Test
public void testStepParserCompletionPolicy() throws Exception {
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext(
"org/springframework/batch/core/configuration/xml/StepParserCompletionPolicyTests-context.xml");
Map<String, Object> beans = ctx.getBeansOfType(Step.class);
@SuppressWarnings("unchecked")
Map<String, Step> beans = ctx.getBeansOfType(Step.class);
assertTrue("'s1' bean not found", beans.containsKey("s1"));
Step s1 = (Step) ctx.getBean("s1");
CompletionPolicy completionPolicy = getCompletionPolicy(s1);

View File

@@ -23,19 +23,25 @@
</bean>
<bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="customEditors">
<map>
<entry key="java.util.Date">
<bean class="org.springframework.beans.propertyeditors.CustomDateEditor">
<constructor-arg>
<bean class="java.text.SimpleDateFormat">
<constructor-arg value="yyyy/MM/dd" />
<property name="propertyEditorRegistrars">
<bean
class="org.springframework.batch.support.DefaultPropertyEditorRegistrar">
<property name="customEditors">
<map>
<entry key="java.util.Date">
<bean
class="org.springframework.beans.propertyeditors.CustomDateEditor">
<constructor-arg>
<bean class="java.text.SimpleDateFormat">
<constructor-arg value="yyyy/MM/dd" />
</bean>
</constructor-arg>
<constructor-arg value="false" />
</bean>
</constructor-arg>
<constructor-arg value="false"/>
</bean>
</entry>
</map>
</entry>
</map>
</property>
</bean>
</property>
</bean>

View File

@@ -160,19 +160,25 @@
</bean>
<bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="customEditors">
<map>
<entry key="java.util.Date">
<bean class="org.springframework.beans.propertyeditors.CustomDateEditor">
<constructor-arg>
<bean class="java.text.SimpleDateFormat">
<constructor-arg value="yyyy/MM/dd" />
<property name="propertyEditorRegistrars">
<bean
class="org.springframework.batch.support.DefaultPropertyEditorRegistrar">
<property name="customEditors">
<map>
<entry key="java.util.Date">
<bean
class="org.springframework.beans.propertyeditors.CustomDateEditor">
<constructor-arg>
<bean class="java.text.SimpleDateFormat">
<constructor-arg value="yyyy/MM/dd" />
</bean>
</constructor-arg>
<constructor-arg value="false" />
</bean>
</constructor-arg>
<constructor-arg value="false" />
</bean>
</entry>
</map>
</entry>
</map>
</property>
</bean>
</property>
</bean>