Testing Web Flow
Testing of multi-page process can be really trouble as you might have to set a test server with the actual application running in all aspects. Even though you do this, it could be really hard to segregate and isolate flows and test it in complete isolation. Also it could be very difficult to test intermediate flows or sub-flows as they have close dependencies with its corresponding parents.
Fortunately, Spring Web Flow allows you to do just that by supplying org.springframework.weblow.test.execution.AbstractXmlFlowExecutionTests class. It’s a JUnit test class running completely inside a Spring container in which all the necessary objects have been created and hooked onto. You can also use any of the mocking frameworks in conjunction to do unit testing of Spring Web Flow.
Unfortunately I would have to leave you here as covering this topic could take lot of time to explain in a Chapter like this which aims to cover only the basics of Spring MVC along with Spring web Flow.
Plugging into Spring MVC
Spring Web Flow plugs very easily with FrontController pattern based web application framework. Spring MVC being one such web application framework, the integration between Spring Web Flow and Spring MVC can be termed as marriage made in heaven. Pictorially the integration can be represented a shown in Figure 14-13 below.
Figure 14-13. Interaction between Spring Web Flow and Spring MVC
The steps in doing this integration can be broken down into finite steps as summarized below:
- In the Spring Web Flow configuration file configure the following:
- Flow Registry
- Flow Executor
- In the Spring MVC configuration file enable flow handling by the framework
- Now map the registered flows to appropriate resource URL’s in your Spring Web Flow configuration
- You have now integrated Spring Web Flow with your Spring MVC web application.
The integraction between the various components in Spring Web Flow and Spring MVC can be pictoraily depcited as shown in Figure 14-14 below.
Figure 14-14. Interaction between various components in Spring Web Flow and Spring MVC
The Chapter started off with Spring MVC and then went onto in brief towards Spring Web Flow. We have the liberty to cover these two projects only briefly as there are whole books written on each of these Spring projects.
Spring MVC is a web application based on famous MVC-based web application framework which uses all the powerful features of the Spring Framework. We started off as to why should we use Spring MVC against other powerful well know MVC-based web application frameworks like Struts and JSF. We then briefly covered its architecture and various terminologies and components. The Chapter’s aim is to give the reader a high level overview of Spring MVC and I think this is achieved in all aspects.
Spring Web Flow is a very powerful page flow management tool which goes hand in hand with any of the MVC frameworks out there in the world of web application which avoids most of the limitations or rather disadvantages that a typical MVC frameworks have in managing the page flows. It nicely complements the MVC frameworks and gives lot of advantages as opposed to using a standalone MVC web application framework. It has built in hooks onto which famous MVC frameworks in Java world namely Struts and JSF can hook onto without anything complicated.
Combining with all powerful features of the Spring framework, it becomes more or less a needed bonding any web application should have. Both works so well with each other that thinking of a Spring based web application without Spring Web Flow could be a crime in itself.
After going through this Chapter you would have got a bird’s eye view of Spring Web Flow as that is what we can do in a book which tries to cover Spring Framework as a whole. For you to jump start on Spring Web Flow, I think this Chapter would have been enough.
Page Visitors: 5549