Search in sources :

Example 96 with MockSqlProvider

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

the class CViewTest method setUp.

@Before
public void setUp() throws CouldntLoadDataException, LoadCancelledException, FileReadException {
    ConfigManager.instance().read();
    m_sql = new MockSqlProvider();
    m_module = MockCreator.createModule(m_sql);
    m_module.load();
    m_view = MockCreator.createView(m_sql, m_module);
    m_unsavedView = m_module.getContent().getViewContainer().createView("Unsaved", "");
    m_function = MockCreator.createFunction(m_module, m_sql);
    m_instruction = MockCreator.createInstruction(m_module, m_sql);
    m_listener = new MockViewListener();
    m_view.addListener(m_listener);
    m_unsavedView.addListener(m_listener);
}
Also used : MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) Before(org.junit.Before)

Example 97 with MockSqlProvider

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

the class CViewTest method testConstructor16.

@Test
public void testConstructor16() {
    final MutableDirectedGraph<INaviViewNode, INaviEdge> graph = new MutableDirectedGraph<INaviViewNode, INaviEdge>(new ArrayList<INaviViewNode>(), new ArrayList<INaviEdge>());
    final Set<CTag> tags = new HashSet<CTag>();
    final MockSqlProvider provider = new MockSqlProvider();
    final MockModule module = new MockModule();
    final CView view = new CView(2, module, "View", "Description", ViewType.Native, new Date(1234), new Date(12345), graph, tags, false, provider);
    assertEquals(2, view.getConfiguration().getId());
    assertEquals("View", view.getName());
    assertEquals("Description", view.getConfiguration().getDescription());
    assertEquals(ViewType.Native, view.getType());
    assertEquals(0, view.getNodeCount());
    assertEquals(0, view.getEdgeCount());
    try {
        new CView(-2, module, "View", "Description", ViewType.Native, new Date(1234), new Date(12345), graph, tags, false, provider);
        fail();
    } catch (final IllegalArgumentException e) {
    }
    try {
        new CView(new BigInteger(31, random).intValue(), (CModule) null, "View", "Description", ViewType.Native, new Date(1234), new Date(12345), graph, tags, false, provider);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        new CView(new BigInteger(31, random).intValue(), module, null, "Description", ViewType.Native, new Date(1234), new Date(12345), graph, tags, false, provider);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        new CView(new BigInteger(31, random).intValue(), module, "Description", null, ViewType.Native, new Date(1234), new Date(12345), graph, tags, false, provider);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        new CView(new BigInteger(31, random).intValue(), module, "stuuf", "Description", null, new Date(1234), new Date(12345), graph, tags, false, provider);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        new CView(new BigInteger(31, random).intValue(), module, "stuuf", "Description", ViewType.Native, null, new Date(12345), graph, tags, false, provider);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        new CView(new BigInteger(31, random).intValue(), module, "stuuf", "Description", ViewType.Native, new Date(12345), null, graph, tags, false, provider);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        new CView(new BigInteger(31, random).intValue(), module, "stuuf", "Description", ViewType.Native, new Date(12345), new Date(12345), null, tags, false, provider);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        new CView(new BigInteger(31, random).intValue(), module, "stuuf", "Description", ViewType.Native, new Date(12345), new Date(12345), graph, null, false, provider);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        new CView(new BigInteger(31, random).intValue(), module, "stuuf", "Description", ViewType.Native, new Date(12345), new Date(12345), graph, tags, false, null);
        fail();
    } catch (final NullPointerException e) {
    }
    final CTag tag1 = new CTag(1, "Tag1", "Tag1 Tag1", TagType.VIEW_TAG, provider);
    final CTag tag2 = new CTag(2, "Tag2", "Tag2 Tag2", TagType.VIEW_TAG, provider);
    final CTag tag3 = new CTag(3, "Tag3", "Tag3 Tag3", TagType.VIEW_TAG, provider);
    final CTag tag4 = new CTag(4, "Tag4", "Tag4 Tag4", TagType.VIEW_TAG, provider);
    tags.add(tag1);
    tags.add(tag2);
    tags.add(tag3);
    tags.add(tag4);
    new CView(new BigInteger(31, random).intValue(), module, "View", "Description", ViewType.Native, new Date(1234), new Date(12345), graph, tags, false, provider);
    tags.add(null);
    try {
        new CView(new BigInteger(31, random).intValue(), module, "View", "Description", ViewType.Native, new Date(1234), new Date(12345), graph, tags, false, provider);
        fail();
    } catch (final NullPointerException e) {
    }
    tags.clear();
    tags.add(tag1);
    tags.add(tag2);
    tags.add(tag3);
    tags.add(tag4);
    final CTag tag5 = new CTag(5, "Tag1", "Tag1 Tag1", TagType.NODE_TAG, provider);
    tags.add(tag5);
    try {
        new CView(new BigInteger(31, random).intValue(), module, "View", "Description", ViewType.Native, new Date(1234), new Date(12345), graph, tags, false, provider);
        fail();
    } catch (final IllegalArgumentException e) {
    }
    tags.clear();
    final CTag tagWrongDB = new CTag(new BigInteger(31, random).intValue(), "Tag4", "Tag4 Tag4", TagType.VIEW_TAG, new MockSqlProvider());
    tags.add(tagWrongDB);
    try {
        new CView(new BigInteger(31, random).intValue(), module, "View", "Description", ViewType.Native, new Date(1234), new Date(12345), graph, tags, false, provider);
        fail();
    } catch (final IllegalArgumentException e) {
    }
}
Also used : CTag(com.google.security.zynamics.binnavi.Tagging.CTag) 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) BigInteger(java.math.BigInteger) MutableDirectedGraph(com.google.security.zynamics.zylib.types.graphs.MutableDirectedGraph) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 98 with MockSqlProvider

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

