change PlaceOfBirth toString() so round tripping from String > new PlaceOfBirth(String) > String works ok

This commit is contained in:
Andy Clement 2009-11-12 20:56:21 +00:00
parent 3faf28ebaf
commit 61a8fa0ebd
2 changed files with 8 additions and 4 deletions

View File

@ -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());

View File

@ -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;