use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule in project binnavi by google.
the class PostgreSQLNotificationParserTest method testGlobalInstructionCommentParsingDelete.
@Test
public void testGlobalInstructionCommentParsingDelete() {
new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
MockPGNotification notification = new MockPGNotification("comment_changes", "bn_instructions UPDATE 1 4608 null");
final CommentNotification result = PostgreSQLCommentNotificationParser.processInstructionGlobalCommentNotification(notification, provider);
assertNotNull(result);
final InstructionCommentNotificationContainer container = (InstructionCommentNotificationContainer) result;
final INaviInstruction instruction = container.getInstruction();
assertEquals(new CAddress(4608), instruction.getAddress());
assertEquals(CommentOperation.DELETE, container.getOperation());
assertNull(container.getCommentId());
assertEquals(CommentScope.GLOBAL, container.getScope());
}
use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule in project binnavi by google.
the class PostgreSQLNotificationParserTest method testLocalEdgeCommentParsingDelete.
@Test
public void testLocalEdgeCommentParsingDelete() {
new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
MockPGNotification notification = new MockPGNotification("comment_changes", "bn_edges UPDATE 4444 null");
final CommentNotification result = PostgreSQLCommentNotificationParser.processEdgeLocalCommentNotification(notification, provider);
assertNotNull(result);
final EdgeCommentNotificationContainer container = (EdgeCommentNotificationContainer) result;
final INaviEdge edge = container.getEdge();
assertEquals(4444, edge.getId());
assertEquals(CommentOperation.DELETE, container.getOperation());
assertNull(container.getCommentId());
assertEquals(CommentScope.LOCAL, container.getScope());
}
use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule in project binnavi by google.
the class PostgreSQLNotificationParserTest method testTypeInstanceCommentParsingAppendComment.
@Test
public void testTypeInstanceCommentParsingAppendComment() throws CouldntSaveDataException, CouldntLoadDataException {
final INaviModule module = new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
module.getContent().getSections().createSection("A", new CAddress(0), new CAddress(1234), SectionPermission.READ, null);
final TypeInstance fakeInstance = module.getContent().getTypeInstanceContainer().createInstance("TYPE INSTANCE", null, module.getTypeManager().getTypes().get(0), module.getContent().getSections().getSection(0), 0);
MockPGNotification notification = new MockPGNotification("comment_changes", "bn_type_instances UPDATE 1 " + fakeInstance.getId() + " 3333");
final CommentNotification result = PostgreSQLCommentNotificationParser.processTypeInstanceCommentNotification(notification, provider);
assertNotNull(result);
final TypeInstanceCommentNotificationContainer container = (TypeInstanceCommentNotificationContainer) result;
assertNotNull(container);
final TypeInstance instance = container.getInstance();
assertEquals(fakeInstance.getId(), instance.getId());
assertEquals(CommentOperation.APPEND, container.getOperation());
assertEquals(new Integer(3333), container.getCommentId());
}
use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule in project binnavi by google.
the class PostgreSQLNotificationParserTest method testFunctionNodeCommentParsingAppendCommentUnknownNodeId.
@Test
public void testFunctionNodeCommentParsingAppendCommentUnknownNodeId() {
new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
MockPGNotification notification = new MockPGNotification("comment_changes", "bn_function_nodes UPDATE 1 6667 4608 3333");
final CommentNotification result = PostgreSQLCommentNotificationParser.processFunctionNodeCommentNotification(notification, provider);
assertNull(result);
}
use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule in project binnavi by google.
the class ModuleHelpersTest method testGetFunction_2.
@Test
public void testGetFunction_2() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
final Database database = new Database(new MockDatabase());
final MockModule mockModule = new MockModule();
final MockSqlProvider provider = new MockSqlProvider();
final CModule internalModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, provider);
final CFunction parentFunction = new CFunction(internalModule, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, provider);
CFunctionContainerHelper.addFunction(mockModule.getContent().getFunctionContainer(), parentFunction);
final TagManager nodeTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.NODE_TAG));
final TagManager viewTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.VIEW_TAG));
final Module module = new Module(database, mockModule, nodeTagManager, viewTagManager);
assertEquals(module.getFunctions().get(0), ModuleHelpers.getFunction(module, new Address(0x123)));
assertNull(ModuleHelpers.getFunction(module, new Address(0x1235)));
try {
ModuleHelpers.getFunction(null, (Address) null);
fail();
} catch (final NullPointerException e) {
}
try {
ModuleHelpers.getFunction(module, (Address) null);
fail();
} catch (final NullPointerException e) {
}
}
Aggregations