From within eclipse everything works in the following test:
> public void testLoadAndVerify() throws Exception {
> FeatureCollection features = loadFeatures(STATE_POP,
> Query.ALL);
> assertEquals("Number of Features loaded",49,features.size());
> }
The referenced data is:
> file:/C:/java/geotools/trunk/modules/library/sample-data/target/classes/org/geotools/test-data/shapes/statepop.shp
From Maven I get test failure:
> testLoadAndVerify(org.geotools.data.shapefile.indexed.ShapefileDataStoreTest)
>
> Time elapsed: 1.547 sec <<< FAILURE!
> junit.framework.AssertionFailedError: Number of Features loaded
> expected:<49> but was:<3>
> at junit.framework.Assert.fail(Assert.java:47)
The referenced data is:
> jar:file:/C:/Documents and
> Settings/jgarnett/.m2/repository/org/geotools/gt2-sample-data/2.4-SNAPSHOT/gt2-sample-data-2.4-SNAPSHOT.jar!/org/geotools/test-data/shapes/statepop.shp
Feeding this by hand into eclipse ... it looks like the change from
features.getCount() to features.size() revealed this bug :-P
DataFeatureCollection.size():
- calls getCount(), in the event of an IOException it returns 0
- correctly calls DefaultFeatureResults.getCount() - which returns 3?!?
DefaultFeatureResults.getCount(): // assume this is what was called
directly before?!?
- tries for featureSource.getCount( query ); if non -1 it will use a
reader to count the features by hand
- actually return 3
AbstractFeatureSource.getCount( Query )
- Has a try at using the TransactionStateDiff if to produce a delta
- Grabs a value from AbstractDataStore.getCount( Query ) and adjusts w/
the delta
- also returns 3 (no delta was used)
ShapefileDataStore.getCount( Query )
- opens a ShapefileReader with provided URL
- calls ShapefileReader.getCount( -1 )
ShapeFileReader.getCount
- takes with readRecord until readRecord returns -1
This loop finds 3 features when using the "jar:/...." URL and 49 when
using the "file:/..." URL - cannot figure out the bug so far.
Previously these test cases made use of an in memory feature collection
that would report the correct size() ... so I am finding a old bug here.
Cheers,
Jody
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel