File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Testing and the fly likes Problem With cactus testing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Problem With cactus testing" Watch "Problem With cactus testing" New topic
Author

Problem With cactus testing

N Naga
Greenhorn

Joined: Jun 02, 2004
Posts: 1
Hi

I am using following code to test our LoginAction (Struts Frame work)


public void testSuccessfulLogin() {

setConfigFile("edrs", "/WEB-INF/struts-config.xml");
setRequestPathInfo("/edrs", "/loginAction.do");

String pathInfo = "/loginAction";
logger.debug(
"Entering+servletunit.struts.CactusStrutsTestCase.setRequestPathInfo() : pathInfo = "
+ pathInfo);
logger.debug("START --Setting Request Parameters");
addRequestParameter("username", "xyz");
addRequestParameter("password", "xyz");
addRequestParameter("action","logon");
logger.debug("END --Setting Request Parameters");
actionPerform();
logger.debug("AfterAction Perform --Setting Request Parameters");
verifyForward("success");
verifyForwardPath("/WEB-INF/jsp/welcome.jsp");
LoginForm loginForm=(LoginForm)getActionForm();
logger.debug("USerName :::::"+loginForm.getUsername());
logger.debug("Compare user id");
verifyNoActionErrors();
}

It's giving me the following error


null

java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:389)
at weblogic.servlet.internal.WebAppServletContext.setAttribute(WebAppServletContext.java:669)
at org.apache.cactus.server.AbstractServletContextWrapper.dispatch115_setAttribute(AbstractServletContextWrapper.java;org/apache/cactus/util/log/LogAspect.aj[1k]:129)
at org.apache.cactus.server.AbstractServletContextWrapper.around115_setAttribute(AbstractServletContextWrapper.java;org/apache/cactus/util/log/LogAspect.aj[1k]:1158)
at org.apache.cactus.server.AbstractServletContextWrapper.setAttribute(AbstractServletContextWrapper.java;org/apache/cactus/util/log/LogAspect.aj[1k]:127)
at org.apache.cactus.server.AbstractServletContextWrapper.dispatch115_setAttribute(AbstractServletContextWrapper.java;org/apache/cactus/util/log/LogAspect.aj[1k]:129)
at org.apache.cactus.server.AbstractServletContextWrapper.around115_setAttribute(AbstractServletContextWrapper.java;org/apache/cactus/util/log/LogAspect.aj[1k]:1151)
at org.apache.cactus.server.AbstractServletContextWrapper.setAttribute(AbstractServletContextWrapper.java;org/apache/cactus/util/log/LogAspect.aj[1k]:127)
at servletunit.struts.CactusStrutsTestCase.tearDown(CactusStrutsTestCase.java:129)
at org.apache.cactus.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:156)
at org.apache.cactus.server.AbstractWebTestController.dispatch133_handleRequest(AbstractWebTestController.java;org/apache/cactus/util/log/LogAspect.aj[1k]:130)
at org.apache.cactus.server.AbstractWebTestController.around133_handleRequest(AbstractWebTestController.java;org/apache/cactus/util/log/LogAspect.aj[1k]:1158)
at org.apache.cactus.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java;org/apache/cactus/util/log/LogAspect.aj[1k]:101)
at org.apache.cactus.server.ServletTestRedirector.dispatch160_doPost(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:125)
at org.apache.cactus.server.ServletTestRedirector.around160_doPost(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:1158)
at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:109)
at org.apache.cactus.server.ServletTestRedirector.dispatch159_doGet(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:96)
at org.apache.cactus.server.ServletTestRedirector.around159_doGet(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:1158)
at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:92)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6350)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)


Am I missing any thing. I am new to cactus. I want to test out struts action class such as forward path, actionForm, ActionMapping.

Can any one help me. I am missing something.
bob morkos
Ranch Hand

Joined: Oct 06, 2003
Posts: 56
I'm getting the same problem, could you tell me what you have done to fix it.

Originally posted by N Naga:
Hi

I am using following code to test our LoginAction (Struts Frame work)


public void testSuccessfulLogin() {

setConfigFile("edrs", "/WEB-INF/struts-config.xml");
setRequestPathInfo("/edrs", "/loginAction.do");

String pathInfo = "/loginAction";
logger.debug(
"Entering+servletunit.struts.CactusStrutsTestCase.setRequestPathInfo() : pathInfo = "
+ pathInfo);
logger.debug("START --Setting Request Parameters");
addRequestParameter("username", "xyz");
addRequestParameter("password", "xyz");
addRequestParameter("action","logon");
logger.debug("END --Setting Request Parameters");
actionPerform();
logger.debug("AfterAction Perform --Setting Request Parameters");
verifyForward("success");
verifyForwardPath("/WEB-INF/jsp/welcome.jsp");
LoginForm loginForm=(LoginForm)getActionForm();
logger.debug("USerName :::::"+loginForm.getUsername());
logger.debug("Compare user id");
verifyNoActionErrors();
}

It's giving me the following error


null

java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:389)
at weblogic.servlet.internal.WebAppServletContext.setAttribute(WebAppServletContext.java:669)
at org.apache.cactus.server.AbstractServletContextWrapper.dispatch115_setAttribute(AbstractServletContextWrapper.java;org/apache/cactus/util/log/LogAspect.aj[1k]:129)
at org.apache.cactus.server.AbstractServletContextWrapper.around115_setAttribute(AbstractServletContextWrapper.java;org/apache/cactus/util/log/LogAspect.aj[1k]:1158)
at org.apache.cactus.server.AbstractServletContextWrapper.setAttribute(AbstractServletContextWrapper.java;org/apache/cactus/util/log/LogAspect.aj[1k]:127)
at org.apache.cactus.server.AbstractServletContextWrapper.dispatch115_setAttribute(AbstractServletContextWrapper.java;org/apache/cactus/util/log/LogAspect.aj[1k]:129)
at org.apache.cactus.server.AbstractServletContextWrapper.around115_setAttribute(AbstractServletContextWrapper.java;org/apache/cactus/util/log/LogAspect.aj[1k]:1151)
at org.apache.cactus.server.AbstractServletContextWrapper.setAttribute(AbstractServletContextWrapper.java;org/apache/cactus/util/log/LogAspect.aj[1k]:127)
at servletunit.struts.CactusStrutsTestCase.tearDown(CactusStrutsTestCase.java:129)
at org.apache.cactus.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:156)
at org.apache.cactus.server.AbstractWebTestController.dispatch133_handleRequest(AbstractWebTestController.java;org/apache/cactus/util/log/LogAspect.aj[1k]:130)
at org.apache.cactus.server.AbstractWebTestController.around133_handleRequest(AbstractWebTestController.java;org/apache/cactus/util/log/LogAspect.aj[1k]:1158)
at org.apache.cactus.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java;org/apache/cactus/util/log/LogAspect.aj[1k]:101)
at org.apache.cactus.server.ServletTestRedirector.dispatch160_doPost(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:125)
at org.apache.cactus.server.ServletTestRedirector.around160_doPost(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:1158)
at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:109)
at org.apache.cactus.server.ServletTestRedirector.dispatch159_doGet(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:96)
at org.apache.cactus.server.ServletTestRedirector.around159_doGet(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:1158)
at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:92)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6350)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)


Am I missing any thing. I am new to cactus. I want to test out struts action class such as forward path, actionForm, ActionMapping.

Can any one help me. I am missing something.
deepak saxena
Greenhorn

Joined: Aug 17, 2005
Posts: 1
I have te same problem pleaze tell me how can i ovrcome with this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem With cactus testing