Search in sources :

Example 16 with CAddressSpace

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

the class CProjectContentTest method testRemoveAddressSpace.

@Test
public void testRemoveAddressSpace() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException, CouldntDeleteException {
    final CProjectContent projectContent = new CProjectContent(m_project, m_listeners, m_provider, m_addressSpaces, m_views, m_traces);
    @SuppressWarnings("unused") final INaviView view = new MockView(m_provider);
    @SuppressWarnings("unused") final INaviView view2 = projectContent.createView("Name", "description");
    assertNotNull(CViewFilter.getTaggedViews(projectContent.getViews(), new CTag(4, "foo", "bar", TagType.VIEW_TAG, m_provider)));
    final CAddressSpace spaceOne = projectContent.createAddressSpace("Address Space 1");
    spaceOne.load();
    final CAddressSpace spaceTwo = projectContent.createAddressSpace("Address Space 2");
    spaceTwo.load();
    final CAddressSpace spaceThree = projectContent.createAddressSpace("Address Space 3");
    spaceThree.load();
    final CAddressSpace spaceFour = projectContent.createAddressSpace("Address Space 4");
    spaceFour.load();
    m_project.load();
    try {
        assertFalse(projectContent.removeAddressSpace(spaceThree));
        fail();
    } catch (final IllegalStateException e) {
    }
    spaceThree.close();
    assertTrue(projectContent.removeAddressSpace(spaceThree));
    try {
        assertFalse(projectContent.removeAddressSpace(spaceThree));
        fail();
    } catch (final IllegalArgumentException e) {
    }
    try {
        assertFalse(projectContent.removeAddressSpace(null));
        fail();
    } catch (final NullPointerException e) {
    }
    m_project.close();
    try {
        assertFalse(projectContent.removeAddressSpace(spaceFour));
        fail();
    } catch (final IllegalStateException e) {
    }
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CAddressSpace(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace) Test(org.junit.Test)

Example 17 with CAddressSpace

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

the class CProjectContentTest method testCreateAddressSpace.

@Test
public void testCreateAddressSpace() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
    final CProjectContent projectContent = new CProjectContent(m_project, m_listeners, m_provider, m_addressSpaces, m_views, m_traces);
    final CAddressSpace spaceOne = projectContent.createAddressSpace("Address Space 1");
    spaceOne.load();
    try {
        projectContent.createAddressSpace(null);
        fail();
    } catch (final NullPointerException e) {
    }
}
Also used : CAddressSpace(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace) Test(org.junit.Test)

Example 18 with CAddressSpace

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

the class CAddressSpaceTest method test_C_Constructors.

@Test
public void test_C_Constructors() {
    final MockSqlProvider sql = new MockSqlProvider();
    try {
        new CAddressSpace(0, "AS Name", "AS Description", new Date(), new Date(), new HashMap<INaviModule, IAddress>(), null, sql, new MockProject());
        fail();
    } catch (final Exception exception) {
    }
    try {
        new CAddressSpace(1, null, "AS Description", new Date(), new Date(), new HashMap<INaviModule, IAddress>(), null, sql, new MockProject());
        fail();
    } catch (final Exception exception) {
    }
    try {
        new CAddressSpace(1, "AS Name", null, new Date(), new Date(), new HashMap<INaviModule, IAddress>(), null, sql, new MockProject());
        fail();
    } catch (final Exception exception) {
    }
    try {
        new CAddressSpace(1, "AS Name", "AS Description", null, new Date(), new HashMap<INaviModule, IAddress>(), null, sql, new MockProject());
        fail();
    } catch (final Exception exception) {
    }
    try {
        new CAddressSpace(1, "AS Name", "AS Description", new Date(), null, new HashMap<INaviModule, IAddress>(), null, sql, new MockProject());
        fail();
    } catch (final Exception exception) {
    }
    try {
        new CAddressSpace(1, "AS Name", "AS Description", new Date(), new Date(), null, null, sql, new MockProject());
        fail();
    } catch (final Exception exception) {
    }
    try {
        new CAddressSpace(1, "AS Name", "AS Description", new Date(), new Date(), new HashMap<INaviModule, IAddress>(), null, null, new MockProject());
        fail();
    } catch (final Exception exception) {
    }
    final CAddressSpace addressSpace = new CAddressSpace(1, "AS Name", "AS Description", new Date(), new Date(), new HashMap<INaviModule, IAddress>(), null, sql, new MockProject());
    assertEquals(1, addressSpace.getConfiguration().getId());
    assertEquals("AS Name", addressSpace.getConfiguration().getName());
    assertEquals("AS Description", addressSpace.getConfiguration().getDescription());
}
Also used : MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CAddressSpace(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace) Date(java.util.Date) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) Test(org.junit.Test)

