ARTEMIS-1093 Moving FQQN methods into CompositeAddress
This commit is contained in:
parent
f344c1ebaf
commit
23b3d2182c
|
@ -20,6 +20,14 @@ import org.apache.activemq.artemis.api.core.SimpleString;
|
||||||
|
|
||||||
public class CompositeAddress {
|
public class CompositeAddress {
|
||||||
|
|
||||||
|
public static SimpleString toFullQN(SimpleString address, SimpleString qName) {
|
||||||
|
return address.concat(SEPARATOR).concat(qName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toFullQN(String address, String qName) {
|
||||||
|
return address + SEPARATOR + qName;
|
||||||
|
}
|
||||||
|
|
||||||
public static String SEPARATOR = "::";
|
public static String SEPARATOR = "::";
|
||||||
private final String address;
|
private final String address;
|
||||||
private final String queueName;
|
private final String queueName;
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.apache.activemq.artemis.core.postoffice.Bindings;
|
||||||
import org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding;
|
import org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding;
|
||||||
import org.apache.activemq.artemis.core.server.QueueQueryResult;
|
import org.apache.activemq.artemis.core.server.QueueQueryResult;
|
||||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||||
import org.apache.activemq.artemis.tests.util.FQQN;
|
import org.apache.activemq.artemis.utils.CompositeAddress;
|
||||||
import org.apache.qpid.jms.JmsConnectionFactory;
|
import org.apache.qpid.jms.JmsConnectionFactory;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -122,9 +122,9 @@ public class ProtonFullQualifiedNameTest extends ProtonTestBase {
|
||||||
System.out.println("checking binidng " + b.getUniqueName() + " " + ((LocalQueueBinding)b).getQueue().getDeliveringMessages());
|
System.out.println("checking binidng " + b.getUniqueName() + " " + ((LocalQueueBinding)b).getQueue().getDeliveringMessages());
|
||||||
SimpleString qName = b.getUniqueName();
|
SimpleString qName = b.getUniqueName();
|
||||||
//do FQQN query
|
//do FQQN query
|
||||||
QueueQueryResult result = server.queueQuery(FQQN.toFullQN(multicastAddress, qName));
|
QueueQueryResult result = server.queueQuery(CompositeAddress.toFullQN(multicastAddress, qName));
|
||||||
assertTrue(result.isExists());
|
assertTrue(result.isExists());
|
||||||
assertEquals(result.getName(), FQQN.toFullQN(multicastAddress, qName));
|
assertEquals(result.getName(), CompositeAddress.toFullQN(multicastAddress, qName));
|
||||||
//do qname query
|
//do qname query
|
||||||
result = server.queueQuery(qName);
|
result = server.queueQuery(qName);
|
||||||
assertTrue(result.isExists());
|
assertTrue(result.isExists());
|
||||||
|
@ -146,9 +146,9 @@ public class ProtonFullQualifiedNameTest extends ProtonTestBase {
|
||||||
connection.start();
|
connection.start();
|
||||||
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||||
|
|
||||||
Queue q1 = session.createQueue(FQQN.toFullQN(anycastAddress, anycastQ1).toString());
|
Queue q1 = session.createQueue(CompositeAddress.toFullQN(anycastAddress, anycastQ1).toString());
|
||||||
Queue q2 = session.createQueue(FQQN.toFullQN(anycastAddress, anycastQ2).toString());
|
Queue q2 = session.createQueue(CompositeAddress.toFullQN(anycastAddress, anycastQ2).toString());
|
||||||
Queue q3 = session.createQueue(FQQN.toFullQN(anycastAddress, anycastQ3).toString());
|
Queue q3 = session.createQueue(CompositeAddress.toFullQN(anycastAddress, anycastQ3).toString());
|
||||||
|
|
||||||
//send 3 messages to anycastAddress
|
//send 3 messages to anycastAddress
|
||||||
ClientSessionFactory cf = createSessionFactory(locator);
|
ClientSessionFactory cf = createSessionFactory(locator);
|
||||||
|
@ -171,10 +171,10 @@ public class ProtonFullQualifiedNameTest extends ProtonTestBase {
|
||||||
//queues are empty now
|
//queues are empty now
|
||||||
for (SimpleString q : new SimpleString[]{anycastQ1, anycastQ2, anycastQ3}) {
|
for (SimpleString q : new SimpleString[]{anycastQ1, anycastQ2, anycastQ3}) {
|
||||||
//FQQN query
|
//FQQN query
|
||||||
QueueQueryResult query = server.queueQuery(FQQN.toFullQN(anycastAddress, q));
|
QueueQueryResult query = server.queueQuery(CompositeAddress.toFullQN(anycastAddress, q));
|
||||||
assertTrue(query.isExists());
|
assertTrue(query.isExists());
|
||||||
assertEquals(anycastAddress, query.getAddress());
|
assertEquals(anycastAddress, query.getAddress());
|
||||||
assertEquals(FQQN.toFullQN(anycastAddress, q), query.getName());
|
assertEquals(CompositeAddress.toFullQN(anycastAddress, q), query.getName());
|
||||||
assertEquals(0, query.getMessageCount());
|
assertEquals(0, query.getMessageCount());
|
||||||
//try query again using qName
|
//try query again using qName
|
||||||
query = server.queueQuery(q);
|
query = server.queueQuery(q);
|
||||||
|
@ -195,7 +195,7 @@ public class ProtonFullQualifiedNameTest extends ProtonTestBase {
|
||||||
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||||
|
|
||||||
//::queue ok!
|
//::queue ok!
|
||||||
String specialName = FQQN.toFullQN(new SimpleString(""), anycastQ1).toString();
|
String specialName = CompositeAddress.toFullQN(new SimpleString(""), anycastQ1).toString();
|
||||||
Queue q1 = session.createQueue(specialName);
|
Queue q1 = session.createQueue(specialName);
|
||||||
|
|
||||||
ClientSessionFactory cf = createSessionFactory(locator);
|
ClientSessionFactory cf = createSessionFactory(locator);
|
||||||
|
@ -210,7 +210,7 @@ public class ProtonFullQualifiedNameTest extends ProtonTestBase {
|
||||||
assertNotNull(consumer1.receive(2000));
|
assertNotNull(consumer1.receive(2000));
|
||||||
|
|
||||||
//queue::
|
//queue::
|
||||||
specialName = FQQN.toFullQN(anycastQ1, new SimpleString("")).toString();
|
specialName = CompositeAddress.toFullQN(anycastQ1, new SimpleString("")).toString();
|
||||||
q1 = session.createQueue(specialName);
|
q1 = session.createQueue(specialName);
|
||||||
try {
|
try {
|
||||||
session.createConsumer(q1);
|
session.createConsumer(q1);
|
||||||
|
@ -220,7 +220,7 @@ public class ProtonFullQualifiedNameTest extends ProtonTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
//::
|
//::
|
||||||
specialName = FQQN.toFullQN(new SimpleString(""), new SimpleString("")).toString();
|
specialName = CompositeAddress.toFullQN(new SimpleString(""), new SimpleString("")).toString();
|
||||||
q1 = session.createQueue(specialName);
|
q1 = session.createQueue(specialName);
|
||||||
try {
|
try {
|
||||||
session.createConsumer(q1);
|
session.createConsumer(q1);
|
||||||
|
|
|
@ -39,7 +39,6 @@ import org.apache.activemq.artemis.core.postoffice.Binding;
|
||||||
import org.apache.activemq.artemis.core.postoffice.Bindings;
|
import org.apache.activemq.artemis.core.postoffice.Bindings;
|
||||||
import org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding;
|
import org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding;
|
||||||
import org.apache.activemq.artemis.core.server.QueueQueryResult;
|
import org.apache.activemq.artemis.core.server.QueueQueryResult;
|
||||||
import org.apache.activemq.artemis.tests.util.FQQN;
|
|
||||||
import org.apache.activemq.artemis.utils.CompositeAddress;
|
import org.apache.activemq.artemis.utils.CompositeAddress;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
@ -114,9 +113,9 @@ public class FQQNOpenWireTest extends OpenWireTestBase {
|
||||||
System.out.println("checking binidng " + b.getUniqueName() + " " + ((LocalQueueBinding)b).getQueue().getDeliveringMessages());
|
System.out.println("checking binidng " + b.getUniqueName() + " " + ((LocalQueueBinding)b).getQueue().getDeliveringMessages());
|
||||||
SimpleString qName = b.getUniqueName();
|
SimpleString qName = b.getUniqueName();
|
||||||
//do FQQN query
|
//do FQQN query
|
||||||
QueueQueryResult result = server.queueQuery(FQQN.toFullQN(multicastAddress, qName));
|
QueueQueryResult result = server.queueQuery(CompositeAddress.toFullQN(multicastAddress, qName));
|
||||||
assertTrue(result.isExists());
|
assertTrue(result.isExists());
|
||||||
assertEquals(result.getName(), FQQN.toFullQN(multicastAddress, qName));
|
assertEquals(result.getName(), CompositeAddress.toFullQN(multicastAddress, qName));
|
||||||
//do qname query
|
//do qname query
|
||||||
result = server.queueQuery(qName);
|
result = server.queueQuery(qName);
|
||||||
assertTrue(result.isExists());
|
assertTrue(result.isExists());
|
||||||
|
@ -141,9 +140,9 @@ public class FQQNOpenWireTest extends OpenWireTestBase {
|
||||||
connection.start();
|
connection.start();
|
||||||
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||||
|
|
||||||
Queue q1 = session.createQueue(FQQN.toFullQN(anycastAddress, anycastQ1).toString());
|
Queue q1 = session.createQueue(CompositeAddress.toFullQN(anycastAddress, anycastQ1).toString());
|
||||||
Queue q2 = session.createQueue(FQQN.toFullQN(anycastAddress, anycastQ2).toString());
|
Queue q2 = session.createQueue(CompositeAddress.toFullQN(anycastAddress, anycastQ2).toString());
|
||||||
Queue q3 = session.createQueue(FQQN.toFullQN(anycastAddress, anycastQ3).toString());
|
Queue q3 = session.createQueue(CompositeAddress.toFullQN(anycastAddress, anycastQ3).toString());
|
||||||
|
|
||||||
//send 3 messages to anycastAddress
|
//send 3 messages to anycastAddress
|
||||||
locator = createNonHALocator(true);
|
locator = createNonHALocator(true);
|
||||||
|
@ -168,10 +167,10 @@ public class FQQNOpenWireTest extends OpenWireTestBase {
|
||||||
//queues are empty now
|
//queues are empty now
|
||||||
for (SimpleString q : new SimpleString[]{anycastQ1, anycastQ2, anycastQ3}) {
|
for (SimpleString q : new SimpleString[]{anycastQ1, anycastQ2, anycastQ3}) {
|
||||||
//FQQN query
|
//FQQN query
|
||||||
QueueQueryResult query = server.queueQuery(FQQN.toFullQN(anycastAddress, q));
|
QueueQueryResult query = server.queueQuery(CompositeAddress.toFullQN(anycastAddress, q));
|
||||||
assertTrue(query.isExists());
|
assertTrue(query.isExists());
|
||||||
assertEquals(anycastAddress, query.getAddress());
|
assertEquals(anycastAddress, query.getAddress());
|
||||||
assertEquals(FQQN.toFullQN(anycastAddress, q), query.getName());
|
assertEquals(CompositeAddress.toFullQN(anycastAddress, q), query.getName());
|
||||||
assertEquals(0, query.getMessageCount());
|
assertEquals(0, query.getMessageCount());
|
||||||
//try query again using qName
|
//try query again using qName
|
||||||
query = server.queueQuery(q);
|
query = server.queueQuery(q);
|
||||||
|
@ -209,7 +208,7 @@ public class FQQNOpenWireTest extends OpenWireTestBase {
|
||||||
|
|
||||||
producer.send(message);
|
producer.send(message);
|
||||||
|
|
||||||
Destination destinationFQN = session.createQueue(FQQN.toFullQN(durableQueue, durableQueue).toString());
|
Destination destinationFQN = session.createQueue(CompositeAddress.toFullQN(durableQueue, durableQueue).toString());
|
||||||
|
|
||||||
MessageConsumer messageConsumer = session.createConsumer(destinationFQN);
|
MessageConsumer messageConsumer = session.createConsumer(destinationFQN);
|
||||||
|
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.artemis.tests.util;
|
|
||||||
|
|
||||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
|
||||||
import org.apache.activemq.artemis.utils.CompositeAddress;
|
|
||||||
|
|
||||||
public final class FQQN {
|
|
||||||
|
|
||||||
public static SimpleString toFullQN(SimpleString address, SimpleString qName) {
|
|
||||||
return address.concat(CompositeAddress.SEPARATOR).concat(qName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toFullQN(String address, String qName) {
|
|
||||||
return address + CompositeAddress.SEPARATOR + qName;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue