public Database getDatabase(int groupno, boolean overwrite) { Database thedb; if (groupno == 1) { if (database1 == null) // not set, so use default with is in memory database1 = new no.priv.garshol.duke.databases.InMemoryDatabase(); thedb = database1; } else if (groupno == 2) thedb = database2; // no default for no 2 else throw new DukeException("Can only have two databases"); if (thedb != null) { thedb.setConfiguration(this); thedb.setOverwrite(overwrite); // hmmm? } return thedb; }
@Test public void testOverwrite() throws IOException { // can we index a record, close and reopen the database with overwrite // set, and not find it again? assertTrue("database claims to be in-memory", !db.isInMemory()); Record record = TestUtils.makeRecord("ID", "1", "NAME", "AND", "EMAIL", "BBBBB"); db.index(record); db.commit(); db.close(); db = createDatabase(config); db.setOverwrite(true); Record r = db.findRecordById("1"); assertTrue("record found after reopening, despite overwrite", r == null); }
public Database getDatabase(boolean overwrite) { database.setConfiguration(this); database.setOverwrite(overwrite); // hmmm? return database; }