Skip to content

Commit

Permalink
[GEOT-4024] shapefile-ng build fails due to failing tests on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
aaime committed Oct 7, 2012
1 parent bc860b7 commit 9ba775f
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 25 deletions.
Expand Up @@ -27,6 +27,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.RandomAccessFile;
import java.net.MalformedURLException;
import java.net.URL;
Expand Down Expand Up @@ -247,11 +248,7 @@ public void logCurrentLockers(Level logLevel) {
for (ShpFilesLocker locker : lockerList) {
StringBuilder sb = new StringBuilder("The following locker still has a lock: ");
sb.append(locker);
if(locker.getTrace() != null) {
sb.append("\nIt was created with the following stack trace:\n");
sb.append(locker.getTrace());
}
ShapefileDataStoreFactory.LOGGER.log(logLevel, sb.toString());
ShapefileDataStoreFactory.LOGGER.log(logLevel, sb.toString(), locker.getTrace());
}
}
}
Expand Down
Expand Up @@ -248,8 +248,14 @@ public void close() throws IOException {
dbf.close();
}
} finally {
shp = null;
dbf = null;
try {
if(fidReader != null) {
fidReader.close();
}
} finally {
shp = null;
dbf = null;
}
}
}

Expand Down
Expand Up @@ -244,11 +244,7 @@ public void logCurrentLockers(Level logLevel) {
for (ShpFilesLocker locker : lockerList) {
StringBuilder sb = new StringBuilder("The following locker still has a lock: ");
sb.append(locker);
if (locker.getTrace() != null) {
sb.append("\nIt was created with the following stack trace:\n");
sb.append(locker.getTrace());
}
LOGGER.log(logLevel, sb.toString());
LOGGER.log(logLevel, sb.toString(), locker.getTrace());
}
}
}
Expand Down
Expand Up @@ -438,11 +438,17 @@ public void testFidFilter() throws Exception {
Set<String> actualFids = new HashSet<String>();
{
features = featureSource.getFeatures(fidFilter);
indexIter = features.features();
while (indexIter.hasNext()) {
SimpleFeature next = indexIter.next();
String id = next.getID();
actualFids.add(id);
try {
indexIter = features.features();
while (indexIter.hasNext()) {
SimpleFeature next = indexIter.next();
String id = next.getID();
actualFids.add(id);
}
} finally {
if(indexIter != null) {
indexIter.close();
}
}
}

Expand Down Expand Up @@ -671,8 +677,16 @@ public void testUpdating() throws Throwable {
SimpleFeatureCollection fc = loadFeatures(sds);

assertEquals(10, fc.size());
for (SimpleFeatureIterator i = fc.features(); i.hasNext();) {
assertEquals(-1, ((Integer) i.next().getAttribute(1)).byteValue());
SimpleFeatureIterator features = null;
try {
features = fc.features();
for (SimpleFeatureIterator i = features; i.hasNext();) {
assertEquals(-1, ((Integer) i.next().getAttribute(1)).byteValue());
}
} finally {
if(features != null) {
features.close();
}
}
sds.dispose();
}
Expand Down Expand Up @@ -1036,6 +1050,7 @@ private void runWriteReadTest(Geometry geom, boolean d3) throws Exception {
+ Arrays.asList(fromShape.getCoordinates()));
}
}
fci.close();
tmpFile.delete();
shapeDataStore.dispose();
}
Expand Down Expand Up @@ -1140,6 +1155,7 @@ public void testWrite() throws Exception {
Transaction t= new DefaultTransaction();
FeatureWriter<SimpleFeatureType, SimpleFeature> writer = s.getFeatureWriter(s.getTypeNames()[0], t);
SimpleFeature feature1 = writer.next();
writer.close();
s.dispose();
}

Expand Down Expand Up @@ -1252,9 +1268,9 @@ public void testIndexOutOfDate() throws Exception {

assertFalse(ds.indexManager.isIndexStale(fix));
long fixMod = fixFile.lastModified();
shpFile.setLastModified(fixMod+1000);
shpFile.setLastModified(fixMod+1000000);
assertTrue(ds.indexManager.isIndexStale(fix));
fixFile.setLastModified(shpFile.lastModified());
assertTrue(fixFile.setLastModified(shpFile.lastModified()));
assertFalse(ds.indexManager.isIndexStale(fix));
assertTrue(fixFile.delete());
assertTrue(ds.indexManager.isIndexStale(fix));
Expand Down
Expand Up @@ -57,9 +57,19 @@ protected void setUp() throws Exception {
fixFile = sibling(backshp, "fix");

shpFiles = new ShpFiles(backshx);

}

@Override
protected void tearDown() throws Exception {
super.tearDown();
}

private void cleanup(File file) {
if(file.exists()) {
assertTrue(file.delete());
}
}



}
Expand Up @@ -182,8 +182,9 @@ public void testDeleteFeature() throws Exception {
try {
assertFalse(features.hasNext());
} finally {
if (features != null)
if (features != null) {
features.close();
}
}

this.assertFidsMatch();
Expand All @@ -203,15 +204,17 @@ private void assertFidsMatch() throws IOException {
FeatureId id = fac.featureId(fid);
Filter filter = fac.id(Collections.singleton(id));
query.setFilter(filter);
SimpleFeatureIterator features = featureStore.getFeatures(query).features();
SimpleFeatureIterator features = null;
try {
features = featureStore.getFeatures(query).features();
assertTrue("Missing feature for fid " + fid, features.hasNext());
SimpleFeature feature = features.next();
assertFalse("More than one feature with fid " + fid, features.hasNext());
assertEquals(i + "th feature", entry.getValue(), feature);
} finally {
if (features != null)
if (features != null) {
features.close();
}
}

}
Expand Down
Expand Up @@ -101,6 +101,7 @@ public void testFindAllFids() throws Exception {
expectedCount++;
expectedFids.add(next.getID());
}
features.close();
ds.dispose();
}

Expand All @@ -125,6 +126,7 @@ public void testFindAllFidsReverseOrder() throws Exception {
expectedCount++;
expectedFids.add(next.getID());
}
features.close();
ds.dispose();
}

Expand Down

0 comments on commit 9ba775f

Please sign in to comment.