avoid ConverterNotFoundException if source object is assignable to target type

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3426 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Juergen Hoeller
2010-06-15 09:35:39 +00:00
parent c04935fc26
commit 463cd8e0b0
2 changed files with 28 additions and 2 deletions
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertEquals;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.UUID;
import org.junit.Test;
@@ -61,12 +62,26 @@ public class PropertiesConversionSpelTests {
assertEquals("123", result);
}
@Test // questionable, but this passes with 3.0.2.RELEASE
@Test
public void mapWithNonStringValue() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("x", "1");
map.put("y", 2);
map.put("z", "3");
map.put("a", new UUID(1, 1));
Expression expression = parser.parseExpression("foo(#props)");
StandardEvaluationContext context = new StandardEvaluationContext();
context.setVariable("props", map);
String result = expression.getValue(context, new TestBean(), String.class);
assertEquals("1null3", result);
}
@Test
public void customMapWithNonStringValue() {
CustomMap map = new CustomMap();
map.put("x", "1");
map.put("y", 2);
map.put("z", "3");
Expression expression = parser.parseExpression("foo(#props)");
StandardEvaluationContext context = new StandardEvaluationContext();
context.setVariable("props", map);
@@ -83,4 +98,9 @@ public class PropertiesConversionSpelTests {
}
}
@SuppressWarnings("serial")
private static class CustomMap extends HashMap<String, Object> {
}
}