use of org.openlca.core.database.Derby in project olca-modules by GreenDelta.
the class Tests method initFileBasedDb.
private static IDatabase initFileBasedDb() {
String tmpDirPath = System.getProperty("java.io.tmpdir");
String dbName = "olca_test_db_1.4";
File tmpDir = new File(tmpDirPath);
File folder = new File(tmpDir, dbName);
return new Derby(folder);
}
use of org.openlca.core.database.Derby in project olca-modules by GreenDelta.
the class DerbyDatabaseTest method testDumpMemoryDB.
@Test
public void testDumpMemoryDB() throws Exception {
Derby db = Derby.createInMemory();
Actor a = new Actor();
a.name = "The Donald";
a = new ActorDao(db).insert(a);
long id = a.id;
Path path = Files.createTempDirectory("_olca_test_");
db.dump(path.toString());
db.close();
db = Derby.restoreInMemory(path.toString());
a = new ActorDao(db).getForId(id);
assertEquals("The Donald", a.name);
db.close();
Dirs.delete(path);
}
use of org.openlca.core.database.Derby in project olca-modules by GreenDelta.
the class DerbyDatabaseTest method testNoMemLeak.
@Test
@Ignore
public void testNoMemLeak() throws Exception {
Runtime rt = Runtime.getRuntime();
long initialUsed = rt.totalMemory() - rt.freeMemory();
for (int i = 0; i < 1000; i++) {
Derby db = Derby.createInMemory();
db.close();
long usedMem = rt.totalMemory() - rt.freeMemory();
if (initialUsed * 10 < usedMem) {
fail("There is probably a memory leak");
}
System.out.println("" + i + "\t" + (usedMem / (1024 * 1024)));
}
}
use of org.openlca.core.database.Derby in project olca-modules by GreenDelta.
the class DerbyDatabaseTest method testFromFolder.
@Test
@Ignore
public void testFromFolder() throws Exception {
File dir = Files.createTempDirectory("olca_test_db").toFile();
assertTrue(dir.delete());
try (Derby db = new Derby(dir)) {
assertEquals(dir.getName(), db.getName());
}
Dirs.delete(dir.getAbsolutePath());
}
use of org.openlca.core.database.Derby in project olca-app by GreenDelta.
the class Main method create.
private static void create(String name, String dataDir) throws Exception {
System.out.println(" Create " + name + " database ...");
var db = new Derby(F("build/" + name));
if (dataDir != null) {
new RefDataImport(F("data/" + dataDir), db).run();
if ("all".equals(dataDir)) {
importDQS(db);
GeoImport.on(db);
}
}
db.close();
System.out.println(" done");
}
Aggregations