I don't know anything about portlets, but here he goes.
Here is portletUnit .
portletUnit is a test environment used to validate JSR-168 portlets from outside a portlet container like servletUnit is used to test servlets outside a servlet container. It is projected to map functionally servletUnit to portlets with servletUnit itself providing the basis for portletUnit.
For more information, see his Project PortletUnit blog , including PortletUnit and Spring Portlet: form validation error checking .
portletUnit , , . , PortletRunner, .
, - 2007 Jetty, Pluto JWebUnit.
Johannes Brodwall Jetty JWebUnit, setup-pluto, . , .
, Spring 10.2 .
org.springframework.mock.web.portlet API , Spring MVC.
[...] org.springframework.test.web ModelAndViewAssert, (, JUnit 4+, TestNG ..) Spring MVC ModelAndView.
[...] MVC Spring, ModelAndViewAssert MockHttpServletRequest, MockHttpSession .. org.springframework.mock.web package.
,
, Spring -MVC.
. Spring -MVC, ( ) ( Java) dead-easy to test - POJO.
Spring -MVC , ( ), . , , MockHttpServletRequest MockHttpServletResponse HTTP- . , Controller Java. , , , . :
public class UpdateClientTest {
request.setMethod("POST");
request.setParameter("id", "100");
request.setParameter("firstName", "Jane");
request.setParameter("lastName", "Doe");
controller = new ChoosePeriodController();
ModelAndView mav = controller.handleRequest(request, response);
controller.setClientService(clientService);
...
assert mav != null;
assertEquals("displayClient",mav.getViewName());
Client client = (Client) mav.getModel().get("client");
assertEquals("Jane",client.getFirstName());
assertEquals("Doe",client.getLastName());
...
}
...