Skip to content

Commit 6174d6c

Browse files
Fix tests
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/batik/trunk@1904401 13f79535-47bb-0310-9956-ffa450edef68
1 parent 57e60d3 commit 6174d6c

File tree

3 files changed

+27
-15
lines changed

3 files changed

+27
-15
lines changed

batik-test-old/src/test/java/org/apache/batik/svggen/SVGAccuracyTest.java

+25-1
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,14 @@ Licensed to the Apache Software Foundation (ASF) under one or more
4444
import org.apache.batik.test.TestReport;
4545

4646
import org.apache.batik.dom.GenericDOMImplementation;
47+
import org.apache.commons.io.IOUtils;
4748
import org.w3c.dom.Document;
4849
import org.w3c.dom.DOMImplementation;
50+
import org.xml.sax.SAXException;
51+
52+
import javax.xml.parsers.DocumentBuilder;
53+
import javax.xml.parsers.DocumentBuilderFactory;
54+
import javax.xml.parsers.ParserConfigurationException;
4955

5056
/**
5157
* This test validates that a given rendering sequence, modeled
@@ -216,6 +222,10 @@ public TestReport runImpl() throws Exception {
216222

217223
InputStream newStream = new ByteArrayInputStream(bos.toByteArray());
218224

225+
if (xmlEqual(bos.toByteArray())) {
226+
return report;
227+
}
228+
219229
boolean accurate = true;
220230
String refLine = null;
221231
String newLine = null;
@@ -289,6 +299,20 @@ public TestReport runImpl() throws Exception {
289299
return report;
290300
}
291301

302+
private boolean xmlEqual(byte[] data) throws ParserConfigurationException, IOException, SAXException {
303+
byte[] ref = IOUtils.toByteArray(refURL.openStream());
304+
if (ref.length == 0) {
305+
return false;
306+
}
307+
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
308+
DocumentBuilder db = factory.newDocumentBuilder();
309+
Document doc1 = db.parse(refURL.openStream());
310+
doc1.normalizeDocument();
311+
Document doc2 = db.parse(new ByteArrayInputStream(data));
312+
doc2.normalizeDocument();
313+
return doc1.isEqualNode(doc2);
314+
}
315+
292316
public int computeColumnNumber(String aStr, String bStr){
293317
if(aStr == null || bStr == null){
294318
return -1;
@@ -320,7 +344,7 @@ protected void save(byte[] data) throws IOException{
320344
if(saveSVG == null){
321345
return;
322346
}
323-
347+
saveSVG.getParentFile().mkdirs();
324348
FileOutputStream os = new FileOutputStream(saveSVG);
325349
os.write(data);
326350
os.close();

batik-test-old/src/test/java/org/apache/batik/test/xml/JUnitRunnerTestCase.java

-14
Original file line numberDiff line numberDiff line change
@@ -133,25 +133,11 @@ public void test() throws ParserConfigurationException, SAXException, TestExcept
133133

134134
private static List<String> EXCLUDE = Arrays.asList(
135135
//fail on CI
136-
"ATransform.defaultContextGeneration",
137-
"BasicShapes.defaultContextGeneration",
138-
"BasicShapes2.defaultContextGeneration",
139-
"BStroke.defaultContextGeneration",
140-
"Bug4945.defaultContextGeneration",
141-
"Bug6535.defaultContextGeneration",
142-
"Bug17965.defaultContextGeneration",
143-
"Color1.defaultContextGeneration",
144136
"Color1.renderingCheck",
145-
"Color2.defaultContextGeneration",
146137
"Gradient.defaultContextGeneration",
147-
"IdentityTest.defaultContextGeneration",
148138
"Lookup.renderingCheck",
149-
"NegativeLengths.defaultContextGeneration",
150139
"Rescale.renderingCheck",
151-
"ShearTest.defaultContextGeneration",
152-
"TextSpacePreserve.defaultContextGeneration",
153140
"TextSpacePreserve.renderingCheck",
154-
"TransformCollapse.defaultContextGeneration",
155141
"NullSetSVGDocumentTest",
156142
"samples/tests/spec/scripting/memoryLeak1.svg",
157143
"samples/tests/spec/scripting/primaryDoc.svg",

batik-test-svg/src/main/java/org/apache/batik/test/svg/AbstractRenderingAccuracyTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ public TestReport run() {
424424
FileOutputStream tmpFileOS = null;
425425

426426
try{
427+
tmpFile.getParentFile().mkdirs();
427428
tmpFileOS = new FileOutputStream(tmpFile);
428429
}catch(IOException e){
429430
report.setErrorCode(ERROR_CANNOT_CREATE_TEMP_FILE_STREAM);
@@ -649,6 +650,7 @@ protected boolean compare(InputStream refStream,
649650
protected void saveImage(BufferedImage img, File imgFile)
650651
throws IOException {
651652
if(!imgFile.exists()){
653+
imgFile.getParentFile().mkdirs();
652654
imgFile.createNewFile();
653655
}
654656
OutputStream out = new FileOutputStream(imgFile);

0 commit comments

Comments
 (0)