aspose file tools*
The moose likes Testing and the fly likes How to setup ServletContext variables in CactusStrutsTestCase Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "How to setup ServletContext variables in CactusStrutsTestCase" Watch "How to setup ServletContext variables in CactusStrutsTestCase" New topic
Author

How to setup ServletContext variables in CactusStrutsTestCase

Ray Lim
Greenhorn

Joined: Jan 10, 2002
Posts: 15
I am trying to create a test for a simple Action that needs to retrieve the "configuration" object from ServletContext. I guess what I need to do is create the Configuration object and set it to ServletContext before testing the perform. How do I set anything to ServletContext in StrutsTestcase?
----------------------------------------
Action perform method

Test Code
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
I might be wrong. I guess CactusStrutsTestCase extends ServletTestCase which exposes a config object. U can get to the servlet context through the config.
config.getServletContext()
HTH.
I have a question for you. Are u able to get CactusStrutsTestCase to work from within a war file?? It's not workign for me from within a war which is in a ear.
Am using strutstest version 1.9.6
Please let me know. I'm not able to automate the daily build bcos of that reason
Ray Lim
Greenhorn

Joined: Jan 10, 2002
Posts: 15
Thanks karthik, I was sure it something like that but just wasn't looking in the right places for the servletcontext.
Not quite sure what problem you are running into when "war"ing the project. I war'd my project and deployed to another context and ran my /ServletTestRunner. Went ok. Have you tried manually deploying the war, instead of having deployed from ear?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to setup ServletContext variables in CactusStrutsTestCase