I'm writing a test case, which is using form authentication. App Server is 

Weblogic Portal Server 7.0 SP4. 
I'm using ServletTestRunner to run the test case. 

But its not working, I tried everything, but didn't get any success. 
Here is the test case code: 

import junit.framework.*; 
import org.apache.cactus.*; 
import org.apache.cactus.client.authentication.BasicAuthentication; 
import org.apache.cactus.configuration.*; 

public class TestUserAccessManagement extends ServletTestCase{ 
 private UserAccessManagement userAccessManagement; 

 public TestUserAccessManagement(String name) { 
   super(name); 
 } 

 public static Test suite() { 
   return new TestSuite(TestUserAccessManagement.class); 
 } 

 public void begin(WebRequest theRequest){ 
// theRequest.addCookie("pc23165","set-cookie;JSESSIONID","1234_ankur"); 
//    theRequest.addHeader("set-cookie","JSESSIONID=1234_ankur;"); 
/*    theRequest.addCookie("pc23165","JSESSIONID","1234_ankur"); 
   theRequest.addHeader("Host", "PC23165"); 
   theRequest.addHeader("Connection", "Keep-Alive"); 
   theRequest.addHeader("Content-Type", 
"application/x-www-form-urlencoded"); 
//    theRequest.addHeader("Accept-Language", "en-au"); 
//    theRequest.addHeader("Cookie","JSESSIONID=1234_ankur");*/ 
   theRequest.setRedirectorName("ServletRedirectorSecure"); 
   FormAuthentication form = new 
FormAuthentication("visitor1","password"); 
   java.net.URL url = null; 
   try{ 
//      url = new 
java.net.URL("http://pc23165/eservice/application?namespace=security&event=button.login&origin=login.jsp&j_username=visitor1&j_password=password";);
 
     url = new 
java.net.URL("http://pc23165/eservice/application?namespace=security&event=button.login&origin=login.jsp";);
 
     System.out.println("URL:"+url); 
   }catch(java.net.MalformedURLException malException){ 
     System.out.println(malException); 
   } 
   theRequest.addHeader("set-cookie","JSESSIONID=1234_ankur;"); 
   theRequest.addCookie("pc23165","JSESSIONID","1234_ankur"); 
   theRequest.addCookie("pc23165","JSESSIONID","1234_ankur"); 
   theRequest.setRedirectorName("ServletRedirectorSecure"); 
 
form.getSecurityRequest().addHeader("set-cookie","JSESSIONID=1234_ankur;"); 

 form.getSecurityRequest().addCookie("pc23165","JSESSIONID","1234_ankur"); 

   form.getSecurityRequest().addParameter("Cactus_Service","GET_RESULTS"); 

   form.getSecurityRequest().setRedirectorName("ServletRedirectorSecure"); 

   form.getSecurityRequest().setAuthentication(form); 
   theRequest.addParameter("Cactus_Service","GET_RESULTS"); 
   form.setSecurityCheckURL(url); 
   theRequest.setAuthentication(form); 
 
 } 

 public void testIsUserLoggedIn() { 
   this.assertEquals("[User Is Not Logged 
In]",true,this.userAccessManagement.isUserLoggedIn()); 
 } 
} 

I enabled debugging for cactus and I will send debug information in my 
next mail.

*********************************************************************************
Important Note
This email (including any attachments) contains information which is 
confidential and may be subject to legal privilege.  If you are not 
the intended recipient you must not use, distribute or copy this 
email.  If you have received this email in error please notify the 
sender immediately and delete this email. Any views expressed in this 
email are not necessarily the views of AXA.   Thank you.
*********************************************************************************

Reply via email to