KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > test > web > validator > ExpectTextValidator


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.validator;
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: ExpectTextValidator.java,v 1.1 2004/10/11 23:36:06 tuan08 Exp $
14  **/

15 public class ExpectTextValidator implements Validator {
16   private String JavaDoc expectText_ ;
17   public ExpectTextValidator(String JavaDoc text) {
18     expectText_ = text ;
19   }
20   
21   public boolean validate(WebResponse response, ExoWebClient client) throws Exception JavaDoc {
22     String JavaDoc text = response.getText() ;
23     boolean b = text.indexOf(expectText_) >= 0 ;
24     if(b ==false) {
25         //System.out.println(response.getText()) ;
26
System.out.println("Expect text: " + expectText_) ;
27     }
28     return b ;
29   }
30   
31   public String JavaDoc getName() { return "ExpectTextvalidator" ; }
32   
33   public String JavaDoc getDescription() {
34     return "Make sure that the return xhtml has the following text '" + expectText_ + "'" ;
35   }
36 }
Popular Tags