mirror of https://github.com/apache/activemq.git
Trim whitespace from destination names git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1240287 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
65fe5e2587
commit
f220607e33
|
@ -42,9 +42,9 @@ import org.apache.activemq.util.URISupport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @openwire:marshaller
|
* @openwire:marshaller
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class ActiveMQDestination extends JNDIBaseStorable implements DataStructure, Destination, Externalizable, Comparable {
|
public abstract class ActiveMQDestination extends JNDIBaseStorable implements DataStructure, Destination, Externalizable, Comparable<Object> {
|
||||||
|
|
||||||
public static final String PATH_SEPERATOR = ".";
|
public static final String PATH_SEPERATOR = ".";
|
||||||
public static final char COMPOSITE_SEPERATOR = ',';
|
public static final char COMPOSITE_SEPERATOR = ',';
|
||||||
|
@ -73,7 +73,7 @@ public abstract class ActiveMQDestination extends JNDIBaseStorable implements Da
|
||||||
protected Map<String, String> options;
|
protected Map<String, String> options;
|
||||||
|
|
||||||
protected static UnresolvedDestinationTransformer unresolvableDestinationTransformer = new DefaultUnresolvedDestinationTransformer();
|
protected static UnresolvedDestinationTransformer unresolvableDestinationTransformer = new DefaultUnresolvedDestinationTransformer();
|
||||||
|
|
||||||
public ActiveMQDestination() {
|
public ActiveMQDestination() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ public abstract class ActiveMQDestination extends JNDIBaseStorable implements Da
|
||||||
if (dest instanceof ActiveMQDestination) {
|
if (dest instanceof ActiveMQDestination) {
|
||||||
return (ActiveMQDestination)dest;
|
return (ActiveMQDestination)dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dest instanceof Queue && dest instanceof Topic) {
|
if (dest instanceof Queue && dest instanceof Topic) {
|
||||||
String queueName = ((Queue) dest).getQueueName();
|
String queueName = ((Queue) dest).getQueueName();
|
||||||
String topicName = ((Topic) dest).getTopicName();
|
String topicName = ((Topic) dest).getTopicName();
|
||||||
|
@ -165,6 +165,7 @@ public abstract class ActiveMQDestination extends JNDIBaseStorable implements Da
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int compareTo(Object that) {
|
public int compareTo(Object that) {
|
||||||
if (that instanceof ActiveMQDestination) {
|
if (that instanceof ActiveMQDestination) {
|
||||||
return compare(this, (ActiveMQDestination)that);
|
return compare(this, (ActiveMQDestination)that);
|
||||||
|
@ -221,6 +222,7 @@ public abstract class ActiveMQDestination extends JNDIBaseStorable implements Da
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPhysicalName(String physicalName) {
|
public void setPhysicalName(String physicalName) {
|
||||||
|
physicalName = physicalName.trim();
|
||||||
final int len = physicalName.length();
|
final int len = physicalName.length();
|
||||||
// options offset
|
// options offset
|
||||||
int p = -1;
|
int p = -1;
|
||||||
|
|
|
@ -334,6 +334,45 @@ public class MBeanTest extends EmbeddedBrokerTestSupport {
|
||||||
assertEquals("dest has no memory usage", 0, queue.getMemoryPercentUsage());
|
assertEquals("dest has no memory usage", 0, queue.getMemoryPercentUsage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCreateDestinationWithSpacesAtEnds() throws Exception {
|
||||||
|
ObjectName brokerName = assertRegisteredObjectName(domain + ":Type=Broker,BrokerName=localhost");
|
||||||
|
BrokerViewMBean broker = (BrokerViewMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);
|
||||||
|
|
||||||
|
assertTrue("broker is not a slave", !broker.isSlave());
|
||||||
|
// create 2 topics
|
||||||
|
broker.addTopic(getDestinationString() + "1 ");
|
||||||
|
broker.addTopic(" " + getDestinationString() + "2");
|
||||||
|
broker.addTopic(" " + getDestinationString() + "3 ");
|
||||||
|
|
||||||
|
assertNotRegisteredObjectName(domain + ":Type=Topic,BrokerName=localhost,Destination=" + getDestinationString() + "1 ");
|
||||||
|
assertNotRegisteredObjectName(domain + ":Type=Topic,BrokerName=localhost,Destination= " + getDestinationString() + "2");
|
||||||
|
assertNotRegisteredObjectName(domain + ":Type=Topic,BrokerName=localhost,Destination= " + getDestinationString() + "3 ");
|
||||||
|
|
||||||
|
ObjectName topicObjName1 = assertRegisteredObjectName(domain + ":Type=Topic,BrokerName=localhost,Destination=" + getDestinationString() + "1");
|
||||||
|
ObjectName topicObjName2 = assertRegisteredObjectName(domain + ":Type=Topic,BrokerName=localhost,Destination=" + getDestinationString() + "2");
|
||||||
|
ObjectName topicObjName3 = assertRegisteredObjectName(domain + ":Type=Topic,BrokerName=localhost,Destination=" + getDestinationString() + "3");
|
||||||
|
|
||||||
|
TopicViewMBean topic1 = (TopicViewMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer, topicObjName1, TopicViewMBean.class, true);
|
||||||
|
TopicViewMBean topic2 = (TopicViewMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer, topicObjName2, TopicViewMBean.class, true);
|
||||||
|
TopicViewMBean topic3 = (TopicViewMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer, topicObjName3, TopicViewMBean.class, true);
|
||||||
|
|
||||||
|
assertEquals("topic1 Durable subscriber count", 0, topic1.getConsumerCount());
|
||||||
|
assertEquals("topic2 Durable subscriber count", 0, topic2.getConsumerCount());
|
||||||
|
assertEquals("topic3 Durable subscriber count", 0, topic3.getConsumerCount());
|
||||||
|
|
||||||
|
String topicName = getDestinationString();
|
||||||
|
String selector = null;
|
||||||
|
|
||||||
|
// create 1 subscriber for each topic
|
||||||
|
broker.createDurableSubscriber(clientID, "topic1.subscriber1", topicName + "1", selector);
|
||||||
|
broker.createDurableSubscriber(clientID, "topic2.subscriber1", topicName + "2", selector);
|
||||||
|
broker.createDurableSubscriber(clientID, "topic3.subscriber1", topicName + "3", selector);
|
||||||
|
|
||||||
|
assertEquals("topic1 Durable subscriber count", 1, topic1.getConsumerCount());
|
||||||
|
assertEquals("topic2 Durable subscriber count", 1, topic2.getConsumerCount());
|
||||||
|
assertEquals("topic3 Durable subscriber count", 1, topic3.getConsumerCount());
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
protected void assertSendViaMBean() throws Exception {
|
protected void assertSendViaMBean() throws Exception {
|
||||||
String queueName = getDestinationString() + ".SendMBBean";
|
String queueName = getDestinationString() + ".SendMBBean";
|
||||||
|
@ -415,7 +454,6 @@ public class MBeanTest extends EmbeddedBrokerTestSupport {
|
||||||
assertEquals("Message " + messageIndex + " CData field: " + name, expected, value);
|
assertEquals("Message " + messageIndex + " CData field: " + name, expected, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void assertQueueBrowseWorks() throws Exception {
|
protected void assertQueueBrowseWorks() throws Exception {
|
||||||
Integer mbeancnt = mbeanServer.getMBeanCount();
|
Integer mbeancnt = mbeanServer.getMBeanCount();
|
||||||
echo("Mbean count :" + mbeancnt);
|
echo("Mbean count :" + mbeancnt);
|
||||||
|
@ -630,6 +668,16 @@ public class MBeanTest extends EmbeddedBrokerTestSupport {
|
||||||
return objectName;
|
return objectName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ObjectName assertNotRegisteredObjectName(String name) throws MalformedObjectNameException, NullPointerException {
|
||||||
|
ObjectName objectName = new ObjectName(name);
|
||||||
|
if (mbeanServer.isRegistered(objectName)) {
|
||||||
|
fail("Found the MBean!: " + objectName);
|
||||||
|
} else {
|
||||||
|
echo("Bean not registered Registered: " + objectName);
|
||||||
|
}
|
||||||
|
return objectName;
|
||||||
|
}
|
||||||
|
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
bindAddress = "tcp://localhost:0";
|
bindAddress = "tcp://localhost:0";
|
||||||
useTopic = false;
|
useTopic = false;
|
||||||
|
|
Loading…
Reference in New Issue