From 206df1bd5741424e3eadd4fcbb38411547a85379 Mon Sep 17 00:00:00 2001 From: Bosanac Dejan Date: Fri, 8 May 2009 10:39:03 +0000 Subject: [PATCH] test case for https://issues.apache.org/activemq/browse/AMQ-2195 git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@772931 13f79535-47bb-0310-9956-ffa450edef68 --- .../transport/tcp/TcpTransportBindTest.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java b/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java index 6db77335f1..33b83eda21 100644 --- a/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java @@ -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 @@ public class TcpTransportBindTest extends EmbeddedBrokerTestSupport { 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 + } + } }