https://issues.apache.org/jira/browse/AMQ-2981 - test case for discory uri with params

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1075407 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bosanac Dejan 2011-02-28 16:19:26 +00:00
parent 99653c6c8c
commit 5ad72d650c
1 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,54 @@
/**
* 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.discovery;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.EmbeddedBrokerTestSupport;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.TransportConnector;
import javax.jms.*;
import java.net.URI;
public class DiscoveryUriTest extends EmbeddedBrokerTestSupport {
@Override
protected BrokerService createBroker() throws Exception {
bindAddress = "tcp://localhost:0";
BrokerService answer = new BrokerService();
answer.setPersistent(isPersistent());
TransportConnector connector = new TransportConnector();
connector.setUri(new URI(bindAddress));
connector.setDiscoveryUri(new URI("multicast://default?group=test"));
answer.addConnector(connector);
return answer;
}
public void testConnect() throws Exception {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("discovery:(multicast://default?group=test)?reconnectDelay=1000&maxReconnectAttempts=30&useExponentialBackOff=false");
Connection conn = factory.createConnection();
conn.start();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = sess.createProducer(sess.createQueue("test"));
producer.send(sess.createTextMessage("test"));
MessageConsumer consumer = sess.createConsumer(sess.createQueue("test"));
Message msg = consumer.receive(1000);
assertNotNull(msg);
}
}