Sorry about the long delay ... ( I hope you're still listening :) ) ... Here is my analysis : * Apparently you're using form login, so you must be using https I imagine. At the current time https is not supported. However, that shouldn't be a problem to test your login process as https is transparent in regards to your server code (should be). * You simply need to send a POST with the parameter name and value that you are expecting on the server side * Let's imagine that the submit button calls a servlet that we'll call LoginServlet, you would test like this :
public void beginLogin(WebRequest request) { request.addParameter("username", "anad"); request.addParameter("password", "mohanram"); } public void testLogin() { LoginServlet servlet = new LoginServlet(); servlet.service(request, response); // or better: servlet.processLogin(request) // At this stage, you would normally set a flag in the // http session specifying that the user is logged in // and this flag would be checked on subsequent logins // so the test should verify that assertEquals("true", session.getAttribute("isLogged")); } Now if your service() method does a forward to the index page of your site, you could check that this is the correct page and not the error page for example but this is not as nice as asserting the session. It is a side effect test ... However, if you'd still like to do it, it is possible, you'll just have to do asserts in the endLogin(WebResponse) method to verify it is the page you're looking for. You would not be able to check the URL as this is not returned (because a forward was done on the server side) so you're left which checking returned items (you should use the signature for HttpUnit integration for that - see the httpunit integration tutorial on the cactus web site). Hope it helps -Vincent ----- Original Message ----- From: "Anand Mohanram" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, August 23, 2001 10:16 AM Subject: RE: Testing Login functionailty Hi Vincent May be I would like to frame my question a little bit differently. Without going to the browser,how do I know whether my Login succeeded or failed ? Once I submit,I want to know whether the current page has been displayed Thanks Anand -----Original Message----- From: Vincent Massol [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 23, 2001 2:16 PM To: [EMAIL PROTECTED] Subject: Re: Testing Login functionailty Hi Anand, It seems what you are trying to do is functional tests. If you have no need for unit tests (checking state on the server side) then you probably don't need Cactus and you can use HttpUnit. Cactus provides a simple integration with HttpUnit that you could use but will needed only if you wish to perform unit tests (if you're interested, see http://jakarta.apache.org/commons/cactus/howto_httpunit.html). Thanks -Vincent ----- Original Message ----- From: "Anand Mohanram" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, August 23, 2001 4:54 AM Subject: Testing Login functionailty Hi I have a Login screen and I would like to supply Username and password and check whether the resulting screen and ofcourse the contents the screen are right. I tried httpunit but I am not able to get the resulting screen correctly. Should I use cactus ? I am trying to simulate the Submit functionality. Thanks Anand M Anand Project Manager - Infosys Technologies, Chennai,India Ph: 91-44-4509530/40 - Ext: 80324 Visit us at http://www.infy.com