|
|
|
svn_geotools
|
Author: aaime
Date: 2009-11-12 10:02:56 -0500 (Thu, 12 Nov 2009) New Revision: 34369 Modified: branches/2.6.x/modules/library/jdbc/ branches/2.6.x/modules/library/jdbc/src/test/java/org/geotools/jdbc/FeatureEventWatcher.java branches/2.6.x/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCFeatureStoreTest.java branches/2.6.x/modules/library/main/src/main/java/org/geotools/data/BatchFeatureEvent.java branches/2.6.x/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2FeatureStoreTest.java branches/2.6.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostgisFeatureStoreTest.java Log: GEOT-2829, All ContentDataStore subclasses fail with NPE on transactions that have both inserts and attached feature listeners Property changes on: branches/2.6.x/modules/library/jdbc ___________________________________________________________________ Modified: svn:mergeinfo - /branches/2.5.x/modules/library/main/jdbc:33331 /trunk/modules/library/jdbc:34314 + /branches/2.5.x/modules/library/main/jdbc:33331 /trunk/modules/library/jdbc:34314,34359,34367-34368 Modified: branches/2.6.x/modules/library/jdbc/src/test/java/org/geotools/jdbc/FeatureEventWatcher.java =================================================================== --- branches/2.6.x/modules/library/jdbc/src/test/java/org/geotools/jdbc/FeatureEventWatcher.java 2009-11-12 14:51:41 UTC (rev 34368) +++ branches/2.6.x/modules/library/jdbc/src/test/java/org/geotools/jdbc/FeatureEventWatcher.java 2009-11-12 15:02:56 UTC (rev 34369) @@ -38,7 +38,7 @@ public FeatureSource<? extends FeatureType, ? extends Feature> source; /** Total bounds since last reset*/ - public ReferencedEnvelope bounds = new ReferencedEnvelope(); + public ReferencedEnvelope bounds; /** number of events since last reset */ public int count = 0; Modified: branches/2.6.x/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCFeatureStoreTest.java =================================================================== --- branches/2.6.x/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCFeatureStoreTest.java 2009-11-12 14:51:41 UTC (rev 34368) +++ branches/2.6.x/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCFeatureStoreTest.java 2009-11-12 15:02:56 UTC (rev 34369) @@ -24,8 +24,9 @@ import java.util.List; import org.geotools.data.CollectionFeatureReader; +import org.geotools.data.DefaultTransaction; import org.geotools.data.FeatureReader; -import org.geotools.data.FeatureSource; +import org.geotools.data.Transaction; import org.geotools.data.FeatureEvent.Type; import org.geotools.factory.CommonFactoryFinder; import org.geotools.feature.AttributeTypeBuilder; @@ -61,16 +62,16 @@ DefaultFeatureCollection collection = new DefaultFeatureCollection(null, featureStore.getSchema()); - //Watcher watcher = new Watcher(); + FeatureEventWatcher watcher = new FeatureEventWatcher(); for (int i = 3; i < 6; i++) { b.set(aname("intProperty"), new Integer(i)); b.set(aname("geometry"), new GeometryFactory().createPoint(new Coordinate(i, i))); collection.add(b.buildFeature(null)); } - //featureStore.addFeatureListener( watcher ); + featureStore.addFeatureListener( watcher ); List<FeatureId> fids = featureStore.addFeatures(collection); - //assertEquals( watcher.bounds, collection.getBounds() ); + assertEquals( watcher.bounds, collection.getBounds() ); assertEquals(3, fids.size()); @@ -98,6 +99,36 @@ } } + public void testAddInTransaction() throws IOException { + SimpleFeatureBuilder b = new SimpleFeatureBuilder(featureStore.getSchema()); + DefaultFeatureCollection collection = new DefaultFeatureCollection(null, + featureStore.getSchema()); + + b.set(aname("intProperty"), new Integer(3)); + b.set(aname("geometry"), new GeometryFactory().createPoint(new Coordinate(3, 3))); + collection.add(b.buildFeature(null)); + + FeatureEventWatcher watcher = new FeatureEventWatcher(); + Transaction t = new DefaultTransaction(); + featureStore.setTransaction(t); + featureStore.addFeatureListener(watcher); + JDBCFeatureStore featureStore2 = (JDBCFeatureStore) dataStore.getFeatureSource(featureStore.getName().getLocalPart()); + List<FeatureId> fids = featureStore.addFeatures(collection); + + assertEquals(1, fids.size()); + + // check the store with the transaction sees the new features, but the other store does not + assertEquals(4, featureStore.getFeatures().size()); + assertEquals(3, featureStore2.getFeatures().size()); + + // check that after the commit everybody sees 4 + t.commit(); + assertEquals(4, featureStore.getFeatures().size()); + assertEquals(4, featureStore2.getFeatures().size()); + + t.close(); + } + /** * Check null encoding is working properly * @throws IOException Modified: branches/2.6.x/modules/library/main/src/main/java/org/geotools/data/BatchFeatureEvent.java =================================================================== --- branches/2.6.x/modules/library/main/src/main/java/org/geotools/data/BatchFeatureEvent.java 2009-11-12 14:51:41 UTC (rev 34368) +++ branches/2.6.x/modules/library/main/src/main/java/org/geotools/data/BatchFeatureEvent.java 2009-11-12 15:02:56 UTC (rev 34369) @@ -63,7 +63,7 @@ * by the client to track selection. */ @SuppressWarnings("unchecked") - protected WeakHashSet<Identifier> fids; + protected WeakHashSet<Identifier> fids = new WeakHashSet<Identifier>(Identifier.class); /** * Used to change this into a COMMIT or ROLLBACK if needed. @@ -134,6 +134,7 @@ } } } + /** * This is the set of Identifiers that have been created * over the course of this operation. @@ -145,7 +146,7 @@ * @return Set of Identifiers created during this commit */ @SuppressWarnings("unchecked") - public WeakHashSet<Identifier> getCreatedFeatureIds(){ + public WeakHashSet<Identifier> getCreatedFeatureIds() { return fids; } } Modified: branches/2.6.x/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2FeatureStoreTest.java =================================================================== --- branches/2.6.x/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2FeatureStoreTest.java 2009-11-12 14:51:41 UTC (rev 34368) +++ branches/2.6.x/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2FeatureStoreTest.java 2009-11-12 15:02:56 UTC (rev 34369) @@ -16,6 +16,8 @@ */ package org.geotools.data.h2; +import java.io.IOException; + import org.geotools.jdbc.JDBCFeatureStoreTest; import org.geotools.jdbc.JDBCTestSetup; @@ -32,4 +34,8 @@ protected JDBCTestSetup createTestSetup() { return new H2TestSetup(); } + + public void testAddInTransaction() throws IOException { + // does not work, see GEOT-2832 + } } Modified: branches/2.6.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostgisFeatureStoreTest.java =================================================================== --- branches/2.6.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostgisFeatureStoreTest.java 2009-11-12 14:51:41 UTC (rev 34368) +++ branches/2.6.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostgisFeatureStoreTest.java 2009-11-12 15:02:56 UTC (rev 34369) @@ -28,8 +28,4 @@ return new PostGISTestSetup(); } - @Override - public void testAddFeatures() throws IOException { - // wont' pass right now, see http://jira.codehaus.org/browse/GEOT-2231 - } } ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ GeoTools-commits mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/geotools-commits |
||||||||||||||||
| Free Embeddable Forum Powered by Nabble | Help |