BATCH-1107: add PropertyEditor support to placeholder resolution to deal with Dates
This commit is contained in:
@@ -38,6 +38,10 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport {
|
||||
@Qualifier("withMultiple")
|
||||
private PlaceholderTargetSource withMultiple;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("withEmbeddedDate")
|
||||
private PlaceholderTargetSource withEmbeddedDate;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("withDate")
|
||||
private PlaceholderTargetSource withDate;
|
||||
@@ -60,7 +64,7 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport {
|
||||
|
||||
private Map<String, Object> map = Collections.singletonMap("foo.foo", (Object) "bar");
|
||||
|
||||
private Date date = new Date();
|
||||
private Date date = new Date(0L);
|
||||
|
||||
public Object getContext() {
|
||||
return this;
|
||||
@@ -154,11 +158,16 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport {
|
||||
assertEquals("bar-4321-4321", target.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEmbeddedDate() {
|
||||
Node target = (Node) withEmbeddedDate.getTarget();
|
||||
assertEquals("bar-1970/01/01", target.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDate() {
|
||||
Node target = (Node) withDate.getTarget();
|
||||
// Remains unconverted because Spring cannot convert from Date to String
|
||||
assertEquals("bar-#{date}", target.getName());
|
||||
assertEquals(0L, target.getDate().getTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -171,6 +180,8 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport {
|
||||
public static interface Node {
|
||||
String getName();
|
||||
|
||||
Date getDate();
|
||||
|
||||
Node getParent();
|
||||
}
|
||||
|
||||
@@ -178,6 +189,8 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport {
|
||||
|
||||
private String name;
|
||||
|
||||
private Date date;
|
||||
|
||||
private Node parent;
|
||||
|
||||
public Foo() {
|
||||
@@ -191,6 +204,14 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user