aboutsummaryrefslogtreecommitdiffstats
path: root/test/java/org
diff options
context:
space:
mode:
authorAndreas L. Delmelle <adelmelle@apache.org>2009-04-19 17:54:06 +0000
committerAndreas L. Delmelle <adelmelle@apache.org>2009-04-19 17:54:06 +0000
commit5deedc814cedf4e1c2ffa746a22bdba34b031d5d (patch)
tree8f837336338a9fb058ab5c6998698ebdfe58db4f /test/java/org
parent8ba60984938cc6250b507f5742b4e99e437b7497 (diff)
downloadxmlgraphics-fop-5deedc814cedf4e1c2ffa746a22bdba34b031d5d.tar.gz
xmlgraphics-fop-5deedc814cedf4e1c2ffa746a22bdba34b031d5d.zip
Bugzilla 47027: Correction for interpretation of pixel-lengths, as suggested by Jeremias.
+ minor changes to the fotreetest-classes: distinguish between fatal errors due to malformed testcases, and genuine assertion failures. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@766492 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/java/org')
-rw-r--r--test/java/org/apache/fop/fotreetest/FOTreeTester.java21
-rw-r--r--test/java/org/apache/fop/fotreetest/ResultCollector.java25
-rw-r--r--test/java/org/apache/fop/fotreetest/ext/AssertElement.java19
3 files changed, 45 insertions, 20 deletions
diff --git a/test/java/org/apache/fop/fotreetest/FOTreeTester.java b/test/java/org/apache/fop/fotreetest/FOTreeTester.java
index fe44e3e23..ba9fde4f9 100644
--- a/test/java/org/apache/fop/fotreetest/FOTreeTester.java
+++ b/test/java/org/apache/fop/fotreetest/FOTreeTester.java
@@ -32,6 +32,7 @@ import org.xml.sax.helpers.XMLFilterImpl;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
+import org.apache.fop.apps.FopFactoryConfigurator;
import org.apache.fop.fotreetest.ext.TestElementMapping;
import org.apache.fop.util.ConsoleEventListenerForTests;
@@ -64,8 +65,13 @@ public class FOTreeTester {
SAXParser parser = spf.newSAXParser();
XMLReader reader = parser.getXMLReader();
+ //Resetting values modified by processing instructions
+ fopFactory.setBreakIndentInheritanceOnReferenceAreaBoundary(
+ FopFactoryConfigurator.DEFAULT_BREAK_INDENT_INHERITANCE);
+ fopFactory.setSourceResolution(FopFactoryConfigurator.DEFAULT_SOURCE_RESOLUTION);
+
FOUserAgent ua = fopFactory.newFOUserAgent();
- ua.setBaseURL(testFile.getParentFile().toURL().toString());
+ ua.setBaseURL(testFile.getParentFile().toURI().toURL().toString());
ua.setFOEventHandlerOverride(new DummyFOEventHandler(ua));
ua.getEventBroadcaster().addEventListener(
new ConsoleEventListenerForTests(testFile.getName()));
@@ -79,14 +85,19 @@ public class FOTreeTester {
reader.setDTDHandler(fop.getDefaultHandler());
reader.setErrorHandler(fop.getDefaultHandler());
reader.setEntityResolver(fop.getDefaultHandler());
- reader.parse(testFile.toURL().toExternalForm());
+ try {
+ reader.parse(testFile.toURI().toURL().toExternalForm());
+ } catch (Exception e) {
+ collector.notifyError(e.getLocalizedMessage());
+ throw e;
+ }
List results = collector.getResults();
if (results.size() > 0) {
for (int i = 0; i < results.size(); i++) {
- System.out.println(((Exception)results.get(i)).getMessage());
+ System.out.println((String)results.get(i));
}
- throw (Exception)results.get(0);
+ throw new IllegalStateException((String)results.get(0));
}
}
@@ -104,6 +115,8 @@ public class FOTreeTester {
if ("fop-useragent-break-indent-inheritance".equals(target)) {
userAgent.getFactory().setBreakIndentInheritanceOnReferenceAreaBoundary(
Boolean.valueOf(data).booleanValue());
+ } else if ("fop-source-resolution".equals(target)) {
+ userAgent.getFactory().setSourceResolution(Float.parseFloat(data));
}
super.processingInstruction(target, data);
}
diff --git a/test/java/org/apache/fop/fotreetest/ResultCollector.java b/test/java/org/apache/fop/fotreetest/ResultCollector.java
index 36d111c7f..3f6502803 100644
--- a/test/java/org/apache/fop/fotreetest/ResultCollector.java
+++ b/test/java/org/apache/fop/fotreetest/ResultCollector.java
@@ -23,7 +23,7 @@ import java.util.Collections;
import java.util.List;
/**
- * This class collects the results from assertions injected into the FO stream.
+ * This class collects failures for assertions injected into the FO stream.
*/
public class ResultCollector {
@@ -31,7 +31,7 @@ public class ResultCollector {
private List results = new java.util.ArrayList();
- /** @return the ResultColletor singleton */
+ /** @return the ResultCollector singleton */
public static ResultCollector getInstance() {
if (instance == null) {
instance = new ResultCollector();
@@ -45,12 +45,23 @@ public class ResultCollector {
}
/**
- * This notifies the ResultCollector about an Exception.
- * @param e the exception
+ * This notifies the ResultCollector about an assertion failure.
+ *
+ * @param message the message containing the details
*/
- public void notifyException(Exception e) {
- System.out.println(e.getMessage());
- results.add(e);
+ public void notifyAssertionFailure(String message) {
+ System.out.println(message);
+ results.add(message);
+ }
+
+ /**
+ * This notifies the ResultCollector about a testcase that ended
+ * with a fatal error
+ *
+ * @param message the message containing the details
+ */
+ public void notifyError(String message) {
+ results.add(message);
}
/** Resets the result list. */
diff --git a/test/java/org/apache/fop/fotreetest/ext/AssertElement.java b/test/java/org/apache/fop/fotreetest/ext/AssertElement.java
index 97b73947c..f4a76d7ed 100644
--- a/test/java/org/apache/fop/fotreetest/ext/AssertElement.java
+++ b/test/java/org/apache/fop/fotreetest/ext/AssertElement.java
@@ -41,7 +41,10 @@ import org.xml.sax.Locator;
public class AssertElement extends TestObj {
/**
- * @see org.apache.fop.fo.FONode#FONode(FONode)
+ * Creates a new AssertElement instance that is a child
+ * of the given {@link FONode}
+ *
+ * @param parent the parent {@link FONode}
*/
public AssertElement(FONode parent) {
super(parent);
@@ -58,6 +61,7 @@ public class AssertElement extends TestObj {
ResultCollector collector = ResultCollector.getInstance();
String propName = attlist.getValue("property");
+ String expected = attlist.getValue("expected");
String component = null;
int dotIndex = propName.indexOf('.');
if (dotIndex >= 0) {
@@ -66,8 +70,7 @@ public class AssertElement extends TestObj {
}
int propID = FOPropertyMapping.getPropertyId(propName);
if (propID < 0) {
- collector.notifyException(new IllegalArgumentException(
- "Property not found: " + propName));
+ collector.notifyAssertionFailure("Property not found: " + propName);
} else {
Property prop;
prop = propertyList.getParentPropertyList().get(propID);
@@ -94,21 +97,20 @@ public class AssertElement extends TestObj {
}
String s;
if (prop instanceof PercentLength) {
- s = ((PercentLength)prop).getString();
+ s = prop.getString();
} else {
s = String.valueOf(prop);
}
- String expected = attlist.getValue("expected");
if (!expected.equals(s)) {
- collector.notifyException(
- new IllegalStateException(locator.getSystemId()
+ collector.notifyAssertionFailure(
+ locator.getSystemId()
+ "\nProperty '" + propName
+ "' expected to evaluate to '" + expected
+ "' but got '" + s
+ "'\n(test:assert in "
+ propertyList.getParentFObj().getName()
+ " at line #" + locator.getLineNumber()
- + ", column #" + locator.getColumnNumber() + ")\n"));
+ + ", column #" + locator.getColumnNumber() + ")\n");
}
}
@@ -120,4 +122,3 @@ public class AssertElement extends TestObj {
}
}
-