use of org.postgresql.PGNotification 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));
}
}
use of org.postgresql.PGNotification in project binnavi by google.
the class PostgreSQLFunctionNotificationParser method parse.
@Override
public Collection<FunctionNotificationContainer> parse(final Collection<PGNotification> notifications, final SQLProvider provider) {
Preconditions.checkNotNull(notifications, "IE02629: notifications argument can not be null");
Preconditions.checkNotNull(provider, "IE02630: provider argument can not be null");
final Collection<FunctionNotificationContainer> containers = new ArrayList<FunctionNotificationContainer>();
for (final PGNotification notification : notifications) {
if (notification.getParameter().startsWith(CTableNames.FUNCTIONS_TABLE)) {
containers.add(parseFunctionNotification(notification, provider));
} else {
throw new IllegalStateException("IE02738: Table name supplied in notification: " + notification.getParameter() + " does not match tables where function notifications are accepted on.");
}
}
return containers;
}
Aggregations