eclipse classpath fix for 2.5.6; now handling ConversionException root class for ValueCoersion scenarios--moved catch logic closer to where exception was thrown
This commit is contained in:
@@ -152,6 +152,25 @@ public class ELExpressionParserTests extends TestCase {
|
||||
assertEquals(int.class, exp.getValueType(context));
|
||||
}
|
||||
|
||||
public void testGetValueWithCoersion() {
|
||||
String expressionString = "maximum";
|
||||
Expression exp = parser.parseExpression(expressionString, new FluentParserContext().expectResult(String.class));
|
||||
TestBean context = new TestBean();
|
||||
assertEquals("2", exp.getValue(context));
|
||||
}
|
||||
|
||||
public void testGetValueCoersionError() {
|
||||
String expressionString = "maximum";
|
||||
Expression exp = parser.parseExpression(expressionString, new FluentParserContext()
|
||||
.expectResult(TestBean.class));
|
||||
TestBean context = new TestBean();
|
||||
try {
|
||||
exp.getValue(context);
|
||||
fail("Should have failed with coersion");
|
||||
} catch (ValueCoercionException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public void testSetValue() {
|
||||
String expressionString = "maximum";
|
||||
Expression exp = parser.parseExpression(expressionString, null);
|
||||
@@ -160,7 +179,15 @@ public class ELExpressionParserTests extends TestCase {
|
||||
assertEquals(5, context.getMaximum());
|
||||
}
|
||||
|
||||
public void testSetValueConversionError() {
|
||||
public void testSetValueWithTypeCoersion() {
|
||||
String expressionString = "maximum";
|
||||
Expression exp = parser.parseExpression(expressionString, null);
|
||||
TestBean context = new TestBean();
|
||||
exp.setValue(context, "5");
|
||||
assertEquals(5, context.getMaximum());
|
||||
}
|
||||
|
||||
public void testSetValueCoersionError() {
|
||||
String expressionString = "maximum";
|
||||
Expression exp = parser.parseExpression(expressionString, null);
|
||||
TestBean context = new TestBean();
|
||||
|
||||
@@ -174,6 +174,33 @@ public class OgnlExpressionParserTests extends TestCase {
|
||||
assertEquals(null, e.getValueType(bean));
|
||||
}
|
||||
|
||||
public void testGetValueWithCoersion() {
|
||||
String expressionString = "number";
|
||||
Expression exp = parser.parseExpression(expressionString, new FluentParserContext().expectResult(String.class));
|
||||
TestBean context = new TestBean();
|
||||
assertEquals("0", exp.getValue(context));
|
||||
}
|
||||
|
||||
public void testGetValueCoersionError() {
|
||||
String expressionString = "number";
|
||||
Expression exp = parser.parseExpression(expressionString, new FluentParserContext()
|
||||
.expectResult(TestBean.class));
|
||||
TestBean context = new TestBean();
|
||||
try {
|
||||
exp.getValue(context);
|
||||
fail("Should have failed with coersion");
|
||||
} catch (ValueCoercionException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public void testSetValue() {
|
||||
String expressionString = "number";
|
||||
Expression exp = parser.parseExpression(expressionString, null);
|
||||
TestBean context = new TestBean();
|
||||
exp.setValue(context, new Integer(5));
|
||||
assertEquals(5, context.getNumber());
|
||||
}
|
||||
|
||||
public void testSetValueWithCoersion() {
|
||||
Expression e = parser.parseExpression("date", null);
|
||||
e.setValue(bean, "2008-9-15");
|
||||
|
||||
Reference in New Issue
Block a user