org.geotools.data
Class DataTestCase

Object
  extended by Assert
      extended by TestCase
          extended by DataTestCase
All Implemented Interfaces:
Test
Direct Known Subclasses:
AbstractDataStoreTest

public class DataTestCase
extends TestCase

A set of constructs and utility methods used to test the data module.

By isolating a common set of SimpleFeatures, SimpleFeatureTypes and Filters 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
protected  FilterFactory2 ff
           
protected  GeometryFactory gf
           
protected  ReferencedEnvelope lakeBounds
           
protected  SimpleFeature[] lakeFeatures
           
protected  SimpleFeatureType lakeType
           
protected  SimpleFeature newRiver
           
protected  SimpleFeature newRoad
           
protected  ReferencedEnvelope rd12Bounds
           
protected  Filter rd12Filter
           
protected  Filter rd1Filter
           
protected  Filter rd2Filter
           
protected  ReferencedEnvelope riverBounds
           
protected  SimpleFeature[] riverFeatures
           
protected  SimpleFeatureType riverType
           
protected  ReferencedEnvelope roadBounds
           
protected  SimpleFeature[] roadFeatures
           
protected  SimpleFeatureType roadType
           
protected  Filter rv1Filter
           
protected  SimpleFeatureType subRiverType
           
protected  SimpleFeatureType subRoadType
           
 
Constructor Summary
DataTestCase(String name)
          Creates a default test case with the given name.
 
Method Summary
protected  void assertEquals(Geometry expected, Geometry actual)
          Compares two geometries for equality.
protected  void assertEquals(String message, 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)
           
 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.
protected  void setUp()
          Invoked before a test is run.
protected  void tearDown()
          Set all data references to null, allowing garbage collection.
 
Methods inherited from class TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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

ff

protected FilterFactory2 ff
Constructor Detail

DataTestCase

public DataTestCase(String name)
Creates a default test case with the given name.

Method Detail

expected

protected int expected(Filter filter)

setUp

protected void setUp()
              throws Exception
Invoked before a test is run. The default implementation invokes dataSetUp().

Overrides:
setUp in class TestCase
Throws:
Exception

dataSetUp

protected void dataSetUp()
                  throws Exception
Loads the data.

Throws:
Exception
See Also:
setUp()

tearDown

protected void tearDown()
                 throws Exception
Set all data references to null, allowing garbage collection. This method is automatically invoked after each test.

Overrides:
tearDown in class TestCase
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.


assertEquals

protected void assertEquals(Geometry expected,
                            Geometry actual)
Compares two geometries for equality.


assertEquals

protected void assertEquals(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


Copyright © 1996-2014 Geotools. All Rights Reserved.