public void testFilteredNotification() throws Exception {
try (PGConnection conn = (PGConnection) TestUtil.openDB()) {
final AtomicBoolean validFlag = new AtomicBoolean(false);
PGNotificationListener validNotificationListener = new PGNotificationListener() {
@Override
public void notification(int processId, String channelName, String payload) {
validFlag.set(true);
}
};
conn.addNotificationListener("1.*", validNotificationListener);
final AtomicBoolean invalidFlag = new AtomicBoolean(false);
PGNotificationListener invalidNotificationListener = new PGNotificationListener() {
@Override
public void notification(int processId, String channelName, String payload) {
invalidFlag.set(true);
}
};
conn.addNotificationListener("2.*", invalidNotificationListener);
final AtomicBoolean allFlag = new AtomicBoolean(false);
PGNotificationListener allNotificationListener = new PGNotificationListener() {
@Override
public void notification(int processId, String channelName, String payload) {
allFlag.set(true);
}