shpFiles.dispose();
}
@Test
public void testAcquireRead1() throws Throwable {
ShpFiles shpFiles = new ShpFiles("http://somefile.com/shp.shp");
URL url = shpFiles.acquireRead(DBF, this);
assertEquals("http://somefile.com/shp.dbf", url.toExternalForm());
assertEquals(1, shpFiles.numberOfLocks());
FileWriter testWriter = new FileWriter() {
public String id() {
return "Other";
}
};
// same thread should work
Result<URL, State> result1 = shpFiles.tryAcquireRead(SHX, testWriter);
assertEquals("http://somefile.com/shp.shx", result1.value
.toExternalForm());
assertEquals(2, shpFiles.numberOfLocks());
// same thread should work
Result<URL, State> result2 = shpFiles.tryAcquireRead(DBF, this);
assertEquals("http://somefile.com/shp.dbf", result2.value
.toExternalForm());
assertEquals(3, shpFiles.numberOfLocks());
shpFiles.unlockRead(result2.value, this);
shpFiles.unlockRead(result1.value, testWriter);
shpFiles.unlockRead(url, this);
shpFiles.dispose();
}