File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to setup ServletContext variables in CactusStrutsTestCase

 
Ray Lim
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1209
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic