RESOLVED - issue BATCH-1095: Optionally throw exception if late binding fails

This commit is contained in:
dsyer
2009-04-07 15:54:52 +00:00
parent 926f61972f
commit ffd11dd427
4 changed files with 92 additions and 114 deletions

View File

@@ -72,12 +72,38 @@ public class PlaceholderTargetSourceErrorTests extends ContextFactorySupport {
assertEquals("bar-bar", target.getName());
}
@Test
public void testPartialReplaceMissingProperty() throws Exception {
try {
Node target = (Node) createValue("name", "#{garbage}-bar").getTarget();
assertEquals("bar", target.getName());
fail("Expected IllegalStateException");
}
catch (Exception e) {
String message = e.getMessage();
assertTrue("Wrong message: " + message, message.toLowerCase().contains("cannot bind"));
}
}
@Test
public void testFullReplaceSunnyDay() throws Exception {
Node target = (Node) createValue("name", "#{foo}").getTarget();
assertEquals("bar", target.getName());
}
@Test
public void testFullReplaceMissingProperty() throws Exception {
try {
Node target = (Node) createValue("name", "#{garbage}").getTarget();
assertEquals("bar", target.getName());
fail("Expected IllegalStateException");
}
catch (Exception e) {
String message = e.getMessage();
assertTrue("Wrong message: " + message, message.toLowerCase().contains("cannot bind"));
}
}
@Test
public void testPartialReplaceIntegerToString() throws Exception {
Node target = (Node) createValue("name", "foo-#{integer}").getTarget();

View File

@@ -47,10 +47,6 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport {
@Qualifier("withDate")
private PlaceholderTargetSource withDate;
@Autowired
@Qualifier("withNull")
private PlaceholderTargetSource withNull;
@Autowired
@Qualifier("compound")
private PlaceholderTargetSource compound;
@@ -172,13 +168,6 @@ public class PlaceholderTargetSourceTests extends ContextFactorySupport {
assertEquals(1L, target.getDate().getTime());
}
@Test
public void testGetNull() {
Node target = (Node) withNull.getTarget();
// Remains unconverted because null is explicitly excluded
assertEquals("bar-#{garbage}", target.getName());
}
public static interface Node {
String getName();