Class TestReader
- java.lang.Object
-
- org.locationtech.jtstest.testrunner.TestReader
-
public class TestReader extends java.lang.Object
- Version:
- 1.7
-
-
Field Summary
Fields Modifier and Type Field Description private GeometryFactory
geometryFactory
private GeometryOperation
geomOp
(package private) java.util.Vector
parsingProblems
private ResultMatcher
resultMatcher
private static java.lang.String
TAG_geometryOperation
private static java.lang.String
TAG_resultMatcher
private double
tolerance
private WKTOrWKBReader
wktorbReader
-
Constructor Summary
Constructors Constructor Description TestReader()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.io.File
absoluteWktFile(java.io.File wktFile, TestRun testRun)
void
clearParsingProblems()
private PrecisionModel
createPrecisionModel(org.jdom2.Element precisionModelElement)
TestRun
createTestRun(java.io.File testFile, int runIndex)
static java.util.List
getContents(java.lang.String textFileName)
Returns a List of the String's in the text file, one per line.GeometryOperation
getGeometryOperation()
private java.lang.Object
getInstance(java.lang.String classname, java.lang.Class baseClass)
Gets an instance of a class with the given name, and ensures that the class is assignable to a specified baseClass.java.util.List
getParsingProblems()
boolean
isBooleanFunction(java.lang.String name)
boolean
isDoubleFunction(java.lang.String name)
boolean
isGeometryFunction(java.lang.String name)
boolean
isIntegerFunction(java.lang.String name)
private GeometryOperation
parseGeometryOperation(org.jdom2.Element runElement)
Parses an optional geometryOperation element.private PrecisionModel
parsePrecisionModel(org.jdom2.Element runElement)
Parses an optional precisionModel element.private ResultMatcher
parseResultMatcher(org.jdom2.Element runElement)
Parses an optional resultMatcher element.private java.util.List
parseTestCases(java.util.List caseElements, java.io.File testFile, TestRun testRun, double tolerance)
Creates a List of TestCase's from the givenElement's. private TestRun
parseTestRun(org.jdom2.Element runElement, java.io.File testFile, int runIndex)
Creates a TestRun from theElement. private java.util.List
parseTests(java.util.List testElements, int caseIndex, java.io.File testFile, TestCase testCase, double tolerance)
Creates a List of Test's from the givenElement's. private double
parseTolerance(org.jdom2.Element runElement)
private Geometry
readGeometry(org.jdom2.Element geometryElement, java.io.File wktFile)
private BooleanResult
toBooleanResult(java.lang.String value)
private DoubleResult
toDoubleResult(java.lang.String value)
private GeometryResult
toGeometryResult(java.lang.String value, TestRun testRun)
private IntegerResult
toIntegerResult(java.lang.String value)
private Result
toResult(java.lang.String value, java.lang.String name, TestRun testRun)
private java.lang.String
toString(java.util.List stringList)
private java.io.File
wktFile(org.jdom2.Element geometryElement, TestRun testRun)
-
-
-
Field Detail
-
TAG_geometryOperation
private static final java.lang.String TAG_geometryOperation
- See Also:
- Constant Field Values
-
TAG_resultMatcher
private static final java.lang.String TAG_resultMatcher
- See Also:
- Constant Field Values
-
parsingProblems
java.util.Vector parsingProblems
-
geometryFactory
private GeometryFactory geometryFactory
-
wktorbReader
private WKTOrWKBReader wktorbReader
-
tolerance
private double tolerance
-
geomOp
private GeometryOperation geomOp
-
resultMatcher
private ResultMatcher resultMatcher
-
-
Method Detail
-
getGeometryOperation
public GeometryOperation getGeometryOperation()
-
isBooleanFunction
public boolean isBooleanFunction(java.lang.String name)
-
isIntegerFunction
public boolean isIntegerFunction(java.lang.String name)
-
isDoubleFunction
public boolean isDoubleFunction(java.lang.String name)
-
isGeometryFunction
public boolean isGeometryFunction(java.lang.String name)
-
getParsingProblems
public java.util.List getParsingProblems()
-
clearParsingProblems
public void clearParsingProblems()
-
createTestRun
public TestRun createTestRun(java.io.File testFile, int runIndex)
-
parseTests
private java.util.List parseTests(java.util.List testElements, int caseIndex, java.io.File testFile, TestCase testCase, double tolerance) throws TestParseException
Creates a List of Test's from the givenElement's. - Throws:
TestParseException
-
toResult
private Result toResult(java.lang.String value, java.lang.String name, TestRun testRun) throws TestParseException, ParseException
- Throws:
TestParseException
ParseException
-
toBooleanResult
private BooleanResult toBooleanResult(java.lang.String value) throws TestParseException
- Throws:
TestParseException
-
toDoubleResult
private DoubleResult toDoubleResult(java.lang.String value) throws TestParseException
- Throws:
TestParseException
-
toIntegerResult
private IntegerResult toIntegerResult(java.lang.String value) throws TestParseException
- Throws:
TestParseException
-
toGeometryResult
private GeometryResult toGeometryResult(java.lang.String value, TestRun testRun) throws ParseException
- Throws:
ParseException
-
parseTestCases
private java.util.List parseTestCases(java.util.List caseElements, java.io.File testFile, TestRun testRun, double tolerance) throws TestParseException
Creates a List of TestCase's from the givenElement's. - Throws:
TestParseException
-
parseTestRun
private TestRun parseTestRun(org.jdom2.Element runElement, java.io.File testFile, int runIndex) throws TestParseException
Creates a TestRun from theElement. - Throws:
TestParseException
-
parsePrecisionModel
private PrecisionModel parsePrecisionModel(org.jdom2.Element runElement) throws TestParseException
Parses an optional precisionModel element. The default is to use a FLOATING model.- Parameters:
runElement
-- Returns:
- a PrecisionModel instance (default if not specified)
- Throws:
TestParseException
-
createPrecisionModel
private PrecisionModel createPrecisionModel(org.jdom2.Element precisionModelElement) throws TestParseException
- Throws:
TestParseException
-
parseGeometryOperation
private GeometryOperation parseGeometryOperation(org.jdom2.Element runElement) throws TestParseException
Parses an optional geometryOperation element. The default is to leave this unspecified .- Parameters:
runElement
-- Returns:
- an instance of the GeometryOperation class, if specified, or null if no geometry operation was specified
- Throws:
TestParseException
- if a parsing error was encountered
-
parseResultMatcher
private ResultMatcher parseResultMatcher(org.jdom2.Element runElement) throws TestParseException
Parses an optional resultMatcher element. The default is to leave this unspecified .- Parameters:
runElement
-- Returns:
- an instance of the ResultMatcher class, if specified, or null if no result matcher was specified
- Throws:
TestParseException
- if a parsing error was encountered
-
parseTolerance
private double parseTolerance(org.jdom2.Element runElement) throws TestParseException
- Throws:
TestParseException
-
getInstance
private java.lang.Object getInstance(java.lang.String classname, java.lang.Class baseClass)
Gets an instance of a class with the given name, and ensures that the class is assignable to a specified baseClass.- Returns:
- an instance of the class, if it is assignment-compatible, or null if the requested class is not assigment-compatible
-
wktFile
private java.io.File wktFile(org.jdom2.Element geometryElement, TestRun testRun) throws TestParseException
- Throws:
TestParseException
-
readGeometry
private Geometry readGeometry(org.jdom2.Element geometryElement, java.io.File wktFile) throws java.io.FileNotFoundException, ParseException, java.io.IOException
- Throws:
java.io.FileNotFoundException
ParseException
java.io.IOException
-
toString
private java.lang.String toString(java.util.List stringList)
-
absoluteWktFile
private java.io.File absoluteWktFile(java.io.File wktFile, TestRun testRun)
-
getContents
public static java.util.List getContents(java.lang.String textFileName) throws java.io.FileNotFoundException, java.io.IOException
Returns a List of the String's in the text file, one per line.- Throws:
java.io.FileNotFoundException
java.io.IOException
-
-