use of org.apache.jena.dboe.base.file.Location in project jena by apache.
the class TestStoreConnectionLock method lock_store_connection_01.
@Test
public void lock_store_connection_01() {
Location dir = Location.create(tempDir.getRoot().getAbsolutePath());
ProcessFileLock lock = StoreConnection.lockForLocation(dir);
assertFalse(lock.isLockedHere());
StoreConnection sConn = StoreConnection.connectCreate(dir);
assertEquals(dir, sConn.getLocation());
assertEquals(lock, sConn.getLock());
assertTrue(lock.isLockedHere());
StoreConnection.release(dir);
assertFalse(lock.isLockedHere());
}
use of org.apache.jena.dboe.base.file.Location in project jena by apache.
the class TestStoreConnectionLock method lock_store_connection_02.
@Test(expected = AlreadyLocked.class)
public void lock_store_connection_02() {
Location dir = Location.create(tempDir.getRoot().getAbsolutePath());
ProcessFileLock lock = StoreConnection.lockForLocation(dir);
lock.lockEx();
StoreConnection sConn = StoreConnection.connectCreate(dir);
}
use of org.apache.jena.dboe.base.file.Location in project jena by apache.
the class TL method createTestDataset.
private static Dataset createTestDataset() {
Location location = cleanLocation();
Dataset dataset = TDB2Factory.connectDataset(location);
return dataset;
}
use of org.apache.jena.dboe.base.file.Location in project jena by apache.
the class TL method cleanLocation.
// Or use these for @Before, @After style.
public static Location cleanLocation() {
// To avoid the problems on MS Windows where memory mapped files
// can't be deleted from a running JVM, we use a different, cleaned
// directory each time.
String dirname = ConfigTest.getCleanDir();
Location location = Location.create(dirname);
return location;
}
use of org.apache.jena.dboe.base.file.Location in project jena by apache.
the class TestDatabaseOps method compact_dsg_1.
@Test
public void compact_dsg_1() {
DatasetGraph dsg = DatabaseMgr.connectDatasetGraph(dir);
DatasetGraphSwitchable dsgs = (DatasetGraphSwitchable) dsg;
DatasetGraph dsg1 = dsgs.get();
Location loc1 = ((DatasetGraphTDB) dsg1).getLocation();
Txn.executeWrite(dsg, () -> {
dsg.add(quad2);
dsg.add(quad1);
});
DatabaseMgr.compact(dsg, false);
assertFalse(StoreConnection.isSetup(loc1));
DatasetGraph dsg2 = dsgs.get();
Location loc2 = ((DatasetGraphTDB) dsg2).getLocation();
assertNotEquals(dsg1, dsg2);
assertNotEquals(loc1, loc2);
Txn.executeRead(dsg, () -> {
assertTrue(dsg.contains(quad2));
assertTrue(dsg.contains(quad1));
});
// dsg1 was closed and expelled. We must carefully reopen its storage only.
DatasetGraph dsgOld = StoreConnection.connectCreate(loc1).getDatasetGraph();
Txn.executeWrite(dsgOld, () -> dsgOld.delete(quad2));
Txn.executeRead(dsg, () -> assertTrue(dsg.contains(quad2)));
Txn.executeRead(dsg2, () -> assertTrue(dsg2.contains(quad2)));
}
Aggregations