Hi, I've been getting to grips with Cactus to use it as a testing harness for testing a container based API. The idea is that we can write Junit tests that tests elements of our API.
We run with Tomcat and use our own Realm implementation inside Tomcat to do authentication against a user repository. A number of other actions are performed as a result. Having authenticated, there is information in the HttpServletRequest that is available via the Princpal. I want to be able to do browser based tests and therefore I have used ServletTestRunner. Both client and server components are in the container. If I protect the ServletTestRunner page then I can do browser based authentication, the HttpServletRequest is then populated with the correct Principal. The problem is that the client component of the test then makes a call to the server based component (both in the same VM) but it seems to create a new HttpServletRequest between client/server components so the authentication information is lost. I changed the test case so the the client component set up the authentication information, as in the example, and it works correctly, in that the authentication takes place with the information supplied by the begin* method. However, there are some drawbacks with this: 1, the second HttpRequest made by the client component also causes authentication to occur. This is unnecessary, and in our environment causes all the additional action to be repeated. 2, it is not possible to change the authenticated user in the test dynamically, which is possible if browser authentication is used. All the tests we need to do will have to run in an authenticated context. Originally I started looking at JUnitEE but there is no access to the HttpServletRequest (unless I extend the runner). What would seem to be a good idea (to me) is that when using browser integration, i.e. all components are in the same VM, then there is no need to instantiate 2 objects and do the communication between them using Http. Also, the REAL HttpServletRequest (and HttpSession) could then be available between client and server components. It may be that I am trying to do with Cactus, something it was not designed to, however, unit testing in my environment includes multiple calls to an API method. I need to be able to retain information over multiple iterations to the test case. I can't get to the CVS at the moment as it's down, but would what I want to do be easy to achieve? Regards Antony --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
