Package org.geotools.data
Class DataTestCase
- Object
-
- DataTestCase
-
public abstract class DataTestCase extends Object
A set of constructs and utility methods used to test the data module.By isolating a common set of
SimpleFeature
s,SimpleFeatureType
s andFilter
s we are able to reduce the amount of overhead in setting up new tests.This code has been made part of the public
geotools.jar
to provide a starting point for test cases involving Data constructs.- Author:
- Jody Garnett, Refractions Research
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description DataTestCase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
assertGeometryEquals(String message, Geometry expected, Geometry actual)
Compares two geometries for equality.protected void
assertGeometryEquals(Geometry expected, Geometry actual)
Compares two geometries for equality.protected int
count(FeatureReader<SimpleFeatureType,SimpleFeature> reader)
Counts the number of Features returned by the specified reader.protected int
count(FeatureWriter<SimpleFeatureType,SimpleFeature> writer)
Counts the number of Features in the specified writer.protected void
dataSetUp()
Loads the data.protected int
expected(Filter filter)
void
init()
Invoked before a test is run.LineString
line(int[] xy)
Creates a line from the specified (x,y) coordinates.MultiLineString
lines(int[][] xy)
Creates a multiline from the specified (x,y) coordinates.Polygon
polygon(int[] xy)
Creates a polygon from the specified (x,y) coordinates.Polygon
polygon(int[] xy, int[][] holes)
Creates a line from the specified (x,y) coordinates and an arbitrary amount of holes.LinearRing
ring(int[] xy)
Creates a ring from the specified (x,y) coordinates.void
tearDown()
Set all data references tonull
, allowing garbage collection.
-
-
-
Field Detail
-
gf
protected GeometryFactory gf
-
roadType
protected SimpleFeatureType roadType
-
subRoadType
protected SimpleFeatureType subRoadType
-
roadFeatures
protected SimpleFeature[] roadFeatures
-
roadBounds
protected ReferencedEnvelope roadBounds
-
rd12Bounds
protected ReferencedEnvelope rd12Bounds
-
rd1Filter
protected Filter rd1Filter
-
rd2Filter
protected Filter rd2Filter
-
rd12Filter
protected Filter rd12Filter
-
newRoad
protected SimpleFeature newRoad
-
riverType
protected SimpleFeatureType riverType
-
subRiverType
protected SimpleFeatureType subRiverType
-
riverFeatures
protected SimpleFeature[] riverFeatures
-
riverBounds
protected ReferencedEnvelope riverBounds
-
rv1Filter
protected Filter rv1Filter
-
newRiver
protected SimpleFeature newRiver
-
lakeType
protected SimpleFeatureType lakeType
-
lakeFeatures
protected SimpleFeature[] lakeFeatures
-
lakeBounds
protected ReferencedEnvelope lakeBounds
-
invalidGeomType
protected SimpleFeatureType invalidGeomType
-
invalidGeomFeatures
protected SimpleFeature[] invalidGeomFeatures
-
invalidGeomBounds
protected ReferencedEnvelope invalidGeomBounds
-
buildingType
protected SimpleFeatureType buildingType
-
buildingFeatures
protected SimpleFeature[] buildingFeatures
-
buildingBounds
protected ReferencedEnvelope buildingBounds
-
ff
protected FilterFactory ff
-
-
Method Detail
-
expected
protected int expected(Filter filter)
-
init
public void init() throws Exception
Invoked before a test is run. The default implementation invokesdataSetUp()
.- Throws:
Exception
-
dataSetUp
protected void dataSetUp() throws Exception
Loads the data.
-
tearDown
public void tearDown() throws Exception
Set all data references tonull
, allowing garbage collection. This method is automatically invoked after each test.- Throws:
Exception
-
line
public LineString line(int[] xy)
Creates a line from the specified (x,y) coordinates. The coordinates are stored in a flat array.
-
lines
public MultiLineString lines(int[][] xy)
Creates a multiline from the specified (x,y) coordinates.
-
polygon
public Polygon polygon(int[] xy)
Creates a polygon from the specified (x,y) coordinates. The coordinates are stored in a flat array.
-
polygon
public Polygon polygon(int[] xy, int[][] holes)
Creates a line from the specified (x,y) coordinates and an arbitrary amount of holes.
-
ring
public LinearRing ring(int[] xy)
Creates a ring from the specified (x,y) coordinates. The coordinates are stored in a flat array.
-
assertGeometryEquals
protected void assertGeometryEquals(Geometry expected, Geometry actual)
Compares two geometries for equality.
-
assertGeometryEquals
protected void assertGeometryEquals(String message, Geometry expected, Geometry actual)
Compares two geometries for equality.
-
count
protected int count(FeatureReader<SimpleFeatureType,SimpleFeature> reader) throws IOException
Counts the number of Features returned by the specified reader.This method will close the reader.
- Throws:
IOException
-
count
protected int count(FeatureWriter<SimpleFeatureType,SimpleFeature> writer) throws NoSuchElementException, IOException
Counts the number of Features in the specified writer. This method will close the writer.- Throws:
NoSuchElementException
IOException
-
-