Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts test case problem

 
geeta gonchala
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not an advanced question. Moving...
 
C Popp
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic