Class 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 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
    • Constructor Detail

      • DataTestCase

        public DataTestCase()
    • Method Detail

      • expected

        protected int expected​(Filter filter)
      • init

        public void init()
                  throws Exception
        Invoked before a test is run. The default implementation invokes dataSetUp().
        Throws:
        Exception
      • dataSetUp

        protected void dataSetUp()
                          throws Exception
        Loads the data.
        Throws:
        Exception
        See Also:
        init()
      • tearDown

        public void tearDown()
                      throws Exception
        Set all data references to null, 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