• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

testing Action class through StrutsTestCase

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi !

I have created on action class and inside that action class i am getting some values from ApplicationResources.properties 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() {
setConfigFile(null,"struts-config-raven.xml");
setServletConfigFile("web.xml");
setRequestPathInfo("/searchForm");
addRequestParameter("searchText","hilton");
addRequestParameter("pageId","1");
actionPerform();
verifyForward("success");
}

Can somebody tell me how to set ApplicationResources.properties 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 ApplicationResources.properties file.

I just wanna know how to unit test it ?
 
Sheriff
Posts: 17734
302
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
make sure ApplicationResources.properties is in the classpath when you run the StrutsTestCase
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic