BATCH-1208: add unit test
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user