// Path: hawtjms-test-support/src/main/java/io/hawtjms/test/support/AmqpTestSupport.java
// public class AmqpTestSupport extends HawtJmsTestSupport {
// 
//     protected static final Logger LOG = LoggerFactory.getLogger(AmqpTestSupport.class);
// 
//     protected boolean isAmqpDiscovery() {
//         return false;
//     }
// 
//     protected String getAmqpTransformer() {
//         return "jms";
//     }
// 
//     protected int getSocketBufferSize() {
//         return 64 * 1024;
//     }
// 
//     protected int getIOBufferSize() {
//         return 8 * 1024;
//     }
// 
//     @Override
//     protected void addAdditionalConnectors(BrokerService brokerService, Map<String, Integer> portMap) throws Exception {
//         int port = 0;
//         if (portMap.containsKey("amqp")) {
//             port = portMap.get("amqp");
//         }
//         TransportConnector connector = brokerService.addConnector(
//             "amqp://0.0.0.0:" + port + "?transport.transformer=" + getAmqpTransformer() +
//             "&transport.socketBufferSize=" + getSocketBufferSize() + "&ioBufferSize=" + getIOBufferSize());
//         connector.setName("amqp");
//         if (isAmqpDiscovery()) {
//             connector.setDiscoveryUri(new URI("multicast://default"));
//         }
//         port = connector.getPublishableConnectURI().getPort();
//         LOG.debug("Using amqp port: {}", port);
//     }
// 
//     public String getAmqpConnectionURIOptions() {
//         return "";
//     }
// 
//     public URI getBrokerAmqpConnectionURI() {
//         try {
//             String uri = "amqp://127.0.0.1:" +
//                 brokerService.getTransportConnectorByName("amqp").getPublishableConnectURI().getPort();
// 
//             if (!getAmqpConnectionURIOptions().isEmpty()) {
//                 uri = uri + "?" + getAmqpConnectionURIOptions();
//             }
// 
//             return new URI(uri);
//         } catch (Exception e) {
//             throw new RuntimeException();
//         }
//     }
// 
//     public String getAmqpFailoverURI() throws Exception {
//         StringBuilder uri = new StringBuilder();
//         uri.append("failover://(");
//         uri.append(brokerService.getTransportConnectorByName("amqp").getPublishableConnectString());
// 
//         for (BrokerService broker : brokers) {
//             uri.append(",");
//             uri.append(broker.getTransportConnectorByName("amqp").getPublishableConnectString());
//         }
// 
//         uri.append(")");
// 
//         return uri.toString();
//     }
// 
//     public Connection createAmqpConnection() throws Exception {
//         return createAmqpConnection(getBrokerAmqpConnectionURI());
//     }
// 
//     public Connection createAmqpConnection(String username, String password) throws Exception {
//         return createAmqpConnection(getBrokerAmqpConnectionURI(), username, password);
//     }
// 
//     public Connection createAmqpConnection(URI brokerURI) throws Exception {
//         return createAmqpConnection(brokerURI, null, null);
//     }
// 
//     public Connection createAmqpConnection(URI brokerURI, String username, String password) throws Exception {
//         ConnectionFactory factory = createAmqpConnectionFactory(brokerURI, username, password);
//         return factory.createConnection();
//     }
// 
//     public ConnectionFactory createAmqpConnectionFactory() throws Exception {
//         return createAmqpConnectionFactory(getBrokerAmqpConnectionURI(), null, null);
//     }
// 
//     public ConnectionFactory createAmqpConnectionFactory(URI brokerURI) throws Exception {
//         return createAmqpConnectionFactory(brokerURI, null, null);
//     }
// 
//     public ConnectionFactory createAmqpConnectionFactory(String username, String password) throws Exception {
//         return createAmqpConnectionFactory(getBrokerAmqpConnectionURI(), username, password);
//     }
// 
//     public ConnectionFactory createAmqpConnectionFactory(URI brokerURI, String username, String password) throws Exception {
//         JmsConnectionFactory factory = new JmsConnectionFactory(brokerURI);
//         factory.setForceAsyncSend(isForceAsyncSends());
//         factory.setAlwaysSyncSend(isAlwaysSyncSend());
//         factory.setMessagePrioritySupported(isMessagePrioritySupported());
//         factory.setSendAcksAsync(isSendAcksAsync());
//         if (username != null) {
//             factory.setUsername(username);
//         }
//         if (password != null) {
//             factory.setPassword(password);
//         }
//         return factory;
//     }
// }


import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import io.hawtjms.jms.JmsConnection;
import io.hawtjms.provider.BlockingProvider;
import io.hawtjms.test.support.AmqpTestSupport;
import io.hawtjms.test.support.Wait;
import java.net.URI;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.jms.Connection;
import javax.jms.Message;
        Queue queue = session.createQueue(name.getMethodName());
        MessageConsumer consumer = session.createConsumer(queue);

        stopPrimaryBroker();
        consumer.close();
        connection.close();
    }

    @SuppressWarnings("unused")
    @Test(timeout=60000)
    public void testSessionCloseWithOpenResourcesDoesNotBlock() throws Exception {
        URI brokerURI = new URI(getAmqpFailoverURI());
        Connection connection = createAmqpConnection(brokerURI);
        connection.start();

        Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
        Queue queue = session.createQueue(name.getMethodName());
        MessageConsumer consumer = session.createConsumer(queue);
        MessageProducer producer = session.createProducer(queue);

        stopPrimaryBroker();
        session.close();
        connection.close();
    }

    @Test(timeout=60000)
    public void testGetRemoteURI() throws Exception {

        startNewBroker();

// Path: hawtjms-test-support/src/main/java/io/hawtjms/test/support/AmqpTestSupport.java
// public class AmqpTestSupport extends HawtJmsTestSupport {
// 
//     protected static final Logger LOG = LoggerFactory.getLogger(AmqpTestSupport.class);
// 
//     protected boolean isAmqpDiscovery() {
//         return false;
//     }
// 
//     protected String getAmqpTransformer() {
//         return "jms";
//     }
// 
//     protected int getSocketBufferSize() {
//         return 64 * 1024;
//     }
// 
//     protected int getIOBufferSize() {
//         return 8 * 1024;
//     }
// 
//     @Override
//     protected void addAdditionalConnectors(BrokerService brokerService, Map<String, Integer> portMap) throws Exception {
//         int port = 0;
//         if (portMap.containsKey("amqp")) {
//             port = portMap.get("amqp");
//         }
//         TransportConnector connector = brokerService.addConnector(
//             "amqp://0.0.0.0:" + port + "?transport.transformer=" + getAmqpTransformer() +
//             "&transport.socketBufferSize=" + getSocketBufferSize() + "&ioBufferSize=" + getIOBufferSize());
//         connector.setName("amqp");
//         if (isAmqpDiscovery()) {
//             connector.setDiscoveryUri(new URI("multicast://default"));
//         }
//         port = connector.getPublishableConnectURI().getPort();
//         LOG.debug("Using amqp port: {}", port);
//     }
// 
//     public String getAmqpConnectionURIOptions() {
//         return "";
//     }
// 
//     public URI getBrokerAmqpConnectionURI() {
//         try {
//             String uri = "amqp://127.0.0.1:" +
//                 brokerService.getTransportConnectorByName("amqp").getPublishableConnectURI().getPort();
// 
//             if (!getAmqpConnectionURIOptions().isEmpty()) {
//                 uri = uri + "?" + getAmqpConnectionURIOptions();
//             }
// 
//             return new URI(uri);
//         } catch (Exception e) {
//             throw new RuntimeException();
//         }
//     }
// 
//     public String getAmqpFailoverURI() throws Exception {
//         StringBuilder uri = new StringBuilder();
//         uri.append("failover://(");
//         uri.append(brokerService.getTransportConnectorByName("amqp").getPublishableConnectString());
// 
//         for (BrokerService broker : brokers) {
//             uri.append(",");
//             uri.append(broker.getTransportConnectorByName("amqp").getPublishableConnectString());
//         }
// 
//         uri.append(")");
// 
//         return uri.toString();
//     }
// 
//     public Connection createAmqpConnection() throws Exception {
//         return createAmqpConnection(getBrokerAmqpConnectionURI());
//     }
// 
//     public Connection createAmqpConnection(String username, String password) throws Exception {
//         return createAmqpConnection(getBrokerAmqpConnectionURI(), username, password);
//     }
// 
//     public Connection createAmqpConnection(URI brokerURI) throws Exception {
//         return createAmqpConnection(brokerURI, null, null);
//     }
// 
//     public Connection createAmqpConnection(URI brokerURI, String username, String password) throws Exception {
//         ConnectionFactory factory = createAmqpConnectionFactory(brokerURI, username, password);
//         return factory.createConnection();
//     }
// 
//     public ConnectionFactory createAmqpConnectionFactory() throws Exception {
//         return createAmqpConnectionFactory(getBrokerAmqpConnectionURI(), null, null);
//     }
// 
//     public ConnectionFactory createAmqpConnectionFactory(URI brokerURI) throws Exception {
//         return createAmqpConnectionFactory(brokerURI, null, null);
//     }
// 
//     public ConnectionFactory createAmqpConnectionFactory(String username, String password) throws Exception {
//         return createAmqpConnectionFactory(getBrokerAmqpConnectionURI(), username, password);
//     }
// 
//     public ConnectionFactory createAmqpConnectionFactory(URI brokerURI, String username, String password) throws Exception {
//         JmsConnectionFactory factory = new JmsConnectionFactory(brokerURI);
//         factory.setForceAsyncSend(isForceAsyncSends());
//         factory.setAlwaysSyncSend(isAlwaysSyncSend());
//         factory.setMessagePrioritySupported(isMessagePrioritySupported());
//         factory.setSendAcksAsync(isSendAcksAsync());
//         if (username != null) {
//             factory.setUsername(username);
//         }
//         if (password != null) {
//             factory.setPassword(password);
//         }
//         return factory;
//     }
// }


// Path: hawtjms-tests/src/test/java/io/hawtjms/tests/failover/JmsOfflineBehaviorTests.java
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import io.hawtjms.jms.JmsConnection;
import io.hawtjms.provider.BlockingProvider;
import io.hawtjms.test.support.AmqpTestSupport;
import io.hawtjms.test.support.Wait;
import java.net.URI;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.jms.Connection;
import javax.jms.Message;

        Queue queue = session.createQueue(name.getMethodName());
        MessageConsumer consumer = session.createConsumer(queue);

        stopPrimaryBroker();
        consumer.close();
        connection.close();
    }

    @SuppressWarnings("unused")
    @Test(timeout=60000)
    public void testSessionCloseWithOpenResourcesDoesNotBlock() throws Exception {
        URI brokerURI = new URI(getAmqpFailoverURI());
        Connection connection = createAmqpConnection(brokerURI);
        connection.start();

        Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
        Queue queue = session.createQueue(name.getMethodName());
        MessageConsumer consumer = session.createConsumer(queue);
        MessageProducer producer = session.createProducer(queue);

        stopPrimaryBroker();
        session.close();
        connection.close();
    }

    @Test(timeout=60000)
    public void testGetRemoteURI() throws Exception {

        startNewBroker();

        URI brokerURI = new URI(getAmqpFailoverURI() + "randomize=false");