Search in sources :

Example 11 with CProject

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

the class PostgreSQLProviderTest method testTraceFunctionsDeleteTrace1.

@Test
public void testTraceFunctionsDeleteTrace1() throws CouldntLoadDataException, LoadCancelledException, CouldntDeleteException, CouldntSaveDataException {
    final CProject project = getProvider().createProject("SOME_NEW_PROJECT");
    getProvider().createTrace(project, "SOME_TRACE_NAME_ONE", "SOME_TRACE_DESCRIPTION_ONE");
    getProvider().createTrace(project, "SOME_TRACE_NAME_TWO", "SOME_TRACE_DESCRIPTION_TWO");
    project.load();
    final int projectTraceCount = project.getContent().getTraceCount();
    assertEquals(2, projectTraceCount);
    PostgreSQLTraceFunctions.deleteTrace((AbstractSQLProvider) getProvider(), project.getContent().getTraces().get(0));
    project.close();
    final List<INaviProject> projects = getProvider().loadProjects();
    INaviProject project2 = null;
    for (final INaviProject cProject : projects) {
        if (cProject.getConfiguration().getId() == project.getConfiguration().getId()) {
            project2 = cProject;
        }
    }
    project2.load();
    assertEquals(projectTraceCount - 1, project2.getContent().getTraceCount());
}
Also used : CProject(com.google.security.zynamics.binnavi.disassembly.CProject) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 12 with CProject

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

the class PostgreSQLProviderTest method testTraceFunctionsCreateTrace2.

@Test
public void testTraceFunctionsCreateTrace2() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
    final CProject project = getProvider().createProject("SOME_NEW_PROJECT");
    getProvider().createTrace(project, "SOME_TRACE_NAME", "SOME_TRACE_DESCRIPTION");
    project.load();
    final String name = "Very new name";
    final String description = "Super cool description";
    final int projectTraceCount = project.getContent().getTraceCount();
    PostgreSQLTraceFunctions.createTrace((AbstractSQLProvider) getProvider(), project, name, description);
    project.close();
    final List<INaviProject> projects = getProvider().loadProjects();
    INaviProject project2 = null;
    for (final INaviProject cProject : projects) {
        if (project.getConfiguration().getId() == cProject.getConfiguration().getId()) {
            project2 = cProject;
        }
    }
    project2.load();
    assertEquals(projectTraceCount + 1, project2.getContent().getTraceCount());
    assertEquals(description, project2.getContent().getTraces().get(project2.getContent().getTraces().size() - 1).getDescription());
}
Also used : CProject(com.google.security.zynamics.binnavi.disassembly.CProject) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 13 with CProject

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

the class PostgreSQLProviderTest method testCAddressSpaceLoaderLoadAddressSpaces4.

@Test(expected = NullPointerException.class)
public void testCAddressSpaceLoaderLoadAddressSpaces4() throws CouldntLoadDataException {
    final CProject project = (CProject) getProvider().loadProjects().get(0);
    PostgreSQLAddressSpaceLoader.loadAddressSpaces((AbstractSQLProvider) getProvider(), project, null, null);
}
Also used : CProject(com.google.security.zynamics.binnavi.disassembly.CProject) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 14 with CProject

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

the class CProjectModulesModelTest method testSimple.

@Test
public void testSimple() throws CouldntLoadDataException, CouldntSaveDataException, LoadCancelledException {
    m_database = new MockDatabase(m_provider);
    m_project = new CProject(1, "Mock Project", "Mock Project Description", new Date(), new Date(), 0, new ArrayList<DebuggerTemplate>(), m_provider);
    m_project.load();
    m_addressSpace = m_project.getContent().createAddressSpace("Address Space");
    m_addressSpace.load();
    final CModule module1 = new CModule(1, "Name 1", "Comment", new Date(), new Date(), "12345678123456781234567812345678", "1234567812345678123456781234567812345678", 55, 66, new CAddress(0x555), new CAddress(0x666), new DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, m_provider), null, Integer.MAX_VALUE, false, m_provider);
    m_addressSpace.getContent().addModule(module1);
    final CModule module2 = new CModule(2, "Name 2", "Comment", new Date(), new Date(), "12345678123456781234567812345678", "1234567812345678123456781234567812345678", 55, 66, new CAddress(0x555), new CAddress(0x666), new DebuggerTemplate(1, "Mock Debugger", "localhaus", 88, m_provider), null, Integer.MAX_VALUE, false, m_provider);
    m_addressSpace.getContent().addModule(module2);
    final CProjectModulesModel model = new CProjectModulesModel(m_addressSpace);
    assertEquals(2, model.getRowCount());
    assertEquals("Name 1", model.getValueAt(0, 0));
    assertEquals("Name 2", model.getValueAt(1, 0));
}
Also used : CProject(com.google.security.zynamics.binnavi.disassembly.CProject) DebuggerTemplate(com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate) ArrayList(java.util.ArrayList) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) CProjectModulesModel(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.AddressSpace.Component.CProjectModulesModel) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) Date(java.util.Date) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 15 with CProject

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

the class CAddressSpaceNodeTest method setUp.

@Before
public void setUp() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException, FileReadException, CouldntLoadDataException, CouldntSaveDataException, LoadCancelledException {
    ConfigManager.instance().read();
    m_database = new MockDatabase(m_provider);
    m_project = new CProject(1, "Mock Project", "Mock Project Description", new Date(), new Date(), 0, new ArrayList<DebuggerTemplate>(), m_provider);
    m_project.load();
    m_addressSpace = m_project.getContent().createAddressSpace("Address Space");
    final CProjectTreeModel model = new CProjectTreeModel(m_tree);
    model.setRoot(new DefaultMutableTreeNode());
    m_tree.setModel(model);
    assertTrue(((LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_database, "listeners"), "m_listeners")) == null);
    assertTrue(((LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_project, "m_listeners"), "m_listeners")) == null);
    assertTrue(((LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(m_addressSpace, "m_listeners"), "m_listeners")) == null);
    assertTrue(((LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(ZyGraphBuilderManager.instance(), "m_listeners"), "m_listeners")) == null);
    m_container = new CProjectContainer(m_database, m_project, m_addressSpace);
}
Also used : CProject(com.google.security.zynamics.binnavi.disassembly.CProject) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CProjectTreeModel(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.CProjectTreeModel) CProjectContainer(com.google.security.zynamics.binnavi.disassembly.CProjectContainer) ArrayList(java.util.ArrayList) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Date(java.util.Date) Before(org.junit.Before)

Aggregations

CProject (com.google.security.zynamics.binnavi.disassembly.CProject)28 Test (org.junit.Test)15 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)12 Date (java.util.Date)10 ArrayList (java.util.ArrayList)9 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)8 DebuggerTemplate (com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate)8 Before (org.junit.Before)8 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)5 CAddressSpace (com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace)4 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)4 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)3 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)3 CProjectTreeModel (com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.CProjectTreeModel)3 INaviProject (com.google.security.zynamics.binnavi.disassembly.INaviProject)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 CouldntDeleteException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)2 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)2 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)2 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)2