Search in sources :

Example 1 with MockDatabaseManagerListener

use of com.google.security.zynamics.binnavi.disassembly.MockDatabaseManagerListener in project binnavi by google.

the class DatabaseManagerTest method testLifecycle.

@Test
public void testLifecycle() {
    final MockDatabaseManagerListener listener = new MockDatabaseManagerListener();
    final DatabaseManager manager = new DatabaseManager(CDatabaseManager.instance());
    manager.addListener(listener);
    manager.addDatabase("Description", "Driver", "Host", "Name", "User", "Password", "identity", true, false);
    final IDatabase internalDatabase = CDatabaseManager.instance().iterator().next();
    assertEquals("Description", internalDatabase.getConfiguration().getDescription());
    assertEquals("Driver", internalDatabase.getConfiguration().getDriver());
    assertEquals("User", internalDatabase.getConfiguration().getUser());
    assertEquals("Password", internalDatabase.getConfiguration().getPassword());
    assertTrue(internalDatabase.getConfiguration().isSavePassword());
    assertFalse(internalDatabase.getConfiguration().isAutoConnect());
    assertEquals(1, manager.getDatabases().size());
    assertEquals("addedDatabase;", listener.events);
    assertEquals("Database Manager ['Description']", manager.toString());
    final Database database = manager.getDatabases().get(0);
    manager.removeDatabase(database);
    assertEquals(0, manager.getDatabases().size());
    assertEquals("addedDatabase;removedDatabase;", listener.events);
    manager.removeListener(listener);
}
Also used : IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) DatabaseManager(com.google.security.zynamics.binnavi.API.disassembly.DatabaseManager) CDatabaseManager(com.google.security.zynamics.binnavi.Database.CDatabaseManager) MockDatabaseManagerListener(com.google.security.zynamics.binnavi.disassembly.MockDatabaseManagerListener) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) Test(org.junit.Test)

Aggregations

Database (com.google.security.zynamics.binnavi.API.disassembly.Database)1 DatabaseManager (com.google.security.zynamics.binnavi.API.disassembly.DatabaseManager)1 CDatabaseManager (com.google.security.zynamics.binnavi.Database.CDatabaseManager)1 IDatabase (com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase)1 MockDatabaseManagerListener (com.google.security.zynamics.binnavi.disassembly.MockDatabaseManagerListener)1 Test (org.junit.Test)1