Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with specifing a module in a JUnit test

Status
Not open for further replies.

raverrz69

Programmer
Feb 27, 2006
1
RO
hello
Here is my problem :

I have an web.xml file witch have this passage where I specify a root of the aplication and 2 struts-config.xml files

the new-struts-config-erp.xml extends all the struts-config.xml files from every module

<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/erp/new-struts-config-erp.xml,
/WEB-INF/erp/other/struts-config.xml
##ERPSTS_STRUTS_MODULES##
</param-value>

and then I tried to make a JUnit test for some java file in my application whitch extends MockStrutsTestCase and where I
need to specify a module..the problem is that the file I intend to test is in the root and It seem logic to me that
method setConfigFile(myModule,"/WEB-INF/struts-config.xml")
should look like this

setConfigFile("","/WEB-INF/erp/new-struts-config-erp.xml");
setRequestPathInfo("","/SpSarbatori.do");


apparently it s wrong the struts doesn t manage to initialize the servlet because struts doesn t find the struts-config file that I specify

the error is the folowing: he is tring to find the struts config ,he doesn t find it and by default he looks in WEB-INF: the error log is the following:

------------- Standard Output ---------------
ERROR [main] - Missing configuration resource for path /WEB-INF/struts-config.xml
ERROR [main] - Error initializing action servlet
javax.servlet.UnavailableException: Missing configuration resource for path /WEB-INF/struts-config.xml
at org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.java:732)
at org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:687)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:333)
at ro.uti.waf.web.JPortalActionServlet.init(JPortalActionServlet.java:31)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at servletunit.struts.MockStrutsTestCase.getActionServlet(MockStrutsTestCase.java:303)
at test.userservice.action.LoginTest.setUp(LoginTest.java:37)
at junit.framework.TestCase.runBare(TestCase.java:125)
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.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:297)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:672)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:567)
------------- ---------------- ---------------
Testcase: testAddDebt(test.src.main.java.command.SpSarbatoriLegaleAdd): FAILED
Missing configuration resource for path /WEB-INF/struts-config.xml
junit.framework.AssertionFailedError: Missing configuration resource for path /WEB-INF/struts-config.xml
at servletunit.struts.MockStrutsTestCase.getActionServlet(MockStrutsTestCase.java:321)
at test.userservice.action.LoginTest.setUp(LoginTest.java:37)

My question is how can I manage to write correctly this method??
setConfigFile("","/WEB-INF/erp/new-struts-config-erp.xml");???


any suggestion would mean a lot to me

best regards

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top