This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Testing and the fly likes struts test case problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "struts test case problem" Watch "struts test case problem" New topic
Author

struts test case problem

geeta gonchala
Greenhorn

Joined: Jul 24, 2007
Posts: 18
Hi friends,
I am new to struts test case.I am using this code in my action.
public void setUp() throws Exception {
super.setUp();
setConfigFile("E:/workspace/PrivoHibernateSep29//struts-config.xml");
// setInitParameter("validating","false");
}
public void testSuccessfulLogin() {


addRequestParameter("username","jprivo");
addRequestParameter("password","tayloe");
setRequestPathInfo("/login");
actionPerform();
verifyForward("success");
verifyForwardPath("/pages/success.jsp");
assertEquals("jprivo",getSession().getAttribute("authentication"));
verifyNoActionErrors();
[junit] Running com.privo.hdomain.dao.impl.test.TestLoginAction
[junit] Testsuite: com.privo.hdomain.dao.impl.test.TestLoginAction
[junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 0.344 sec
[junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 0.344 sec
[junit] ------------- Standard Output ---------------
[junit] - The /WEB-INF/web.xml was not found.
[junit] - Unable to initialize Struts ActionServlet due to an unexpected exception or error thrown, so marking the servlet as unavailable. Most likely, this is due to an incorrect or missing library dependency.
[junit] javax.servlet.ServletException: The /WEB-INF/web.xml was not found.
[junit] at org.apache.struts.action.ActionServlet.initServlet(ActionServlet.java:1138)
[junit] at org.apache.struts.action.ActionServlet.init(ActionServlet.java:328)
[junit] at javax.servlet.GenericServlet.init(GenericServlet.java:211)
[junit] at servletunit.struts.MockStrutsTestCase.getActionServlet(MockStrutsTestCase.java:226)
[junit] at servletunit.struts.MockStrutsTestCase.tearDown(MockStrutsTestCase.java:126)
[junit] at junit.framework.TestCase.runBare(TestCase.java:130)
[junit] at junit.framework.TestResult$1.protect(TestResult.java:106)
[junit] at junit.framework.TestResult.runProtected(TestResult.java:124)
[junit] at junit.framework.TestResult.run(TestResult.java:109)
[junit] at junit.framework.TestCase.run(TestCase.java:118)
[junit] at junit.framework.TestSuite.runTest(TestSuite.java:208)
[junit] at junit.framework.TestSuite.run(TestSuite.java:203)
[junit] at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
[junit] at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:32)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:421)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:912)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:766)
[junit] - Error initializing action servlet
[junit] javax.servlet.UnavailableException: The /WEB-INF/web.xml was not found.
[junit] at org.apache.struts.action.ActionServlet.init(ActionServlet.java:368)
[junit] at javax.servlet.GenericServlet.init(GenericServlet.java:211)
[junit] at servletunit.struts.MockStrutsTestCase.getActionServlet(MockStrutsTestCase.java:226)
[junit] at servletunit.struts.MockStrutsTestCase.tearDown(MockStrutsTestCase.java:126)
[junit] at junit.framework.TestCase.runBare(TestCase.java:130)
[junit] at junit.framework.TestResult$1.protect(TestResult.java:106)
[junit] at junit.framework.TestResult.runProtected(TestResult.java:124)
[junit] at junit.framework.TestResult.run(TestResult.java:109)
[junit] at junit.framework.TestCase.run(TestCase.java:118)
[junit] at junit.framework.TestSuite.runTest(TestSuite.java:208)
[junit] at junit.framework.TestSuite.run(TestSuite.java:203)
[junit] at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
[junit] at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:32)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:421)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:912)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:766)
[junit] ------------- ---------------- ---------------
[junit] Testcase: testSuccessfulLogin(com.privo.hdomain.dao.impl.test.TestLoginAction):FAILED
[junit] The /WEB-INF/web.xml was not found.
[junit] junit.framework.AssertionFailedError: The /WEB-INF/web.xml was not found.
[junit] at servletunit.struts.MockStrutsTestCase.getActionServlet(MockStrutsTestCase.java:244)
[junit] at servletunit.struts.MockStrutsTestCase.tearDown(MockStrutsTestCase.java:126)
[junit] Test com.privo.hdomain.dao.impl.test.TestLoginAction FAILED

when i'm trying to run this i'm getting this in my console,i added all the jars specified by the examples given.

can any body help me.
Thank's in advance
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Not an advanced question. Moving...


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
C Popp
Greenhorn

Joined: Aug 08, 2007
Posts: 14
Hi,

I believe this would be a starting point:

From the error log:
The /WEB-INF/web.xml was not found.

I would verify your struts and web app environment are configured and setup correctly. It looks like the web.xml file is having an issue.
Daud Miyan
Greenhorn

Joined: Jul 07, 2010
Posts: 23
You might find this link useful - http://old.nabble.com/javax.servlet.ServletException:-The--WEB-INF-web.xml-was-not-found.-td17083127.html. KIt involves setting setContextDirectory to the directory containing the WEB-INF
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts test case problem