This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes testing Action class through StrutsTestCase Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "testing Action class through StrutsTestCase" Watch "testing Action class through StrutsTestCase" New topic

testing Action class through StrutsTestCase

subhit chauhan
Ranch Hand

Joined: Jun 20, 2002
Posts: 40
Hi !

I have created on action class and inside that action class i am getting some values from file,

//code snippet to get values through ApplicationResources.propeties
MessageResources messageResources = getResources(request);
String value = messageResources.getMessage("results.totalToDisplayPerPage");
String totalNumber = messageResources.getMessage("results.totalNumber");

I am using StrutsTestCase for unit testing my action class but when i run my test case i am getting values for value and totalNumber as null.

My testExcute() method is as below :

public void testExecute() {

Can somebody tell me how to set file through StrutsTestCase.

My application is running properly in webserver which shows my web.xml and struts-config.xml files are correct and when i run inside webserver my application is able to read from file.

I just wanna know how to unit test it ?
Junilu Lacar

Joined: Feb 26, 2001
Posts: 4442

make sure is in the classpath when you run the StrutsTestCase

Junilu - [How to Ask Questions] [How to Answer Questions]
I agree. Here's the link:
subject: testing Action class through StrutsTestCase
Similar Threads
in Eclipse - web.xml not found
StrutsTestCase problem
How do I set value in my test case method for testing Action Class?
junit Error - web.xml was not found
Getting values from properties in validate-using multiple message-resources in struts