mirror of https://github.com/apache/activemq.git
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@772931 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
01e2aec7b5
commit
206df1bd57
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue