/**
 * 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.hawtjms.provider.discovery;

import static org.junit.Assert.assertNotNull;
import io.hawtjms.provider.DefaultBlockingProvider;
import io.hawtjms.provider.DefaultProviderListener;
import io.hawtjms.provider.discovery.DiscoveryProviderFactory;

import java.net.URI;

import org.hawtjms.util.AmqpTestSupport;
import org.junit.Test;

/**
 * Test basic discovery of remote brokers
 */
public class JmsDiscoveryProviderTest extends AmqpTestSupport {

    @Override
    protected boolean isAmqpDiscovery() {
        return true;
    }

    @Test(timeout=30000)
    public void testCreateDiscvoeryProvider() throws Exception {
        URI discoveryUri = new URI("discovery:multicast://default");
        DefaultBlockingProvider blocking = (DefaultBlockingProvider)
            DiscoveryProviderFactory.createBlocking(discoveryUri);
        assertNotNull(blocking);

        DefaultProviderListener listener = new DefaultProviderListener();
        blocking.setProviderListener(listener);
        blocking.start();
        blocking.close();
    }

    @Test(timeout=30000, expected=IllegalStateException.class)
    public void testStartFailsWithNoListener() throws Exception {
        URI discoveryUri = new URI("discovery:multicast://default");
        DefaultBlockingProvider blocking = (DefaultBlockingProvider)
            DiscoveryProviderFactory.createBlocking(discoveryUri);
        assertNotNull(blocking);
        blocking.start();
        blocking.close();
    }
}

@@ -1048,24 +1048,52 @@
 erFactory;%0A%0A
+import java.io.IOException;%0A
 import java.
@@ -2300,11 +2300,369 @@
 );%0A    %7D
+%0A%0A    @Test(timeout=30000, expected=IOException.class)%0A    public void testCreateFailsWithUnknownAgent() throws Exception %7B%0A        URI discoveryUri = new URI(%22discovery:unknown://default%22);%0A        DefaultBlockingProvider blocking = (DefaultBlockingProvider)%0A            DiscoveryProviderFactory.createBlocking(discoveryUri);%0A        blocking.close();%0A    %7D
 %0A%7D%0A

Add new test