fixes for known 2.0.0 bugs reported since release - see changelog

This commit is contained in:
Keith Donald
2008-05-06 07:05:18 +00:00
parent c9179d9d21
commit 797e203f8f
54 changed files with 840 additions and 397 deletions

View File

@@ -26,7 +26,7 @@ import java.util.List;
import java.util.Map;
import org.springframework.binding.collection.MapAccessor;
import org.springframework.binding.convert.ConversionException;
import org.springframework.binding.convert.ConversionExecutionException;
import org.springframework.binding.convert.ConversionExecutor;
import org.springframework.binding.convert.ConversionService;
import org.springframework.binding.convert.service.DefaultConversionService;
@@ -149,16 +149,16 @@ public class LocalParameterMap implements ParameterMap, Serializable {
}
}
public Object[] getArray(String parameterName, Class targetElementType) throws ConversionException {
public Object[] getArray(String parameterName, Class targetElementType) throws ConversionExecutionException {
String[] parameters = getArray(parameterName);
return parameters != null ? convert(parameters, targetElementType) : null;
}
public Object get(String parameterName, Class targetType) throws ConversionException {
public Object get(String parameterName, Class targetType) throws ConversionExecutionException {
return get(parameterName, targetType, null);
}
public Object get(String parameterName, Class targetType, Object defaultValue) throws ConversionException {
public Object get(String parameterName, Class targetType, Object defaultValue) throws ConversionExecutionException {
if (defaultValue != null) {
assertAssignableTo(targetType, defaultValue.getClass());
}
@@ -177,65 +177,65 @@ public class LocalParameterMap implements ParameterMap, Serializable {
}
public Object[] getRequiredArray(String parameterName, Class targetElementType) throws IllegalArgumentException,
ConversionException {
ConversionExecutionException {
String[] parameters = getRequiredArray(parameterName);
return convert(parameters, targetElementType);
}
public Object getRequired(String parameterName, Class targetType) throws IllegalArgumentException,
ConversionException {
ConversionExecutionException {
return convert(getRequired(parameterName), targetType);
}
public Number getNumber(String parameterName, Class targetType) throws ConversionException {
public Number getNumber(String parameterName, Class targetType) throws ConversionExecutionException {
assertAssignableTo(Number.class, targetType);
return (Number) get(parameterName, targetType);
}
public Number getNumber(String parameterName, Class targetType, Number defaultValue) throws ConversionException {
public Number getNumber(String parameterName, Class targetType, Number defaultValue) throws ConversionExecutionException {
assertAssignableTo(Number.class, targetType);
return (Number) get(parameterName, targetType, defaultValue);
}
public Number getRequiredNumber(String parameterName, Class targetType) throws IllegalArgumentException,
ConversionException {
ConversionExecutionException {
assertAssignableTo(Number.class, targetType);
return (Number) getRequired(parameterName, targetType);
}
public Integer getInteger(String parameterName) throws ConversionException {
public Integer getInteger(String parameterName) throws ConversionExecutionException {
return (Integer) get(parameterName, Integer.class);
}
public Integer getInteger(String parameterName, Integer defaultValue) throws ConversionException {
public Integer getInteger(String parameterName, Integer defaultValue) throws ConversionExecutionException {
return (Integer) get(parameterName, Integer.class, defaultValue);
}
public Integer getRequiredInteger(String parameterName) throws IllegalArgumentException, ConversionException {
public Integer getRequiredInteger(String parameterName) throws IllegalArgumentException, ConversionExecutionException {
return (Integer) getRequired(parameterName, Integer.class);
}
public Long getLong(String parameterName) throws ConversionException {
public Long getLong(String parameterName) throws ConversionExecutionException {
return (Long) get(parameterName, Long.class);
}
public Long getLong(String parameterName, Long defaultValue) throws ConversionException {
public Long getLong(String parameterName, Long defaultValue) throws ConversionExecutionException {
return (Long) get(parameterName, Long.class, defaultValue);
}
public Long getRequiredLong(String parameterName) throws IllegalArgumentException, ConversionException {
public Long getRequiredLong(String parameterName) throws IllegalArgumentException, ConversionExecutionException {
return (Long) getRequired(parameterName, Long.class);
}
public Boolean getBoolean(String parameterName) throws ConversionException {
public Boolean getBoolean(String parameterName) throws ConversionExecutionException {
return (Boolean) get(parameterName, Boolean.class);
}
public Boolean getBoolean(String parameterName, Boolean defaultValue) throws ConversionException {
public Boolean getBoolean(String parameterName, Boolean defaultValue) throws ConversionExecutionException {
return (Boolean) get(parameterName, Boolean.class, defaultValue);
}
public Boolean getRequiredBoolean(String parameterName) throws IllegalArgumentException, ConversionException {
public Boolean getRequiredBoolean(String parameterName) throws IllegalArgumentException, ConversionExecutionException {
return (Boolean) getRequired(parameterName, Boolean.class);
}
@@ -272,14 +272,14 @@ public class LocalParameterMap implements ParameterMap, Serializable {
/**
* Convert given String parameter to specified target type.
*/
private Object convert(String parameter, Class targetType) throws ConversionException {
private Object convert(String parameter, Class targetType) throws ConversionExecutionException {
return conversionService.getConversionExecutor(String.class, targetType).execute(parameter);
}
/**
* Convert given array of String parameters to specified target type and return the resulting array.
*/
private Object[] convert(String[] parameters, Class targetElementType) throws ConversionException {
private Object[] convert(String[] parameters, Class targetElementType) throws ConversionExecutionException {
List list = new ArrayList(parameters.length);
ConversionExecutor converter = conversionService.getConversionExecutor(String.class, targetElementType);
for (int i = 0; i < parameters.length; i++) {

View File

@@ -16,7 +16,7 @@
package org.springframework.webflow.core.collection;
import org.springframework.binding.collection.MapAdaptable;
import org.springframework.binding.convert.ConversionException;
import org.springframework.binding.convert.ConversionExecutionException;
import org.springframework.web.multipart.MultipartFile;
/**
@@ -78,18 +78,18 @@ public interface ParameterMap extends MapAdaptable {
* @param parameterName the parameter name
* @param targetElementType the target type of the array's elements
* @return the converterd parameter value array
* @throws ConversionException when the value could not be converted
* @throws ConversionExecutionException when the value could not be converted
*/
public Object[] getArray(String parameterName, Class targetElementType) throws ConversionException;
public Object[] getArray(String parameterName, Class targetElementType) throws ConversionExecutionException;
/**
* Get a parameter value, converting it from <code>String</code> to the target type.
* @param parameterName the name of the parameter
* @param targetType the target type of the parameter value
* @return the converted parameter value, or null if not found
* @throws ConversionException when the value could not be converted
* @throws ConversionExecutionException when the value could not be converted
*/
public Object get(String parameterName, Class targetType) throws ConversionException;
public Object get(String parameterName, Class targetType) throws ConversionExecutionException;
/**
* Get a parameter value, converting it from <code>String</code> to the target type or returning the defaultValue
@@ -98,9 +98,9 @@ public interface ParameterMap extends MapAdaptable {
* @param targetType the target type of the parameter value
* @param defaultValue the default value
* @return the converted parameter value, or the default if not found
* @throws ConversionException when a value could not be converted
* @throws ConversionExecutionException when a value could not be converted
*/
public Object get(String parameterName, Class targetType, Object defaultValue) throws ConversionException;
public Object get(String parameterName, Class targetType, Object defaultValue) throws ConversionExecutionException;
/**
* Get the value of a required parameter.
@@ -123,10 +123,10 @@ public interface ParameterMap extends MapAdaptable {
* @param parameterName the name of the parameter
* @return the parameter value
* @throws IllegalArgumentException when the parameter is not found
* @throws ConversionException when a value could not be converted
* @throws ConversionExecutionException when a value could not be converted
*/
public Object[] getRequiredArray(String parameterName, Class targetElementType) throws IllegalArgumentException,
ConversionException;
ConversionExecutionException;
/**
* Get the value of a required parameter and convert it to the target type.
@@ -134,10 +134,10 @@ public interface ParameterMap extends MapAdaptable {
* @param targetType the target type of the parameter value
* @return the converted parameter value
* @throws IllegalArgumentException when the parameter is not found
* @throws ConversionException when the value could not be converted
* @throws ConversionExecutionException when the value could not be converted
*/
public Object getRequired(String parameterName, Class targetType) throws IllegalArgumentException,
ConversionException;
ConversionExecutionException;
/**
* Returns a number parameter value in the map that is of the specified type, returning <code>null</code> if no
@@ -145,9 +145,9 @@ public interface ParameterMap extends MapAdaptable {
* @param parameterName the parameter name
* @param targetType the target number type
* @return the number parameter value
* @throws ConversionException when the value could not be converted
* @throws ConversionExecutionException when the value could not be converted
*/
public Number getNumber(String parameterName, Class targetType) throws ConversionException;
public Number getNumber(String parameterName, Class targetType) throws ConversionExecutionException;
/**
* Returns a number parameter value in the map of the specified type, returning the defaultValue if no value was
@@ -155,9 +155,9 @@ public interface ParameterMap extends MapAdaptable {
* @param parameterName the parameter name
* @param defaultValue the default
* @return the number parameter value
* @throws ConversionException when the value could not be converted
* @throws ConversionExecutionException when the value could not be converted
*/
public Number getNumber(String parameterName, Class targetType, Number defaultValue) throws ConversionException;
public Number getNumber(String parameterName, Class targetType, Number defaultValue) throws ConversionExecutionException;
/**
* Returns a number parameter value in the map, throwing an exception if the parameter is not present or could not
@@ -165,27 +165,27 @@ public interface ParameterMap extends MapAdaptable {
* @param parameterName the parameter name
* @return the number parameter value
* @throws IllegalArgumentException if the parameter is not present
* @throws ConversionException when the value could not be converted
* @throws ConversionExecutionException when the value could not be converted
*/
public Number getRequiredNumber(String parameterName, Class targetType) throws IllegalArgumentException,
ConversionException;
ConversionExecutionException;
/**
* Returns an integer parameter value in the map, returning <code>null</code> if no value was found.
* @param parameterName the parameter name
* @return the integer parameter value
* @throws ConversionException when the value could not be converted
* @throws ConversionExecutionException when the value could not be converted
*/
public Integer getInteger(String parameterName) throws ConversionException;
public Integer getInteger(String parameterName) throws ConversionExecutionException;
/**
* Returns an integer parameter value in the map, returning the defaultValue if no value was found.
* @param parameterName the parameter name
* @param defaultValue the default
* @return the integer parameter value
* @throws ConversionException when the value could not be converted
* @throws ConversionExecutionException when the value could not be converted
*/
public Integer getInteger(String parameterName, Integer defaultValue) throws ConversionException;
public Integer getInteger(String parameterName, Integer defaultValue) throws ConversionExecutionException;
/**
* Returns an integer parameter value in the map, throwing an exception if the parameter is not present or could not
@@ -193,26 +193,26 @@ public interface ParameterMap extends MapAdaptable {
* @param parameterName the parameter name
* @return the integer parameter value
* @throws IllegalArgumentException if the parameter is not present
* @throws ConversionException when the value could not be converted
* @throws ConversionExecutionException when the value could not be converted
*/
public Integer getRequiredInteger(String parameterName) throws IllegalArgumentException, ConversionException;
public Integer getRequiredInteger(String parameterName) throws IllegalArgumentException, ConversionExecutionException;
/**
* Returns a long parameter value in the map, returning <code>null</code> if no value was found.
* @param parameterName the parameter name
* @return the long parameter value
* @throws ConversionException when the value could not be converted
* @throws ConversionExecutionException when the value could not be converted
*/
public Long getLong(String parameterName) throws ConversionException;
public Long getLong(String parameterName) throws ConversionExecutionException;
/**
* Returns a long parameter value in the map, returning the defaultValue if no value was found.
* @param parameterName the parameter name
* @param defaultValue the default
* @return the long parameter value
* @throws ConversionException when the value could not be converted
* @throws ConversionExecutionException when the value could not be converted
*/
public Long getLong(String parameterName, Long defaultValue) throws ConversionException;
public Long getLong(String parameterName, Long defaultValue) throws ConversionExecutionException;
/**
* Returns a long parameter value in the map, throwing an exception if the parameter is not present or could not be
@@ -220,26 +220,26 @@ public interface ParameterMap extends MapAdaptable {
* @param parameterName the parameter name
* @return the long parameter value
* @throws IllegalArgumentException if the parameter is not present
* @throws ConversionException when the value could not be converted
* @throws ConversionExecutionException when the value could not be converted
*/
public Long getRequiredLong(String parameterName) throws IllegalArgumentException, ConversionException;
public Long getRequiredLong(String parameterName) throws IllegalArgumentException, ConversionExecutionException;
/**
* Returns a boolean parameter value in the map, returning <code>null</code> if no value was found.
* @param parameterName the parameter name
* @return the long parameter value
* @throws ConversionException when the value could not be converted
* @throws ConversionExecutionException when the value could not be converted
*/
public Boolean getBoolean(String parameterName) throws ConversionException;
public Boolean getBoolean(String parameterName) throws ConversionExecutionException;
/**
* Returns a boolean parameter value in the map, returning the defaultValue if no value was found.
* @param parameterName the parameter name
* @param defaultValue the default
* @return the boolean parameter value
* @throws ConversionException when the value could not be converted
* @throws ConversionExecutionException when the value could not be converted
*/
public Boolean getBoolean(String parameterName, Boolean defaultValue) throws ConversionException;
public Boolean getBoolean(String parameterName, Boolean defaultValue) throws ConversionExecutionException;
/**
* Returns a boolean parameter value in the map, throwing an exception if the parameter is not present or could not
@@ -247,9 +247,9 @@ public interface ParameterMap extends MapAdaptable {
* @param parameterName the parameter name
* @return the boolean parameter value
* @throws IllegalArgumentException if the parameter is not present
* @throws ConversionException when the value could not be converted
* @throws ConversionExecutionException when the value could not be converted
*/
public Boolean getRequiredBoolean(String parameterName) throws IllegalArgumentException, ConversionException;
public Boolean getRequiredBoolean(String parameterName) throws IllegalArgumentException, ConversionExecutionException;
/**
* Get a multi-part file parameter value, returning <code>null</code> if no value is found.

View File

@@ -24,7 +24,7 @@ import java.util.List;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.binding.convert.ConversionException;
import org.springframework.binding.convert.ConversionExecutionException;
import org.springframework.binding.convert.ConversionExecutor;
import org.springframework.binding.convert.service.RuntimeBindingConversionExecutor;
import org.springframework.binding.expression.EvaluationException;
@@ -905,7 +905,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder {
}
}
private ConversionExecutor fromStringTo(Class targetType) throws ConversionException {
private ConversionExecutor fromStringTo(Class targetType) throws ConversionExecutionException {
return getLocalContext().getConversionService().getConversionExecutor(String.class, targetType);
}

View File

@@ -15,7 +15,7 @@
*/
package org.springframework.webflow.engine.builder.support;
import org.springframework.binding.convert.ConversionException;
import org.springframework.binding.convert.ConversionExecutionException;
import org.springframework.binding.convert.ConversionExecutor;
import org.springframework.binding.convert.ConversionService;
import org.springframework.binding.convert.service.GenericConversionService;
@@ -125,7 +125,7 @@ public class FlowBuilderContextImpl implements FlowBuilderContext {
*/
private class ParentConversionServiceProxy implements ConversionService {
public ConversionExecutor getConversionExecutor(Class sourceClass, Class targetClass)
throws ConversionException {
throws ConversionExecutionException {
return getFlowBuilderServices().getConversionService().getConversionExecutor(sourceClass, targetClass);
}
}

View File

@@ -15,7 +15,7 @@
*/
package org.springframework.webflow.engine.builder.support;
import org.springframework.binding.convert.converters.AbstractConverter;
import org.springframework.binding.convert.Converter;
import org.springframework.binding.expression.Expression;
import org.springframework.binding.expression.ExpressionParser;
import org.springframework.binding.expression.support.FluentParserContext;
@@ -40,7 +40,7 @@ import org.springframework.webflow.execution.RequestContext;
* @author Keith Donald
* @author Erwin Vervaet
*/
class TextToTargetStateResolver extends AbstractConverter {
class TextToTargetStateResolver implements Converter {
/**
* Context for flow builder services.
@@ -63,7 +63,7 @@ class TextToTargetStateResolver extends AbstractConverter {
return new Class[] { TargetStateResolver.class };
}
protected Object doConvert(Object source, Class targetClass, Object context) throws Exception {
public Object convert(Object source, Class targetClass, Object context) throws Exception {
String targetStateId = (String) source;
if (!StringUtils.hasText(targetStateId)) {
return null;

View File

@@ -15,8 +15,8 @@
*/
package org.springframework.webflow.engine.builder.support;
import org.springframework.binding.convert.ConversionException;
import org.springframework.binding.convert.converters.AbstractConverter;
import org.springframework.binding.convert.ConversionExecutionException;
import org.springframework.binding.convert.Converter;
import org.springframework.binding.expression.Expression;
import org.springframework.binding.expression.ExpressionParser;
import org.springframework.binding.expression.ExpressionVariable;
@@ -47,7 +47,7 @@ import org.springframework.webflow.execution.RequestContext;
* @author Keith Donald
* @author Erwin Vervaet
*/
class TextToTransitionCriteria extends AbstractConverter {
class TextToTransitionCriteria implements Converter {
/**
* Context for flow builder services.
@@ -70,7 +70,7 @@ class TextToTransitionCriteria extends AbstractConverter {
return new Class[] { TransitionCriteria.class };
}
protected Object doConvert(Object source, Class targetClass, Object context) throws Exception {
public Object convert(Object source, Class targetClass, Object context) throws Exception {
String encodedCriteria = (String) source;
ExpressionParser parser = flowBuilderContext.getExpressionParser();
if (!StringUtils.hasText(encodedCriteria)
@@ -87,10 +87,10 @@ class TextToTransitionCriteria extends AbstractConverter {
* @param encodedCriteria the encoded transition criteria expression
* @param parser the parser that should parse the expression
* @return the transition criteria object
* @throws ConversionException when something goes wrong
* @throws ConversionExecutionException when something goes wrong
*/
protected TransitionCriteria createBooleanExpressionTransitionCriteria(String encodedCriteria,
ExpressionParser parser) throws ConversionException {
ExpressionParser parser) throws ConversionExecutionException {
Expression expression = parser.parseExpression(encodedCriteria, new FluentParserContext().template().evaluate(
RequestContext.class).variable(new ExpressionVariable("result", "lastEvent.id")));
return new DefaultTransitionCriteria(expression);

View File

@@ -17,6 +17,8 @@ package org.springframework.webflow.expression;
import javax.el.ExpressionFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.binding.expression.Expression;
import org.springframework.binding.expression.ExpressionParser;
import org.springframework.binding.expression.ParserContext;
@@ -42,6 +44,8 @@ import org.springframework.webflow.expression.el.WebFlowELExpressionParser;
*/
public final class DefaultExpressionParserFactory {
private static final Log logger = LogFactory.getLog(DefaultExpressionParserFactory.class);
/**
* The singleton instance of the default expression parser.
*/
@@ -73,6 +77,9 @@ public final class DefaultExpressionParserFactory {
private static synchronized ExpressionParser getDefaultExpressionParser() {
if (INSTANCE == null) {
INSTANCE = createDefaultExpressionParser();
if (logger.isDebugEnabled()) {
logger.debug("Initialized default Web Flow ExpressionParser " + INSTANCE);
}
}
return INSTANCE;
}

View File

@@ -23,7 +23,7 @@ import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.binding.convert.ConversionException;
import org.springframework.binding.convert.ConversionExecutionException;
import org.springframework.binding.convert.ConversionExecutor;
import org.springframework.binding.expression.EvaluationException;
import org.springframework.binding.expression.Expression;
@@ -356,11 +356,11 @@ public abstract class AbstractMvcView implements View {
this.formatterRegistry = formatterRegistry;
}
public Object execute(Object source) throws ConversionException {
public Object execute(Object source) throws ConversionExecutionException {
throw new UnsupportedOperationException("Should never be called");
}
public Object execute(Object source, Object context) throws ConversionException {
public Object execute(Object source, Object context) throws ConversionExecutionException {
String formattedValue = (String) source;
DefaultMappingContext mappingContext = (DefaultMappingContext) context;
Expression target = mappingContext.getCurrentMapping().getTargetExpression();
@@ -380,7 +380,7 @@ public abstract class AbstractMvcView implements View {
try {
return formatter.parse(formattedValue);
} catch (InvalidFormatException e) {
throw new ConversionException(String.class, targetClass, e);
throw new ConversionExecutionException(formattedValue, String.class, targetClass, e);
}
} else {
return formattedValue;

View File

@@ -2,7 +2,7 @@ package org.springframework.webflow.config;
import junit.framework.TestCase;
import org.springframework.binding.convert.ConversionException;
import org.springframework.binding.convert.ConversionExecutionException;
import org.springframework.binding.convert.ConversionExecutor;
import org.springframework.binding.convert.ConversionService;
import org.springframework.binding.convert.service.DefaultConversionService;
@@ -57,21 +57,21 @@ public class FlowBuilderServicesBeanDefinitionParserTests extends TestCase {
public static class TestConversionService implements ConversionService {
public Class getClassByAlias(String alias) throws ConversionException {
public Class getClassByAlias(String alias) throws ConversionExecutionException {
throw new UnsupportedOperationException("Auto-generated method stub");
}
public ConversionExecutor getConversionExecutor(Class sourceClass, Class targetClass)
throws ConversionException {
throws ConversionExecutionException {
throw new UnsupportedOperationException("Auto-generated method stub");
}
public ConversionExecutor getConversionExecutorByTargetAlias(Class sourceClass, String targetAlias)
throws ConversionException {
throws ConversionExecutionException {
throw new UnsupportedOperationException("Auto-generated method stub");
}
public ConversionExecutor[] getConversionExecutorsForSource(Class sourceClass) throws ConversionException {
public ConversionExecutor[] getConversionExecutorsForSource(Class sourceClass) throws ConversionExecutionException {
throw new UnsupportedOperationException("Auto-generated method stub");
}

View File

@@ -30,33 +30,36 @@ public class TextToTargetStateResolverTests extends TestCase {
public void setUp() {
}
public void testStatic() {
public void testStatic() throws Exception {
String expression = "mockState";
TargetStateResolver resolver = (TargetStateResolver) converter.convert(expression);
TargetStateResolver resolver = (TargetStateResolver) converter.convert(expression, TargetStateResolver.class,
null);
MockRequestContext context = new MockRequestContext();
Transition transition = new Transition();
assertEquals("mockState", resolver.resolveTargetState(transition, null, context).getId());
}
public void testDynamic() {
public void testDynamic() throws Exception {
String expression = "${flowScope.lastState}";
TargetStateResolver resolver = (TargetStateResolver) converter.convert(expression);
TargetStateResolver resolver = (TargetStateResolver) converter.convert(expression, TargetStateResolver.class,
null);
MockRequestContext context = new MockRequestContext();
context.getFlowScope().put("lastState", "mockState");
Transition transition = new Transition();
assertEquals("mockState", resolver.resolveTargetState(transition, null, context).getId());
}
public void testNull() {
public void testNull() throws Exception {
String expression = null;
TargetStateResolver resolver = (TargetStateResolver) converter.convert(expression);
TargetStateResolver resolver = (TargetStateResolver) converter.convert(expression, TargetStateResolver.class,
null);
assertNull(resolver);
}
public void testEmpty() {
public void testEmpty() throws Exception {
String expression = "";
TargetStateResolver resolver = (TargetStateResolver) converter.convert(expression);
TargetStateResolver resolver = (TargetStateResolver) converter.convert(expression, TargetStateResolver.class,
null);
assertNull(resolver);
}
}

View File

@@ -39,40 +39,45 @@ public class TextToTransitionCriteriaTests extends TestCase {
public void setUp() {
}
public void testAny() {
public void testAny() throws Exception {
String expression = "*";
TransitionCriteria criterion = (TransitionCriteria) converter.convert(expression);
TransitionCriteria criterion = (TransitionCriteria) converter.convert(expression, TransitionCriteria.class,
null);
RequestContext ctx = getRequestContext();
assertTrue("Criterion should evaluate to true", criterion.test(ctx));
assertSame(WildcardTransitionCriteria.INSTANCE, converter.convert("*"));
assertSame(WildcardTransitionCriteria.INSTANCE, converter.convert(""));
assertSame(WildcardTransitionCriteria.INSTANCE, converter.convert(null));
assertSame(WildcardTransitionCriteria.INSTANCE, converter.convert("*", TransitionCriteria.class, null));
assertSame(WildcardTransitionCriteria.INSTANCE, converter.convert("", TransitionCriteria.class, null));
assertSame(WildcardTransitionCriteria.INSTANCE, converter.convert(null, TransitionCriteria.class, null));
}
public void testStaticEventId() {
public void testStaticEventId() throws Exception {
String expression = "sample";
TransitionCriteria criterion = (TransitionCriteria) converter.convert(expression);
TransitionCriteria criterion = (TransitionCriteria) converter.convert(expression, TransitionCriteria.class,
null);
RequestContext ctx = getRequestContext();
assertTrue("Criterion should evaluate to true", criterion.test(ctx));
}
public void testTrueEvaluation() throws Exception {
String expression = "${flowScope.foo == 'bar'}";
TransitionCriteria criterion = (TransitionCriteria) converter.convert(expression);
TransitionCriteria criterion = (TransitionCriteria) converter.convert(expression, TransitionCriteria.class,
null);
RequestContext ctx = getRequestContext();
assertTrue("Criterion should evaluate to true", criterion.test(ctx));
}
public void testFalseEvaluation() throws Exception {
String expression = "${flowScope.foo != 'bar'}";
TransitionCriteria criterion = (TransitionCriteria) converter.convert(expression);
TransitionCriteria criterion = (TransitionCriteria) converter.convert(expression, TransitionCriteria.class,
null);
RequestContext ctx = getRequestContext();
assertFalse("Criterion should evaluate to false", criterion.test(ctx));
}
public void testNonStringEvaluation() throws Exception {
String expression = "${3 + 4}";
TransitionCriteria criterion = (TransitionCriteria) converter.convert(expression);
TransitionCriteria criterion = (TransitionCriteria) converter.convert(expression, TransitionCriteria.class,
null);
MockRequestContext ctx = getRequestContext();
ctx.setCurrentEvent(new Event(this, "7"));
assertTrue("Criterion should evaluate to true", criterion.test(ctx));
@@ -84,7 +89,8 @@ public class TextToTransitionCriteriaTests extends TestCase {
return new StaticExpression(null);
}
});
TransitionCriteria criterion = (TransitionCriteria) converter.convert("doesnt matter");
TransitionCriteria criterion = (TransitionCriteria) converter.convert("doesnt matter",
TransitionCriteria.class, null);
RequestContext ctx = getRequestContext();
assertFalse("Criterion should evaluate to false", criterion.test(ctx));
}