shpFiles.dispose();
}
@Test
public void testUnlockWriteAssertion() throws Throwable {
ShpFiles shpFiles = new ShpFiles("http://somefile.com/shp.shp");
URL url = shpFiles.acquireWrite(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.tryAcquireWrite(SHX, testWriter);
assertEquals("http://somefile.com/shp.shx", result1.value
.toExternalForm());
assertEquals(2, shpFiles.numberOfLocks());
try {
shpFiles.unlockRead(result1.value, this);
throw new RuntimeException(
"Unlock should fail because it is in the wrong reader");
} catch (IllegalArgumentException e) {
// good
} catch (RuntimeException e) {
fail(e.getMessage());
}
shpFiles.unlockWrite(url, this);
shpFiles.unlockWrite(result1.value, testWriter);
shpFiles.dispose();
}