diff --git a/build-spring-webflow/ivy.xml b/build-spring-webflow/ivy.xml
index 5ccfeb44..9a573c93 100644
--- a/build-spring-webflow/ivy.xml
+++ b/build-spring-webflow/ivy.xml
@@ -14,4 +14,5 @@
+
\ No newline at end of file
diff --git a/spring-binding/src/main/java/org/springframework/binding/format/IntegerNumberFormatFactory.java b/spring-binding/src/main/java/org/springframework/binding/format/IntegerNumberFormatFactory.java
index 22c8877b..780f7872 100644
--- a/spring-binding/src/main/java/org/springframework/binding/format/IntegerNumberFormatFactory.java
+++ b/spring-binding/src/main/java/org/springframework/binding/format/IntegerNumberFormatFactory.java
@@ -19,6 +19,8 @@ import java.text.NumberFormat;
import java.util.Locale;
/**
+ * Produces NumberFormat instances that format integer values.
+ *
* @see NumberFormat
* @author Keith Donald
*/
diff --git a/spring-binding/src/main/java/org/springframework/binding/format/NumberFormatFactory.java b/spring-binding/src/main/java/org/springframework/binding/format/NumberFormatFactory.java
index 2212556a..1cdea943 100644
--- a/spring-binding/src/main/java/org/springframework/binding/format/NumberFormatFactory.java
+++ b/spring-binding/src/main/java/org/springframework/binding/format/NumberFormatFactory.java
@@ -13,7 +13,7 @@ public interface NumberFormatFactory {
/**
* Factory method that returns a fully-configured {@link NumberFormat} instance to use to format an object for
* display.
- * @return returns the number for a
+ * @return the number format
*/
public NumberFormat getNumberFormat();
diff --git a/spring-binding/src/main/java/org/springframework/binding/message/MessageContextErrors.java b/spring-binding/src/main/java/org/springframework/binding/message/MessageContextErrors.java
index 4648cecc..32a78405 100644
--- a/spring-binding/src/main/java/org/springframework/binding/message/MessageContextErrors.java
+++ b/spring-binding/src/main/java/org/springframework/binding/message/MessageContextErrors.java
@@ -53,13 +53,15 @@ public class MessageContextErrors extends AbstractErrors {
* Creates a new message context errors adapter.
* @param messageContext the backing message context
* @param objectName the object name
+ * @param boundObject the model object
+ * @param expressionParser the expression parser
+ * @param mappingResults object mapping results
*/
public MessageContextErrors(MessageContext messageContext, String objectName, Object boundObject,
ExpressionParser expressionParser, MappingResults mappingResults) {
this.messageContext = messageContext;
- this.messageContext = messageContext;
- this.boundObject = boundObject;
this.objectName = objectName;
+ this.boundObject = boundObject;
this.expressionParser = expressionParser;
this.mappingResults = mappingResults;
}
@@ -118,6 +120,7 @@ public class MessageContextErrors extends AbstractErrors {
}
public Object getFieldValue(String field) {
+ // requires boundObject, and expressionParser to work
if (mappingResults != null) {
List results = mappingResults.getResults(new FieldErrorResult(field));
if (!results.isEmpty()) {
diff --git a/spring-faces/src/test/java/org/springframework/faces/config/FacesFlowBuilderServicesBeanDefinitionParserTests.java b/spring-faces/src/test/java/org/springframework/faces/config/FacesFlowBuilderServicesBeanDefinitionParserTests.java
index 972de9ea..ae5d036b 100644
--- a/spring-faces/src/test/java/org/springframework/faces/config/FacesFlowBuilderServicesBeanDefinitionParserTests.java
+++ b/spring-faces/src/test/java/org/springframework/faces/config/FacesFlowBuilderServicesBeanDefinitionParserTests.java
@@ -53,14 +53,23 @@ public class FacesFlowBuilderServicesBeanDefinitionParserTests extends TestCase
assertTrue(builderServices.getConversionService() instanceof FacesConversionService);
}
- public void testFlowBuilderServicesCustomized() {
- builderServices = (FlowBuilderServices) context.getBean("flowBuilderServicesCustom");
+ public void testFlowBuilderServicesAllCustomized() {
+ builderServices = (FlowBuilderServices) context.getBean("flowBuilderServicesAllCustom");
assertNotNull(builderServices);
- assertNotNull(builderServices.getExpressionParser());
+ assertTrue(builderServices.getExpressionParser() instanceof WebFlowELExpressionParser);
assertTrue(builderServices.getViewFactoryCreator() instanceof TestViewFactoryCreator);
assertTrue(builderServices.getConversionService() instanceof TestConversionService);
}
+ public void testFlowBuilderServicesConversionServiceCustomized() {
+ builderServices = (FlowBuilderServices) context.getBean("flowBuilderServicesConversionServiceCustom");
+ assertNotNull(builderServices);
+ assertTrue(builderServices.getConversionService() instanceof TestConversionService);
+ assertTrue(builderServices.getExpressionParser() instanceof WebFlowELExpressionParser);
+ assertTrue(((WebFlowELExpressionParser) builderServices.getExpressionParser()).getConversionService() instanceof TestConversionService);
+ assertTrue(builderServices.getViewFactoryCreator() instanceof JsfViewFactoryCreator);
+ }
+
public static class TestViewFactoryCreator implements ViewFactoryCreator {
public ViewFactory createViewFactory(Expression viewIdExpression, ExpressionParser expressionParser,
diff --git a/spring-faces/src/test/java/org/springframework/faces/config/flow-builder-services.xml b/spring-faces/src/test/java/org/springframework/faces/config/flow-builder-services.xml
index 80e95a5f..a741449c 100644
--- a/spring-faces/src/test/java/org/springframework/faces/config/flow-builder-services.xml
+++ b/spring-faces/src/test/java/org/springframework/faces/config/flow-builder-services.xml
@@ -12,10 +12,13 @@
-
+
+
diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/EndStateModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/EndStateModel.java
index 31c0b7c2..98b46ad6 100644
--- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/EndStateModel.java
+++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/EndStateModel.java
@@ -110,17 +110,4 @@ public class EndStateModel extends AbstractStateModel {
this.outputs = outputs;
}
- /**
- * @param output the output mapping to add
- */
- public void addOutput(OutputModel output) {
- if (output == null) {
- return;
- }
- if (outputs == null) {
- outputs = new LinkedList();
- }
- outputs.add(output);
- }
-
}
diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/FlowModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/FlowModel.java
index f2988b5f..6c884501 100644
--- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/FlowModel.java
+++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/FlowModel.java
@@ -163,13 +163,6 @@ public class FlowModel extends AbstractModel {
}
}
- /**
- * @param startState the flow's start state to set
- */
- public void setStartState(AbstractStateModel startState) {
- setStartStateId(startState.getId());
- }
-
/**
* @return the attributes
*/
@@ -184,32 +177,6 @@ public class FlowModel extends AbstractModel {
this.attributes = attributes;
}
- /**
- * @param attribute the attribute to add
- */
- public void addAttribute(AttributeModel attribute) {
- if (attribute == null) {
- return;
- }
- if (attributes == null) {
- attributes = new LinkedList();
- }
- attributes.add(attribute);
- }
-
- /**
- * @param attributes the attributes to add
- */
- public void addAttributes(LinkedList attributes) {
- if (attributes == null || attributes.isEmpty()) {
- return;
- }
- if (this.attributes == null) {
- this.attributes = new LinkedList();
- }
- this.attributes.addAll(attributes);
- }
-
/**
* @return the secured
*/
@@ -252,32 +219,6 @@ public class FlowModel extends AbstractModel {
this.vars = vars;
}
- /**
- * @param var the var to add
- */
- public void addVar(VarModel var) {
- if (var == null) {
- return;
- }
- if (vars == null) {
- vars = new LinkedList();
- }
- vars.add(var);
- }
-
- /**
- * @param vars the vars to add
- */
- public void addVars(LinkedList vars) {
- if (vars == null || vars.isEmpty()) {
- return;
- }
- if (this.vars == null) {
- this.vars = new LinkedList();
- }
- this.vars.addAll(vars);
- }
-
/**
* @return the input mappings
*/
@@ -292,32 +233,6 @@ public class FlowModel extends AbstractModel {
this.inputs = inputs;
}
- /**
- * @param input the input mapping to add
- */
- public void addInput(InputModel input) {
- if (input == null) {
- return;
- }
- if (inputs == null) {
- inputs = new LinkedList();
- }
- inputs.add(input);
- }
-
- /**
- * @param inputs the input mappings to add
- */
- public void addInputs(LinkedList inputs) {
- if (inputs == null || inputs.isEmpty()) {
- return;
- }
- if (this.inputs == null) {
- this.inputs = new LinkedList();
- }
- this.inputs.addAll(inputs);
- }
-
/**
* @return the output mappings
*/
@@ -332,32 +247,6 @@ public class FlowModel extends AbstractModel {
this.outputs = outputs;
}
- /**
- * @param output the output mapping to add
- */
- public void addOutput(OutputModel output) {
- if (output == null) {
- return;
- }
- if (outputs == null) {
- outputs = new LinkedList();
- }
- outputs.add(output);
- }
-
- /**
- * @param outputs the output mappings to add
- */
- public void addOutputs(LinkedList outputs) {
- if (outputs == null || outputs.isEmpty()) {
- return;
- }
- if (this.outputs == null) {
- this.outputs = new LinkedList();
- }
- this.outputs.addAll(outputs);
- }
-
/**
* @return the on start actions
*/
@@ -372,32 +261,6 @@ public class FlowModel extends AbstractModel {
this.onStartActions = onStartActions;
}
- /**
- * @param onStartAction the on start action to add
- */
- public void addOnStartAction(AbstractActionModel onStartAction) {
- if (onStartAction == null) {
- return;
- }
- if (onStartActions == null) {
- onStartActions = new LinkedList();
- }
- onStartActions.add(onStartAction);
- }
-
- /**
- * @param onStartActions the on start actions to add
- */
- public void addOnStartActions(LinkedList onStartActions) {
- if (onStartActions == null || onStartActions.isEmpty()) {
- return;
- }
- if (this.onStartActions == null) {
- this.onStartActions = new LinkedList();
- }
- this.onStartActions.addAll(onStartActions);
- }
-
/**
* @return the states
*/
@@ -429,67 +292,6 @@ public class FlowModel extends AbstractModel {
this.states = states;
}
- /**
- * @param state the state to add
- */
- public void addState(AbstractStateModel state) {
- if (state == null) {
- return;
- }
- if (states == null) {
- states = new LinkedList();
- }
- states.add(state);
- }
-
- /**
- * @param states the states to add
- */
- public void addStates(LinkedList states) {
- if (states == null || states.isEmpty()) {
- return;
- }
- if (this.states == null) {
- this.states = new LinkedList();
- }
- this.states.addAll(states);
- }
-
- /**
- * @param state the action state to add
- */
- public void addActionState(ActionStateModel state) {
- addState(state);
- }
-
- /**
- * @param state the view state to add
- */
- public void addViewState(ViewStateModel state) {
- addState(state);
- }
-
- /**
- * @param state the decision state to add
- */
- public void addDecisionState(DecisionStateModel state) {
- addState(state);
- }
-
- /**
- * @param state the subflow state to add
- */
- public void addSubflowState(SubflowStateModel state) {
- addState(state);
- }
-
- /**
- * @param state the end state to add
- */
- public void addEndState(EndStateModel state) {
- addState(state);
- }
-
/**
* @return the global transitions
*/
@@ -504,32 +306,6 @@ public class FlowModel extends AbstractModel {
this.globalTransitions = globalTransitions;
}
- /**
- * @param globalTransition the global transition to add
- */
- public void addGlobalTransition(TransitionModel globalTransition) {
- if (globalTransition == null) {
- return;
- }
- if (globalTransitions == null) {
- globalTransitions = new LinkedList();
- }
- globalTransitions.add(globalTransition);
- }
-
- /**
- * @param globalTransitions the global transitions to add
- */
- public void addGlobalTransitions(LinkedList globalTransitions) {
- if (globalTransitions == null || globalTransitions.isEmpty()) {
- return;
- }
- if (this.globalTransitions == null) {
- this.globalTransitions = new LinkedList();
- }
- this.globalTransitions.addAll(globalTransitions);
- }
-
/**
* @return the on end actions
*/
@@ -544,32 +320,6 @@ public class FlowModel extends AbstractModel {
this.onEndActions = onEndActions;
}
- /**
- * @param onEndAction the on end action to add
- */
- public void addOnEndAction(AbstractActionModel onEndAction) {
- if (onEndAction == null) {
- return;
- }
- if (onEndActions == null) {
- onEndActions = new LinkedList();
- }
- onEndActions.add(onEndAction);
- }
-
- /**
- * @param onEndActions the on end actions to add
- */
- public void addOnEndActions(LinkedList onEndActions) {
- if (onEndActions == null || onEndActions.isEmpty()) {
- return;
- }
- if (this.onEndActions == null) {
- this.onEndActions = new LinkedList();
- }
- this.onEndActions.addAll(onEndActions);
- }
-
/**
* @return the exception handlers
*/
@@ -584,32 +334,6 @@ public class FlowModel extends AbstractModel {
this.exceptionHandlers = exceptionHandlers;
}
- /**
- * @param exceptionHandler the exception handler to add
- */
- public void addExceptionHandler(ExceptionHandlerModel exceptionHandler) {
- if (exceptionHandler == null) {
- return;
- }
- if (exceptionHandlers == null) {
- exceptionHandlers = new LinkedList();
- }
- exceptionHandlers.add(exceptionHandler);
- }
-
- /**
- * @param exceptionHandlers the exception handlers to add
- */
- public void addExceptionHandlers(LinkedList exceptionHandlers) {
- if (exceptionHandlers == null || exceptionHandlers.isEmpty()) {
- return;
- }
- if (this.exceptionHandlers == null) {
- this.exceptionHandlers = new LinkedList();
- }
- this.exceptionHandlers.addAll(exceptionHandlers);
- }
-
/**
* @return the bean imports
*/
@@ -624,30 +348,4 @@ public class FlowModel extends AbstractModel {
this.beanImports = beanImports;
}
- /**
- * @param beanImport the bean import to add
- */
- public void addBeanImport(BeanImportModel beanImport) {
- if (beanImport == null) {
- return;
- }
- if (beanImports == null) {
- beanImports = new LinkedList();
- }
- beanImports.add(beanImport);
- }
-
- /**
- * @param beanImports the bean imports to add
- */
- public void addBeanImports(LinkedList beanImports) {
- if (beanImports == null || beanImports.isEmpty()) {
- return;
- }
- if (this.beanImports == null) {
- this.beanImports = new LinkedList();
- }
- this.beanImports.addAll(beanImports);
- }
-
-}
+}
\ No newline at end of file
diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/ViewStateModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/ViewStateModel.java
index 938a1ec2..e7017c95 100644
--- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/ViewStateModel.java
+++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/ViewStateModel.java
@@ -161,19 +161,6 @@ public class ViewStateModel extends AbstractTransitionableStateModel {
this.vars = vars;
}
- /**
- * @param var the var to add
- */
- public void addVar(VarModel var) {
- if (var == null) {
- return;
- }
- if (vars == null) {
- vars = new LinkedList();
- }
- vars.add(var);
- }
-
public BinderModel getBinder() {
return binder;
}
diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/xml/XmlFlowModelBuilder.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/xml/XmlFlowModelBuilder.java
index 27b152df..b51d9aee 100644
--- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/xml/XmlFlowModelBuilder.java
+++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/xml/XmlFlowModelBuilder.java
@@ -198,18 +198,18 @@ public class XmlFlowModelBuilder implements FlowModelBuilder {
flow.setAbstract(element.getAttribute("abstract"));
flow.setParent(element.getAttribute("parent"));
flow.setStartStateId(element.getAttribute("start-state"));
- flow.addAttributes(parseAttributes(element));
+ flow.setAttributes(parseAttributes(element));
flow.setSecured(parseSecured(element));
flow.setPersistenceContext(parsePersistenceContext(element));
- flow.addVars(parseVars(element));
- flow.addInputs(parseInputs(element));
- flow.addOnStartActions(parseOnStartActions(element));
- flow.addStates(parseStates(element));
- flow.addGlobalTransitions(parseGlobalTransitions(element));
- flow.addOnEndActions(parseOnEndActions(element));
- flow.addOutputs(parseOutputs(element));
- flow.addExceptionHandlers(parseExceptionHandlers(element));
- flow.addBeanImports(parseBeanImports(element));
+ flow.setVars(parseVars(element));
+ flow.setInputs(parseInputs(element));
+ flow.setOnStartActions(parseOnStartActions(element));
+ flow.setStates(parseStates(element));
+ flow.setGlobalTransitions(parseGlobalTransitions(element));
+ flow.setOnEndActions(parseOnEndActions(element));
+ flow.setOutputs(parseOutputs(element));
+ flow.setExceptionHandlers(parseExceptionHandlers(element));
+ flow.setBeanImports(parseBeanImports(element));
return flow;
}
diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcView.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcView.java
index 0d403c93..5bc7709b 100644
--- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcView.java
+++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcView.java
@@ -288,14 +288,14 @@ public abstract class AbstractMvcView implements View {
DefaultMapper mapper = new DefaultMapper();
ParameterMap requestParameters = requestContext.getRequestParameters();
if (binderConfiguration != null) {
- addModelBindingMappings(mapper, requestParameters.asMap().keySet(), model);
+ addModelBindings(mapper, requestParameters.asMap().keySet(), model);
} else {
addDefaultMappings(mapper, requestParameters.asMap().keySet(), model);
}
return mapper.map(requestParameters, model);
}
- private void addModelBindingMappings(DefaultMapper mapper, Set parameterNames, Object model) {
+ private void addModelBindings(DefaultMapper mapper, Set parameterNames, Object model) {
Iterator it = binderConfiguration.getBindings().iterator();
while (it.hasNext()) {
Binding binding = (Binding) it.next();
diff --git a/spring-webflow/src/test/java/org/springframework/webflow/config/FlowBuilderServicesBeanDefinitionParserTests.java b/spring-webflow/src/test/java/org/springframework/webflow/config/FlowBuilderServicesBeanDefinitionParserTests.java
index c69684ce..5ebfa93e 100644
--- a/spring-webflow/src/test/java/org/springframework/webflow/config/FlowBuilderServicesBeanDefinitionParserTests.java
+++ b/spring-webflow/src/test/java/org/springframework/webflow/config/FlowBuilderServicesBeanDefinitionParserTests.java
@@ -17,6 +17,7 @@ import org.springframework.webflow.engine.builder.BinderConfiguration;
import org.springframework.webflow.engine.builder.ViewFactoryCreator;
import org.springframework.webflow.engine.builder.support.FlowBuilderServices;
import org.springframework.webflow.execution.ViewFactory;
+import org.springframework.webflow.expression.el.WebFlowELExpressionParser;
import org.springframework.webflow.mvc.builder.MvcViewFactoryCreator;
public class FlowBuilderServicesBeanDefinitionParserTests extends TestCase {
@@ -31,19 +32,28 @@ public class FlowBuilderServicesBeanDefinitionParserTests extends TestCase {
public void testFlowBuilderServicesDefaultConfig() {
builderServices = (FlowBuilderServices) context.getBean("flowBuilderServicesDefault");
assertNotNull(builderServices);
- assertNotNull(builderServices.getExpressionParser());
+ assertTrue(builderServices.getExpressionParser() instanceof WebFlowELExpressionParser);
assertTrue(builderServices.getViewFactoryCreator() instanceof MvcViewFactoryCreator);
assertTrue(builderServices.getConversionService() instanceof DefaultConversionService);
}
- public void testFlowBuilderServicesCustomized() {
- builderServices = (FlowBuilderServices) context.getBean("flowBuilderServicesCustom");
+ public void testFlowBuilderServicesAllCustomized() {
+ builderServices = (FlowBuilderServices) context.getBean("flowBuilderServicesAllCustom");
assertNotNull(builderServices);
- assertNotNull(builderServices.getExpressionParser());
+ assertTrue(builderServices.getExpressionParser() instanceof WebFlowELExpressionParser);
assertTrue(builderServices.getViewFactoryCreator() instanceof TestViewFactoryCreator);
assertTrue(builderServices.getConversionService() instanceof TestConversionService);
}
+ public void testFlowBuilderServicesConversionServiceCustomized() {
+ builderServices = (FlowBuilderServices) context.getBean("flowBuilderServicesConversionServiceCustom");
+ assertNotNull(builderServices);
+ assertTrue(builderServices.getConversionService() instanceof TestConversionService);
+ assertTrue(builderServices.getExpressionParser() instanceof WebFlowELExpressionParser);
+ assertTrue(((WebFlowELExpressionParser) builderServices.getExpressionParser()).getConversionService() instanceof TestConversionService);
+ assertTrue(builderServices.getViewFactoryCreator() instanceof MvcViewFactoryCreator);
+ }
+
public static class TestViewFactoryCreator implements ViewFactoryCreator {
public ViewFactory createViewFactory(Expression viewIdExpression, ExpressionParser expressionParser,
diff --git a/spring-webflow/src/test/java/org/springframework/webflow/config/flow-builder-services.xml b/spring-webflow/src/test/java/org/springframework/webflow/config/flow-builder-services.xml
index 9e56d9de..bb490176 100644
--- a/spring-webflow/src/test/java/org/springframework/webflow/config/flow-builder-services.xml
+++ b/spring-webflow/src/test/java/org/springframework/webflow/config/flow-builder-services.xml
@@ -10,10 +10,13 @@
-
+
+
diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/builder/model/FlowModelFlowBuilderTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/builder/model/FlowModelFlowBuilderTests.java
index 931c8c77..ac332fa2 100644
--- a/spring-webflow/src/test/java/org/springframework/webflow/engine/builder/model/FlowModelFlowBuilderTests.java
+++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/builder/model/FlowModelFlowBuilderTests.java
@@ -1,5 +1,7 @@
package org.springframework.webflow.engine.builder.model;
+import java.util.LinkedList;
+
import junit.framework.TestCase;
import org.springframework.beans.factory.support.StaticListableBeanFactory;
@@ -11,8 +13,6 @@ import org.springframework.webflow.core.collection.LocalAttributeMap;
import org.springframework.webflow.core.collection.MutableAttributeMap;
import org.springframework.webflow.engine.Flow;
import org.springframework.webflow.engine.FlowExecutionExceptionHandler;
-import org.springframework.webflow.engine.FlowInputMappingException;
-import org.springframework.webflow.engine.FlowOutputMappingException;
import org.springframework.webflow.engine.RequestControlContext;
import org.springframework.webflow.engine.ViewState;
import org.springframework.webflow.engine.builder.FlowAssembler;
@@ -23,6 +23,7 @@ import org.springframework.webflow.engine.model.EndStateModel;
import org.springframework.webflow.engine.model.ExceptionHandlerModel;
import org.springframework.webflow.engine.model.FlowModel;
import org.springframework.webflow.engine.model.InputModel;
+import org.springframework.webflow.engine.model.Model;
import org.springframework.webflow.engine.model.OutputModel;
import org.springframework.webflow.engine.model.PersistenceContextModel;
import org.springframework.webflow.engine.model.SecuredModel;
@@ -60,15 +61,37 @@ public class FlowModelFlowBuilderTests extends TestCase {
}
}
+ private LinkedList singleList(Model model) {
+ LinkedList list = new LinkedList();
+ list.add(model);
+ return list;
+ }
+
+ private LinkedList doubleList(Model model, Model model2) {
+ LinkedList list = new LinkedList();
+ list.add(model);
+ list.add(model2);
+ return list;
+ }
+
+ private LinkedList quadList(Model model, Model model2, Model model3, Model model4) {
+ LinkedList list = new LinkedList();
+ list.add(model);
+ list.add(model2);
+ list.add(model3);
+ list.add(model4);
+ return list;
+ }
+
public void testBuildFlowWithEndState() {
- model.addEndState(new EndStateModel("end"));
+ model.setStates(singleList(new EndStateModel("end")));
Flow flow = getFlow(model);
assertEquals("flow", flow.getId());
assertEquals("end", flow.getStartState().getId());
}
public void testBuildFlowWithDefaultStartState() {
- model.addEndState(new EndStateModel("end"));
+ model.setStates(singleList(new EndStateModel("end")));
Flow flow = getFlow(model);
assertEquals("flow", flow.getId());
assertEquals("end", flow.getStartState().getId());
@@ -76,19 +99,19 @@ public class FlowModelFlowBuilderTests extends TestCase {
public void testBuildFlowWithStartStateAttribute() {
model.setStartStateId("end");
- model.addEndState(new EndStateModel("foo"));
- model.addEndState(new EndStateModel("end"));
+ model.setStates(doubleList(new EndStateModel("foo"), new EndStateModel("end")));
Flow flow = getFlow(model);
assertEquals("flow", flow.getId());
assertEquals("end", flow.getStartState().getId());
}
public void testCustomFlowAttribute() {
- model.addAttribute(new AttributeModel("foo", "bar"));
- AttributeModel attribute = new AttributeModel("number", "1");
- attribute.setType("integer");
- model.addAttribute(attribute);
- model.addEndState(new EndStateModel("end"));
+ AttributeModel attribute1 = new AttributeModel("foo", "bar");
+ AttributeModel attribute2 = new AttributeModel("number", "1");
+ attribute2.setType("integer");
+ model.setAttributes(doubleList(attribute1, attribute2));
+
+ model.setStates(singleList(new EndStateModel("end")));
Flow flow = getFlow(model);
assertEquals("bar", flow.getAttributes().get("foo"));
assertEquals(new Integer(1), flow.getAttributes().get("number"));
@@ -96,38 +119,38 @@ public class FlowModelFlowBuilderTests extends TestCase {
public void testPersistenceContextFlow() {
model.setPersistenceContext(new PersistenceContextModel());
- model.addEndState(new EndStateModel("end"));
+ model.setStates(singleList(new EndStateModel("end")));
Flow flow = getFlow(model);
assertNotNull(flow.getAttributes().get("persistenceContext"));
assertTrue(((Boolean) flow.getAttributes().get("persistenceContext")).booleanValue());
}
public void testFlowInputOutputMapping() {
- InputModel input;
- OutputModel output;
- model.addInput(new InputModel("foo", "flowScope.foo"));
- model.addInput(new InputModel("foo", "flowScope.bar"));
- input = new InputModel("number", "flowScope.baz");
- input.setType("integer");
- model.addInput(input);
- input = new InputModel("required", "flowScope.boop");
- input.setRequired("true");
- model.addInput(input);
+ InputModel input1 = new InputModel("foo", "flowScope.foo");
+ InputModel input2 = new InputModel("foo", "flowScope.bar");
+ InputModel input3 = new InputModel("number", "flowScope.baz");
+ input3.setType("integer");
+ InputModel input4 = new InputModel("required", "flowScope.boop");
+ input4.setRequired("true");
+ model.setInputs(quadList(input1, input2, input3, input4));
+
+ OutputModel output1 = new OutputModel("differentName", "flowScope.bar");
+ OutputModel output2 = new OutputModel("number", "flowScope.baz");
+ output2.setType("integer");
+ OutputModel output3 = new OutputModel("required", "flowScope.baz");
+ output3.setType("integer");
+ output3.setRequired("true");
+ OutputModel output4 = new OutputModel("literal", "'a literal'");
+ model.setOutputs(quadList(output1, output2, output3, output4));
+
EndStateModel end = new EndStateModel("end");
- end.addOutput(new OutputModel("foo", "flowScope.foo"));
- model.addEndState(end);
+ end.setOutputs(singleList(new OutputModel("foo", "flowScope.foo")));
+
EndStateModel notReached = new EndStateModel("notReached");
- notReached.addOutput(new OutputModel("notReached", "flowScope.foo"));
- model.addEndState(notReached);
- model.addOutput(new OutputModel("differentName", "flowScope.bar"));
- output = new OutputModel("number", "flowScope.baz");
- output.setType("integer");
- model.addOutput(output);
- output = new OutputModel("required", "flowScope.baz");
- output.setType("integer");
- output.setRequired("true");
- model.addOutput(output);
- model.addOutput(new OutputModel("literal", "'a literal'"));
+ notReached.setOutputs(singleList(new OutputModel("notReached", "flowScope.foo")));
+
+ model.setStates(doubleList(end, notReached));
+
Flow flow = getFlow(model);
FlowExecutionImplFactory factory = new FlowExecutionImplFactory();
FlowExecution execution = factory.createFlowExecution(flow);
@@ -147,86 +170,9 @@ public class FlowModelFlowBuilderTests extends TestCase {
assertNull(outcome.getOutput().get("notReached"));
}
- public void testFlowRequiredInputMapping() {
- InputModel input;
- OutputModel output;
- model.addInput(new InputModel("foo", "flowScope.foo"));
- model.addInput(new InputModel("foo", "flowScope.bar"));
- input = new InputModel("number", "flowScope.baz");
- input.setType("integer");
- model.addInput(input);
- input = new InputModel("required", "flowScope.boop");
- input.setRequired("true");
- model.addInput(input);
- EndStateModel end = new EndStateModel("end");
- end.addOutput(new OutputModel("foo", "flowScope.foo"));
- model.addEndState(end);
- EndStateModel notReached = new EndStateModel("notReached");
- notReached.addOutput(new OutputModel("notReached", "flowScope.foo"));
- model.addEndState(notReached);
- model.addOutput(new OutputModel("differentName", "flowScope.bar"));
- output = new OutputModel("number", "flowScope.baz");
- output.setType("integer");
- model.addOutput(output);
- output = new OutputModel("required", "flowScope.baz");
- output.setType("integer");
- output.setRequired("true");
- model.addOutput(output);
- model.addOutput(new OutputModel("literal", "'a literal'"));
- Flow flow = getFlow(model);
- FlowExecutionImplFactory factory = new FlowExecutionImplFactory();
- FlowExecution execution = factory.createFlowExecution(flow);
- MockExternalContext context = new MockExternalContext();
- MutableAttributeMap map = new LocalAttributeMap();
- try {
- execution.start(map, context);
- fail("Should have failed");
- } catch (FlowInputMappingException e) {
- }
- }
-
- public void testFlowRequiredOutputMapping() {
- InputModel input;
- OutputModel output;
- model.addInput(new InputModel("foo", "flowScope.foo"));
- model.addInput(new InputModel("foo", "flowScope.bar"));
- input = new InputModel("number", "flowScope.baz");
- input.setType("integer");
- model.addInput(input);
- input = new InputModel("required", "flowScope.boop");
- input.setRequired("true");
- model.addInput(input);
- EndStateModel end = new EndStateModel("end");
- end.addOutput(new OutputModel("foo", "flowScope.foo"));
- model.addEndState(end);
- EndStateModel notReached = new EndStateModel("notReached");
- notReached.addOutput(new OutputModel("notReached", "flowScope.foo"));
- model.addEndState(notReached);
- model.addOutput(new OutputModel("differentName", "flowScope.bar"));
- output = new OutputModel("number", "flowScope.baz");
- output.setType("integer");
- model.addOutput(output);
- output = new OutputModel("required", "flowScope.baz");
- output.setType("integer");
- output.setRequired("true");
- model.addOutput(output);
- model.addOutput(new OutputModel("literal", "'a literal'"));
- Flow flow = getFlow(model);
- FlowExecutionImplFactory factory = new FlowExecutionImplFactory();
- FlowExecution execution = factory.createFlowExecution(flow);
- MockExternalContext context = new MockExternalContext();
- MutableAttributeMap map = new LocalAttributeMap();
- map.put("required", "yo");
- try {
- execution.start(map, context);
- fail("Should have failed");
- } catch (FlowOutputMappingException e) {
- }
- }
-
public void testFlowSecured() {
model.setSecured(new SecuredModel("ROLE_USER"));
- model.addEndState(new EndStateModel("end"));
+ model.setStates(singleList(new EndStateModel("end")));
Flow flow = getFlow(model);
SecurityRule rule = (SecurityRule) flow.getAttributes().get(SecurityRule.SECURITY_ATTRIBUTE_NAME);
assertNotNull(rule);
@@ -238,7 +184,7 @@ public class FlowModelFlowBuilderTests extends TestCase {
public void testFlowSecuredState() {
EndStateModel end = new EndStateModel("end");
end.setSecured(new SecuredModel("ROLE_USER"));
- model.addEndState(end);
+ model.setStates(singleList(end));
Flow flow = getFlow(model);
SecurityRule rule = (SecurityRule) flow.getState("end").getAttributes().get(
SecurityRule.SECURITY_ATTRIBUTE_NAME);
@@ -249,11 +195,11 @@ public class FlowModelFlowBuilderTests extends TestCase {
}
public void testFlowSecuredTransition() {
- model.addEndState(new EndStateModel("end"));
+ model.setStates(singleList(new EndStateModel("end")));
TransitionModel transition = new TransitionModel();
transition.setTo("end");
transition.setSecured(new SecuredModel("ROLE_USER"));
- model.addGlobalTransition(transition);
+ model.setGlobalTransitions(singleList(transition));
Flow flow = getFlow(model);
SecurityRule rule = (SecurityRule) flow.getGlobalTransitionSet().toArray()[0].getAttributes().get(
SecurityRule.SECURITY_ATTRIBUTE_NAME);
@@ -264,16 +210,16 @@ public class FlowModelFlowBuilderTests extends TestCase {
}
public void testFlowVariable() {
- model.addVar(new VarModel("flow-foo", "org.springframework.webflow.TestBean"));
- model.addEndState(new EndStateModel("end"));
+ model.setVars(singleList(new VarModel("flow-foo", "org.springframework.webflow.TestBean")));
+ model.setStates(singleList(new EndStateModel("end")));
Flow flow = getFlow(model);
assertEquals("flow-foo", flow.getVariable("flow-foo").getName());
}
public void testViewStateVariable() {
ViewStateModel view = new ViewStateModel("view");
- view.addVar(new VarModel("foo", "org.springframework.webflow.TestBean"));
- model.addViewState(view);
+ view.setVars(singleList(new VarModel("foo", "org.springframework.webflow.TestBean")));
+ model.setStates(singleList(view));
Flow flow = getFlow(model);
assertNotNull(((ViewState) flow.getStateInstance("view")).getVariable("foo"));
}
@@ -281,7 +227,7 @@ public class FlowModelFlowBuilderTests extends TestCase {
public void testViewStateRedirect() {
ViewStateModel view = new ViewStateModel("view");
view.setRedirect("true");
- model.addViewState(view);
+ model.setStates(singleList(view));
Flow flow = getFlow(model);
assertTrue(((ViewState) flow.getStateInstance("view")).getRedirect());
}
@@ -289,7 +235,7 @@ public class FlowModelFlowBuilderTests extends TestCase {
public void testViewStatePopup() {
ViewStateModel view = new ViewStateModel("view");
view.setPopup("true");
- model.addViewState(view);
+ model.setStates(singleList(view));
Flow flow = getFlow(model);
assertTrue(((ViewState) flow.getStateInstance("view")).getPopup());
}
@@ -297,7 +243,7 @@ public class FlowModelFlowBuilderTests extends TestCase {
public void testViewStateFlowRedirect() {
ViewStateModel state = new ViewStateModel("view");
state.setView("flowRedirect:myFlow?input=#{flowScope.foo}");
- model.addViewState(state);
+ model.setStates(singleList(state));
Flow flow = getFlow(model);
ViewFactory vf = ((ViewState) flow.getStateInstance("view")).getViewFactory();
assertTrue(vf instanceof ActionExecutingViewFactory);
@@ -308,7 +254,7 @@ public class FlowModelFlowBuilderTests extends TestCase {
public void testViewStateExternalRedirect() {
ViewStateModel state = new ViewStateModel("view");
state.setView("externalRedirect:http://www.paypal.com?_callbackUrl=#{flowExecutionUri}");
- model.addViewState(state);
+ model.setStates(singleList(state));
Flow flow = getFlow(model);
ViewFactory vf = ((ViewState) flow.getStateInstance("view")).getViewFactory();
assertTrue(vf instanceof ActionExecutingViewFactory);
@@ -342,8 +288,8 @@ public class FlowModelFlowBuilderTests extends TestCase {
public void testExceptionHandlers() {
FlowModel model = new FlowModel();
- model.addState(new EndStateModel("state"));
- model.addExceptionHandler(new ExceptionHandlerModel("exceptionHandler"));
+ model.setStates(singleList(new EndStateModel("state")));
+ model.setExceptionHandlers(singleList(new ExceptionHandlerModel("exceptionHandler")));
FlowExecutionExceptionHandler handler = new FlowExecutionExceptionHandler() {
public boolean canHandle(FlowExecutionException exception) {
return true;
diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/model/FlowModelTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/model/FlowModelTests.java
index 5dbd2bad..89e81090 100644
--- a/spring-webflow/src/test/java/org/springframework/webflow/engine/model/FlowModelTests.java
+++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/model/FlowModelTests.java
@@ -15,6 +15,8 @@
*/
package org.springframework.webflow.engine.model;
+import java.util.LinkedList;
+
import junit.framework.TestCase;
/**
@@ -36,14 +38,14 @@ public class FlowModelTests extends TestCase {
public void testMergeAttributes() {
FlowModel child = new FlowModel();
FlowModel parent = new FlowModel();
- AttributeModel attribute;
- child.addAttribute(new AttributeModel("name", "value"));
- attribute = new AttributeModel("name", "value");
- attribute.setType("type");
- parent.addAttribute(attribute);
- attribute = new AttributeModel("name2", "value2");
- attribute.setType("type2");
- parent.addAttribute(attribute);
+ child.setAttributes(singleList(new AttributeModel("name", "value")));
+
+ AttributeModel parentAttribute1 = new AttributeModel("name", "value");
+ parentAttribute1.setType("type");
+ AttributeModel parentAttribute2 = new AttributeModel("name2", "value2");
+ parentAttribute2.setType("type2");
+ parent.setAttributes(doubleList(parentAttribute1, parentAttribute2));
+
child.merge(parent);
assertEquals(2, child.getAttributes().size());
assertEquals("name", ((AttributeModel) child.getAttributes().get(0)).getName());
@@ -73,11 +75,11 @@ public class FlowModelTests extends TestCase {
public void testMergeVars() {
FlowModel parent = new FlowModel();
- VarModel var = new VarModel("name", "value");
- parent.addVar(var);
+ parent.setVars(singleList(new VarModel("name", "value")));
+
FlowModel child = new FlowModel();
- var = new VarModel("name", "value2");
- child.addVar(var);
+ child.setVars(singleList(new VarModel("name", "value2")));
+
child.merge(parent);
assertEquals(1, child.getVars().size());
assertEquals("value2", ((VarModel) child.getVars().get(0)).getClassName());
@@ -86,39 +88,41 @@ public class FlowModelTests extends TestCase {
public void testMergeMappings() {
FlowModel child = new FlowModel();
FlowModel parent = new FlowModel();
- InputModel input;
- child.addInput(new InputModel("name", "value"));
- input = new InputModel("name2", "value2");
- input.setType("type2");
- input.setRequired("required2");
- child.addInput(input);
- input = new InputModel("name3", "value3");
- input.setType("type3");
- input.setRequired("required3");
- child.addInput(input);
- input = new InputModel("name", "value");
- input.setType("type");
- input.setRequired("required");
- parent.addInput(input);
- input = new InputModel("name3", "value3");
- input.setType("type3");
- input.setRequired("required3");
- parent.addInput(input);
+
+ InputModel input1 = new InputModel("name", "value");
+ input1.setType("type");
+ input1.setType("required");
+
+ InputModel input2 = new InputModel("name2", "value2");
+ input2.setType("type2");
+ input2.setRequired("required2");
+
+ InputModel input3 = new InputModel("name3", "value3");
+ input2.setType("type3");
+ input2.setRequired("required3");
+
+ child.setInputs(tripleList(input1, input2, input3));
+
+ InputModel parentInput = new InputModel("name3", "value3");
+ parentInput.setType("type3");
+ parentInput.setRequired("required3");
+ parent.setInputs(singleList(parentInput));
+
child.merge(parent);
assertEquals(3, child.getInputs().size());
}
public void testMergeOnStart() {
FlowModel child = new FlowModel();
+ child.setOnStartActions(tripleList(new EvaluateModel("expression"), new RenderModel("expression"),
+ new SetModel("expression", "value")));
+
FlowModel parent = new FlowModel();
- child.addOnStartAction(new EvaluateModel("expression"));
- child.addOnStartAction(new RenderModel("expression"));
- child.addOnStartAction(new SetModel("expression", "value"));
+
EvaluateModel eval = new EvaluateModel("expression");
eval.setResult("result");
- parent.addOnStartAction(eval);
- parent.addOnStartAction(new RenderModel("expression"));
- parent.addOnStartAction(new SetModel("expression", "value"));
+ parent.setOnStartActions(tripleList(eval, new RenderModel("expression"), new SetModel("expression", "value")));
+
child.merge(parent);
assertEquals(6, child.getOnStartActions().size());
assertNotNull(((EvaluateModel) child.getOnStartActions().get(0)).getResult());
@@ -126,14 +130,13 @@ public class FlowModelTests extends TestCase {
public void testMergeStates() {
FlowModel child = new FlowModel();
+ child.setStates(doubleList(new ViewStateModel("view"), new EndStateModel("end")));
+
FlowModel parent = new FlowModel();
- child.addViewState(new ViewStateModel("view"));
- child.addEndState(new EndStateModel("end"));
ViewStateModel view = new ViewStateModel("view");
view.setView("jsp");
- parent.addViewState(view);
- parent.addState(new DecisionStateModel("decider"));
- parent.addActionState(new ActionStateModel("end"));
+ parent.setStates(tripleList(view, new DecisionStateModel("decider"), new ActionStateModel("action")));
+
child.merge(parent);
assertEquals(4, child.getStates().size());
assertEquals("jsp", ((ViewStateModel) child.getStates().get(0)).getView());
@@ -141,21 +144,20 @@ public class FlowModelTests extends TestCase {
public void testMergeGlobalTransitions() {
FlowModel child = new FlowModel();
+ TransitionModel transition1 = new TransitionModel();
+ transition1.setOn("end");
+ TransitionModel transition2 = new TransitionModel();
+ transition2.setOn("start");
+ child.setGlobalTransitions(doubleList(transition1, transition2));
+
FlowModel parent = new FlowModel();
- TransitionModel transition;
- transition = new TransitionModel();
- transition.setOn("end");
- child.addGlobalTransition(transition);
- transition = new TransitionModel();
- transition.setOn("start");
- child.addGlobalTransition(transition);
- transition = new TransitionModel();
- transition.setOn("search");
- parent.addGlobalTransition(transition);
- transition = new TransitionModel();
- transition.setOn("end");
- transition.setTo("theend");
- parent.addGlobalTransition(transition);
+ transition1 = new TransitionModel();
+ transition1.setOn("search");
+ transition2 = new TransitionModel();
+ transition2.setOn("end");
+ transition2.setTo("theend");
+ parent.setGlobalTransitions(doubleList(transition1, transition2));
+
child.merge(parent);
assertEquals(3, child.getGlobalTransitions().size());
assertEquals("theend", ((TransitionModel) child.getGlobalTransitions().get(0)).getTo());
@@ -163,15 +165,14 @@ public class FlowModelTests extends TestCase {
public void testMergeOnEnd() {
FlowModel child = new FlowModel();
+ child.setOnEndActions(tripleList(new EvaluateModel("expression"), new RenderModel("expression"), new SetModel(
+ "expression", "value")));
+
FlowModel parent = new FlowModel();
- child.addOnEndAction(new EvaluateModel("expression"));
- child.addOnEndAction(new RenderModel("expression"));
- child.addOnEndAction(new SetModel("expression", "value"));
EvaluateModel eval = new EvaluateModel("expression");
eval.setResult("result");
- parent.addOnEndAction(eval);
- parent.addOnEndAction(new RenderModel("expression"));
- parent.addOnEndAction(new SetModel("expression", "value"));
+ parent.setOnEndActions(tripleList(eval, new RenderModel("expression"), new SetModel("expression", "value")));
+
child.merge(parent);
assertEquals(6, child.getOnEndActions().size());
assertNotNull(((EvaluateModel) child.getOnEndActions().get(0)).getResult());
@@ -179,24 +180,45 @@ public class FlowModelTests extends TestCase {
public void testMergeExceptionHandlers() {
FlowModel child = new FlowModel();
+ child.setExceptionHandlers(doubleList(new ExceptionHandlerModel("bean1"), new ExceptionHandlerModel("bean2")));
+
FlowModel parent = new FlowModel();
- child.addExceptionHandler(new ExceptionHandlerModel("bean1"));
- child.addExceptionHandler(new ExceptionHandlerModel("bean2"));
- parent.addExceptionHandler(new ExceptionHandlerModel("bean2"));
- parent.addExceptionHandler(new ExceptionHandlerModel("bean3"));
+ parent.setExceptionHandlers(doubleList(new ExceptionHandlerModel("bean2"), new ExceptionHandlerModel("bean3")));
+
child.merge(parent);
assertEquals(4, child.getExceptionHandlers().size());
}
public void testMergeBeanImports() {
FlowModel child = new FlowModel();
+ child.setBeanImports(doubleList(new BeanImportModel("path1"), new BeanImportModel("path2")));
+
FlowModel parent = new FlowModel();
- child.addBeanImport(new BeanImportModel("path1"));
- child.addBeanImport(new BeanImportModel("path2"));
- parent.addBeanImport(new BeanImportModel("path2"));
- parent.addBeanImport(new BeanImportModel("path3"));
+ parent.setBeanImports(doubleList(new BeanImportModel("path1"), new BeanImportModel("path2")));
+
child.merge(parent);
assertEquals(4, child.getBeanImports().size());
}
+ private LinkedList singleList(Model model) {
+ LinkedList list = new LinkedList();
+ list.add(model);
+ return list;
+ }
+
+ private LinkedList doubleList(Model model, Model model2) {
+ LinkedList list = new LinkedList();
+ list.add(model);
+ list.add(model2);
+ return list;
+ }
+
+ private LinkedList tripleList(Model model, Model model2, Model model3) {
+ LinkedList list = new LinkedList();
+ list.add(model);
+ list.add(model2);
+ list.add(model3);
+ return list;
+ }
+
}
diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/model/registry/DefaultFlowModelHolderTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/model/registry/DefaultFlowModelHolderTests.java
index d3c87055..8e086bae 100644
--- a/spring-webflow/src/test/java/org/springframework/webflow/engine/model/registry/DefaultFlowModelHolderTests.java
+++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/model/registry/DefaultFlowModelHolderTests.java
@@ -1,5 +1,8 @@
package org.springframework.webflow.engine.model.registry;
+import java.util.Collections;
+import java.util.LinkedList;
+
import junit.framework.TestCase;
import org.springframework.core.io.Resource;
@@ -37,7 +40,7 @@ public class DefaultFlowModelHolderTests extends TestCase {
public FlowModel getFlowModel() throws FlowModelBuilderException {
FlowModel flow = new FlowModel();
- flow.addEndState(new EndStateModel("end"));
+ flow.setStates(new LinkedList(Collections.singletonList(new EndStateModel("end"))));
return flow;
}