Example 19 with CAddressSpace

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

the class AddressSpaceTest method setUp.

@Before
public void setUp() {
    final MockSqlProvider provider = new MockSqlProvider();
    creationDate = new Date();
    modificationDate = new Date();
    final MockDatabase mockDb = new MockDatabase();
    database = new Database(mockDb);
    internalAddressSpace = new CAddressSpace(1, "Mock Space", "Mock Space Description", creationDate, modificationDate, new LinkedHashMap<INaviModule, IAddress>(), null, provider, new MockProject());
    addressSpace = new AddressSpace(database, null, internalAddressSpace);
    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 com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, provider), null, Integer.MAX_VALUE, false, provider);
    mockDb.getContent().addModule(internalModule);
    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));
    module = new Module(database, internalModule, nodeTagManager, viewTagManager);
}
Also used : CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) Date(java.util.Date) LinkedHashMap(java.util.LinkedHashMap) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) CAddressSpace(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Tree(com.google.security.zynamics.zylib.types.trees.Tree) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) CAddressSpace(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace) Before(org.junit.Before)

Example 20 with CAddressSpace

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

the class AddressSpaceTest method testConstructorAlternative.

@Test
public void testConstructorAlternative() throws com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException, com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException, LoadCancelledException {
    final MockSqlProvider provider = new MockSqlProvider();
    final MockDatabase mockDb = new MockDatabase(provider);
    final Database database = new Database(mockDb);
    final com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate template = new com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate(1, "", "", 0, provider);
    mockDb.getContent().getDebuggerTemplateManager().addDebugger(template);
    final CModule internalModule = new CModule(123, "Name", "Comment", new Date(), new Date(), "12345678123456781234567812345678", "1234567812345678123456781234567812345678", 55, 66, new CAddress(0x555), new CAddress(0x666), new com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, provider), null, Integer.MAX_VALUE, false, provider);
    mockDb.getContent().addModule(internalModule);
    final CAddressSpace internalAddressSpace = new CAddressSpace(1, "Mock Space", "Mock Space Description", new Date(), new Date(), new LinkedHashMap<INaviModule, IAddress>(), null, provider, new MockProject());
    internalAddressSpace.load();
    internalAddressSpace.getConfiguration().setDebuggerTemplate(template);
    internalAddressSpace.getContent().addModule(internalModule);
    final Project project = ProjectFactory.get();
    final AddressSpace addressSpace = new AddressSpace(database, project, internalAddressSpace);
    assertEquals(1, addressSpace.getModules().size());
    assertNotNull(addressSpace.getDebuggerTemplate());
    assertNotNull(addressSpace.getDebugger());
}
Also used : Date(java.util.Date) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) CAddressSpace(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) CAddressSpace(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace) Test(org.junit.Test)

Aggregations

CAddressSpace (com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace)23 Test (org.junit.Test)17 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)9 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)8 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)6 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)6 LoadCancelledException (com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)5 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)4 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)4 CProject (com.google.security.zynamics.binnavi.disassembly.CProject)4 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)4 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)4 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)4 CProjectNode (com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Project.CProjectNode)3 CProjectContainer (com.google.security.zynamics.binnavi.disassembly.CProjectContainer)3 INaviProject (com.google.security.zynamics.binnavi.disassembly.INaviProject)3 MockProject (com.google.security.zynamics.binnavi.disassembly.MockProject)3 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3