/*
 *
 * 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.qpid.jms.integration;

import static org.junit.Assert.assertNull;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;

import org.apache.qpid.jms.JmsConnectionFactory;
import org.apache.qpid.jms.test.QpidJmsTestCase;
import org.apache.qpid.jms.test.testpeer.TestAmqpPeer;
import org.junit.Test;

public class SaslIntegrationTest extends QpidJmsTestCase {

    @Test(timeout = 5000)
    public void testSaslExternalConnection() throws Exception {
        try (TestAmqpPeer testPeer = new TestAmqpPeer();) {

            // Expect an EXTERNAL connection
            testPeer.expectExternalConnect();
            // Each connection creates a session for managing temporary destinations etc
            testPeer.expectBegin(true);

            ConnectionFactory factory = new JmsConnectionFactory("amqp://localhost:" + testPeer.getServerPort());
            Connection connection = factory.createConnection();
            // Set a clientID to provoke the actual AMQP connection process to occur.
            connection.setClientID("clientName");

            testPeer.waitForAllHandlersToComplete(1000);
            assertNull(testPeer.getThrowable());

            testPeer.expectClose();
            connection.close();
        }
    }
}

@@ -1986,24 +1986,1822 @@
 owable());%0A%0A
+            testPeer.expectClose();%0A            connection.close();%0A        %7D%0A    %7D%0A%0A    @Test(timeout = 5000)%0A    public void testSaslPlainConnection() throws Exception %7B%0A        try (TestAmqpPeer testPeer = new TestAmqpPeer();) %7B%0A%0A            // Expect a PLAIN connection%0A            testPeer.expectPlainConnect(%22guest%22, %22guest%22, null, null);%0A            // Each connection creates a session for managing temporary destinations etc%0A            testPeer.expectBegin(true);%0A%0A            ConnectionFactory factory = new JmsConnectionFactory(%22amqp://localhost:%22 + testPeer.getServerPort());%0A            Connection connection = factory.createConnection(%22guest%22, %22guest%22);%0A            // Set a clientID to provoke the actual AMQP connection process to occur.%0A            connection.setClientID(%22clientName%22);%0A%0A            testPeer.waitForAllHandlersToComplete(1000);%0A            assertNull(testPeer.getThrowable());%0A%0A            testPeer.expectClose();%0A            connection.close();%0A        %7D%0A    %7D%0A%0A    @Test(timeout = 5000)%0A    public void testSaslAnonymousConnection() throws Exception %7B%0A        try (TestAmqpPeer testPeer = new TestAmqpPeer();) %7B%0A%0A            // Expect an ANOYMOUS connection%0A            testPeer.expectAnonymousConnect(true);%0A            // Each connection creates a session for managing temporary destinations etc%0A            testPeer.expectBegin(true);%0A%0A            ConnectionFactory factory = new JmsConnectionFactory(%22amqp://localhost:%22 + testPeer.getServerPort());%0A            Connection connection = factory.createConnection();%0A            // Set a clientID to provoke the actual AMQP connection process to occur.%0A            connection.setClientID(%22clientName%22);%0A%0A            testPeer.waitForAllHandlersToComplete(1000);%0A            assertNull(testPeer.getThrowable());%0A%0A
             

add some tests using ANONYMOUS and PLAIN explicitly