From 3e5b5b81721bcd49cbd8f9ea750dc098601cc57e Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Thu, 12 Nov 2009 20:56:21 +0000 Subject: [PATCH] change PlaceOfBirth toString() so round tripping from String > new PlaceOfBirth(String) > String works ok git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2417 50f2f4bb-b051-0410-bef5-90022cba6387 --- .../springframework/expression/spel/SetValueTests.java | 4 +--- .../expression/spel/testresources/PlaceOfBirth.java | 8 +++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/SetValueTests.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/SetValueTests.java index 47e80614160..45ddcf23946 100644 --- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/SetValueTests.java +++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/SetValueTests.java @@ -21,7 +21,6 @@ import java.util.Set; import junit.framework.Assert; -import org.junit.Ignore; import org.junit.Test; import org.springframework.expression.EvaluationException; import org.springframework.expression.Expression; @@ -102,7 +101,6 @@ public class SetValueTests extends ExpressionTestCase { } @Test - @Ignore public void testSetGenericListElementValueTypeCoersion() { // TODO currently failing since setValue does a getValue and "Wien" string != PlaceOfBirth - check with andy setValue("placesLivedList[0]", "Wien"); @@ -221,7 +219,7 @@ public class SetValueTests extends ExpressionTestCase { StandardEvaluationContext lContext = TestScenarioCreator.getTestEvaluationContext(); Assert.assertTrue("Expression is not writeable but should be", e.isWritable(lContext)); e.setValue(lContext, value); - Assert.assertEquals("Retrieved value was not equal to set value", value, e.getValue(lContext)); + Assert.assertEquals("Retrieved value was not equal to set value", value, e.getValue(lContext,value.getClass())); } catch (EvaluationException ee) { ee.printStackTrace(); Assert.fail("Unexpected Exception: " + ee.getMessage()); diff --git a/org.springframework.expression/src/test/java/org/springframework/expression/spel/testresources/PlaceOfBirth.java b/org.springframework.expression/src/test/java/org/springframework/expression/spel/testresources/PlaceOfBirth.java index 4541a446364..658855cd7c5 100644 --- a/org.springframework.expression/src/test/java/org/springframework/expression/spel/testresources/PlaceOfBirth.java +++ b/org.springframework.expression/src/test/java/org/springframework/expression/spel/testresources/PlaceOfBirth.java @@ -6,8 +6,14 @@ public class PlaceOfBirth { public String Country; + /** + * Keith now has a converter that supports String to X, if X has a ctor that takes a String. + * In order for round tripping to work we need toString() for X to return what it was + * constructed with. This is a bit of a hack because a PlaceOfBirth also encapsulates a + * country - but as it is just a test object, it is ok. + */ @Override - public String toString() {return "PlaceOfBirth("+city+")";} + public String toString() {return city;} public String getCity() { return city;