git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@772931 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bosanac Dejan 2009-05-08 10:39:03 +00:00
parent 01e2aec7b5
commit 206df1bd57
1 changed files with 31 additions and 0 deletions

View File

@ -16,7 +16,13 @@
*/ */
package org.apache.activemq.transport.tcp; package org.apache.activemq.transport.tcp;
import java.util.Timer;
import java.util.TimerTask;
import javax.jms.Connection; 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.ActiveMQConnectionFactory;
import org.apache.activemq.EmbeddedBrokerTestSupport; import org.apache.activemq.EmbeddedBrokerTestSupport;
@ -37,4 +43,29 @@ public class TcpTransportBindTest extends EmbeddedBrokerTestSupport {
Connection connection = new ActiveMQConnectionFactory(addr).createConnection(); Connection connection = new ActiveMQConnectionFactory(addr).createConnection();
connection.start(); 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
}
}
} }