[jboss-cvs] JBoss Messaging SVN: r7922 - branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Dec 18 05:54:12 EST 2009
Author: gaohoward
Date: 2009-12-18 05:54:12 -0500 (Fri, 18 Dec 2009)
New Revision: 7922
Modified:
branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/ConnectionTest.java
Log:
JBMESSAGING-1776
Modified: branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/ConnectionTest.java
===================================================================
--- branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/ConnectionTest.java 2009-12-17 04:26:49 UTC (rev 7921)
+++ branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/ConnectionTest.java 2009-12-18 10:54:12 UTC (rev 7922)
@@ -39,6 +39,7 @@
import org.jboss.jms.tx.ResourceManager;
import org.jboss.jms.tx.ResourceManagerFactory;
import org.jboss.logging.Logger;
+import org.jboss.test.messaging.tools.ServerManagement;
/**
@@ -356,6 +357,75 @@
conn.close();
}
+
+ /**
+ * setExceptionListener should throw exception when
+ * the connection is bad.
+ */
+ public void testExceptionListener2() throws Exception
+ {
+ Connection conn1 = null;
+ Connection conn2 = null;
+
+ try
+ {
+ MyExceptionListener listener1 = new MyExceptionListener();
+ MyExceptionListener listener2 = new MyExceptionListener();
+
+ conn1 = cf.createConnection();
+ conn2 = cf.createConnection();
+
+ conn1.setExceptionListener(listener1);
+
+ //kill the server
+ ServerManagement.kill(0);
+
+ while (listener1.exceptionReceived == null)
+ {
+ try
+ {
+ log.info("sleeping");
+ Thread.sleep(1000);
+ }
+ catch (InterruptedException e)
+ {
+ //ignore
+ }
+ }
+
+ //sleep 5 more sec to make sure conn2's listener having been called
+ try
+ {
+ log.info("sleeping");
+ Thread.sleep(5000);
+ }
+ catch (InterruptedException e)
+ {
+ //ignore
+ }
+
+ //should throw exception
+ log.debug("------------------------seting listener 2");
+ conn2.setExceptionListener(listener2);
+ log.debug("--------------------listener 2 set");
+
+ listener2.waitForException(5000);
+
+ assertNotNull(listener2.exceptionReceived);
+
+ }
+ finally
+ {
+ if (conn1 != null)
+ {
+ conn1.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
+ }
/*
* See http://jira.jboss.com/jira/browse/JBMESSAGING-635
@@ -424,10 +494,27 @@
{
JMSException exceptionReceived;
- public void onException(JMSException exception)
+ public synchronized void onException(JMSException exception)
{
this.exceptionReceived = exception;
log.trace("Received exception");
+ System.err.println(this + "--------------------------exception got: " + exceptionReceived);
+ notify();
}
+
+ public synchronized void waitForException(long i)
+ {
+ if (exceptionReceived == null)
+ {
+ try
+ {
+ wait(i);
+ }
+ catch(InterruptedException e)
+ {
+ //ignore
+ }
+ }
+ }
}
}
More information about the jboss-cvs-commits
mailing list