diff --git a/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/FlowExecutionHolderUtils.java b/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/FlowExecutionHolderUtils.java
index c9e5d1ed..4874b55e 100644
--- a/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/FlowExecutionHolderUtils.java
+++ b/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/FlowExecutionHolderUtils.java
@@ -113,7 +113,11 @@ public class FlowExecutionHolderUtils {
}
}
- private static String getFlowExecutionHolderKey() {
+ /**
+ * Returns the key used to index the flow execution holder in the request
+ * attributes.
+ */
+ static String getFlowExecutionHolderKey() {
return FlowExecutionHolder.class.getName();
}
}
\ No newline at end of file
diff --git a/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/FlowSystemCleanupFilter.java b/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/FlowSystemCleanupFilter.java
index c1f0b84a..522288c4 100644
--- a/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/FlowSystemCleanupFilter.java
+++ b/spring-webflow/src/main/java/org/springframework/webflow/executor/jsf/FlowSystemCleanupFilter.java
@@ -28,11 +28,11 @@ import org.springframework.webflow.context.ExternalContextHolder;
import org.springframework.webflow.execution.FlowExecutionContextHolder;
/**
- * A servlet filter used to guarantee that webflow context information is
+ * A servlet filter used to guarantee that web flow context information is
* cleaned up in a JSF environment.
*
* @author Ben Hale
- * @since 1.1
+ * @since 1.0.4
*/
public class FlowSystemCleanupFilter extends OncePerRequestFilter {
@@ -40,7 +40,8 @@ public class FlowSystemCleanupFilter extends OncePerRequestFilter {
throws ServletException, IOException {
try {
chain.doFilter(request, response);
- } finally {
+ }
+ finally {
cleanupCurrentFlowExecution(request);
ExternalContextHolder.setExternalContext(null);
}
@@ -58,7 +59,7 @@ public class FlowSystemCleanupFilter extends OncePerRequestFilter {
if (isFlowExecutionRestored(request)) {
FlowExecutionContextHolder.setFlowExecutionContext(null);
getFlowExecutionHolder(request).unlockFlowExecutionIfNecessary();
- request.removeAttribute(getFlowExecutionHolderKey());
+ request.removeAttribute(FlowExecutionHolderUtils.getFlowExecutionHolderKey());
}
}
@@ -78,11 +79,6 @@ public class FlowSystemCleanupFilter extends OncePerRequestFilter {
* @return the flow execution holder, or null if none set.
*/
private FlowExecutionHolder getFlowExecutionHolder(ServletRequest request) {
- return (FlowExecutionHolder) request.getAttribute(getFlowExecutionHolderKey());
+ return (FlowExecutionHolder) request.getAttribute(FlowExecutionHolderUtils.getFlowExecutionHolderKey());
}
-
- private static String getFlowExecutionHolderKey() {
- return FlowExecutionHolder.class.getName();
- }
-
}
diff --git a/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractExternalizedFlowExecutionTests.java b/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractExternalizedFlowExecutionTests.java
index 6e5d88ed..1466fb11 100644
--- a/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractExternalizedFlowExecutionTests.java
+++ b/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractExternalizedFlowExecutionTests.java
@@ -32,10 +32,9 @@ import org.springframework.webflow.execution.factory.StaticFlowExecutionListener
import org.springframework.webflow.test.MockFlowServiceLocator;
/**
- * Base class for flow integration tests that verify an externalized flow
- * definition executes as expected. Supports caching of the flow definition
- * built from an externalized resource to speed up test execution.
- *
+ * Base class for flow integration tests that verify an externalized flow definition executes as expected. Supports
+ * caching of the flow definition built from an externalized resource to speed up test execution.
+ *
* @author Keith Donald
*/
public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlowExecutionTests {
@@ -46,8 +45,8 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo
private static FlowDefinition cachedFlowDefinition;
/**
- * The flag indicating if the flow definition built from an externalized
- * resource as part of this test should be cached.
+ * The flag indicating if the flow definition built from an externalized resource as part of this test should be
+ * cached.
*/
private boolean cacheFlowDefinition = false;
@@ -58,7 +57,7 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo
public AbstractExternalizedFlowExecutionTests() {
super();
}
-
+
/**
* Constructs an externalized flow execution test with given name.
* @param name the name of the test
@@ -69,13 +68,13 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo
}
/**
- * Internal helper that return the flow execution factory used by the
- * test cast to a {@link FlowExecutionImplFactory}.
+ * Internal helper that returns the flow execution factory used by the test cast to a
+ * {@link FlowExecutionImplFactory}.
*/
private FlowExecutionImplFactory getFlowExecutionImplFactory() {
- return (FlowExecutionImplFactory)getFlowExecutionFactory();
+ return (FlowExecutionImplFactory) getFlowExecutionFactory();
}
-
+
/**
* Returns if flow definition caching is turned on.
*/
@@ -84,18 +83,16 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo
}
/**
- * Sets the flag indicating if the flow definition built from an
- * externalized resource as part of this test should be cached.
- * Default is false.
+ * Sets the flag indicating if the flow definition built from an externalized resource as part of this test should
+ * be cached. Default is false.
*/
protected void setCacheFlowDefinition(boolean cacheFlowDefinition) {
this.cacheFlowDefinition = cacheFlowDefinition;
}
/**
- * Sets system attributes to be associated with the flow execution the next
- * time one is {@link #startFlow() started} by this test. Useful for
- * assigning attributes that influence flow execution behavior.
+ * Sets system attributes to be associated with the flow execution the next time one is {@link #startFlow() started}
+ * by this test. Useful for assigning attributes that influence flow execution behavior.
* @param executionAttributes the system attributes to assign
*/
protected void setFlowExecutionAttributes(AttributeMap executionAttributes) {
@@ -103,27 +100,29 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo
}
/**
- * Set the listener to be attached to the flow execution the next time one
- * is {@link #startFlow() started} by this test. Useful for attaching a
- * listener that does test assertions during the execution of the flow.
+ * Set a single listener to be attached to the flow execution the next time one is {@link #startFlow() started} by
+ * this test. Useful for attaching a listener that does test assertions during the execution of the flow.
* @param executionListener the listener to attach
*/
protected void setFlowExecutionListener(FlowExecutionListener executionListener) {
getFlowExecutionImplFactory().setExecutionListenerLoader(
new StaticFlowExecutionListenerLoader(executionListener));
}
-
+
/**
- * Set the listeners to be attached to the flow execution the next time one
- * is {@link #startFlow() started} by this test. Useful for attaching
- * listeners that do test assertions during the execution of the flow.
+ * Set the listeners to be attached to the flow execution the next time one is {@link #startFlow() started} by this
+ * test. Useful for attaching listeners that do test assertions during the execution of the flow.
* @param executionListeners the listeners to attach
+ * @since 1.0.4
*/
protected void setFlowExecutionListeners(FlowExecutionListener[] executionListeners) {
getFlowExecutionImplFactory().setExecutionListenerLoader(
new StaticFlowExecutionListenerLoader(executionListeners));
}
+ /**
+ * Returns the flow definition being tested.
+ */
protected final FlowDefinition getFlowDefinition() {
if (isCacheFlowDefinition() && cachedFlowDefinition != null) {
return cachedFlowDefinition;
@@ -137,12 +136,11 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo
}
/**
- * Returns the flow artifact factory to use during flow definition
- * construction time for accessing externally managed flow artifacts such as
- * actions and flows to be used as subflows.
+ * Returns the flow service locator to use during flow definition construction time for accessing externally
+ * managed flow artifacts such as actions and flows to be used as subflows.
*
- * This implementation just creates a {@link MockFlowServiceLocator} and - * populates it with services by calling {@link #registerMockServices(MockFlowServiceLocator)}. + * This implementation just creates a {@link MockFlowServiceLocator} and populates it with services by calling + * {@link #registerMockServices(MockFlowServiceLocator)}. * @return the flow artifact factory */ protected FlowServiceLocator createFlowServiceLocator() { @@ -152,20 +150,18 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo } /** - * Template method called by {@link #createFlowServiceLocator()} to allow - * registration of mock implementations of services needed to test the flow - * execution. Useful when testing flow definitions in execution in isolation - * from flows and middle-tier services. Subclasses may override. + * Template method called by {@link #createFlowServiceLocator()} to allow registration of mock implementations of + * services needed to test the flow execution. Useful when testing flow definitions in execution in isolation from + * flows and middle-tier services. Subclasses may override. * @param serviceRegistry the mock service registry (and locator) */ protected void registerMockServices(MockFlowServiceLocator serviceRegistry) { } /** - * Factory method to assemble another flow definition from a resource. - * Called by {@link #getFlowDefinition()} to create the "main" flow to test. - * May also be called by subclasses to create subflow definitions whose - * executions should also be exercised by this test. + * Factory method to assemble a flow definition from a resource. Called by {@link #getFlowDefinition()} to + * create the "main" flow to test. May also be called by subclasses to create subflow definitions whose executions + * should also be exercised by this test. * @param resource the flow definition resource * @return the built flow definition, ready for execution * @see #createFlowBuilder(Resource, FlowServiceLocator) @@ -177,22 +173,25 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo } /** - * Returns the pointer to the resource that houses the definition of the - * flow to be tested. Subclasses must implement. + * Returns the pointer to the resource that houses the definition of the flow to be tested. Subclasses must + * implement. *
* Example usage: *
- * protected FlowDefinitionResource getFlowDefinitionResource() {
- * return createFlowDefinitionResource("/WEB-INF/flows/order-flow.xml");
- * }
+ * protected FlowDefinitionResource getFlowDefinitionResource() {
+ * return createFlowDefinitionResource("/WEB-INF/flows/order-flow.xml");
+ * }
*
* @return the flow definition resource
*/
protected abstract FlowDefinitionResource getFlowDefinitionResource();
/**
- * Factory method to create the builder that will build the flow whose
- * execution will be tested. Subclasses must override.
+ * Factory method to create the builder that will build the flow definition whose execution will be tested.
+ * Subclasses must implement.
+ * + * A subclass may return a builder that sets up mock implementations of services needed locally by the flow + * definition at runtime. * @param resource the externalized flow definition resource location * @param serviceLocator the flow service locator * @return the flow builder that will build the flow to be tested @@ -200,9 +199,8 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo protected abstract FlowBuilder createFlowBuilder(Resource resource, FlowServiceLocator serviceLocator); /** - * Convenient factory method that creates a {@link FlowDefinitionResource} - * from a file path. Typically called by subclasses overriding - * {@link #getFlowDefinitionResource()}. + * Convenient factory method that creates a {@link FlowDefinitionResource} from a file path. Typically called by + * subclasses overriding {@link #getFlowDefinitionResource()}. * @param filePath the full path to the externalized flow definition file * @return the flow definition resource */ @@ -211,9 +209,8 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo } /** - * Convenient factory method that creates a {@link FlowDefinitionResource} - * from a file in a directory. Typically called by subclasses overriding - * {@link #getFlowDefinitionResource()}. + * Convenient factory method that creates a {@link FlowDefinitionResource} from a file in a directory. Typically + * called by subclasses overriding {@link #getFlowDefinitionResource()}. * @param fileDirectory the directory containing the file * @param fileName the short file name * @return the flow definition resource pointing to the file @@ -223,8 +220,8 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo } /** - * Convenient factory method that creates a {@link FlowDefinitionResource} - * from a file. + * Convenient factory method that creates a {@link FlowDefinitionResource} from a file. Typically + * called by subclasses overriding {@link #getFlowDefinitionResource()}. * @param file the file * @return the flow definition resource */ diff --git a/spring-webflow/src/test/java/org/springframework/webflow/executor/jsf/FlowSystemCleanupFilterTests.java b/spring-webflow/src/test/java/org/springframework/webflow/executor/jsf/FlowSystemCleanupFilterTests.java index ec3dbf8e..73894095 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/executor/jsf/FlowSystemCleanupFilterTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/executor/jsf/FlowSystemCleanupFilterTests.java @@ -1,3 +1,18 @@ +/* + * Copyright 2004-2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.webflow.executor.jsf; import java.io.IOException; diff --git a/spring-webflow/src/test/java/org/springframework/webflow/support/persistence/TestBean.java b/spring-webflow/src/test/java/org/springframework/webflow/support/persistence/TestBean.java index de53b624..5b7526e6 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/support/persistence/TestBean.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/support/persistence/TestBean.java @@ -1,3 +1,18 @@ +/* + * Copyright 2004-2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.webflow.support.persistence; public class TestBean {