wood burning stoves
The moose likes Testing and the fly likes Newbie having problems with StrutsMocktestCase Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Newbie having problems with StrutsMocktestCase" Watch "Newbie having problems with StrutsMocktestCase" New topic

Newbie having problems with StrutsMocktestCase

Vidya Moorthy
Ranch Hand

Joined: Nov 13, 2003
Posts: 57
Hi all
I was trying to practice a Struts tutorial of testing a UserRegistrationActionTest by extending MockStrutsTestCase in MyEclipse IDE. When I ran the Action class as a Junit, I get 3 errors.
This is the trace
at servletunit.struts.MockStrutsTestCase.getActionServlet(MockStrutsTestCase.java:284)
at strutsTutorial.struts.UserRegistrationActionTest.setUp(UserRegistrationActionTest.java:28)
at junit.framework.TestCase.runBare(TestCase.java:128)
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:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

Here is the code for the UserRegistrationActionTest

Please help me figure out the problem!
Thanks in advance
Vidya moorthy
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

Did you follow the API's note :
NOTE: By default, the Struts ActionServlet will look for the file WEB-INF/struts-config.xml, so you must place the directory that contains WEB-INF in your CLASSPATH. If you would like to use an alternate configuration file, please see the setConfigFile() method for details on how this file is located.

[My Blog]
All roads lead to JavaRanch
Hannibal Ou

Joined: Feb 06, 2007
Posts: 11
Vidya Moorthy:
Are you studing struts by the book "JakartaStrutsLive"?
I do it.But I also have many issues .Can you show me the code of class "JDBCTestUtils".
I really can't find the code in the book.

Vidya Moorthy
Ranch Hand

Joined: Nov 13, 2003
Posts: 57
Here it is

I have lot of problems too because that book is based on Struts 1.1 and many methods are deprecated now.
I am not able to finish it only
Hannibal Ou

Joined: Feb 06, 2007
Posts: 11
Thanks for your code!
I also feel it is so hard that when you have a book which using Struts1.1 but you work environment is based on struts 1.2x.
Because my struts is version 1.2.15. So I reading the book with google!When the compiler throws a warning that I used a deprecated method I will search in google to check which method we should used to instead of the deprecated method.
So if any question you have maybe I also have,I hope can study this books together and can I have your MSN or Skype?
I agree. Here's the link: http://aspose.com/file-tools
subject: Newbie having problems with StrutsMocktestCase
It's not a secret anymore!