KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > test > web > unit > NewSessionUnit


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.test.web.unit;
6
7 import org.exoplatform.test.web.ExoWebClient;
8 import com.meterware.httpunit.*;
9 /**
10  * May 21, 2004
11  * @author: Tuan Nguyen
12  * @email: tuan08@users.sourceforge.net
13  * @version: $Id: NewSessionUnit.java,v 1.1 2004/10/11 23:36:06 tuan08 Exp $
14  **/

15 public class NewSessionUnit extends WebUnit {
16   private String JavaDoc website_ ;
17   
18   public NewSessionUnit(String JavaDoc name, String JavaDoc description) {
19     super(name, description) ;
20   }
21   
22   public NewSessionUnit setWebsite(String JavaDoc url) {
23     website_ = url ;
24     return this ;
25   }
26   
27   public WebResponse execute(WebResponse previousResponse, WebTable block,
28                                ExoWebClient client) throws Exception JavaDoc {
29     WebConversation wc = new WebConversation() ;
30     client.setWebClient(wc) ;
31     String JavaDoc url = website_ ;
32     if(url == null) url = client.getHomePageURL() ;
33     WebRequest req = new GetMethodWebRequest(url);
34     WebResponse response = wc.getResponse( req );
35     return response ;
36   }
37   
38   public String JavaDoc getActionDescription() {
39     return "This web unit create a new session for the site '" + website_ + "' " +
40            "if there is no defined website, the web unit will use the default website of the web client at the runtime";
41   }
42 }
Popular Tags