WW-4427 - Converters are no longer applied to values coming from the context - fix and UT

This commit is contained in:
Przemek Bruski
2014-12-09 17:17:15 +01:00
parent 5f2898eadf
commit 6834b78fe9
2 changed files with 13 additions and 0 deletions
@@ -351,6 +351,8 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
value = getValue(expr, asType);
if (value == null) {
value = findInContext(expr);
final XWorkConverter conv = ((Container)getContext().get(ActionContext.CONTAINER)).getInstance(XWorkConverter.class);
return conv.convertValue(getContext(), value, asType);
}
} finally {
context.remove(THROW_EXCEPTION_ON_FAILURE);
@@ -93,6 +93,17 @@ public class OgnlValueStackTest extends XWorkTestCase {
assertEquals("1, 2", vs.findValue("childAges", String.class));
}
public void testValuesFromContextAreConverted() {
final OgnlValueStack vs = createValueStack();
vs.getContext().put(ActionContext.CONTAINER, container);
final String propertyName = "dogName";
final String propertyValue = "Rover";
vs.getContext().put(propertyName, new String[]{propertyValue});
assertEquals(propertyValue, vs.findValue(propertyName, String.class));
}
public void testFailOnException() {
OgnlValueStack vs = createValueStack();