1 5 package org.exoplatform.test.web.validator; 6 7 import org.exoplatform.test.web.*; 8 import com.meterware.httpunit.*; 9 15 public class ExpectLinkWithURLValidator implements Validator { 16 private String partOfURL_ ; 17 private int numberOfLink_ = -1; 18 19 public ExpectLinkWithURLValidator(String text, int numberOfLink) { 20 partOfURL_ = text ; 21 numberOfLink_ = numberOfLink ; 22 } 23 24 public ExpectLinkWithURLValidator(String text) { 25 partOfURL_ = text ; 26 } 27 28 public boolean validate(WebResponse response, ExoWebClient client) throws Exception { 29 WebLink[] links = Util.findLinksWithURL(response,null, partOfURL_) ; 30 if(numberOfLink_ == -1) { 31 return links.length > 0; 32 } 33 return links.length == numberOfLink_ ; 34 } 35 36 public String getName() { return "ExpectLinkWithURLValidator" ; } 37 38 public String getDescription() { 39 return "Make sure that the return xhtml has the link with url '..." + partOfURL_ + "...'" ; 40 } 41 } | Popular Tags |