use of com.revolsys.geometry.test.util.LineNumberElement in project com.revolsys.open by revolsys.
the class TestReader method parseTestCases.
/**
* Creates a List of TestCase's from the given <case> Element's.
*/
private List<TestCase> parseTestCases(final List caseElements, final File testFile, final TestFile testRun, final double tolerance) throws Throwable {
this.wktorbReader = new WKTOrWKBReader(this.geometryFactory);
final Vector<TestCase> testCases = new Vector<>();
int caseIndex = 0;
for (final Iterator i = caseElements.iterator(); i.hasNext(); ) {
final Element caseElement = (Element) i.next();
// System.out.println("Line: " +
// ((LineNumberElement)caseElement).getStartLine());
caseIndex++;
try {
final Element descElement = caseElement.getChild("desc");
final Element aElement = caseElement.getChild("a");
final Element bElement = caseElement.getChild("b");
final File aWktFile = wktFile(aElement, testRun);
final File bWktFile = wktFile(bElement, testRun);
final String description = descElement != null ? descElement.getTextTrim() : "";
final Geometry a = readGeometry(aElement, absoluteWktFile(aWktFile, testRun));
final Geometry b = readGeometry(bElement, absoluteWktFile(bWktFile, testRun));
final TestCase testCase = new TestCase(description, a, b, aWktFile, bWktFile, testRun, caseIndex, ((LineNumberElement) caseElement).getStartLine());
final List testElements = caseElement.getChildren("test");
// if (testElements.size() == 0) {
// throw new TestParseException("Missing <test> in <case>");
// }
final List<GeometryOperationTest> tests = parseTests(testElements, caseIndex, testFile, testCase, tolerance);
for (final GeometryOperationTest test : tests) {
testCase.add(test);
}
testCases.add(testCase);
} catch (final Exception e) {
throw new IllegalArgumentException("An exception occurred while parsing <case> " + caseIndex + " in " + testFile, e);
}
}
return testCases;
}
Aggregations