Search in sources :

Example 16 with Database

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

the class ModuleFactory method get.

public static Module get() {
    final MockSqlProvider provider = new MockSqlProvider();
    final Date creationDate = new Date();
    final Date modificationDate = new Date();
    final CModule internalModule = new CModule(123, "Name", "Comment", creationDate, modificationDate, "12345678123456781234567812345678", "1234567812345678123456781234567812345678", 55, 66, new CAddress(0x555), new CAddress(0x666), new DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, provider), null, Integer.MAX_VALUE, false, provider);
    final TagManager nodeTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(0, "", "", TagType.NODE_TAG, provider))), TagType.NODE_TAG, provider));
    final TagManager viewTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(0, "", "", TagType.VIEW_TAG, provider))), TagType.VIEW_TAG, provider));
    final Database db = new Database(new MockDatabase());
    return new Module(db, internalModule, nodeTagManager, viewTagManager);
}
Also used : DebuggerTemplate(com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) Date(java.util.Date) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) TagManager(com.google.security.zynamics.binnavi.API.disassembly.TagManager) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) Tree(com.google.security.zynamics.zylib.types.trees.Tree) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) Module(com.google.security.zynamics.binnavi.API.disassembly.Module) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule)

Example 17 with Database

use of com.google.security.zynamics.binnavi.API.disassembly.Database 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)

Example 18 with Database

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

the class DatabaseTest method testSetPassword.

@Test
public void testSetPassword() {
    final MockDatabaseListener listener = new MockDatabaseListener();
    final MockDatabase mockDatabase = new MockDatabase();
    final Database database = new Database(mockDatabase);
    database.addListener(listener);
    database.setPassword("Fark 1");
    assertEquals("changedPassword;", listener.events);
    assertEquals("Fark 1", database.getPassword());
    assertEquals("Fark 1", mockDatabase.getConfiguration().getPassword());
    mockDatabase.getConfiguration().setPassword("Fark 2");
    assertEquals("changedPassword;changedPassword;", listener.events);
    assertEquals("Fark 2", database.getPassword());
    assertEquals("Fark 2", mockDatabase.getConfiguration().getPassword());
    database.removeListener(listener);
}
Also used : MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Test(org.junit.Test)

Example 19 with Database

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

the class DatabaseTest method testSetHost.

@Test
public void testSetHost() {
    final MockDatabaseListener listener = new MockDatabaseListener();
    final MockDatabase mockDatabase = new MockDatabase();
    final Database database = new Database(mockDatabase);
    database.addListener(listener);
    database.setHost("Fark 1");
    assertEquals("changedHost;", listener.events);
    assertEquals("Fark 1", database.getHost());
    assertEquals("Fark 1", mockDatabase.getConfiguration().getHost());
    mockDatabase.getConfiguration().setHost("Fark 2");
    assertEquals("changedHost;changedHost;", listener.events);
    assertEquals("Fark 2", database.getHost());
    assertEquals("Fark 2", mockDatabase.getConfiguration().getHost());
    database.removeListener(listener);
}
Also used : MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Test(org.junit.Test)

Example 20 with Database

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

the class DatabaseTest method testSetSavePassword.

@Test
public void testSetSavePassword() {
    final MockDatabaseListener listener = new MockDatabaseListener();
    final MockDatabase mockDatabase = new MockDatabase();
    final Database database = new Database(mockDatabase);
    database.addListener(listener);
    database.setSavePassword(false);
    assertEquals("changedSavePassword;", listener.events);
    assertFalse(database.isSavePassword());
    assertFalse(mockDatabase.getConfiguration().isSavePassword());
    mockDatabase.getConfiguration().setSavePassword(true);
    assertEquals("changedSavePassword;changedSavePassword;", listener.events);
    assertTrue(database.isSavePassword());
    assertTrue(mockDatabase.getConfiguration().isSavePassword());
    database.removeListener(listener);
}
Also used : MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Test(org.junit.Test)

Aggregations

Database (com.google.security.zynamics.binnavi.API.disassembly.Database)26 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)19 Test (org.junit.Test)15 TagManager (com.google.security.zynamics.binnavi.API.disassembly.TagManager)9 Module (com.google.security.zynamics.binnavi.API.disassembly.Module)8 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)7 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)7 Tree (com.google.security.zynamics.zylib.types.trees.Tree)7 Project (com.google.security.zynamics.binnavi.API.disassembly.Project)6 IDatabase (com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase)6 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)6 DatabaseManager (com.google.security.zynamics.binnavi.API.disassembly.DatabaseManager)4 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)4 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)4 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)3 Date (java.util.Date)3 Before (org.junit.Before)3 View (com.google.security.zynamics.binnavi.API.disassembly.View)2 CDatabase (com.google.security.zynamics.binnavi.Database.CDatabase)2 SQLProvider (com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider)2