aspose file tools*
The moose likes Websphere and the fly likes Junit in WSAD problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "Junit in WSAD problems" Watch "Junit in WSAD problems" New topic
Author

Junit in WSAD problems

Greg Reinl
Ranch Hand

Joined: Feb 11, 2003
Posts: 45
I'm trying to use the eclipse junit plug-in with Websphere Studio Application Developer workbench and am having some trouble.
I can run a simple test case just fine, but when I run a test case that tests a class that relies on information from the application environment (like a web.xml file) it doesn't find the environment variables it needs. (When using the same class from a JSP it finds the variables). I'm also seeing situations where it is not finding classes in jar files in the WEBINF\lib directory.
I assume that both of these problems are due to the fact that the junit test is not running in the web/servlet container. If that is the case, how do I run junit test cases to test classes that depend on things such as variables in the web.xml file or .jars in the WEBINF\lib directory?
Martin Coetzee
Greenhorn

Joined: Dec 02, 2003
Posts: 21
Hi Greg. Look at the apache cactus framework. Cactus is a framework that extends the JUnit framework. It allows you to write JUnit test cases and run them inside the scope of the application server. I'm sure this will solve your problem. You can contact me at any stage if you need help getting cactus running on your machine.
Apache Cactus
Regards
Martin Coetzee (martin@coetzee-family.com)
Greetings from South Africa....
Greg Reinl
Ranch Hand

Joined: Feb 11, 2003
Posts: 45
Thank you very much! I'll look into Cactus and let you know how I make out.
Greg Reinl
Ranch Hand

Joined: Feb 11, 2003
Posts: 45
Well, I was hoping to use the cactus eclipse plug-in, but according to the download page, there is no working version currently available.
The Eclipse plugin is a work in progress. In the past it was working, but since we moved to the new Ant integration it has been broken. This requires a rewrite of the plugin code to fix. In the meantime, we have removed the plugin download. Sorry about that. Any help will be much welcome.

I realize I can use cactus outside of an eclipse IDE, but I would prefer not to go there just yet. I'll have to check back later. Thanks again for your help.
Martin Coetzee
Greenhorn

Joined: Dec 02, 2003
Posts: 21
Hi Greg...Download the libraries, and configure it into your classpath. Then, read the documentation. I'm currently using cactus in WSAD 5, and I have no problems. I think the plug-in will help you to setup certain property files. But if you read the documentation of cactus, you can get it working under a day.
Like I said...Download the libraries, and import it into your application. Inside the web.xml add a servlet: ServletRedirector, with the servlet-class as: org.apache.cactus.server.ServletTestRedirector
After that, make sure you've got the following properties file inside your Java Source root of you web project: cactus.properties and add the following into it:
Then read the documentation regarding writing your own cactus tests. I think the eclipse plug-in would have helped you wilh doing the above mentioned stuff...But give it a try...
Cheers
Martin Coetzee (South Africa)
[ February 09, 2004: Message edited by: Martin Coetzee ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Junit in WSAD problems
 
Similar Threads
Required directory structure in tomcat4.1.24
Ant war task and JSP tag files
saxon9-dom.jar not found only when running junit
HttpSessionAttributeListener and HttpSessionBindingListener
[junit] java.lang.ClassNotFoundException: UserActivityTest