From bba06d9477bd122a263a16449f86aeef6d7021ad Mon Sep 17 00:00:00 2001 From: Erwin Vervaet Date: Wed, 4 Apr 2007 07:54:17 +0000 Subject: [PATCH] Added getFlashAttribute and getRequiredFlashAttribute methods to AbstractFlowExecutionTests. --- spring-webflow/changelog.txt | 1 + .../execution/AbstractFlowExecutionTests.java | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/spring-webflow/changelog.txt b/spring-webflow/changelog.txt index 8413f01b..549921cc 100644 --- a/spring-webflow/changelog.txt +++ b/spring-webflow/changelog.txt @@ -67,6 +67,7 @@ Package org.springframework.webflow.executor Package org.springframework.webflow.test * Added constructor taking test name argument to AbstractFlowExecutionTests, AbstractExternalizedFlowExecutionTests and AbstractXmlFlowExecutionTests. +* Added getFlashAttribute and getRequiredFlashAttribute methods to AbstractFlowExecutionTests. Package org.springframework.webflow.samples * Made all samples Spring IDE 2.0 projects for use with the Spring Web Flow Graphical Editor and XML Flow diff --git a/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractFlowExecutionTests.java b/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractFlowExecutionTests.java index 4d4c5674..7bd55151 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractFlowExecutionTests.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractFlowExecutionTests.java @@ -396,6 +396,40 @@ public abstract class AbstractFlowExecutionTests extends TestCase { return getFlowExecution().getActiveSession().getScope().getRequired(attributeName, requiredType); } + /** + * Returns the attribute in flash scope. Flash-scoped attributes are local to + * the active flow session. + * @param attributeName the name of the attribute + * @return the attribute value + */ + protected Object getFlashAttribute(String attributeName) { + return getFlowExecution().getActiveSession().getFlashMap().get(attributeName); + } + + /** + * Returns the required attribute in flash scope; asserts the attribute is + * present. Flash-scoped attributes are local to the active flow session. + * @param attributeName the name of the attribute + * @return the attribute value + * @throws IllegalStateException if the attribute was not present + */ + protected Object getRequiredFlashAttribute(String attributeName) throws IllegalStateException { + return getFlowExecution().getActiveSession().getFlashMap().getRequired(attributeName); + } + + /** + * Returns the required attribute in flash scope; asserts the attribute is + * present and of the correct type. Flash-scoped attributes are local to the + * active flow session. + * @param attributeName the name of the attribute + * @return the attribute value + * @throws IllegalStateException if the attribute was not present or was of + * the wrong type + */ + protected Object getRequiredFlashAttribute(String attributeName, Class requiredType) throws IllegalStateException { + return getFlowExecution().getActiveSession().getFlashMap().getRequired(attributeName, requiredType); + } + // assert helpers /**