Mock object that attempts to make it easier to use the other Mock objects in this package to interact with Stripes and to interrogate the results. Everything that is done in this class is do-able without this class! It simply exists to make things a bit easier. As a result all the methods in this class simply manipulate one or more of the underlying Mock objects. If some needed capability is not exposed through the MockRoundtrip it is always possible to fetch the underlying request, response and context and interact with them directly.
It is worth noting that the Mock system does not process forwards, includes and redirects. When an ActionBean (or other object) invokes the servlet APIs for any of these actions it is recorded so that it can be reported and verified later. In the majority of cases it should be sufficient to test ActionBeans in isolation and verify that they produced the expected output data and/or forward/redirect. If your ActionBeans depend on being able to include other resources before continuing, sorry - you're on your own!
An example usage of this class might look like:
MockServletContext context = ...; MockRoundtrip trip = new MockRoundtrip(context, CalculatorActionBean.class); trip.setParameter("numberOne", "2"); trip.setParameter("numberTwo", "2"); trip.execute(); CalculatorActionBean bean = trip.getActionBean(CalculatorActionBean.class); Assert.assertEquals(bean.getResult(), 4, "two plus two should equal four"); Assert.assertEquals(trip.getDestination(), ""/quickstart/index.jsp");
@author Tim Fennell
@since Stripes 1.1.1