BATCH-1208: add unit test

This commit is contained in:
dsyer
2009-05-06 12:31:48 +00:00
parent 91cf3c83c3
commit 51c7a96369
2 changed files with 43 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ import static org.junit.Assert.fail;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.junit.Test;
@@ -35,6 +36,10 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport {
@Qualifier("withInteger")
private PlaceholderTargetSource withInteger;
@Autowired
@Qualifier("withList")
private PlaceholderTargetSource withList;
@Autowired
@Qualifier("withMultiple")
private PlaceholderTargetSource withMultiple;
@@ -153,6 +158,13 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport {
assertEquals("bar-4321", target.getName());
}
@Test
public void testGetList() {
Node target = (Node) withList.getTarget();
assertEquals(3, target.getList().size());
assertEquals("[bar, foo-4321, bar-4321]", target.getList().toString());
}
@Test
public void testGetMultiple() {
Node target = (Node) withMultiple.getTarget();
@@ -186,6 +198,8 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport {
Date getDate();
Node getParent();
List<String> getList();
}
public static class Foo implements Node {
@@ -195,6 +209,8 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport {
private Date date;
private Node parent;
private List<String> list;
public Foo() {
}
@@ -227,6 +243,14 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport {
this.parent = parent;
}
public void setList(List<String> list) {
this.list = list;
}
public List<String> getList() {
return list;
}
}
}

View File

@@ -52,6 +52,12 @@
<property name="targetBeanName" value="withIntegerTarget" />
</bean>
<bean id="withList"
class="org.springframework.batch.core.scope.util.PlaceholderTargetSource">
<property name="contextFactory" ref="context" />
<property name="targetBeanName" value="withListTarget" />
</bean>
<bean id="withMultiple"
class="org.springframework.batch.core.scope.util.PlaceholderTargetSource">
<property name="contextFactory" ref="context" />
@@ -117,6 +123,18 @@
<property name="name" value="bar-#{integer}" />
</bean>
<bean id="withListTarget"
class="org.springframework.batch.core.scope.util.PlaceholderTargetSourceTests$Foo"
lazy-init="true">
<property name="list">
<list>
<value>#{foo}</value>
<value>foo-#{integer}</value>
<value>bar-#{integer}</value>
</list>
</property>
</bean>
<bean id="withMultipleTarget"
class="org.springframework.batch.core.scope.util.PlaceholderTargetSourceTests$Foo"
lazy-init="true">
@@ -151,7 +169,7 @@
<constructor-arg value="yyyy/MM/dd" />
</bean>
</constructor-arg>
<constructor-arg value="false"/>
<constructor-arg value="false" />
</bean>
</entry>
</map>