org.geotools.data
Class DataTestCase

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended byorg.geotools.data.DataTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
AbstractDataStoreTest

public class DataTestCase
extends junit.framework.TestCase

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

By isolating a commong set of Features, FeatureTypes and Filters we are able to reduce the amount of overhead in setting up new tests.

We have also special cased assertEquals(Geometry, Geometry) to work around not working as expected.

This code has been made part of the public to provide a starting point for test cases involving Data constructs.

Version:
$Id: DataTestCase.java 17701 2006-01-23 00:00:51Z desruisseaux $
Author:
Jody Garnett, Refractions Research
To Do:
It should be possible to move this class in the module.

Field Summary
protected  com.vividsolutions.jts.geom.GeometryFactory gf
           
protected  com.vividsolutions.jts.geom.Envelope lakeBounds
           
protected  Feature[] lakeFeatures
           
protected  FeatureType lakeType
           
protected  Feature newRiver
           
protected  Feature newRoad
           
protected  com.vividsolutions.jts.geom.Envelope rd12Bounds
           
protected  Filter rd12Filter
           
protected  Filter rd1Filter
           
protected  Filter rd2Filter
           
protected  com.vividsolutions.jts.geom.Envelope riverBounds
           
protected  Feature[] riverFeatures
           
protected  FeatureType riverType
           
protected  com.vividsolutions.jts.geom.Envelope roadBounds
           
protected  SimpleFeature[] roadFeatures
           
protected  FeatureType roadType
           
protected  Filter rv1Filter
           
protected  FeatureType subRiverType
           
protected  FeatureType subRoadType
           
 
Constructor Summary
DataTestCase(java.lang.String name)
          Creates a default test case with the given name.
 
Method Summary
protected  void assertEquals(com.vividsolutions.jts.geom.Geometry expected, com.vividsolutions.jts.geom.Geometry actual)
          Compares two geometries for equality.
protected  void assertEquals(java.lang.String message, com.vividsolutions.jts.geom.Geometry expected, com.vividsolutions.jts.geom.Geometry actual)
          Compares two geometries for equality.
protected  int count(FeatureReader reader)
          Counts the number of Features returned by the specified reader.
protected  int count(FeatureWriter writer)
          Counts the number of Features in the specified writer.
protected  void dataSetUp()
          Loads the data.
 com.vividsolutions.jts.geom.LineString line(int[] xy)
          Creates a line from the specified (x,y) coordinates.
 com.vividsolutions.jts.geom.MultiLineString lines(int[][] xy)
          Creates a multiline from the specified (x,y) coordinates.
 com.vividsolutions.jts.geom.Polygon polygon(int[] xy)
          Creates a polygon from the specified (x,y) coordinates.
 com.vividsolutions.jts.geom.Polygon polygon(int[] xy, int[][] holes)
          Creates a line from the specified (x,y) coordinates and an arbitrary amount of holes.
 com.vividsolutions.jts.geom.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 , allowing garbage collection.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

gf

protected com.vividsolutions.jts.geom.GeometryFactory gf

roadType

protected FeatureType roadType

subRoadType

protected FeatureType subRoadType

roadFeatures

protected SimpleFeature[] roadFeatures

roadBounds

protected com.vividsolutions.jts.geom.Envelope roadBounds

rd12Bounds

protected com.vividsolutions.jts.geom.Envelope rd12Bounds

rd1Filter

protected Filter rd1Filter

rd2Filter

protected Filter rd2Filter

rd12Filter

protected Filter rd12Filter

newRoad

protected Feature newRoad

riverType

protected FeatureType riverType

subRiverType

protected FeatureType subRiverType

riverFeatures

protected Feature[] riverFeatures

riverBounds

protected com.vividsolutions.jts.geom.Envelope riverBounds

rv1Filter

protected Filter rv1Filter

newRiver

protected Feature newRiver

lakeType

protected FeatureType lakeType

lakeFeatures

protected Feature[] lakeFeatures

lakeBounds

protected com.vividsolutions.jts.geom.Envelope lakeBounds
Constructor Detail

DataTestCase

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

Method Detail

setUp

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

Throws:
java.lang.Exception

dataSetUp

protected void dataSetUp()
                  throws java.lang.Exception
Loads the data.

Throws:
java.lang.Exception
See Also:
setUp()

tearDown

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

Throws:
java.lang.Exception

line

public com.vividsolutions.jts.geom.LineString line(int[] xy)
Creates a line from the specified (x,y) coordinates. The coordinates are stored in a flat array.


lines

public com.vividsolutions.jts.geom.MultiLineString lines(int[][] xy)
Creates a multiline from the specified (x,y) coordinates.


polygon

public com.vividsolutions.jts.geom.Polygon polygon(int[] xy)
Creates a polygon from the specified (x,y) coordinates. The coordinates are stored in a flat array.


polygon

public com.vividsolutions.jts.geom.Polygon polygon(int[] xy,
                                                   int[][] holes)
Creates a line from the specified (x,y) coordinates and an arbitrary amount of holes.


ring

public com.vividsolutions.jts.geom.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(com.vividsolutions.jts.geom.Geometry expected,
                            com.vividsolutions.jts.geom.Geometry actual)
Compares two geometries for equality.


assertEquals

protected void assertEquals(java.lang.String message,
                            com.vividsolutions.jts.geom.Geometry expected,
                            com.vividsolutions.jts.geom.Geometry actual)
Compares two geometries for equality.


count

protected int count(FeatureReader reader)
             throws java.io.IOException
Counts the number of Features returned by the specified reader.

This method will close the reader.

Throws:
java.io.IOException

count

protected int count(FeatureWriter writer)
             throws java.util.NoSuchElementException,
                    java.io.IOException,
                    IllegalAttributeException
Counts the number of Features in the specified writer. This method will close the writer.

Throws:
java.util.NoSuchElementException
java.io.IOException
IllegalAttributeException


Copyright © GeoTools. All Rights Reserved.