Brian Bonner - 2002-10-15

I'm not able to successfully get StrutsTestCase to launch.  It is blowing a SAXParseException  as follows:

[INFO] ServletContextSimulator - -ActionServlet: init
[INFO] PropertyMessageResources - -Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true
[INFO] PropertyMessageResources - -Initializing, config='org.apache.struts.action.ActionResources', returnNull=true
org.xml.sax.SAXParseException: File "null" not found.
    at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1202)
    at org.apache.xerces.readers.DefaultEntityHandler.startReadingFromDocument(DefaultEntityHandler.java:499)
    at org.apache.xerces.framework.XMLParser.parseSomeSetup(XMLParser.java:312)
    at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1080)
    at org.apache.commons.digester.Digester.parse(Digester.java:1514)
    at org.apache.struts.action.ActionServlet.initServlet(ActionServlet.java:1257)
    at org.apache.struts.action.ActionServlet.init(ActionServlet.java:451)
    at javax.servlet.GenericServlet.init(GenericServlet.java:258)
    at servletunit.struts.MockStrutsTestCase.getActionServlet(MockStrutsTestCase.java:134)
    at servletunit.struts.MockStrutsTestCase.actionPerform(MockStrutsTestCase.java:173)
    at test.com.kroger.accounting.esc.struts.action.esc.display.ApplicationSelectorTest.testSuccess(ApplicationSelectorTest.java:37)
    at java.lang.reflect.Method.invoke(Native Method)
    at junit.framework.TestCase.runTest(TestCase.java:154)
    at junit.framework.TestCase.runBare(TestCase.java:127)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:208)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at junit.swingui.TestRunner$16.run(TestRunner.java:625)
[ERROR] Digester - -Parse Fatal Error at line 0 column 0: File "null" not found. <org.xml.sax.SAXParseException: File "null" not found.>
org.xml.sax.SAXException: Stopping after fatal error: File "null" not found.
    at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1228)
    at org.apache.xerces.readers.DefaultEntityHandler.startReadingFromDocument(DefaultEntityHandler.java:499)
    at org.apache.xerces.framework.XMLParser.parseSomeSetup(XMLParser.java:312)
    at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1080)
    at org.apache.commons.digester.Digester.parse(Digester.java:1514)
    at org.apache.struts.action.ActionServlet.initServlet(ActionServlet.java:1257)
    at org.apache.struts.action.ActionServlet.init(ActionServlet.java:451)
    at javax.servlet.GenericServlet.init(GenericServlet.java:258)
    at servletunit.struts.MockStrutsTestCase.getActionServlet(MockStrutsTestCase.java:134)
    at servletunit.struts.MockStrutsTestCase.actionPerform(MockStrutsTestCase.java:173)
    at test.com.kroger.accounting.esc.struts.action.esc.display.ApplicationSelectorTest.testSuccess(ApplicationSelectorTest.java:37)
    at java.lang.reflect.Method.invoke(Native Method)
    at junit.framework.TestCase.runTest(TestCase.java:154)
    at junit.framework.TestCase.runBare(TestCase.java:127)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:208)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at junit.swingui.TestRunner$16.run(TestRunner.java:625)
[ERROR] ActionServlet - -null <org.xml.sax.SAXException: Stopping after fatal error: File "null" not found.>
java.lang.NullPointerException
    at org.apache.struts.action.ActionServlet.initApplicationConfig(ActionServlet.java:857)
    at org.apache.struts.action.ActionServlet.init(ActionServlet.java:455)
    at javax.servlet.GenericServlet.init(GenericServlet.java:258)
    at servletunit.struts.MockStrutsTestCase.getActionServlet(MockStrutsTestCase.java:134)
    at servletunit.struts.MockStrutsTestCase.actionPerform(MockStrutsTestCase.java:173)
    at test.com.kroger.accounting.esc.struts.action.esc.display.ApplicationSelectorTest.testSuccess(ApplicationSelectorTest.java:37)
    at java.lang.reflect.Method.invoke(Native Method)
    at junit.framework.TestCase.runTest(TestCase.java:154)
    at junit.framework.TestCase.runBare(TestCase.java:127)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:208)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at junit.swingui.TestRunner$16.run(TestRunner.java:625)
[ERROR] ActionServlet - -Parsing error processing resource path /WEB-INF/struts-config.xml <java.lang.NullPointerException>

Here's the test case:

package test.com.kroger.accounting.esc.struts.action.esc.display;

import com.kroger.accounting.esc.struts.servlet.ESCActionServlet;
import junit.framework.TestCase;
import org.apache.struts.action.ActionServlet;
import servletunit.ServletConfigSimulator;
import servletunit.struts.MockStrutsTestCase;
// import test.com.kroger.accounting.esc.struts.SNCUserHttpServletRequestWrapper;

public class ApplicationSelectorTest extends MockStrutsTestCase{
    private String myAppRoot = "d:\\program files\\ibm\\application developer\\workspace\\kroger_escWeb\\webApplication";

    /**
     * Constructor for TestApplicationSelector
     */
    public ApplicationSelectorTest(String arg0) {
        super(arg0);
    }

    public void setUp() throws Exception {
        super.setUp();       
        javax.servlet.ServletConfig cfg = new ServletConfigSimulator(myAppRoot);       
        ((ServletConfigSimulator) cfg).setInitParameter(
            "serviceFactory.className",
            "com.kroger.accounting.esc.service.test.ServiceFactory");
    }

    public void tearDown() throws Exception {
        super.tearDown();

    }

    public void testSuccess() throws Exception {

        //        setRequestWrapper(new SNCUserHttpServletRequestWrapper());
        setRequestPathInfo("/start");
        actionPerform();
        verifyForward("success");
    }
}

strutstest.jar is in a /lib directory
and struts-config.xml is in /WEB-INF/lib along with struts.jar

Any ideas?