Some testing code as per what Peppo and I were doing

jjp32 [2002-05-21 21:27:25]
Some testing code as per what Peppo and I were doing
Filename
siena/tests/OrderTestSingleJVM.java
diff --git a/siena/tests/OrderTestSingleJVM.java b/siena/tests/OrderTestSingleJVM.java
new file mode 100644
index 0000000..707f2e8
--- /dev/null
+++ b/siena/tests/OrderTestSingleJVM.java
@@ -0,0 +1,58 @@
+package psl.events.siena.tests;
+
+import siena.*;
+
+/**
+ * Ordering test for single JVM, one HD, one publisher, one subscriber.
+ *
+ * @author Janak J Parekh
+ * @version $Revision$
+ */
+public class OrderTestSingleJVM implements Notifiable {
+  public static final int numNotifications = 5000;
+  public long lastReceived = -1;
+
+  public static void main(String[] args) {
+    new OrderTestSingleJVM();
+  }
+
+  /**
+   * CTOR.
+   */
+  public OrderTestSingleJVM() {
+    HierarchicalDispatcher hd = new HierarchicalDispatcher();
+    Filter f = new Filter();
+    try { hd.subscribe(f, this); } catch(Exception e) { e.printStackTrace(); }
+
+    Notification n = null;
+    for(long i = 0; i < 5000; i++) {
+      n = new Notification();
+      n.putAttribute("Count", i);
+      n.putAttribute("Junk", "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.");
+      try { hd.publish(n); } catch(Exception e) { e.printStackTrace(); }
+    }
+    hd.shutdown();
+  }
+
+  /**
+   * Receive mechanism
+   */
+  public void notify(Notification n) {
+    // get the count
+    if(n.getAttribute("Count").longValue() != (++lastReceived)) {
+      System.err.println("FAIL: Received " +
+      n.getAttribute("Count").longValue() + ", was expecting " +
+      (lastReceived - 1));
+      System.exit(-1);
+    }
+    // if a multiple of 100 print
+    if(n.getAttribute("Count").longValue() % 100 == 0) {
+      System.out.println("Received " + n.getAttribute("Count").longValue() +
+      "th event");
+    }
+  }
+
+  public void notify(Notification[] n) { ; }
+
+}
+
\ No newline at end of file