1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.qedeq.kernel.xml.dao; |
17 |
|
|
18 |
|
import java.io.File; |
19 |
|
import java.io.FileFilter; |
20 |
|
import java.io.IOException; |
21 |
|
import java.util.Iterator; |
22 |
|
import java.util.List; |
23 |
|
|
24 |
|
import org.qedeq.base.io.IoUtility; |
25 |
|
import org.qedeq.kernel.bo.test.QedeqBoTestCase; |
26 |
|
import org.qedeq.kernel.se.common.SourceFileExceptionList; |
27 |
|
import org.qedeq.kernel.se.visitor.InterruptException; |
28 |
|
import org.qedeq.kernel.xml.test.XmlNormalizer; |
29 |
|
import org.xml.sax.SAXException; |
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
@author |
35 |
|
|
|
|
| 93.8% |
Uncovered Elements: 3 (48) |
Complexity: 10 |
Complexity Density: 0.29 |
|
36 |
|
public final class GenerateXmlTest extends QedeqBoTestCase { |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
@throws |
42 |
|
|
|
|
| 89.7% |
Uncovered Elements: 3 (29) |
Complexity: 6 |
Complexity Density: 0.29 |
1
PASS
|
|
43 |
1
|
public void testGeneration() throws Exception {... |
44 |
1
|
File docDir = new File("../QedeqDoc"); |
45 |
1
|
File inDir2 = new File("../QedeqKernelBoTest/data"); |
46 |
1
|
File genDir = new File("../../../qedeq_gen"); |
47 |
|
|
48 |
|
|
49 |
1
|
if (!docDir.exists()) { |
50 |
1
|
docDir = new File(getIndir(), "doc"); |
51 |
1
|
genDir = new File(getOutdir(), "doc"); |
52 |
1
|
inDir2 = getIndir(); |
53 |
1
|
if (!docDir.exists()) { |
54 |
0
|
throw new IOException("unknown source directory for QEDEQ modules"); |
55 |
|
} |
56 |
|
} |
57 |
|
|
58 |
|
|
59 |
1
|
generate(getIndir(), "qedeq_set_theory_compare.xml", genDir, false); |
60 |
1
|
generate(getIndir(), "qedeq_basic_concept_compare.xml", genDir, false); |
61 |
|
|
62 |
1
|
final FileFilter filter = new FileFilter() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
63 |
241
|
public boolean accept(File pathname) {... |
64 |
241
|
return pathname.isDirectory() || pathname.getName().endsWith(".xml"); |
65 |
|
} |
66 |
|
}; |
67 |
|
|
68 |
|
|
69 |
1
|
final List docFiles = IoUtility.listFilesRecursively(docDir, filter); |
70 |
1
|
final Iterator i = docFiles.iterator(); |
71 |
11
|
while (i.hasNext()) { |
72 |
10
|
generate((File) i.next(), genDir, true); |
73 |
|
} |
74 |
|
|
75 |
|
|
76 |
1
|
final List dataFiles = IoUtility.listFilesRecursively(inDir2, filter); |
77 |
1
|
final Iterator j = dataFiles.iterator(); |
78 |
132
|
while (j.hasNext()) { |
79 |
131
|
try { |
80 |
131
|
generate((File) j.next(), genDir, true); |
81 |
|
} catch (SourceFileExceptionList e) { |
82 |
|
|
83 |
|
} |
84 |
|
} |
85 |
|
|
86 |
|
|
87 |
|
} |
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
@param |
93 |
|
@param |
94 |
|
@param |
95 |
|
@param |
96 |
|
@throws |
97 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
98 |
2
|
private void generate(final File dir, final String xml,... |
99 |
|
final File destinationDirectory, final boolean normalize) |
100 |
|
throws IOException, SourceFileExceptionList, SAXException, InterruptException { |
101 |
2
|
generate(new File(dir, xml), destinationDirectory, normalize); |
102 |
|
} |
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
@param |
108 |
|
@param |
109 |
|
@param |
110 |
|
@throws |
111 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 2 |
Complexity Density: 0.18 |
|
112 |
143
|
private void generate(final File xmlFile, final File destinationDirectory, final boolean normalize)... |
113 |
|
throws IOException, SourceFileExceptionList, SAXException, InterruptException { |
114 |
143
|
final File destination = new File(destinationDirectory, xmlFile.getName() + "_").getAbsoluteFile(); |
115 |
143
|
System.out.println("generation of " + xmlFile + " to " + destination); |
116 |
143
|
Xml2Xml.generate(getServices(), getInternalServices(), xmlFile, destination); |
117 |
132
|
if (!normalize) { |
118 |
2
|
assertEquals(true, IoUtility.compareTextFiles(xmlFile, destination, "UTF-8")); |
119 |
|
|
120 |
|
|
121 |
|
} else { |
122 |
130
|
final File xmlFile2 = new File(destinationDirectory, xmlFile.getName() + "2_").getAbsoluteFile(); |
123 |
130
|
XmlNormalizer.normalize(xmlFile, xmlFile2); |
124 |
130
|
final File destination2 = new File(destinationDirectory, xmlFile.getName() + "3_").getAbsoluteFile(); |
125 |
130
|
XmlNormalizer.normalize(destination, destination2); |
126 |
130
|
System.out.println("comparing " + xmlFile2 + " with " + destination2); |
127 |
130
|
assertEquals(true, IoUtility.compareTextFiles(xmlFile2, destination2, "UTF-8")); |
128 |
|
} |
129 |
|
} |
130 |
|
|
131 |
|
} |