switch (c)
{
case 'A': // Asynchronous Notify
- int pid = stream.ReceiveInteger(4);
+ int msglen = stream.ReceiveIntegerR(4);
+ int pid = stream.ReceiveIntegerR(4);
String msg = stream.ReceiveString(conn.getEncoding());
+ String param = stream.ReceiveString(conn.getEncoding());
conn.addNotification(new org.postgresql.core.Notification(msg, pid));
break;
//------------------------------
{
case 'A': // Asynchronous Notify
//TODO: do something with this
- int pid = stream.ReceiveInteger(4);
+ int pid = stream.ReceiveIntegerR(4);
String msg = stream.ReceiveString(conn.getEncoding());
+ conn.addNotification(new org.postgresql.core.Notification(msg, pid));
break;
//------------------------------
// features some applications require.
suite.addTestSuite(JBuilderTest.class);
suite.addTestSuite(MiscTest.class);
+ suite.addTestSuite(NotifyTest.class);
// Fastpath/LargeObject
suite.addTestSuite(BlobTest.class);
--- /dev/null
+package org.postgresql.test.jdbc2;
+
+import org.postgresql.test.TestUtil;
+import junit.framework.TestCase;
+import java.sql.*;
+
+import org.postgresql.PGConnection;
+import org.postgresql.PGNotification;
+
+public class NotifyTest extends TestCase
+{
+
+ private Connection conn;
+
+ public NotifyTest(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws SQLException
+ {
+ conn = TestUtil.openDB();
+ }
+
+ protected void tearDown() throws SQLException
+ {
+ TestUtil.closeDB(conn);
+ }
+
+ public void testNotify() throws SQLException
+ {
+ Statement stmt = conn.createStatement();
+ stmt.executeUpdate("LISTEN mynotification");
+ stmt.executeUpdate("NOTIFY mynotification");
+
+ PGNotification notifications[] = ((org.postgresql.PGConnection)conn).getNotifications();
+ assertNotNull(notifications);
+ assertEquals(notifications.length, 1);
+ assertEquals(notifications[0].getName(), "mynotification");
+
+ stmt.close();
+ }
+}