Thinking more about it, I'm not so sure that the solution is a method
that is called only once... Each test must set its own fixture. So you
should group test using the same fixture (i.e. user being logging in) in
the same TestCase class. Then simply use either begin() or even better
setUp() (it has direct access to the session) to log the user in before
*each* test.
Ah ha - the begin() method is exactly what I was looking for. Of course, I'd prefer to use setUp() because then my test looks more like JUnit than Cactus (making it easier to understand for those familiar with JUnit). However, I'm unsure of how to get the WebRequest (in order to set authorization) in the setUp() method.
I tried removing all my beginXX() methods and just using one begin() method and this worked great - thanks!
So the question is - is it possible to combine the following 2 methods?
public void begin(WebRequest request) { request.setRedirectorName("ServletRedirectorSecure"); request.setAuthentication(new FormAuthentication( login.getString("username"), login.getString("encryptedPassword"))); }
public void setUp() throws Exception { super.setUp();
conn = ServiceLocator.getConnection(); // populate the userForm and place into session String username = login.getString("username"); UserManager userMgr = new UserManagerImpl(conn); userForm = (UserForm) userMgr.getUser(username); session.setAttribute(Constants.USER_KEY, userForm); }
Matt
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]