Search in sources :

Example 1 with MockProject

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

the class TraceLoggerTest method setUp.

@Before
public void setUp() throws CouldntLoadDataException, InvalidDatabaseVersionException {
    final SQLProvider mockProvider = new MockSqlProvider();
    // CDatabase("", "", "", "", "", false,
    final IDatabase internalDatabase = new MockDatabase();
    // false);
    final Database database = new Database(internalDatabase);
    database.load();
    final MockProject mockProject = new MockProject();
    final ITreeNode<CTag> nodeRootNode = new TreeNode<CTag>(new CTag(0, "", "", TagType.NODE_TAG, mockProvider));
    final Tree<CTag> nodeTagTree = new Tree<CTag>(nodeRootNode);
    final TagManager nodeTagManager = new TagManager(new CTagManager(nodeTagTree, TagType.NODE_TAG, mockProvider));
    final ITreeNode<CTag> viewRootNode = new TreeNode<CTag>(new CTag(0, "", "", TagType.VIEW_TAG, mockProvider));
    final Tree<CTag> viewTagTree = new Tree<CTag>(viewRootNode);
    final TagManager viewTagManager = new TagManager(new CTagManager(viewTagTree, TagType.VIEW_TAG, mockProvider));
    final Module module = new Module(database, mockModule, nodeTagManager, viewTagManager);
    final Project project = new Project(database, mockProject, nodeTagManager, viewTagManager);
    m_mockModule = new Module(database, mockModule, viewTagManager, nodeTagManager);
    m_debugSettings = new ModuleTargetSettings(m_mockModule.getNative());
    m_mockDebugger = new MockDebugger(m_debugSettings);
    m_mockDebugger.setAddressTranslator(mockModule, new CAddress(0), new CAddress(0x1000));
    final Debugger debugger = new Debugger(m_mockDebugger);
    m_logger = new TraceLogger(debugger, module);
    m_projectLogger = new TraceLogger(debugger, project);
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) SQLProvider(com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) Project(com.google.security.zynamics.binnavi.API.disassembly.Project) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) TagManager(com.google.security.zynamics.binnavi.API.disassembly.TagManager) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) TreeNode(com.google.security.zynamics.zylib.types.trees.TreeNode) ITreeNode(com.google.security.zynamics.zylib.types.trees.ITreeNode) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Tree(com.google.security.zynamics.zylib.types.trees.Tree) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) Module(com.google.security.zynamics.binnavi.API.disassembly.Module) Before(org.junit.Before)

Example 2 with MockProject

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

the class PostgreSQLViewNotificationParserTest method testProjectViewInform2.

@Test(expected = IllegalArgumentException.class)
public void testProjectViewInform2() throws CouldntLoadDataException {
    final INaviProject project = new MockProject(provider);
    final ViewNotificationContainer container = new ViewNotificationContainer(view.getConfiguration().getId(), Optional.fromNullable(view), Optional.of(project.getConfiguration().getId()), Optional.<INaviModule>absent(), Optional.of(project), "DELETE");
    final PostgreSQLViewNotificationParser parser = new PostgreSQLViewNotificationParser();
    parser.inform(Lists.<ViewNotificationContainer>newArrayList(container), provider);
}
Also used : MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) PostgreSQLViewNotificationParser(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLViewNotificationParser) ViewNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.ViewNotificationContainer) Test(org.junit.Test)

Example 3 with MockProject

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

the class PostgreSQLViewNotificationParserTest method testProjectViewInform1.

@Test
public void testProjectViewInform1() throws CouldntLoadDataException {
    final INaviProject project = new MockProject(provider);
    final ViewNotificationContainer container = new ViewNotificationContainer(view.getConfiguration().getId(), Optional.fromNullable(view), Optional.of(project.getConfiguration().getId()), Optional.<INaviModule>absent(), Optional.of(project), "UPDATE");
    final PostgreSQLViewNotificationParser parser = new PostgreSQLViewNotificationParser();
    parser.inform(Lists.<ViewNotificationContainer>newArrayList(container), provider);
}
Also used : MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) PostgreSQLViewNotificationParser(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLViewNotificationParser) ViewNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.ViewNotificationContainer) Test(org.junit.Test)

Example 4 with MockProject

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

the class PostgreSQLProviderTestSetup method testCreateViewProject4.

@Test(expected = CouldntSaveDataException.class)
public void testCreateViewProject4() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException, CPartialLoadException {
    final INaviView view = getKernel32Module().getContent().getViewContainer().getViews().get(223);
    view.load();
    getProvider().createView(new MockProject(), view, "View Name", null);
}
Also used : MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 5 with MockProject

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

the class PostgreSQLViewNotificationParserTest method testProjectViewInform3.

@Test
public void testProjectViewInform3() throws CouldntLoadDataException {
    final INaviProject project = new MockProject(provider);
    final int currentUserViewSize = project.getContent().getViews().size();
    final ViewNotificationContainer container = new ViewNotificationContainer(view.getConfiguration().getId(), Optional.fromNullable(view), Optional.of(project.getConfiguration().getId()), Optional.<INaviModule>absent(), Optional.of(project), "INSERT");
    final PostgreSQLViewNotificationParser parser = new PostgreSQLViewNotificationParser();
    parser.inform(Lists.<ViewNotificationContainer>newArrayList(container), provider);
    assertEquals(currentUserViewSize + 1, project.getContent().getViews().size());
    final ViewNotificationContainer container2 = new ViewNotificationContainer(view.getConfiguration().getId(), Optional.fromNullable(view), Optional.of(project.getConfiguration().getId()), Optional.<INaviModule>absent(), Optional.of(project), "DELETE");
    parser.inform(Lists.<ViewNotificationContainer>newArrayList(container2), provider);
    assertEquals(currentUserViewSize, project.getContent().getViews().size());
}
Also used : MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) PostgreSQLViewNotificationParser(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLViewNotificationParser) ViewNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.ViewNotificationContainer) Test(org.junit.Test)

Aggregations

MockProject (com.google.security.zynamics.binnavi.disassembly.MockProject)10 Test (org.junit.Test)8 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)4 ViewNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.ViewNotificationContainer)4 PostgreSQLViewNotificationParser (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLViewNotificationParser)4 INaviProject (com.google.security.zynamics.binnavi.disassembly.INaviProject)4 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)3 CAddressSpace (com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace)3 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)3 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)3 Date (java.util.Date)3 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)2 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)2 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)2 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)2 Tree (com.google.security.zynamics.zylib.types.trees.Tree)2 Before (org.junit.Before)2 Database (com.google.security.zynamics.binnavi.API.disassembly.Database)1 Module (com.google.security.zynamics.binnavi.API.disassembly.Module)1 Project (com.google.security.zynamics.binnavi.API.disassembly.Project)1