KickJava   Java API By Example, From Geeks To Geeks.

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


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.*;
8 import com.meterware.httpunit.*;
9 /**
10  * May 21, 2004
11  * @author: Tuan Nguyen
12  * @email: tuan08@users.sourceforge.net
13  * @version: $Id: ClickURLLinkUnit.java,v 1.1 2004/10/11 23:36:06 tuan08 Exp $
14  **/

15 public class ClickURLLinkUnit extends WebUnit {
16   protected String JavaDoc url_ ;
17
18   public ClickURLLinkUnit(String JavaDoc name, String JavaDoc description) {
19     super(name, description) ;
20   }
21   
22   public ClickURLLinkUnit setURL(String JavaDoc text) {
23     url_ = text ;
24     return this ;
25   }
26   
27   public WebResponse execute(WebResponse previousResponse, WebTable block,
28                                ExoWebClient client) throws Exception JavaDoc {
29     String JavaDoc name = client.getName() ;
30     String JavaDoc url = url_.replaceAll("#\\{client.name\\}", name) ;
31     WebLink link = Util.findLinkWithURL(previousResponse, block, url);
32     if(link != null) return link.click() ;
33     throw new Exception JavaDoc("Cannot find the link " + url_ + ", Block ID " + getBlockId()) ;
34   }
35   
36   public String JavaDoc getActionDescription() {
37     return "This web unit look for the link with the partial url '..." + url_ + "...' and click on it";
38   }
39 }
Popular Tags