• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

struts test case problem

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not an advanced question. Moving...
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic