/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.activemq.transport.tcp;

import javax.jms.Connection;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.EmbeddedBrokerTestSupport;

public class TcpTransportBindTest extends EmbeddedBrokerTestSupport {
    final String addr = "tcp://localhost:61617";
    
    /**
     * exercise some server side socket options
     * @throws Exception
     */
    protected void setUp() throws Exception {   
        bindAddress = addr + "?transport.reuseAddress=true&transport.soTimeout=1000";
        super.setUp();
    }
    
    public void testConnect() throws Exception {
        Connection connection = new ActiveMQConnectionFactory(addr).createConnection();
        connection.start();
    }
}

@@ -856,21 +856,160 @@
 java
-x.jms.Connect
+.util.Timer;%0Aimport java.util.TimerTask;%0A%0Aimport javax.jms.Connection;%0Aimport javax.jms.Message;%0Aimport javax.jms.MessageConsumer;%0Aimport javax.jms.Sess
 ion;
@@ -1634,24 +1634,24 @@
 nnection();%0A
-
         conn
@@ -1672,10 +1672,874 @@
 ;%0A    %7D%0A
+    %0A    %0A    public void testReceiveThrowsException() throws Exception %7B%0A        Connection connection = new ActiveMQConnectionFactory(addr).createConnection();%0A        connection.start();%0A        Session sess = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);%0A        MessageConsumer consumer = sess.createConsumer(createDestination());%0A        class StopTask extends TimerTask %7B%0A            public void run() %7B%0A                try %7B%0A                    broker.stop();%0A                %7D catch (Exception e) %7B%0A                    e.printStackTrace();%0A                %7D%0A            %7D%0A        %7D%0A        Timer timer = new Timer();%0A        timer.schedule(new StopTask(), 1000);%0A        try %7B%0A            consumer.receive(30000);%0A            fail(%22Should have thrown an exception%22);%0A        %7D catch (Exception e) %7B%0A            // should fail%0A        %7D%0A    %7D%0A
 %7D%0A

test case for https://issues.apache.org/activemq/browse/AMQ-2195