the class CViewTest method testConstructor3.

@Test
public void testConstructor3() {
    try {
        new CView(new BigInteger(31, random).intValue(), (INaviProject) null, "Blub", "Bla", ViewType.Native, GraphType.FLOWGRAPH, new Date(1234), new Date(12345), 123, 700, new HashSet<CTag>(), new HashSet<CTag>(), false, new MockSqlProvider());
        fail();
    } catch (final NullPointerException e) {
    }
    final int viewId = new BigInteger(31, random).intValue();
    final CView view = new CView(viewId, new MockProject(), "Blub", "Bla", ViewType.Native, GraphType.FLOWGRAPH, new Date(1234), new Date(12345), 123, 700, new HashSet<CTag>(), new HashSet<CTag>(), false, new MockSqlProvider());
    assertEquals(viewId, view.getConfiguration().getId());
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) BigInteger(java.math.BigInteger) Date(java.util.Date) Test(org.junit.Test)

Example 99 with MockSqlProvider

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

the class SectionContainerBackendTest method setUp.

@Before
public void setUp() {
    provider = new MockSqlProvider();
    module = new MockModule(provider);
}
Also used : MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) Before(org.junit.Before)

Example 100 with MockSqlProvider

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

the class ZyGraphTest method setUp.

@Before
public void setUp() throws IllegalStateException, FileReadException, LoadCancelledException {
    ConfigManager.instance().read();
    final ZyGraphViewSettings settings = ConfigManager.instance().getDefaultFlowGraphSettings();
    settings.getProximitySettings().setProximityBrowsingActivationThreshold(50);
    settings.getProximitySettings().setProximityBrowsingChildren(2);
    settings.getProximitySettings().setProximityBrowsingParents(2);
    ConfigManager.instance().updateFlowgraphSettings(settings);
    m_provider = new MockSqlProvider();
    m_module = new MockModule(m_provider);
    m_function = new MockFunction(m_provider);
    m_view = MockViewGenerator.generate(m_provider, m_module, m_function);
    m_graph = CGraphBuilder.buildGraph(m_view);
}
Also used : MockFunction(com.google.security.zynamics.binnavi.disassembly.MockFunction) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) Before(org.junit.Before)

Aggregations

MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)111 Test (org.junit.Test)82 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)55 Date (java.util.Date)47 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)44 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)42 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)32 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)29 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)25 CFunction (com.google.security.zynamics.binnavi.disassembly.CFunction)24 Before (org.junit.Before)23 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)17 MockTagManager (com.google.security.zynamics.binnavi.Tagging.MockTagManager)17 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)14 CInstruction (com.google.security.zynamics.binnavi.disassembly.CInstruction)13 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)13 DebuggerTemplate (com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate)12 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)12 Tree (com.google.security.zynamics.zylib.types.trees.Tree)12 ArrayList (java.util.ArrayList)12