Is there a usable standard (168/286) portlet testing framework? (especially the one that works with Spring PortletMVC)

I have not seen anything in this area that I would recommend to the client. If you used Spring PortletMVC, how did you test it?

It is easy to test at the portlet code level and it is relatively easy to test on the client side via HtmlUnit, Selenium, etc., but I have not seen anything that would be a JSFUnit-style β€œGray Box” test (which looks like I will continue).

  • Apache Pluto can theoretically be used to load a test harness. Has anyone tried this?
  • Is any provider of stubs or data suitable?
  • Any approach to solving two-phase processing problems?
+3
source share
2 answers

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 {
        //
        // Prepare your request
        //
        request.setMethod("POST");      
        request.setParameter("id", "100");
        request.setParameter("firstName", "Jane");
        request.setParameter("lastName", "Doe");
        //
        // Invoke the controller
        //
    controller = new ChoosePeriodController();
        ModelAndView mav = controller.handleRequest(request, response);
    //
    // Inject any service objects you need
    //
        controller.setClientService(clientService);
    ...
        //
        // Inspect the results
        //
        assert mav != null;
        assertEquals("displayClient",mav.getViewName());  
        Client client = (Client) mav.getModel().get("client");
        assertEquals("Jane",client.getFirstName());  
        assertEquals("Doe",client.getLastName());  
    ...        
    }
    ...
+6

spring -test-portlet-mvc (https://github.com/markusf/spring-test-portlet-mvc), MockMvc Spring.

0

Source: https://habr.com/ru/post/1709984/


All Articles