protected void assertAttributeValuesEqual(Object expected, Object actual) { if (expected == null) { assertNull(actual); return; } if (expected instanceof Geometry) { assertTrue(((Geometry) expected).equals((Geometry) actual)); return; } assertEquals(expected, actual); }
protected <F extends Feature> void assertFeatureIterator( int startIndex, int numberExpected, FeatureIterator<F> iter, FeatureAssertion assertion) { try { boolean[] loadedFeatures = new boolean[numberExpected]; for (int j = startIndex; j < numberExpected + startIndex; j++) { F feature = iter.next(); assertNotNull(feature); int i = assertion.toIndex(feature); assertTrue(loadedFeatures.length > i - startIndex); assertTrue(i > startIndex - 1); assertFalse(loadedFeatures[i - startIndex]); loadedFeatures[i - startIndex] = true; assertion.check(i, feature); } assertFalse(iter.hasNext()); for (int i = 0; i < numberExpected; i++) { assertTrue("feature " + i + " is missing", loadedFeatures[i]); } } finally { iter.close(); } }
protected <F extends Feature> void assertFeatureIterator( int startIndex, int numberExpected, final Iterator<F> iterator, FeatureAssertion assertion) { FeatureIterator<F> adapter = new FeatureIterator<F>() { public boolean hasNext() { return iterator.hasNext(); } public F next() { return iterator.next(); } public void close() {} }; assertFeatureIterator(startIndex, numberExpected, adapter, assertion); }
@Override protected void connect() throws Exception { super.connect(); dataStore.setDatabaseSchema(null); }
/** * Checkes the two feature types are equal, taking into consideration the eventual modification * the datastore had to perform in order to actually manage the type (change in names case, for * example) */ protected void assertAttributesEqual(AttributeDescriptor expected, AttributeDescriptor actual) { assertEquals(aname(expected.getName()), actual.getName()); assertEquals(expected.getMinOccurs(), actual.getMinOccurs()); assertEquals(expected.getMaxOccurs(), actual.getMaxOccurs()); assertEquals(expected.isNillable(), actual.isNillable()); assertEquals(expected.getDefaultValue(), actual.getDefaultValue()); AttributeType texpected = expected.getType(); AttributeType tactual = actual.getType(); if (Number.class.isAssignableFrom(texpected.getBinding())) { assertTrue(Number.class.isAssignableFrom(tactual.getBinding())); } else if (Geometry.class.isAssignableFrom(texpected.getBinding())) { assertTrue(Geometry.class.isAssignableFrom(tactual.getBinding())); } else { assertTrue(texpected.getBinding().isAssignableFrom(tactual.getBinding())); } }
/** * Checkes the two feature types are equal, taking into consideration the eventual modification * the datastore had to perform in order to actually manage the type (change in names case, for * example) */ protected void assertFeatureTypesEqual(SimpleFeatureType expected, SimpleFeatureType actual) { for (int i = 0; i < expected.getAttributeCount(); i++) { AttributeDescriptor expectedAttribute = expected.getDescriptor(i); AttributeDescriptor actualAttribute = actual.getDescriptor(i); assertAttributesEqual(expectedAttribute, actualAttribute); } // make sure the geometry is nillable and has minOccurrs to 0 if (expected.getGeometryDescriptor() != null) { AttributeDescriptor dg = actual.getGeometryDescriptor(); assertTrue(dg.isNillable()); assertEquals(0, dg.getMinOccurs()); } }
protected boolean areReferencedEnvelopesEqual(ReferencedEnvelope e1, ReferencedEnvelope e2) { if (e1 == null && e2 == null) return true; if (e1 == null || e2 == null) return false; boolean equal = Math.round(e1.getMinX()) == Math.round(e2.getMinX()) && Math.round(e1.getMinY()) == Math.round(e2.getMinY()) && Math.round(e1.getMaxX()) == Math.round(e2.getMaxX()) && Math.round(e1.getMaxY()) == Math.round(e2.getMaxY()); if (!equal) return false; return areCRSEqual(e1.getCoordinateReferenceSystem(), e2.getCoordinateReferenceSystem()); }
/** * Returns the attribute name as the datastore understands it (some datastore are incapable of * supporting mixed case names for example) */ protected Name aname(Name raw) { return new NameImpl(raw.getNamespaceURI(), aname(raw.getLocalPart())); }
@Override protected void connect() throws Exception { super.connect(); dataStore.setDatabaseSchema(null); }
@Override protected void connect() throws Exception { super.connect(); fs = dataStore.getFeatureSource(tname("ft1")); }
assertFeatureIterator(startIndex, numberExpected, iter, assertion);
@Override protected void connect() throws Exception { super.connect(); schema = DataUtilities.createType( dataStore.getNamespaceURI() + "." + SKIPCOLUMN, ID + ":0," + GEOM + ":Point," + NAME + ":String"); }
protected <FT extends FeatureType, F extends Feature> void assertFeatureCollection( int startIndex, int numberExpected, FeatureCollection<FT, F> collection, FeatureAssertion assertion) { assertFeatureIterator(startIndex, numberExpected, collection.features(), assertion); }
protected void connect() throws Exception { super.connect(); featureStore = (JDBCFeatureStore) dataStore.getFeatureSource(tname("ft1")); }
protected void connect() throws Exception { super.connect(); featureStore = (JDBCFeatureStore) dataStore.getFeatureSource(tname("ft1")); }
@Override protected void connect() throws Exception { super.connect(); lakeSchema = DataUtilities.createType( dataStore.getNamespaceURI() + "." + LAKE, ID + ":0," + GEOM + ":Polygon," + NAME + ":String"); }
protected void connect() throws Exception { super.connect(); featureSource = (JDBCFeatureStore) dataStore.getFeatureSource(tname("ft1")); }
protected void connect() throws Exception { super.connect(); source = (JDBCFeatureStore) dataStore.getFeatureSource(tname("ft1")); collection = source.getFeatures(); }
protected void connect() throws Exception { super.connect(); store = (JDBCFeatureStore) dataStore.getFeatureSource(tname("ft1")); store.setFeatureLock(FeatureLock.TRANSACTION); }
@Override protected void connect() throws Exception { super.connect(); personSchema = DataUtilities.createType( dataStore.getNamespaceURI() + "." + PERSON, ID + ":0," + NAME + ":String," + AGE + ":0"); zipCodeSchema = DataUtilities.createType( dataStore.getNamespaceURI() + "." + ZIPCODE, ID + ":0," + CODE + ":String"); }