[Schmitzm-commits] r1434 - in trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools: . grid io

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Jan 27 13:29:11 CET 2011


Author: alfonx
Date: 2011-01-27 13:29:11 +0100 (Thu, 27 Jan 2011)
New Revision: 1434

Added:
   trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/grid/
   trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/grid/GridUtilTest.java
   trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/io/
   trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/io/GeoImportUtilTest.java
Log:


Added: trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/grid/GridUtilTest.java
===================================================================
--- trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/grid/GridUtilTest.java	2011-01-27 12:29:10 UTC (rev 1433)
+++ trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/grid/GridUtilTest.java	2011-01-27 12:29:11 UTC (rev 1434)
@@ -0,0 +1,40 @@
+package de.schmitzm.geotools.grid;
+
+import static org.junit.Assert.assertTrue;
+
+import java.awt.Color;
+import java.io.IOException;
+
+import org.geotools.coverage.grid.GridCoverage2D;
+import org.geotools.styling.Style;
+import org.junit.Test;
+
+import de.schmitzm.geotools.styling.StylingUtil;
+import de.schmitzm.geotools.testing.GTTestingUtil;
+import de.schmitzm.testing.TestingClass;
+public class GridUtilTest extends TestingClass {
+
+	@Test
+	public void testCreateDefaultStyleValidates() throws IOException {
+		Style style = GridUtil.createDefaultStyle();
+		assertTrue(StylingUtil.validates(style));
+	}
+
+	@Test
+	public void testCreateInterpolativeStyleValidates() throws Exception {
+		GridCoverage2D grid = (GridCoverage2D) GTTestingUtil.TestDatasetsRaster.geotiffWithSld.getCoverage();
+		Style style = GridUtil.createInterpolativeStyle(grid, 1., new Color[] {
+				Color.red, Color.green });
+		assertTrue(StylingUtil.validates(style));
+	}
+	
+	@Test
+	public void testCreateDiscreteStyleValidates() throws Exception {
+		GridCoverage2D grid = (GridCoverage2D) GTTestingUtil.TestDatasetsRaster.geotiffWithSld.getCoverage();
+		Style style = GridUtil.createDiscreteStyle(grid, 1., 2, new Color[] {
+				Color.red, Color.green });
+		assertTrue(StylingUtil.validates(style));
+	}
+
+
+}
\ No newline at end of file


Property changes on: trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/grid/GridUtilTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id URL
Name: svn:eol-style
   + native

Added: trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/io/GeoImportUtilTest.java
===================================================================
--- trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/io/GeoImportUtilTest.java	2011-01-27 12:29:10 UTC (rev 1433)
+++ trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/io/GeoImportUtilTest.java	2011-01-27 12:29:11 UTC (rev 1434)
@@ -0,0 +1,59 @@
+package de.schmitzm.geotools.io;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import org.geotools.data.DataStore;
+import org.geotools.data.FeatureSource;
+import org.geotools.data.shapefile.indexed.IndexedShapefileDataStore;
+import org.geotools.feature.FeatureCollection;
+import org.junit.Test;
+import org.opengis.feature.simple.SimpleFeature;
+import org.opengis.feature.simple.SimpleFeatureType;
+
+import de.schmitzm.geotools.testing.GTTestingUtil;
+import de.schmitzm.testing.TestingClass;
+
+public class GeoImportUtilTest extends TestingClass {
+
+	@Test
+	public void testOpenBrokenQixShapefile1() throws IOException {
+		FeatureSource<SimpleFeatureType, SimpleFeature> fs = GTTestingUtil.TestDatasetsVector.lineBrokenQuix
+				.getFeatureSource();
+
+		FeatureCollection<SimpleFeatureType, SimpleFeature> features = fs
+				.getFeatures();
+		Iterator<SimpleFeature> it = features.iterator();
+		try {
+			while (it.hasNext()) {
+				SimpleFeature next = it.next();
+				log.info(next);
+				fail("We expect this to crash with a WARNUNG: Old qix file format; this file format is deprecated; It is strongly recommended to regenerate it in new format.");
+			}
+		} catch (NoSuchElementException e) {
+			// This is expected
+		} finally {
+			features.close(it);
+		}
+	}
+
+	@Test
+	public void testOpenBrokenQixShapefile2() throws IOException {
+		DataStore ds = GTTestingUtil.TestDatasetsVector.lineBrokenQuix
+				.getDataStore();
+
+		final IndexedShapefileDataStore idxShpDs = (IndexedShapefileDataStore) ds;
+		assertTrue(GTTestingUtil.TestDatasetsVector.lineBrokenQuix
+				+ " is not reported as broken!",
+				GeoImportUtil.isOldBrokenQix(idxShpDs));
+
+		// Annoyingly this test changes the test-data in 'target' directory and
+		// makes the test fail in a second run...
+		// idxShpDs.buildQuadTree();
+		// assertFalse(GeoImportUtil.isOldBrokenQix(idxShpDs));
+	}
+}
\ No newline at end of file


Property changes on: trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/io/GeoImportUtilTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id URL
Name: svn:eol-style
   + native



More information about the Schmitzm-commits mailing list