I'm using cactus 1.6 to unit/integration test J2EE components, servlets in this particular case. My environment is Jetty/Cactus/Eclipse 3.0.
My test case extends the Cactus ServletTestCase class.
In the setUp method i create an instance of my servlet to be tested.
........
myServlet = new MyServlet();
........
In the beginMyTest(WebRequest request) method I set the URL as:
.......
request.setURL(
"myserver:port",
"/contextpath",
"/some/path/someCommand.pp", null, null);
.......
Now in the testMyTest() method I call myServlet's doPost method. like:
.......
servlet.init(config);
myServlet.doPost(request, response);
.......
In doPost a command object is created from the parameter request. This command object does some processing and then returns a String as URL to the doPost method which in turn tries to forward the call. The pseudocode looks like:
{pseudocode ---
Command command = CommandFactory.getCommand(request), //1
String urlStr = command.execute(); //2
RequestDispatcher disp = request.getRequestDispatcher(urlStr); //3
disp.forward(request, response); //4
--- pseudocode}
On the line //4 there is a NullPointerException. The reason is that the originalDispatcher in the RequestDispatcher instance is null.
Any hint would be greatly appreciated.
--------------------------------------------------
java.lang.NullPointerException
at org.apache.cactus.server.RequestDispatcherWrapper.forward_aroundBody0(RequestDispatcherWrapper.java:71)
at org.apache.cactus.server.RequestDispatcherWrapper.forward_aroundBody1$advice(RequestDispatcherWrapper.java:117)
at org.apache.cactus.server.RequestDispatcherWrapper.forward(RequestDispatcherWrapper.java)
at com.mycompany.mypackage.MyServlet.doPost(MyServlet.java:110)
at com.mycompany.mypackage.test.MyIntegrationTestCase.testMyTest(MyIntegrationTestCase.java:58)
---------------------------------------------------
-- Regards,
Mamadou
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
