1 5 package org.exoplatform.test.web.validator; 6 7 import org.exoplatform.test.web.ExoWebClient; 8 import com.meterware.httpunit.*; 9 15 public class ExpectBlockValidator implements Validator { 16 static private WebTable[] EMPTY = new WebTable[0] ; 17 private String blockId_ ; 18 private int numberOfBlock_ = -1 ; 19 20 public ExpectBlockValidator(String text) { 21 blockId_ = text ; 22 } 23 24 public ExpectBlockValidator(String text, int num) { 25 blockId_ = text ; 26 numberOfBlock_ = num ; 27 } 28 29 30 public boolean validate(WebResponse response, ExoWebClient client) throws Exception { 31 WebTable[] tables = response.getMatchingTables(WebTable.MATCH_ID, blockId_) ; 32 if(tables == null) tables = EMPTY ; 33 if(numberOfBlock_ == -1) { 34 return tables.length > 0 ; 35 } 36 return tables.length == numberOfBlock_ ; 37 } 38 39 public String getName() { return "ExpectBlockValidator" ; } 40 41 public String getDescription() { 42 return "Make sure that the return xhtml has a block(it can be a div, table.. block) with the id '" + blockId_ + "'" ; 43 } 44 } | Popular Tags |