sample tests

This commit is contained in:
Keith Donald
2008-04-04 23:46:42 +00:00
parent de810aae30
commit bb3671e597
8 changed files with 233 additions and 265 deletions

View File

@@ -31,26 +31,30 @@ public class DefaultExpressionFactoryUtils {
try {
expressionFactoryClass = ClassUtils.forName(getDefaultExpressionFactoryClassName());
} catch (ClassNotFoundException e) {
throw new IllegalStateException(
IllegalStateException ise = new IllegalStateException(
"The default ExpressionFactory class '"
+ getDefaultExpressionFactoryClassName()
+ "' could not be found in the classpath. "
+ "Please add this to your classpath or set the default ExpressionFactory class name to something that is in the classpath.");
ise.initCause(e);
throw ise;
} catch (NoClassDefFoundError e) {
throw new IllegalStateException(
IllegalStateException ise = new IllegalStateException(
"The default ExpressionFactory class '"
+ getDefaultExpressionFactoryClassName()
+ "' could not be found in the classpath. "
+ "Please add this to your classpath or set the default ExpressionFactory class name to something that is in the classpath.");
ise.initCause(e);
throw ise;
}
try {
return (ExpressionFactory) expressionFactoryClass.newInstance();
} catch (Exception e) {
IllegalStateException iae = new IllegalStateException("An instance of the default ExpressionFactory '"
IllegalStateException ise = new IllegalStateException("An instance of the default ExpressionFactory '"
+ getDefaultExpressionFactoryClassName()
+ "' could not be instantiated. Check your EL implementation configuration.");
iae.initCause(e);
throw iae;
ise.initCause(e);
throw ise;
}
}
}

View File

@@ -21,35 +21,30 @@
<dependencies>
<!-- global dependencies -->
<dependency org="com.sun.facelets" name="jsf-facelets" rev="1.1.14" conf="compile->default"/>
<dependency org="javax.servlet" name="jstl" rev="1.1.2" conf="compile->default"/>
<dependency org="javax.persistence" name="persistence-api" rev="1.0.0" conf="compile->default"/>
<dependency org="org.aopalliance" name="aopalliance" rev="1.0" conf="compile->default"/>
<dependency org="org.apache" name="commons-codec" rev="1.3" conf="compile, compile->default" />
<dependency org="org.apache.commons" name="commons-collections" rev="3.2" conf="compile->default" />
<dependency org="org.apache.logging" name="log4j" rev="1.2.15" conf="compile->default"/>
<dependency org="org.apache.taglibs" name="standard" rev="1.1.2" conf="compile->default"/>
<dependency org="javax.servlet" name="jstl" rev="1.1.2" conf="compile->default"/>
<dependency org="com.sun.facelets" name="jsf-facelets" rev="1.1.14" conf="compile->default"/>
<dependency org="org.aopalliance" name="aopalliance" rev="1.0" conf="compile->default"/>
<dependency org="org.springframework.webflow" name="spring-faces" rev="latest.integration" conf="compile->jsf12"/>
<dependency org="org.springframework.webflow" name="spring-webflow" rev="latest.integration" conf="compile->compile"/>
<dependency org="org.springframework.webflow" name="spring-binding" rev="latest.integration" conf="compile->compile"/>
<dependency org="org.hibernate" name="hibernate" rev="3.2.5.ga" conf="compile->default"/>
<dependency org="org.hibernate" name="hibernate-annotations" rev="3.3.0.ga" conf="compile->default"/>
<dependency org="org.hibernate" name="hibernate-commons-annotations" rev="3.3.0.ga" conf="compile->default"/>
<dependency org="org.hibernate" name="hibernate-entitymanager" rev="3.3.1.ga" conf="compile->default"/>
<dependency org="org.jboss" name="jboss-common-core" rev="2.0.4.GA" conf="compile->default"/>
<dependency org="org.jboss" name="javassist" rev="3.3.ga" conf="compile->default"/>
<dependency org="org.jboss.seam" name="jboss-el" rev="2.0.0.GA" conf="compile->default"/>
<dependency org="org.hsqldb" name="hsqldb" rev="1.8.0.9" conf="compile->default"/>
<dependency org="org.springframework" name="spring-aop" rev="2.5.2" conf="compile->default"/>
<dependency org="org.springframework" name="spring-orm" rev="2.5.2" conf="compile->default"/>
<dependency org="org.springframework" name="spring-jdbc" rev="2.5.2" conf="compile->default"/>
<dependency org="org.springframework.security" name="spring-security-core" rev="2.0.0.m2" conf="compile->default"/>
<dependency org="org.springframework" name="spring-tx" rev="2.5.2" conf="compile->default"/>
<dependency org="org.jboss.seam" name="jboss-el" rev="2.0.0.GA" conf="compile->default"/>
<dependency org="org.hibernate" name="hibernate" rev="3.2.5.ga" conf="compile->default"/>
<dependency org="org.hibernate" name="hibernate-annotations" rev="3.3.0.ga" conf="compile->default"/>
<dependency org="org.hibernate" name="hibernate-entitymanager" rev="3.3.1.ga" conf="compile->default"/>
<dependency org="org.springframework.security" name="spring-security-core" rev="2.0.0.m2" conf="compile->default"/>
<dependency org="org.springframework.webflow" name="spring-faces" rev="latest.integration" conf="compile->jsf12"/>
<dependency org="org.springframework.webflow" name="spring-webflow" rev="latest.integration" conf="compile->compile"/>
<dependency org="net.sf.cglib" name="cglib_nodep" rev="2.1.3" conf="compile->default"/>
<dependency org="org.jboss" name="jboss-common-core" rev="2.0.4.GA" conf="compile->default"/>
<dependency org="org.jboss" name="javassist" rev="3.3.ga" conf="compile->default"/>
<dependency org="org.antlr" name="antlr" rev="2.7.6" conf="compile->default"/>
<dependency org="org.apache.commons" name="commons-collections" rev="3.2" conf="compile->default" />
<dependency org="org.apache" name="commons-codec" rev="1.3" conf="compile, compile->default" />
<dependency org="org.hibernate" name="hibernate-commons-annotations" rev="3.3.0.ga" conf="compile->default"/>
<dependency org="javax.persistence" name="persistence-api" rev="1.0.0" conf="compile->default"/>
<dependency org="org.hsqldb" name="hsqldb" rev="1.8.0.9" conf="compile->default"/>
<!-- Required by "jboss archive browsing" which is used by hibernate-entity manager but not noted in their docs -->
<dependency org="edu.oswego.cs" name="concurrent" rev="1.3.4" conf="compile->default"/>
<!-- build-time only dependencies -->
<dependency org="javax.servlet" name="servlet-api" rev="2.4" conf="provided->default"/>

View File

@@ -0,0 +1,92 @@
package org.springframework.webflow.samples.booking;
import org.easymock.EasyMock;
import org.springframework.faces.model.converter.FacesConversionService;
import org.springframework.webflow.config.FlowDefinitionResource;
import org.springframework.webflow.config.FlowDefinitionResourceFactory;
import org.springframework.webflow.core.collection.LocalAttributeMap;
import org.springframework.webflow.core.collection.MutableAttributeMap;
import org.springframework.webflow.test.MockExternalContext;
import org.springframework.webflow.test.MockFlowBuilderContext;
import org.springframework.webflow.test.execution.AbstractXmlFlowExecutionTests;
public class BookingFlowExecutionTests extends AbstractXmlFlowExecutionTests {
private BookingService bookingService;
private boolean persistCalled;
protected void setUp() {
bookingService = EasyMock.createMock(BookingService.class);
}
@Override
protected FlowDefinitionResource getResource(FlowDefinitionResourceFactory resourceFactory) {
return resourceFactory.createFileResource("src/main/webapp/WEB-INF/flows/booking/booking.xml");
}
@Override
protected void configureFlowBuilderContext(MockFlowBuilderContext builderContext) {
builderContext.registerBean("bookingService", bookingService);
builderContext.getFlowBuilderServices().setConversionService(new FacesConversionService());
}
public void testStartBookingFlow() {
Booking booking = createTestBooking();
EasyMock.expect(bookingService.createBooking(1L, "keith")).andReturn(booking);
EasyMock.replay(bookingService);
MutableAttributeMap input = new LocalAttributeMap();
input.put("hotelId", "1");
MockExternalContext context = new MockExternalContext();
context.setCurrentUser("keith");
startFlow(input, context);
assertCurrentStateEquals("enterBookingDetails");
assertResponseWrittenEquals("enterBookingDetails", context);
assertTrue(getRequiredFlowAttribute("booking") instanceof Booking);
EasyMock.verify(bookingService);
}
public void testEnterBookingDetails_Proceed() {
setCurrentState("enterBookingDetails");
getFlowScope().put("booking", createTestBooking());
MockExternalContext context = new MockExternalContext();
context.setEventId("proceed");
resumeFlow(context);
assertCurrentStateEquals("reviewBooking");
assertResponseWrittenEquals("reviewBooking", context);
}
public void testReviewBooking_Confirm() {
setCurrentState("reviewBooking");
getFlowScope().put("booking", createTestBooking());
getFlowScope().put("entityManager", new Object() {
public void persist(Booking booking) {
persistCalled = true;
}
});
MockExternalContext context = new MockExternalContext();
context.setEventId("confirm");
resumeFlow(context);
assertTrue(persistCalled);
assertFlowExecutionEnded();
assertFlowExecutionOutcomeEquals("bookingConfirmed");
}
private Booking createTestBooking() {
Hotel hotel = new Hotel();
hotel.setId(1L);
hotel.setName("Jameson Inn");
User user = new User("keith", "pass", "Keith Donald");
Booking booking = new Booking(hotel, user);
return booking;
}
}

View File

@@ -6,222 +6,7 @@
<classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="lib" path="/spring-webflow/target/artifacts/spring-webflow.jar" sourcepath="/spring-webflow/target/artifacts/spring-webflow-sources.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="/spring-binding/target/artifacts/spring-binding.jar" sourcepath="/spring-binding/target/artifacts/spring-binding-sources.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="/spring-faces/target/artifacts/spring-faces.jar" sourcepath="/spring-faces/target/artifacts/spring-faces-sources.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/edu.oswego.cs/concurrent/concurrent-1.3.4.jar" sourcepath="IVY_CACHE/edu.oswego.cs/concurrent/concurrent-sources-1.3.4.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/javax.el/el-api/el-api-1.0.jar" sourcepath="IVY_CACHE/javax.el/el-api/el-api-sources-1.0.jar"/>
<classpathentry kind="var" path="IVY_CACHE/javax.persistence/persistence-api/persistence-api-1.0.0.jar" sourcepath="IVY_CACHE/javax.persistence/persistence-api/persistence-api-sources-1.0.0.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/javax.servlet/jstl/jstl-1.1.2.jar" sourcepath="IVY_CACHE/javax.servlet/jstl/jstl-1.1.2-sources.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/javax.servlet/servlet-api/servlet-api-2.4.jar" sourcepath="IVY_CACHE/javax.servlet/servlet-api/servlet-api-sources-2.4.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/javax.transaction/jta/jta-1.1.0.jar" sourcepath="IVY_CACHE/javax.transaction/jta/jta-sources-1.1.0.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/net.sf.cglib/cglib_nodep/cglib_nodep-2.1.3.jar" sourcepath="IVY_CACHE/net.sf.cglib/cglib_nodep/cglib_nodep-sources-2.1.3.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.antlr/antlr/antlr-2.7.6.jar" sourcepath="IVY_CACHE/org.antlr/antlr/antlr-sources-2.7.6.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.aopalliance/aopalliance/aopalliance-1.0.jar" sourcepath="IVY_CACHE/org.aopalliance/aopalliance/aopalliance-sources-1.0.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.apache/commons-codec/commons-codec-1.3.jar" sourcepath="/IVY_CACHE/org.apache/commons-codec/commons-codec-sources-1.3.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.apache/commons-logging/commons-logging-1.1.1.jar" sourcepath="/IVY_CACHE/org.apache/commons-logging/commons-logging-sources-1.1.1.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.apache.commons/commons-beanutils/commons-beanutils-1.7.0.jar" sourcepath="/IVY_CACHE/org.apache.commons/commons-beanutils/commons-beanutils-sources-1.7.0.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.apache.commons/commons-collections/commons-collections-3.2.jar" sourcepath="/IVY_CACHE/org.apache.commons/commons-collections/commons-collections-sources-3.2.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.apache.commons/commons-digester/commons-digester-1.8.0.jar" sourcepath="/IVY_CACHE/org.apache.commons/commons-digester/commons-digester-sources-1.8.0.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.apache.commons/commons-discovery/commons-discovery-0.4.0.jar" sourcepath="/IVY_CACHE/org.apache.commons/commons-discovery/commons-discovery-sources-0.4.0.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.apache.logging/log4j/log4j-1.2.15.jar" sourcepath="IVY_CACHE/org.apache.logging/log4j/log4j-sources-1.2.15.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.apache.taglibs/standard/standard-1.1.2.jar" sourcepath="IVY_CACHE/org.apache.taglibs/standard/standard-sources-1.1.2.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.apache.tiles/tiles-api/tiles-api-2.0.5.jar" sourcepath="IVY_CACHE/org.apache.tiles/tiles-api/tiles-api-sources-2.0.5.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.apache.tiles/tiles-core/tiles-core-2.0.5.jar" sourcepath="IVY_CACHE/org.apache.tiles/tiles-core/tiles-core-sources-2.0.5.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.apache.tiles/tiles-jsp/tiles-jsp-2.0.5.jar" sourcepath="IVY_CACHE/org.apache.tiles/tiles-jsp/tiles-jsp-sources-2.0.5.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.dom4j/dom4j/dom4j-1.6.1.jar" sourcepath="IVY_CACHE/org.dom4j/dom4j/dom4j-sources-1.6.1.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.hibernate/hibernate/hibernate-3.2.5.ga.jar" sourcepath="IVY_CACHE/org.hibernate/hibernate/hibernate-sources-3.2.5.ga.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.hibernate/hibernate-commons-annotations/hibernate-commons-annotations-3.3.0.ga.jar" sourcepath="IVY_CACHE/org.hibernate/hibernate-commons-annotations/hibernate-commons-annotations-sources-3.3.0.ga.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.hibernate/hibernate-annotations/hibernate-annotations-3.3.0.ga.jar" sourcepath="IVY_CACHE/org.hibernate/hibernate-annotations/hibernate-annotations-sources-3.3.0.ga.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.hibernate/hibernate-entitymanager/hibernate-entitymanager-3.3.1.ga.jar" sourcepath="IVY_CACHE/org.hibernate/hibernate-entitymanager/hibernate-entitymanager-sources-3.3.1.ga.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.hsqldb/hsqldb/hsqldb-1.8.0.9.jar" sourcepath="IVY_CACHE/org.hsqldb/hsqldb/hsqldb-sources-1.8.0.9.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.jboss/javassist/javassist-3.3.ga.jar" sourcepath="IVY_CACHE/org.jboss/javassist/javassist-sources-3.3.ga.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.jboss/jboss-common-core/jboss-common-core-2.0.4.GA.jar" sourcepath="IVY_CACHE/org.jboss/jboss-common-core/jboss-common-core-sources-2.0.4.GA.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.jboss.seam/jboss-el/jboss-el-2.0.0.GA.jar" sourcepath="IVY_CACHE/org.jboss.seam/jboss-el/jboss-el-sources-2.0.0.GA.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.junit/junit/junit-3.8.2.jar" sourcepath="/IVY_CACHE/org.junit/junit/junit-sources-3.8.2.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/spring-aop/spring-aop-2.5.2.jar" sourcepath="IVY_CACHE/org.springframework/spring-aop/spring-aop-sources-2.5.2.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/spring-beans/spring-beans-2.5.2.jar" sourcepath="IVY_CACHE/org.springframework/spring-beans/spring-beans-sources-2.5.2.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/spring-context/spring-context-2.5.2.jar" sourcepath="IVY_CACHE/org.springframework/spring-context/spring-context-sources-2.5.2.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/spring-core/spring-core-2.5.2.jar" sourcepath="IVY_CACHE/org.springframework/spring-core/spring-core-sources-2.5.2.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/spring-jdbc/spring-jdbc-2.5.2.jar" sourcepath="IVY_CACHE/org.springframework/spring-jdbc/spring-jdbc-sources-2.5.2.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/spring-orm/spring-orm-2.5.2.jar" sourcepath="IVY_CACHE/org.springframework/spring-orm/spring-orm-sources-2.5.2.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/spring-test/spring-test-2.5.2.jar" sourcepath="IVY_CACHE/org.springframework/spring-test/spring-test-sources-2.5.2.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/spring-tx/spring-tx-2.5.2.jar" sourcepath="IVY_CACHE/org.springframework/spring-tx/spring-tx-sources-2.5.2.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/spring-web/spring-web-2.5.2.jar" sourcepath="IVY_CACHE/org.springframework/spring-web/spring-web-sources-2.5.2.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/spring-webmvc/spring-webmvc-2.5.2.jar" sourcepath="IVY_CACHE/org.springframework/spring-webmvc/spring-webmvc-sources-2.5.2.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.springframework.security/spring-security-core/spring-security-core-2.0.0.m2.jar" sourcepath="IVY_CACHE/org.springframework.security/spring-security-core/spring-security-core-sources-2.0.0.m2.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.springframework.security/spring-security-taglibs/spring-security-taglibs-2.0.0.m2.jar" sourcepath="IVY_CACHE/org.springframework.security/spring-security-taglibs/spring-security-taglibs-sources-2.0.0.m2.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="var" path="IVY_CACHE/org.easymock/easymock/easymock-2.3.jar" sourcepath="/IVY_CACHE/org.easymock/easymock/easymock-sources-2.3.jar"/>
<classpathentry kind="var" path="IVY_CACHE/javax.servlet/servlet-api/servlet-api-2.4.jar" sourcepath="IVY_CACHE/javax.servlet/servlet-api/servlet-api-sources-2.4.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
</classpath>

View File

@@ -21,38 +21,36 @@
<dependencies>
<!-- global dependencies -->
<dependency org="org.apache.logging" name="log4j" rev="1.2.15" conf="runtime->default"/>
<dependency org="org.apache.taglibs" name="standard" rev="1.1.2" conf="compile->default"/>
<dependency org="javax.servlet" name="jstl" rev="1.1.2" conf="compile->default"/>
<dependency org="javax.persistence" name="persistence-api" rev="1.0.0" conf="compile->default"/>
<dependency org="org.aopalliance" name="aopalliance" rev="1.0" conf="compile->default"/>
<dependency org="org.apache" name="commons-codec" rev="1.3" conf="compile->default"/>
<dependency org="org.apache.logging" name="log4j" rev="1.2.15" conf="runtime->default"/>
<dependency org="org.apache.taglibs" name="standard" rev="1.1.2" conf="compile->default"/>
<dependency org="org.apache.tiles" name="tiles-api" rev="2.0.5" conf="compile->default"/>
<dependency org="org.apache.tiles" name="tiles-core" rev="2.0.5" conf="compile->default"/>
<dependency org="org.apache.tiles" name="tiles-jsp" rev="2.0.5" conf="compile->default"/>
<dependency org="org.springframework.webflow" name="spring-faces" rev="latest.integration" conf="compile->compile"/>
<dependency org="org.springframework.webflow" name="spring-webflow" rev="latest.integration" conf="compile->compile"/>
<dependency org="org.hibernate" name="hibernate" rev="3.2.5.ga" conf="compile->default"/>
<dependency org="org.hibernate" name="hibernate-entitymanager" rev="3.3.1.ga" conf="compile->default"/>
<dependency org="org.hibernate" name="hibernate-annotations" rev="3.3.0.ga" conf="compile->default"/>
<dependency org="org.hibernate" name="hibernate-commons-annotations" rev="3.3.0.ga" conf="compile->default"/>
<dependency org="org.hsqldb" name="hsqldb" rev="1.8.0.9" conf="compile->default"/>
<dependency org="org.ognl" name="ognl" rev="2.6.9" conf="compile->default"/>
<dependency org="org.springframework" name="spring-aop" rev="2.5.2" conf="compile->default"/>
<dependency org="org.springframework" name="spring-orm" rev="2.5.2" conf="compile->default"/>
<dependency org="org.springframework" name="spring-jdbc" rev="2.5.2" conf="compile->default"/>
<dependency org="org.springframework" name="spring-tx" rev="2.5.2" conf="compile->default"/>
<dependency org="org.springframework.security" name="spring-security-core" rev="2.0.0.m2"/>
<dependency org="org.springframework.security" name="spring-security-taglibs" rev="2.0.0.m2"/>
<dependency org="org.jboss.seam" name="jboss-el" rev="2.0.0.GA" conf="compile->default"/>
<dependency org="org.hibernate" name="hibernate" rev="3.2.5.ga" conf="compile->default"/>
<dependency org="org.hibernate" name="hibernate-entitymanager" rev="3.3.1.ga" conf="compile->default"/>
<!-- Required by "jboss archive browsing" which is used by hibernate-entity manager but not noted in their docs -->
<dependency org="edu.oswego.cs" name="concurrent" rev="1.3.4" conf="compile->default"/>
<dependency org="org.hibernate" name="hibernate-annotations" rev="3.3.0.ga" conf="compile->default"/>
<dependency org="org.hibernate" name="hibernate-commons-annotations" rev="3.3.0.ga" conf="compile->default"/>
<dependency org="javax.persistence" name="persistence-api" rev="1.0.0" conf="compile->default"/>
<dependency org="org.hsqldb" name="hsqldb" rev="1.8.0.9" conf="compile->default"/>
<dependency org="org.springframework.webflow" name="spring-faces" rev="latest.integration" conf="compile->compile"/>
<dependency org="org.springframework.webflow" name="spring-webflow" rev="latest.integration" conf="compile->compile"/>
<!-- build-time only dependencies -->
<dependency org="javax.servlet" name="servlet-api" rev="2.4" conf="provided->default"/>
<dependency org="javax.el" name="el-api" rev="1.0" conf="provided->default"/>
<!-- test-time only dependencies -->
<dependency org="org.junit" name="junit" rev="3.8.2" conf="test->default"/>
<dependency org="org.easymock" name="easymock" rev="2.3" conf="test->default" />
<dependency org="org.springframework" name="spring-test" rev="2.5.2" conf="test->default"/>
</dependencies>

View File

@@ -0,0 +1,92 @@
package org.springframework.webflow.samples.booking;
import org.easymock.EasyMock;
import org.springframework.faces.model.converter.FacesConversionService;
import org.springframework.webflow.config.FlowDefinitionResource;
import org.springframework.webflow.config.FlowDefinitionResourceFactory;
import org.springframework.webflow.core.collection.LocalAttributeMap;
import org.springframework.webflow.core.collection.MutableAttributeMap;
import org.springframework.webflow.test.MockExternalContext;
import org.springframework.webflow.test.MockFlowBuilderContext;
import org.springframework.webflow.test.execution.AbstractXmlFlowExecutionTests;
public class BookingFlowExecutionTests extends AbstractXmlFlowExecutionTests {
private BookingService bookingService;
private boolean persistCalled;
protected void setUp() {
bookingService = EasyMock.createMock(BookingService.class);
}
@Override
protected FlowDefinitionResource getResource(FlowDefinitionResourceFactory resourceFactory) {
return resourceFactory.createFileResource("src/main/webapp/WEB-INF/hotels/booking/booking.xml");
}
@Override
protected void configureFlowBuilderContext(MockFlowBuilderContext builderContext) {
builderContext.registerBean("bookingService", bookingService);
builderContext.getFlowBuilderServices().setConversionService(new FacesConversionService());
}
public void testStartBookingFlow() {
Booking booking = createTestBooking();
EasyMock.expect(bookingService.createBooking(1L, "keith")).andReturn(booking);
EasyMock.replay(bookingService);
MutableAttributeMap input = new LocalAttributeMap();
input.put("hotelId", "1");
MockExternalContext context = new MockExternalContext();
context.setCurrentUser("keith");
startFlow(input, context);
assertCurrentStateEquals("enterBookingDetails");
assertResponseWrittenEquals("enterBookingDetails", context);
assertTrue(getRequiredFlowAttribute("booking") instanceof Booking);
EasyMock.verify(bookingService);
}
public void testEnterBookingDetails_Proceed() {
setCurrentState("enterBookingDetails");
getFlowScope().put("booking", createTestBooking());
MockExternalContext context = new MockExternalContext();
context.setEventId("proceed");
resumeFlow(context);
assertCurrentStateEquals("reviewBooking");
assertResponseWrittenEquals("reviewBooking", context);
}
public void testReviewBooking_Confirm() {
setCurrentState("reviewBooking");
getFlowScope().put("booking", createTestBooking());
getFlowScope().put("entityManager", new Object() {
public void persist(Booking booking) {
persistCalled = true;
}
});
MockExternalContext context = new MockExternalContext();
context.setEventId("confirm");
resumeFlow(context);
assertTrue(persistCalled);
assertFlowExecutionEnded();
assertFlowExecutionOutcomeEquals("bookingConfirmed");
}
private Booking createTestBooking() {
Hotel hotel = new Hotel();
hotel.setId(1L);
hotel.setName("Jameson Inn");
User user = new User("keith", "pass", "Keith Donald");
Booking booking = new Booking(hotel, user);
return booking;
}
}

View File

@@ -90,11 +90,15 @@ public final class DefaultExpressionParserFactory {
ClassUtils.forName("ognl.Ognl");
return new WebFlowOgnlExpressionParser();
} catch (ClassNotFoundException ex) {
throw new IllegalStateException(
IllegalStateException ise = new IllegalStateException(
"Unable to create the default expression parser for Spring Web Flow: Neither a Unified EL implementation or OGNL could be found.");
ise.initCause(ex);
throw ise;
} catch (NoClassDefFoundError ex) {
throw new IllegalStateException(
IllegalStateException ise = new IllegalStateException(
"Unable to create the default expression parser for Spring Web Flow: Neither a Unified EL implementation or OGNL could be found.");
ise.initCause(ex);
throw ise;
}
}
}

View File

@@ -17,8 +17,6 @@ package org.springframework.webflow.expression;
import java.util.Map;
import javax.el.PropertyNotWritableException;
import ognl.ObjectPropertyAccessor;
import ognl.OgnlException;
import ognl.PropertyAccessor;
@@ -143,10 +141,10 @@ public class WebFlowOgnlExpressionParser extends OgnlExpressionParser {
String property = name.toString();
RequestContext requestContext = (RequestContext) target;
if (property.equals("flowRequestContext")) {
throw new PropertyNotWritableException("The 'flowRequestContext' variable is not writeable");
throw new OgnlException("The 'flowRequestContext' variable is not writeable");
}
if (securityPresent && property.equals("currentUser")) {
throw new PropertyNotWritableException("The 'currentUser' variable is not writeable");
throw new OgnlException("The 'currentUser' variable is not writeable");
}
if (requestContext.getRequestScope().contains(property)) {
if (logger.isDebugEnabled()) {