1 17 18 19 20 package org.apache.fop.layoutengine; 21 22 import org.apache.fop.apps.FormattingResults; 23 import org.w3c.dom.Node ; 24 25 28 public class ResultCheck implements LayoutEngineCheck { 29 30 private String expected; 31 private String property; 32 33 38 public ResultCheck(String expected, String property) { 39 this.expected = expected; 40 this.property = property; 41 } 42 43 47 public ResultCheck(Node node) { 48 this.expected = node.getAttributes().getNamedItem("expected").getNodeValue(); 49 this.property = node.getAttributes().getNamedItem("property").getNodeValue(); 50 } 51 52 55 public void check(LayoutResult result) { 56 FormattingResults results = result.getResults(); 57 String actual; 58 if (property.equals("pagecount")) { 59 actual = Integer.toString(results.getPageCount()); 60 } else { 61 throw new RuntimeException ("No such property test: " + property); 62 } 63 if (!expected.equals(actual)) { 64 throw new RuntimeException ( 65 "Expected property to evaluate to '" + expected + "', but got '" 66 + actual + "' (" + this + ")"); 67 } 68 69 } 70 71 72 public String toString() { 73 return "Property: " + property; 74 } 75 76 } 77 | Popular Tags |