1 5 package org.exoplatform.test.web.validator; 6 7 import java.io.* ; 8 import org.dom4j.Document; 9 import org.dom4j.io.SAXReader; 10 import org.exoplatform.test.web.ExoWebClient; 11 import com.meterware.httpunit.*; 12 18 public class WellFormedXhtmlValidator implements Validator { 19 20 public boolean validate(WebResponse response, ExoWebClient client) throws Exception { 21 String xhtml = response.getText(); 22 try { 23 ByteArrayInputStream is = new ByteArrayInputStream(xhtml.getBytes()) ; 24 SAXReader reader = new SAXReader(); 25 Document document = reader.read(is); 26 } catch (Exception ex) { 27 System.out.println("Validate xhtml error: " + ex.getMessage()) ; 28 FileOutputStream out = new FileOutputStream("./target/output.html") ; 29 out.write(xhtml.getBytes()) ; 30 return false ; 31 } 32 return true ; 33 } 34 35 public String getName() { return "WellFormedXhtmlValidator" ; } 36 37 public String getDescription() { 38 return "Make sure that the return xhtml is well formed." ; 39 } 40 } | Popular Tags |