SWF-928 Evaluation exceptions caused by type conversion errors within target Expression of a data mapping not treating as a type conversion error

SWF-780 Transition on-exception not handled with ognl

Introduced ValueCoercionException as a subclass of EvaluationException for type conversion failures.  OGNL exceptions will no longer be wrapped directly,  the reason for the ognl exception will be passed instead.
This commit is contained in:
Scott Andrews
2008-10-31 22:33:38 +00:00
parent 987e14bcca
commit 4c3c1158f5
12 changed files with 137 additions and 22 deletions

View File

@@ -18,9 +18,9 @@ package org.springframework.binding.expression.beanwrapper;
import junit.framework.TestCase;
import org.springframework.beans.TypeMismatchException;
import org.springframework.binding.expression.EvaluationException;
import org.springframework.binding.expression.Expression;
import org.springframework.binding.expression.ParserException;
import org.springframework.binding.expression.ValueCoercionException;
import org.springframework.binding.expression.ognl.TestBean;
import org.springframework.binding.expression.support.FluentParserContext;
@@ -108,8 +108,9 @@ public class BeanWrapperExpressionParserTests extends TestCase {
try {
e.setValue(bean, "bogus");
fail("Should have failed tme");
} catch (EvaluationException ex) {
} catch (ValueCoercionException ex) {
assertTrue(ex.getCause() instanceof TypeMismatchException);
}
}
}

View File

@@ -16,6 +16,7 @@ import org.springframework.binding.expression.EvaluationException;
import org.springframework.binding.expression.Expression;
import org.springframework.binding.expression.ExpressionVariable;
import org.springframework.binding.expression.ParserException;
import org.springframework.binding.expression.ValueCoercionException;
import org.springframework.binding.expression.support.FluentParserContext;
public class ELExpressionParserTests extends TestCase {
@@ -166,8 +167,7 @@ public class ELExpressionParserTests extends TestCase {
try {
exp.setValue(context, "bogus");
fail("Should have failed with coersion");
} catch (EvaluationException e) {
} catch (ValueCoercionException e) {
}
}

View File

@@ -17,10 +17,10 @@ package org.springframework.binding.expression.ognl;
import junit.framework.TestCase;
import org.springframework.binding.expression.EvaluationException;
import org.springframework.binding.expression.Expression;
import org.springframework.binding.expression.ExpressionVariable;
import org.springframework.binding.expression.ParserException;
import org.springframework.binding.expression.ValueCoercionException;
import org.springframework.binding.expression.support.FluentParserContext;
public class OgnlExpressionParserTests extends TestCase {
@@ -184,7 +184,8 @@ public class OgnlExpressionParserTests extends TestCase {
try {
e.setValue(bean, "bogus");
fail("Should have failed tme");
} catch (EvaluationException ex) {
} catch (ValueCoercionException ex) {
}
}
}

View File

@@ -11,6 +11,7 @@ import org.springframework.binding.expression.el.DefaultExpressionFactoryUtils;
import org.springframework.binding.expression.el.ELExpressionParser;
import org.springframework.binding.mapping.impl.DefaultMapper;
import org.springframework.binding.mapping.impl.DefaultMapping;
import org.springframework.binding.mapping.results.TypeConversionError;
public class DefaultMapperTests extends TestCase {
private DefaultMapper mapper = new DefaultMapper();
@@ -65,7 +66,8 @@ public class DefaultMapperTests extends TestCase {
bean1.put("boop", "bogus");
TestBean2 bean2 = new TestBean2();
MappingResults results = mapper.map(bean1, bean2);
assertTrue(results.hasErrorResults());
assertEquals(TypeConversionError.class, ((MappingResult) results.getErrorResults().get(0)).getResult()
.getClass());
}
public static class TestBean {