From: Tony O. <to...@co...> - 2003-08-16 22:58:26
|
I've used the j2ee v1.2 MockHttpServletRequest and added code to the class to implement new methods that were previously un-implemented. So, I have a degree of familiarity with Mock Objects that do not use the Dynamic Mock pattern, they seemed quite easy to use, just a java class that had methods, if the method you wanted wasn't implemented, you added an implementation. Now I'm trying to use the latest j2ee mock objects (mockobjects-jdk1.4-j2ee1.3-0.09.jar) which require the use of Dynamic Mock objects. I've followed the documentation to be able to test the getParameter method but have no idea of how to set up the getParameterNames method. Mock mockRequest = new Mock(javax.servlet.http.HttpServletRequest.class); mockRequest.expectAndReturn("getParameter", "param1", "value1"); HttpServletRequest _request = (HttpServletRequest)mockRequest.proxy(); System.out.println("param = " + _request.getParameter("param1")); // Works well!!!!! I cannot find any documentation or examples of dynamic mock objects that goes beyond the simple example above and am subsequently stuck. Any help is appreciated, otherwise I'll go back to the j2ee 1.2 mock library, I was really hoping to move forward with the new dynamic approach but the lack of examples and my inexperience with dynamic mocks is holding me up. Tony |