jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Wang <mw...@epolicysolutions.com>
Subject NullPointerException -- can't run tests
Date Thu, 07 Nov 2002 21:58:49 GMT

Hi all,

I'm running into a dead end trying to configure Cactus. Actually I'm 
using StrutsTest's in-container mode, which uses Cactus to run 
tests. I've installed and configured my client/server side following 
instructions from the Cactus website, but for the life of me I can't 
get it to run. I'm using Tomcat 4.0.3 and Eclipse 2.0 on Win2k.

Here's my test code:
-------------------------
package mike.web;

import java.util.HashMap;
import javax.servlet.http.HttpSession;
import servletunit.struts.CactusStrutsTestCase;
import org.apache.struts.action.Action;


public class CactusTestLoginAction extends CactusStrutsTestCase
{
    public CactusTestLoginAction(String testName) {
        super(testName);
    }
	
    public void testSuccessfulLogin()
    {
    	// set up request params & trigger action
        addRequestParameter("username","mike");
        addRequestParameter("password","123");
        setRequestPathInfo("/login");
        actionPerform();

		verifyForward("success");   // are we going to the right
place?
		verifyNoActionErrors();     // any validation error?

        // validate everything is in order...
        HttpSession session = getSession();
        assertEquals("mike", session.getAttribute("username"));
        assertEquals("none", session.getAttribute("lastAction"));
        
        HashMap map = (HashMap)session.getAttribute("userdata");
        assertEquals(new Integer(81818), map.get("userId"));
        assertEquals("Homer", map.get("firstname"));
        assertEquals("Simpson", map.get("lastname"));
        assertNotNull(map.get("address"));
        
        Address a = (Address)map.get("address");
        assertEquals("300 Pine St.", a.street);
        assertEquals("Springfield", a.city);
        assertEquals("XX", a.state);
        assertEquals("99999", a.zip);
    }
}
-------------------------

Here's the error I get:
-------------------
1)
testSuccessfulLogin(mike.web.CactusTestLoginAction)java.lang.NullPointerExce
ption
	at
org.apache.struts.util.MessageResources.getMessageResources(MessageResources
.java:558)
	at
org.apache.struts.action.ActionServlet.initInternal(ActionServlet.java:1153)
	at
org.apache.struts.action.ActionServlet.init(ActionServlet.java:449)
	at javax.servlet.GenericServlet.init(GenericServlet.java:258)
	at
servletunit.struts.CactusStrutsTestCase.getActionServlet(CactusStrutsTestCas
e.java:255)
	at
servletunit.struts.CactusStrutsTestCase.actionPerform(CactusStrutsTestCase.j
ava:306)
	at
mike.web.CactusTestLoginAction.testSuccessfulLogin(CactusTestLoginAction.jav
a:22)
	at
org.apache.cactus.AbstractTestCase.runServerTest(AbstractTestCase.java:332)
	at
org.apache.cactus.AbstractTestCase.runBareServerTest(AbstractTestCase.java:2
35)
	at
org.apache.cactus.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.
java:149)
	at
org.apache.cactus.server.AbstractWebTestController.dispatch87_handleRequest(
AbstractWebTestController.java;org/apache/cactus/util/log/LogAspect.aj(1k):1
25)
	at
org.apache.cactus.server.AbstractWebTestController.around87_handleRequest(Ab
stractWebTestController.java;org/apache/cactus/util/log/LogAspect.aj(1k):115
6)
	at
org.apache.cactus.server.AbstractWebTestController.handleRequest(AbstractWeb
TestController.java;org/apache/cactus/util/log/LogAspect.aj(1k):101)
	at
org.apache.cactus.server.ServletTestRedirector.dispatch113_doPost(ServletTes
tRedirector.java;org/apache/cactus/util/log/LogAspect.aj(1k):123)
	at
org.apache.cactus.server.ServletTestRedirector.around113_doPost(ServletTestR
edirector.java;org/apache/cactus/util/log/LogAspect.aj(1k):1156)
	at
org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.
java;org/apache/cactus/util/log/LogAspect.aj(1k):109)
	at
org.apache.cactus.server.ServletTestRedirector.dispatch112_doGet(ServletTest
Redirector.java;org/apache/cactus/util/log/LogAspect.aj(1k):96)
	at
org.apache.cactus.server.ServletTestRedirector.around112_doGet(ServletTestRe
director.java;org/apache/cactus/util/log/LogAspect.aj(1k):1156)
	at
org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.j
ava;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)
		:
		:
--------------------

The stack trace changes when I run it on ATG, but the exception is 
always NullPointerException.

Any suggestion is welcome. I'm all out of ideas here. Thanks.


mw



--
To unsubscribe, e-mail:   <mailto:cactus-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:cactus-user-help@jakarta.apache.org>


Mime
View raw message