use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule in project binnavi by google.
the class PostgreSQLNotificationParserTest method testGlobalInstructionCommentParsingAppend.
@Test
public void testGlobalInstructionCommentParsingAppend() {
new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
MockPGNotification notification = new MockPGNotification("comment_changes", "bn_instructions UPDATE 1 4608 3333");
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.APPEND, container.getOperation());
assertEquals(new Integer(3333), 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 testFunctionNodeCommentParsingAppendCommentUnknownModule.
@Test
public void testFunctionNodeCommentParsingAppendCommentUnknownModule() {
new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
MockPGNotification notification = new MockPGNotification("comment_changes", "bn_function_nodes UPDATE 2 6666 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 PostgreSQLNotificationParserTest method testGlobalEdgeCommentParsingDeleteLastComment.
@Test
public void testGlobalEdgeCommentParsingDeleteLastComment() {
new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
MockPGNotification notification = new MockPGNotification("comment_changes", "bn_global_edge_comments DELETE 1 1 4608 4614");
Collection<CommentNotification> result = PostgreSQLCommentNotificationParser.processEdgeGlobalCommentNotification(notification, provider);
assertEquals(1, result.size());
final EdgeCommentNotificationContainer container = (EdgeCommentNotificationContainer) Iterables.getFirst(result, null);
final INaviEdge edge = container.getEdge();
assertEquals(1111, edge.getId());
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 testFunctionNodeCommentParsingAppendComment.
@Test
public void testFunctionNodeCommentParsingAppendComment() {
new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
MockPGNotification notification = new MockPGNotification("comment_changes", "bn_function_nodes UPDATE 1 6666 4608 3333");
final CommentNotification result = PostgreSQLCommentNotificationParser.processFunctionNodeCommentNotification(notification, provider);
assertNotNull(result);
final FunctionNodeCommentNotificationContainer container = (FunctionNodeCommentNotificationContainer) result;
final INaviFunction function = container.getNode().getFunction();
assertEquals(new CAddress(4608), function.getAddress());
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 testFunctionNodeCommentParsingCompleteGarbageInput.
@Test
public void testFunctionNodeCommentParsingCompleteGarbageInput() {
new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
// Normal input "bn_function_nodes UPDATE 1 6666 4608 null"
notifications.add(new MockPGNotification("comment_changes", "bn_function_nodes 1 1 1 1 1"));
notifications.add(new MockPGNotification("comment_changes", "bn_function_nodes UPDATE"));
notifications.add(new MockPGNotification("comment_changes", "bn_function_nodes UPDATE 1 "));
notifications.add(new MockPGNotification("comment_changes", "bn_function_nodes"));
notifications.add(new MockPGNotification("comment_changes", "bn_function_nodes 1 FOO FOO FOOO ooqwkepqwpoekpqowkep" + "oqw\\n\\\n\\\n\\\\\\n\\n\n\\n\\\n\\n\\\n\\c\\c\\c\\c" + "ckepokqwpekpqwokepoaksjeofijsoiefjosejfosjoefjsoisje" + "foisjefoisjeofijsoeifjsoeifj"));
for (PGNotification notification : notifications) {
assertNull(PostgreSQLCommentNotificationParser.processFunctionCommentNotification(notification, provider));
}
}
Aggregations