This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

StrutsTestCase problem

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi - I use eclipse to run this test case and point "WEB-INF" folder for classpath and I still get the error message below. could you please help me this issue? Thanks

junit 3.8.2. jar
jdk 1.6
Strut-config is located at WebRoot/WEB-INF folder.

====================
import servletunit.struts.MockStrutsTestCase;
public class LogoffActionTest extends MockStrutsTestCase {

private static final String ACTION_PATH = "/logoff";
private static final String CONTEXT_DIR = "WebRoot";

public LogoffActionTest(String arg0) {
super(arg0);
}

protected void setUp() throws Exception {
super.setUp();
setRequestPathInfo(ACTION_PATH);
setContextDirectory(new File(CONTEXT_DIR));
}

protected void tearDown() throws Exception {
super.tearDown();
}

public void testCaseForSuccessfulLogoff() {
actionPerform();
verifyForwardPath("/Logon.jsp");
}
}

--------------Error --------
servletunit.struts.ExceptionDuringTestError: A NullPointerException was thrown. This may indicate an error in your ActionForm, or it may indicate that the Struts ActionServlet was unable to find struts config file. TestCase is running from C:\Workspaces\Test\ directory. Context directory is C:\Workspaces\Test\WebRoot. struts config file must be found under the context directory, the directory the test case is running from, or in the classpath.
at servletunit.struts.MockStrutsTestCase.actionPerform(MockStrutsTestCase.java:407)
at com.ingenix.itg.subrotrack.security.action.LogoffActionTest.testCaseForSuccessfulLogoff(LogoffActionTest.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
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:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
------------
Root Cause:
------------
java.lang.NullPointerException
at servletunit.struts.MockStrutsTestCase.getActionServlet(MockStrutsTestCase.java:331)
at servletunit.struts.MockStrutsTestCase.actionPerform(MockStrutsTestCase.java:394)
at com.ingenix.itg.subrotrack.security.action.LogoffActionTest.testCaseForSuccessfulLogoff(LogoffActionTest.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
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:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)


 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you might be better off asking the project owner, since it's not an actual Struts product, but: is there a config file? The error message is pretty clear on what it *believes* the problem to be.
 
Jason Vo
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Strut-config.xml file is located at WebRoot/WEB-INF folder and I'm not sure why it doesn't recognize the config file. From debug, i can see this line of code throw NPE

//This method is from MockStrutsTestCase class
public ActionServlet getActionServlet() {
.....
this.actionServlet.init(config); ======> NPE happened here

}
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I don't really know anything about the framework, but the config file appears to not be in one of the three locations it mentions, no?
 
I didn't do it. You can't prove it. Nobody saw me. The sheep are lying! This tiny ad is my witness!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!