Search in sources :

Example 31 with MockDatabase

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

Example 32 with MockDatabase

use of com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase in project binnavi by google.

the class CAddressSpaceNodeComponentTest method setUp.

@Before
public void setUp() throws CouldntLoadDataException, CouldntSaveDataException, IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException, LoadCancelledException {
    final JTree tree = new JTree();
    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_component = new CAddressSpaceNodeComponent(tree, m_database, m_project, m_addressSpace);
    m_saveButton = (JButton) ReflectionHelpers.getField(m_component, "m_saveButton");
    m_editPanel = (CStandardEditPanel) ReflectionHelpers.getField(m_component, "m_stdEditPanel");
    m_titledBorder = (TitledBorder) ReflectionHelpers.getField(m_component, "m_titledBorder");
    m_debuggerCombo = (CDebuggerComboBox) ReflectionHelpers.getField(m_component, "m_debuggerCombo");
}
Also used : CProject(com.google.security.zynamics.binnavi.disassembly.CProject) JTree(javax.swing.JTree) ArrayList(java.util.ArrayList) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Date(java.util.Date) Before(org.junit.Before)

Example 33 with MockDatabase

use of com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase in project binnavi by google.

the class CModuleTest method testInSameDatabase.

@Test
public void testInSameDatabase() throws CouldntLoadDataException, LoadCancelledException {
    m_module.load();
    assertFalse(m_module.inSameDatabase(new MockSqlProvider()));
    assertTrue(m_module.inSameDatabase(m_sql));
    try {
        m_module.inSameDatabase((SQLProvider) null);
        fail();
    } catch (final NullPointerException e) {
    }
    final MockDatabase database = new MockDatabase();
    assertFalse(m_module.inSameDatabase(database));
    try {
        m_module.inSameDatabase((IDatabaseObject) null);
        fail();
    } catch (final NullPointerException e) {
    }
}
Also used : MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Test(org.junit.Test)

Example 34 with MockDatabase

use of com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase in project binnavi by google.

the class CProjectContainerTest method setUp.

@Before
public void setUp() throws CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException, IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    m_provider = new MockSqlProvider();
    m_module = new MockModule(m_provider);
    m_database = new MockDatabase(m_provider);
    m_function = new MockFunction(m_provider);
    m_project = new CProject(123, "Name", "Comment", new Date(), new Date(), 55, new FilledList<DebuggerTemplate>(), m_provider);
    m_project.load();
    m_space = m_project.getContent().createAddressSpace("space");
    m_space.load();
    m_space.getContent().addModule(m_module);
    m_debugger = new DebuggerTemplate(2, "gdb", "local", 2222, m_provider);
    m_space.getConfiguration().setDebuggerTemplate(m_debugger);
    m_listener = new MockAddressSpaceListener();
    m_space.addListener(m_listener);
    m_module.load();
    CFunctionContainerHelper.addFunction(m_module.getContent().getFunctionContainer(), m_function);
    final CView view = m_module.getContent().getViewContainer().createView("foo", "bar");
    @SuppressWarnings("unused") final MockViewContainer mockViewContainer = new MockViewContainer();
    final MockViewListener listener = new MockViewListener();
    view.addListener(listener);
}
Also used : CProject(com.google.security.zynamics.binnavi.disassembly.CProject) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) DebuggerTemplate(com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate) MockAddressSpaceListener(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.MockAddressSpaceListener) Date(java.util.Date) CView(com.google.security.zynamics.binnavi.disassembly.views.CView) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Before(org.junit.Before)

Example 35 with MockDatabase

use of com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase in project binnavi by google.

the class TextNodeTest method setUp.

@Before
public void setUp() throws IllegalArgumentException {
    final INaviTextNode internalNode = CTextNodeFactory.getWithComment("Fark");
    final TagManager tagManager = new TagManager(new MockTagManager(TagType.NODE_TAG));
    final TagManager viewTagManager = new TagManager(new MockTagManager(TagType.VIEW_TAG));
    final Database database = new Database(new MockDatabase());
    final INaviModule internalModule = new MockModule();
    final Module module = new Module(database, internalModule, tagManager, viewTagManager);
    final INaviView internalView = new MockView();
    final View view = new View(module, internalView, tagManager, viewTagManager);
    m_node = new TextNode(view, internalNode, tagManager);
}
Also used : MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) INaviTextNode(com.google.security.zynamics.binnavi.disassembly.INaviTextNode) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) INaviTextNode(com.google.security.zynamics.binnavi.disassembly.INaviTextNode) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) Before(org.junit.Before)

Aggregations

MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)59 Test (org.junit.Test)31 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)29 Date (java.util.Date)29 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)28 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)24 Before (org.junit.Before)23 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)20 Database (com.google.security.zynamics.binnavi.API.disassembly.Database)19 MockTagManager (com.google.security.zynamics.binnavi.Tagging.MockTagManager)19 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)14 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)13 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)12 DebuggerTemplate (com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate)11 Tree (com.google.security.zynamics.zylib.types.trees.Tree)10 ArrayList (java.util.ArrayList)10 CFunction (com.google.security.zynamics.binnavi.disassembly.CFunction)9 CProjectTreeModel (com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.CProjectTreeModel)8 CProject (com.google.security.zynamics.binnavi.disassembly.CProject)8 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)8