CDATA
This commit is contained in:
@@ -12,10 +12,10 @@
|
||||
<para>
|
||||
To test the execution of a XML-based flow definition, extend <code>AbstractXmlFlowExecutionTests</code>:
|
||||
</para>
|
||||
<programlisting language="java">
|
||||
<programlisting language="java"><![CDATA[
|
||||
public class BookingFlowExecutionTests extends AbstractXmlFlowExecutionTests {
|
||||
|
||||
}
|
||||
}]]>
|
||||
</programlisting>
|
||||
</sect1>
|
||||
<sect1 id="override-getResource">
|
||||
@@ -23,11 +23,11 @@ public class BookingFlowExecutionTests extends AbstractXmlFlowExecutionTests {
|
||||
<para>
|
||||
At a minimum, you must override <code>getResource(FlowDefinitionResourceFactory)</code> to return the path to the flow you wish to test:
|
||||
</para>
|
||||
<programlisting language="java">
|
||||
<programlisting language="java"><![CDATA[
|
||||
@Override
|
||||
protected FlowDefinitionResource getResource(FlowDefinitionResourceFactory resourceFactory) {
|
||||
return resourceFactory.createFileResource("src/main/webapp/WEB-INF/flows/booking/booking.xml");
|
||||
}
|
||||
}]]>
|
||||
</programlisting>
|
||||
</sect1>
|
||||
<sect1 id="override-configureFlowBuilderContext">
|
||||
@@ -36,11 +36,11 @@ protected FlowDefinitionResource getResource(FlowDefinitionResourceFactory resou
|
||||
If your flow has dependencies on externally managed services,
|
||||
also override <code>configureFlowBuilderContext(MockFlowBuilderContext)</code> to register stubs or mocks of those services:
|
||||
</para>
|
||||
<programlisting language="java">
|
||||
<programlisting language="java"><![CDATA[
|
||||
@Override
|
||||
protected void configureFlowBuilderContext(MockFlowBuilderContext builderContext) {
|
||||
builderContext.registerBean("bookingService", new StubBookingService());
|
||||
}
|
||||
}]]>
|
||||
</programlisting>
|
||||
</sect1>
|
||||
<sect1 id="testing-flowstartup">
|
||||
@@ -48,7 +48,7 @@ protected void configureFlowBuilderContext(MockFlowBuilderContext builderContext
|
||||
<para>
|
||||
Have your first test exercise the startup of your flow:
|
||||
</para>
|
||||
<programlisting language="java">
|
||||
<programlisting language="java"><![CDATA[
|
||||
public void testStartBookingFlow() {
|
||||
|
||||
Booking booking = createTestBooking();
|
||||
@@ -61,7 +61,7 @@ public void testStartBookingFlow() {
|
||||
|
||||
assertCurrentStateEquals("enterBookingDetails");
|
||||
assertTrue(getRequiredFlowAttribute("booking") instanceof Booking);
|
||||
}
|
||||
}]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Assertions generally verify the flow is in the correct state you expect.
|
||||
@@ -74,7 +74,7 @@ public void testStartBookingFlow() {
|
||||
You goal should be to exercise all paths through the flow.
|
||||
You can use the convenient <code>setCurrentState(String)</code> method to jump to the flow state where you wish to begin your test.
|
||||
</para>
|
||||
<programlisting>
|
||||
<programlisting><![CDATA[
|
||||
public void testEnterBookingDetails_Proceed() {
|
||||
|
||||
setCurrentState("enterBookingDetails");
|
||||
@@ -86,7 +86,7 @@ public void testEnterBookingDetails_Proceed() {
|
||||
resumeFlow(context);
|
||||
|
||||
assertCurrentStateEquals("reviewBooking");
|
||||
}
|
||||
}]]>
|
||||
</programlisting>
|
||||
</sect1>
|
||||
<sect1 id="testing-mockingsubflows">
|
||||
@@ -95,7 +95,7 @@ public void testEnterBookingDetails_Proceed() {
|
||||
To test calling a subflow, register a mock implementation of the subflow that asserts input was passed in correctly and
|
||||
returns the correct outcome for your test scenario.
|
||||
</para>
|
||||
<programlisting language="java">
|
||||
<programlisting language="java"><![CDATA[
|
||||
public void testBookHotel() {
|
||||
|
||||
setCurrentState("reviewHotel");
|
||||
@@ -127,7 +127,7 @@ public Flow createMockBookingSubflow() {
|
||||
});
|
||||
// immediately return the bookingConfirmed outcome so the caller can respond
|
||||
new EndState(mockBookingFlow, "bookingConfirmed");
|
||||
}
|
||||
}]]>
|
||||
</programlisting>
|
||||
</sect1>
|
||||
</chapter>
|
||||
Reference in New Issue
Block a user