You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2018/06/18 21:02:24 UTC
[sis] 02/33: Ignore a test that depends on a shapefile removed from
history. See https://issues.apache.org/jira/browse/SIS-422
This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
commit e25aebe82038fe406fbfc91ac010b0947d1494bd
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Thu Jun 14 20:13:59 2018 +0200
Ignore a test that depends on a shapefile removed from history.
See https://issues.apache.org/jira/browse/SIS-422
(cherry picked from commit 39d1bd93ae91925d418ded31bddeaf15d03f3061)
---
.../sis/storage/shapefile/ShapeFileTest.java | 39 +++++++++++-----------
1 file changed, 20 insertions(+), 19 deletions(-)
diff --git a/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java b/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java
index 8b17baa..26b529a 100644
--- a/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java
+++ b/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java
@@ -67,6 +67,7 @@ public final strictfp class ShapeFileTest extends TestCase {
* @throws DataStoreException if a general file reading trouble occurs.
*/
@Test
+ @Ignore("Shapefile removed from history (SIS-422)")
public void testPolygonCount() throws URISyntaxException, DataStoreException {
ShapeFile shp = new ShapeFile(path("ANC90Ply_4326.shp"));
readAll(shp);
@@ -84,30 +85,30 @@ public final strictfp class ShapeFileTest extends TestCase {
}
/**
- * Test loading of shapefile descriptors.
+ * Test loading of shapefile descriptors.
* @throws URISyntaxException if the resource name is incorrect.
* @throws DataStoreException if a general file reading trouble occurs.
*/
@Test
public void testDescriptors() throws URISyntaxException, DataStoreException {
Logger log = org.apache.sis.util.logging.Logging.getLogger(ShapeFileTest.class.getName());
-
+
ShapeFile shp = new ShapeFile(path("ABRALicenseePt_4326_clipped.shp"));
shp.loadDescriptors();
-
+
assertNotNull("The features type of the shapefile should have been set.", shp.getFeaturesType());
log.info(MessageFormat.format("ABRALicenseePt_4326_clipped.shp features type : {0}", shp.getFeaturesType()));
-
+
assertNotNull("The shapefile descriptor of the shapefile should have been set.", shp.getShapefileDescriptor());
log.info(MessageFormat.format("ABRALicenseePt_4326_clipped.shp shapefile descriptor : {0}", shp.getShapefileDescriptor()));
assertNotNull("The DBase III fields descriptors of the shapefile should have been set.", shp.getDatabaseFieldsDescriptors());
log.info(MessageFormat.format("ABRALicenseePt_4326_clipped.shp DBase fields descriptors : {0}", shp.getDatabaseFieldsDescriptors()));
-
+
// Loading of the descriptor shall not prevent the shapefile from being red again.
readAll(shp);
}
-
+
/**
* Checks that the reader is able to detect EoF signs in the DBase file.
* @throws URISyntaxException if the resource name is incorrect.
@@ -128,7 +129,7 @@ public final strictfp class ShapeFileTest extends TestCase {
if (first == null) {
first = feature;
}
-
+
// Advice : To debug just before the last record, put a conditional breakpoint on department name "MEURTHE-ET-MOSELLE".
String deptName = (String)feature.getProperty("NOM_DEPT").getValue();
log.info(deptName);
@@ -137,56 +138,56 @@ public final strictfp class ShapeFileTest extends TestCase {
feature = is.readFeature();
}
}
-
+
assertNotNull("No record has been found in the DBase file or Shapefile.", first);
assertNotNull("This test is not working well : last feature should always be set if any feature has been found.", last);
assertEquals("The first record red must be JURA department.", "JURA", first.getProperty("NOM_DEPT").getValue());
assertEquals("The last record red must be DEUX-SEVRES department.", "DEUX-SEVRES", last.getProperty("NOM_DEPT").getValue());
}
-
+
/**
* Testing direct access in the shapefile.
* @throws URISyntaxException if the resource name is incorrect.
* @throws DataStoreException if a general file reading trouble occurs.
*/
- @Test
+ @Test
public void testDirectAcces() throws DataStoreException, URISyntaxException {
ShapeFile shp = new ShapeFile(path("ABRALicenseePt_4326_clipped.shp"));
-
+
// 1) Find the third record, sequentially.
Feature thirdFeature;
-
+
try(InputFeatureStream isSequential = shp.findAll()) {
isSequential.readFeature();
isSequential.readFeature();
thirdFeature = isSequential.readFeature();
}
-
+
// Take one of its key fields and another field for reference, and its geometry.
Double sequentialAddressId = Double.valueOf((String)(thirdFeature.getProperty("ADDRID")).getValue());
String sequentialAddress = (String)(thirdFeature.getProperty("ADDRESS")).getValue();
Object sequentialGeometry = thirdFeature.getPropertyValue("geometry");
-
- // 2) Now attempt a direct access to this feature.
+
+ // 2) Now attempt a direct access to this feature.
Feature directFeature;
String sql = MessageFormat.format("SELECT * FROM ABRALicenseePt_4326_clipped WHERE ADDRID = {0,number,#0}", sequentialAddressId);
-
+
try(InputFeatureStream isDirect = shp.find(sql)) {
directFeature = isDirect.readFeature();
assertNotNull("The direct access feature returned should not be null", directFeature);
}
assertNotNull("The field ADDRID in the direct access feature has not been found again.", directFeature.getProperty("ADDRID"));
-
+
Double directAddressId = Double.valueOf((String)(directFeature.getProperty("ADDRID")).getValue());
String directAddress = (String)(directFeature.getProperty("ADDRESS")).getValue();
Object directGeometry = directFeature.getPropertyValue("geometry");
-
+
assertEquals("DBase part : direct access didn't returned the same address id than sequential access.", sequentialAddressId, directAddressId);
assertEquals("DBase part : direct access didn't returned the same address than sequential access.", sequentialAddress, directAddress);
assertEquals("Shapefile part : direct access didn't returned the same geometry than sequential access.", sequentialGeometry, directGeometry);
}
-
+
/**
* Read all the shapefile content.
* @param shp Shapefile to read.