activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r772931 - /activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java
Date Fri, 08 May 2009 10:38:56 GMT
Author: dejanb
Date: Fri May  8 10:38:55 2009
New Revision: 772931

URL: http://svn.apache.org/viewvc?rev=772931&view=rev
Log:
test case for https://issues.apache.org/activemq/browse/AMQ-2195

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java?rev=772931&r1=772930&r2=772931&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java
Fri May  8 10:38:55 2009
@@ -16,7 +16,13 @@
  */
 package org.apache.activemq.transport.tcp;
 
+import java.util.Timer;
+import java.util.TimerTask;
+
 import javax.jms.Connection;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.Session;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.EmbeddedBrokerTestSupport;
@@ -37,4 +43,29 @@
         Connection connection = new ActiveMQConnectionFactory(addr).createConnection();
         connection.start();
     }
+    
+    
+    public void testReceiveThrowsException() throws Exception {
+        Connection connection = new ActiveMQConnectionFactory(addr).createConnection();
+        connection.start();
+        Session sess = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        MessageConsumer consumer = sess.createConsumer(createDestination());
+        class StopTask extends TimerTask {
+            public void run() {
+                try {
+                    broker.stop();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        Timer timer = new Timer();
+        timer.schedule(new StopTask(), 1000);
+        try {
+            consumer.receive(30000);
+            fail("Should have thrown an exception");
+        } catch (Exception e) {
+            // should fail
+        }
+    }
 }



Mime
View raw message