Search in sources :

Example 6 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)

Example 7 with MockProject

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

the class PostgreSQLViewNotificationParserTest method testProjectViewInform0.

@Test
public void testProjectViewInform0() 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());
}
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 8 with MockProject

use of com.google.security.zynamics.binnavi.disassembly.MockProject 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 9 with MockProject

use of com.google.security.zynamics.binnavi.disassembly.MockProject 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)

Example 10 with MockProject

use of com.google.security.zynamics.binnavi.disassembly.MockProject 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)

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