I have my web application deployed in WAS 5.1
I have written a JUnit test suite which actually uses MockStrutsTestCase to call my action class. But down the line my bean classes tries to get the access to datasource and for that uses the InitialContext class.
Due to some reason it is failing, my guess is because I am calling the application from a client outside the server it is not gettin gthe sever context and the context it showing is something like this "localhost\persitent".
Thanks a lot.
If you really need a context from your JUnit class, you are correct that you need to be running in one of the server's threads with the context set.
The simple solution for you is to use JUnitEE, which executes the tests from within the up and running server.
On a side note, you unittest should really not be dependent on a datasource, server contex, etc, but that is a totally different issue...