org.geotools.data
Class DataTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.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 common set of SimpleFeatures, SimpleFeatureTypes 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 Geometry.equals( Object ) not working as expected.

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

Version:
$Id: DataTestCase.java 31750 2008-11-01 10:02:11Z aaime $
Author:
Jody Garnett, Refractions Research

Field Summary
protected  org.opengis.filter.FilterFactory2 ff
           
protected  com.vividsolutions.jts.geom.GeometryFactory gf
           
protected  ReferencedEnvelope lakeBounds
           
protected  org.opengis.feature.simple.SimpleFeature[] lakeFeatures
           
protected  org.opengis.feature.simple.SimpleFeatureType lakeType
           
protected  org.opengis.feature.simple.SimpleFeature newRiver
           
protected  org.opengis.feature.simple.SimpleFeature newRoad
           
protected  ReferencedEnvelope rd12Bounds
           
protected  org.opengis.filter.Filter rd12Filter
           
protected  org.opengis.filter.Filter rd1Filter
           
protected  org.opengis.filter.Filter rd2Filter
           
protected  ReferencedEnvelope riverBounds
           
protected  org.opengis.feature.simple.SimpleFeature[] riverFeatures
           
protected  org.opengis.feature.simple.SimpleFeatureType riverType
           
protected  ReferencedEnvelope roadBounds
           
protected  org.opengis.feature.simple.SimpleFeature[] roadFeatures
           
protected  org.opengis.feature.simple.SimpleFeatureType roadType
           
protected  org.opengis.filter.Filter rv1Filter
           
protected  org.opengis.feature.simple.SimpleFeatureType subRiverType
           
protected  org.opengis.feature.simple.SimpleFeatureType 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<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> reader)
          Counts the number of Features returned by the specified reader.
protected  int count(FeatureWriter<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> 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 null, 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, failNotEquals, failNotSame, failSame, format
 
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 org.opengis.feature.simple.SimpleFeatureType roadType

subRoadType

protected org.opengis.feature.simple.SimpleFeatureType subRoadType

roadFeatures

protected org.opengis.feature.simple.SimpleFeature[] roadFeatures

roadBounds

protected ReferencedEnvelope roadBounds

rd12Bounds

protected ReferencedEnvelope rd12Bounds

rd1Filter

protected org.opengis.filter.Filter rd1Filter

rd2Filter

protected org.opengis.filter.Filter rd2Filter

rd12Filter

protected org.opengis.filter.Filter rd12Filter

newRoad

protected org.opengis.feature.simple.SimpleFeature newRoad

riverType

protected org.opengis.feature.simple.SimpleFeatureType riverType

subRiverType

protected org.opengis.feature.simple.SimpleFeatureType subRiverType

riverFeatures

protected org.opengis.feature.simple.SimpleFeature[] riverFeatures

riverBounds

protected ReferencedEnvelope riverBounds

rv1Filter

protected org.opengis.filter.Filter rv1Filter

newRiver

protected org.opengis.feature.simple.SimpleFeature newRiver

lakeType

protected org.opengis.feature.simple.SimpleFeatureType lakeType

lakeFeatures

protected org.opengis.feature.simple.SimpleFeature[] lakeFeatures

lakeBounds

protected ReferencedEnvelope lakeBounds

ff

protected org.opengis.filter.FilterFactory2 ff
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().

Overrides:
setUp in class junit.framework.TestCase
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 null, allowing garbage collection. This method is automatically invoked after each test.

Overrides:
tearDown in class junit.framework.TestCase
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<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> 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<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> writer)
             throws java.util.NoSuchElementException,
                    java.io.IOException
Counts the number of Features in the specified writer. This method will close the writer.

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


Copyright © 1996-2010 Geotools. All Rights Reserved.