mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 03:39:05 +01:00
Create an identity at startup if the database doesn't exist.
This commit is contained in:
@@ -14,7 +14,11 @@ public class TestDatabaseConfig implements DatabaseConfig {
|
||||
this.maxSize = maxSize;
|
||||
}
|
||||
|
||||
public File getDataDirectory() {
|
||||
public boolean databaseExists() {
|
||||
return dir.isDirectory() && dir.listFiles().length > 0;
|
||||
}
|
||||
|
||||
public File getDatabaseDirectory() {
|
||||
return dir;
|
||||
}
|
||||
|
||||
|
||||
@@ -125,8 +125,9 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
|
||||
exactly(13).of(database).startTransaction();
|
||||
will(returnValue(txn));
|
||||
exactly(13).of(database).commitTransaction(txn);
|
||||
// open(false)
|
||||
oneOf(database).open(false);
|
||||
// open()
|
||||
oneOf(database).open();
|
||||
will(returnValue(false));
|
||||
oneOf(cleaner).startCleaning(
|
||||
with(any(DatabaseCleaner.Callback.class)),
|
||||
with(any(long.class)));
|
||||
@@ -199,7 +200,7 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
|
||||
DatabaseComponent db = createDatabaseComponent(database, cleaner,
|
||||
shutdown);
|
||||
|
||||
db.open(false);
|
||||
assertFalse(db.open());
|
||||
db.addListener(listener);
|
||||
assertEquals(UNRATED, db.getRating(authorId));
|
||||
db.setRating(authorId, GOOD); // First time - listeners called
|
||||
|
||||
@@ -1832,7 +1832,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
private Database<Connection> open(boolean resume) throws Exception {
|
||||
Database<Connection> db = new H2Database(new TestDatabaseConfig(testDir,
|
||||
MAX_SIZE), new SystemClock());
|
||||
db.open(resume);
|
||||
if(!resume) TestUtils.deleteTestDirectory(testDir);
|
||||
db.open();
|
||||
return db;
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
|
||||
private byte[] write() throws Exception {
|
||||
// Open Alice's database
|
||||
DatabaseComponent db = alice.getInstance(DatabaseComponent.class);
|
||||
db.open(false);
|
||||
assertFalse(db.open());
|
||||
// Start Alice's key manager
|
||||
KeyManager km = alice.getInstance(KeyManager.class);
|
||||
km.start();
|
||||
@@ -156,7 +156,7 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
|
||||
private void read(byte[] b) throws Exception {
|
||||
// Open Bob's database
|
||||
DatabaseComponent db = bob.getInstance(DatabaseComponent.class);
|
||||
db.open(false);
|
||||
assertFalse(db.open());
|
||||
// Start Bob's key manager
|
||||
KeyManager km = bob.getInstance(KeyManager.class);
|
||||
km.start();
|
||||
|
||||
Reference in New Issue
Block a user