Author: timfox
Date: 2010-01-29 13:51:42 -0500 (Fri, 29 Jan 2010)
New Revision: 8859
Added:
trunk/tests/src/org/hornetq/tests/integration/jms/client/CreateQueueTest.java
Removed:
trunk/src/main/org/hornetq/jms/client/HornetQQueue.java
trunk/src/main/org/hornetq/jms/client/HornetQTemporaryQueue.java
trunk/src/main/org/hornetq/jms/client/HornetQTemporaryTopic.java
trunk/src/main/org/hornetq/jms/client/HornetQTopic.java
trunk/tests/src/org/hornetq/tests/unit/jms/HornetQQueueTest.java
trunk/tests/src/org/hornetq/tests/unit/jms/HornetQTopicTest.java
Modified:
trunk/src/main/org/hornetq/api/jms/HornetQJMSClient.java
trunk/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
trunk/src/main/org/hornetq/jms/client/HornetQDestination.java
trunk/src/main/org/hornetq/jms/client/HornetQQueueBrowser.java
trunk/src/main/org/hornetq/jms/client/HornetQSession.java
trunk/src/main/org/hornetq/jms/management/impl/JMSQueueControlImpl.java
trunk/src/main/org/hornetq/jms/management/impl/JMSTopicControlImpl.java
trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
trunk/src/main/org/hornetq/jms/server/management/JMSManagementService.java
trunk/src/main/org/hornetq/jms/server/management/impl/JMSManagementServiceImpl.java
trunk/src/main/org/hornetq/ra/inflow/HornetQMessageHandler.java
trunk/tests/jms-tests/src/org/hornetq/jms/tests/ReferenceableTest.java
trunk/tests/src/org/hornetq/tests/integration/jms/cluster/JMSFailoverTest.java
trunk/tests/src/org/hornetq/tests/integration/jms/cluster/JMSReconnectTest.java
trunk/tests/src/org/hornetq/tests/integration/jms/consumer/ConsumerTest.java
trunk/tests/src/org/hornetq/tests/integration/jms/divert/DivertAndACKClientTest.java
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSQueueControlTest.java
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSQueueControlUsingJMSTest.java
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/TopicControlTest.java
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/TopicControlUsingJMSTest.java
trunk/tests/src/org/hornetq/tests/unit/jms/HornetQDestinationTest.java
trunk/tests/src/org/hornetq/tests/unit/jms/referenceable/DestinationObjectFactoryTest.java
trunk/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java
trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java
Log:
https://jira.jboss.org/jira/browse/HORNETQ-281
Modified: trunk/src/main/org/hornetq/api/jms/HornetQJMSClient.java
===================================================================
--- trunk/src/main/org/hornetq/api/jms/HornetQJMSClient.java 2010-01-29 13:43:32 UTC (rev
8858)
+++ trunk/src/main/org/hornetq/api/jms/HornetQJMSClient.java 2010-01-29 18:51:42 UTC (rev
8859)
@@ -23,8 +23,7 @@
import org.hornetq.api.core.client.ClientSessionFactory;
import org.hornetq.core.logging.Logger;
import org.hornetq.jms.client.HornetQConnectionFactory;
-import org.hornetq.jms.client.HornetQQueue;
-import org.hornetq.jms.client.HornetQTopic;
+import org.hornetq.jms.client.HornetQDestination;
/**
* A utility class for creating HornetQ client-side JMS managed resources.
@@ -111,7 +110,7 @@
*/
public static Topic createTopic(final String name)
{
- return new HornetQTopic(name);
+ return HornetQDestination.createTopic(name);
}
/**
@@ -122,7 +121,7 @@
*/
public static Queue createQueue(final String name)
{
- return new HornetQQueue(name);
+ return HornetQDestination.createQueue(name);
}
private HornetQJMSClient()
Modified: trunk/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2010-01-29 13:43:32
UTC (rev 8858)
+++ trunk/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2010-01-29 18:51:42
UTC (rev 8859)
@@ -147,7 +147,7 @@
final boolean preAcknowledge,
final boolean strictUpdateDeliveryCount,
final boolean xa,
- final RemotingConnection remotingConnection,
+ final RemotingConnection remotingConnection,
final StorageManager storageManager,
final PostOffice postOffice,
final ResourceManager resourceManager,
@@ -195,7 +195,7 @@
this.managementAddress = managementAddress;
this.callback = callback;
-
+
remotingConnection.addFailureListener(this);
remotingConnection.addCloseListener(this);
@@ -278,14 +278,14 @@
{
holder.store.returnProducerCredits(holder.outstandingCredits);
}
-
+
callback.closed();
}
public void createConsumer(final long consumerID,
- final SimpleString queueName,
- final SimpleString filterString,
- final boolean browseOnly) throws Exception
+ final SimpleString queueName,
+ final SimpleString filterString,
+ final boolean browseOnly) throws Exception
{
Binding binding = postOffice.getBinding(queueName);
@@ -340,11 +340,11 @@
}
public void createQueue(final SimpleString address,
- final SimpleString name,
- final SimpleString filterString,
- final boolean temporary,
- final boolean durable) throws Exception
- {
+ final SimpleString name,
+ final SimpleString filterString,
+ final boolean temporary,
+ final boolean durable) throws Exception
+ {
if (durable)
{
// make sure the user has privileges to create this queue
Modified: trunk/src/main/org/hornetq/jms/client/HornetQDestination.java
===================================================================
--- trunk/src/main/org/hornetq/jms/client/HornetQDestination.java 2010-01-29 13:43:32 UTC
(rev 8858)
+++ trunk/src/main/org/hornetq/jms/client/HornetQDestination.java 2010-01-29 18:51:42 UTC
(rev 8859)
@@ -14,12 +14,17 @@
package org.hornetq.jms.client;
import java.io.Serializable;
+import java.util.UUID;
import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.TemporaryQueue;
+import javax.jms.TemporaryTopic;
import javax.naming.NamingException;
import javax.naming.Reference;
import javax.naming.Referenceable;
+import org.hornetq.api.core.Pair;
import org.hornetq.api.core.SimpleString;
import org.hornetq.jms.referenceable.DestinationObjectFactory;
import org.hornetq.jms.referenceable.SerializableObjectRefAddr;
@@ -27,13 +32,12 @@
/**
* HornetQ implementation of a JMS Destination.
*
- * @author <a href="mailto:ovidiu@feodorov.com">Ovidiu
Feodorov</a>
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
* @version <tt>$Revision$</tt>
*
* $Id$
*/
-public abstract class HornetQDestination implements Destination, Serializable,
Referenceable
+public class HornetQDestination implements TemporaryQueue, TemporaryTopic, Serializable,
Referenceable
{
// Constants -----------------------------------------------------
@@ -43,7 +47,13 @@
*
*/
private static final long serialVersionUID = 5027962425462382883L;
-
+
+ public static final String JMS_QUEUE_ADDRESS_PREFIX = "jms.queue.";
+
+ public static final String JMS_TOPIC_ADDRESS_PREFIX = "jms.topic.";
+
+ private static final char SEPARATOR = '.';
+
protected static String escape(final String input)
{
if (input == null)
@@ -55,55 +65,155 @@
public static Destination fromAddress(final String address)
{
- if (address.startsWith(HornetQQueue.JMS_QUEUE_ADDRESS_PREFIX))
+ if (address.startsWith(HornetQDestination.JMS_QUEUE_ADDRESS_PREFIX))
{
- String name =
address.substring(HornetQQueue.JMS_QUEUE_ADDRESS_PREFIX.length());
+ String name =
address.substring(HornetQDestination.JMS_QUEUE_ADDRESS_PREFIX.length());
- return new HornetQQueue(address, name);
+ return createQueue(name);
}
- else if (address.startsWith(HornetQTopic.JMS_TOPIC_ADDRESS_PREFIX))
+ else if (address.startsWith(HornetQDestination.JMS_TOPIC_ADDRESS_PREFIX))
{
- String name =
address.substring(HornetQTopic.JMS_TOPIC_ADDRESS_PREFIX.length());
+ String name =
address.substring(HornetQDestination.JMS_TOPIC_ADDRESS_PREFIX.length());
- return new HornetQTopic(address, name);
+ return createTopic(name);
}
- else if (address.startsWith(HornetQTemporaryQueue.JMS_TEMP_QUEUE_ADDRESS_PREFIX))
+ else
{
- String name =
address.substring(HornetQTemporaryQueue.JMS_TEMP_QUEUE_ADDRESS_PREFIX.length());
+ throw new IllegalArgumentException("Invalid address " + address);
+ }
+ }
+
+ public static String createQueueNameForDurableSubscription(final String clientID,
final String subscriptionName)
+ {
+ return HornetQDestination.escape(clientID) + SEPARATOR +
HornetQDestination.escape(subscriptionName);
+ }
+
+ public static Pair<String, String>
decomposeQueueNameForDurableSubscription(final String queueName)
+ {
+ StringBuffer[] parts = new StringBuffer[2];
+ int currentPart = 0;
- return new HornetQTemporaryQueue(null, name);
- }
- else if (address.startsWith(HornetQTemporaryTopic.JMS_TEMP_TOPIC_ADDRESS_PREFIX))
+ parts[0] = new StringBuffer();
+ parts[1] = new StringBuffer();
+
+ int pos = 0;
+ while (pos < queueName.length())
{
- String name =
address.substring(HornetQTemporaryTopic.JMS_TEMP_TOPIC_ADDRESS_PREFIX.length());
+ char ch = queueName.charAt(pos);
+ pos++;
- return new HornetQTemporaryTopic(null, name);
+ if (ch == SEPARATOR)
+ {
+ currentPart++;
+ if (currentPart >= parts.length)
+ {
+ throw new IllegalArgumentException("Invalid message queue name:
" + queueName);
+ }
+
+ continue;
+ }
+
+ if (ch == '\\')
+ {
+ if (pos >= queueName.length())
+ {
+ throw new IllegalArgumentException("Invalid message queue name:
" + queueName);
+ }
+ ch = queueName.charAt(pos);
+ pos++;
+ }
+
+ parts[currentPart].append(ch);
}
- else
+
+ if (currentPart != 1)
{
- throw new IllegalArgumentException("Invalid address " + address);
+ throw new IllegalArgumentException("Invalid message queue name: " +
queueName);
}
+
+ Pair<String, String> pair = new Pair<String,
String>(parts[0].toString(), parts[1].toString());
+
+ return pair;
}
+
+ public static SimpleString createQueueAddressFromName(final String name)
+ {
+ return new SimpleString(JMS_QUEUE_ADDRESS_PREFIX + name);
+ }
+
+ public static SimpleString createTopicAddressFromName(final String name)
+ {
+ return new SimpleString(JMS_TOPIC_ADDRESS_PREFIX + name);
+ }
+
+ public static HornetQDestination createQueue(final String name)
+ {
+ return new HornetQDestination(JMS_QUEUE_ADDRESS_PREFIX.concat(name), name, false,
true, null);
+ }
+
+ public static HornetQDestination createTopic(final String name)
+ {
+ return new HornetQDestination(JMS_TOPIC_ADDRESS_PREFIX.concat(name), name, false,
false, null);
+ }
+
+ public static HornetQDestination createTemporaryQueue(final HornetQSession session)
+ {
+ String name = UUID.randomUUID().toString();
+
+ return new HornetQDestination(JMS_QUEUE_ADDRESS_PREFIX.concat(name), name, true,
true, session);
+ }
+
+ public static HornetQDestination createTemporaryTopic(final HornetQSession session)
+ {
+ String name = UUID.randomUUID().toString();
+
+ return new HornetQDestination(JMS_TOPIC_ADDRESS_PREFIX.concat(name), name, true,
false, session);
+ }
+
// Attributes ----------------------------------------------------
+ /**
+ * The JMS name
+ */
protected final String name;
+ /**
+ * The core address
+ */
private final String address;
+ /**
+ * SimpleString version of address
+ */
private final SimpleString simpleAddress;
-
+
+ private final boolean temporary;
+
+ private final boolean queue;
+
+ private final HornetQSession session;
+
// Constructors --------------------------------------------------
- public HornetQDestination(final String address, final String name)
+ private HornetQDestination(final String address, final String name,
+ final boolean temporary,
+ final boolean queue,
+ final HornetQSession session)
{
this.address = address;
this.name = name;
simpleAddress = new SimpleString(address);
+
+ this.temporary = temporary;
+
+ this.queue = queue;
+
+ this.session = session;
}
-
+
// Referenceable implementation ---------------------------------------
public Reference getReference() throws NamingException
@@ -114,6 +224,36 @@
null);
}
+ public String getQueueName()
+ {
+ return name;
+ }
+
+ public String getTopicName()
+ {
+ return name;
+ }
+
+ public void delete() throws JMSException
+ {
+ if (session != null)
+ {
+ if (queue)
+ {
+ session.deleteTemporaryQueue(this);
+ }
+ else
+ {
+ session.deleteTemporaryTopic(this);
+ }
+ }
+ }
+
+ public boolean isQueue()
+ {
+ return queue;
+ }
+
// Public --------------------------------------------------------
public String getAddress()
@@ -131,8 +271,11 @@
return name;
}
- public abstract boolean isTemporary();
-
+ public boolean isTemporary()
+ {
+ return temporary;
+ }
+
@Override
public boolean equals(final Object o)
{
Deleted: trunk/src/main/org/hornetq/jms/client/HornetQQueue.java
===================================================================
--- trunk/src/main/org/hornetq/jms/client/HornetQQueue.java 2010-01-29 13:43:32 UTC (rev
8858)
+++ trunk/src/main/org/hornetq/jms/client/HornetQQueue.java 2010-01-29 18:51:42 UTC (rev
8859)
@@ -1,93 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat 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.hornetq.jms.client;
-
-import javax.jms.JMSException;
-import javax.jms.Queue;
-
-import org.hornetq.api.core.SimpleString;
-import org.hornetq.jms.client.HornetQDestination;
-import org.hornetq.core.logging.Logger;
-
-/**
- * HornetQ implementation of a JMS Queue.
- * <br>
- * This class can be instantiated directly.
- *
- * @author <a href="mailto:ovidiu@feodorov.com">Ovidiu
Feodorov</a>
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class HornetQQueue extends HornetQDestination implements Queue
-{
- // Constants -----------------------------------------------------
-
- private static final Logger log = Logger.getLogger(HornetQQueue.class);
-
- private static final long serialVersionUID = -1106092883162295462L;
-
- public static final String JMS_QUEUE_ADDRESS_PREFIX = "jms.queue.";
-
- // Static --------------------------------------------------------
-
- public static SimpleString createAddressFromName(final String name)
- {
- return new SimpleString(HornetQQueue.JMS_QUEUE_ADDRESS_PREFIX + name);
- }
-
- // Attributes ----------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public HornetQQueue(final String name)
- {
- super(HornetQQueue.JMS_QUEUE_ADDRESS_PREFIX + name, name);
- }
-
- protected HornetQQueue(final String address, final String name)
- {
- super(address, name);
- }
-
- // Queue implementation ------------------------------------------
-
- public String getQueueName() throws JMSException
- {
- return name;
- }
-
- // Public --------------------------------------------------------
-
- @Override
- public boolean isTemporary()
- {
- return false;
- }
-
- @Override
- public String toString()
- {
- return "HornetQQueue[" + name + "]";
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Modified: trunk/src/main/org/hornetq/jms/client/HornetQQueueBrowser.java
===================================================================
--- trunk/src/main/org/hornetq/jms/client/HornetQQueueBrowser.java 2010-01-29 13:43:32 UTC
(rev 8858)
+++ trunk/src/main/org/hornetq/jms/client/HornetQQueueBrowser.java 2010-01-29 18:51:42 UTC
(rev 8859)
@@ -49,13 +49,13 @@
private ClientConsumer consumer;
- private final HornetQQueue queue;
+ private final HornetQDestination queue;
private SimpleString filterString;
// Constructors
---------------------------------------------------------------------------------
- protected HornetQQueueBrowser(final HornetQQueue queue, final String messageSelector,
final ClientSession session) throws JMSException
+ protected HornetQQueueBrowser(final HornetQDestination queue, final String
messageSelector, final ClientSession session) throws JMSException
{
this.session = session;
this.queue = queue;
Modified: trunk/src/main/org/hornetq/jms/client/HornetQSession.java
===================================================================
--- trunk/src/main/org/hornetq/jms/client/HornetQSession.java 2010-01-29 13:43:32 UTC (rev
8858)
+++ trunk/src/main/org/hornetq/jms/client/HornetQSession.java 2010-01-29 18:51:42 UTC (rev
8859)
@@ -57,10 +57,8 @@
import org.hornetq.api.core.client.ClientSession;
import org.hornetq.api.core.client.ClientSession.BindingQuery;
import org.hornetq.api.core.client.ClientSession.QueueQuery;
-import org.hornetq.api.jms.*;
import org.hornetq.core.filter.impl.FilterImpl;
import org.hornetq.core.logging.Logger;
-import org.hornetq.jms.*;
/**
* HornetQ implementation of a JMS Session.
@@ -324,7 +322,7 @@
if (jbd != null)
{
- if (jbd instanceof Queue)
+ if (jbd.isQueue())
{
QueueQuery response = session.queueQuery(jbd.getSimpleAddress());
@@ -399,8 +397,8 @@
throw new IllegalStateException("Cannot create a queue using a
TopicSession");
}
- HornetQQueue queue = (HornetQQueue) HornetQJMSClient.createQueue(queueName);
-
+ HornetQDestination queue = HornetQDestination.createQueue(queueName);
+
try
{
QueueQuery response = session.queueQuery(queue.getSimpleAddress());
@@ -428,8 +426,8 @@
throw new IllegalStateException("Cannot create a topic on a
QueueSession");
}
- HornetQTopic topic = (HornetQTopic) HornetQJMSClient.createTopic(topicName);
-
+ HornetQDestination topic = HornetQDestination.createTopic(topicName);
+
try
{
BindingQuery query = session.bindingQuery(topic.getSimpleAddress());
@@ -468,7 +466,7 @@
{
throw new InvalidDestinationException("Cannot create a durable subscriber
on a null topic");
}
- if (!(topic instanceof HornetQTopic))
+ if (!(topic instanceof HornetQDestination))
{
throw new InvalidDestinationException("Not a HornetQTopic:" + topic);
}
@@ -478,6 +476,11 @@
}
HornetQDestination jbdest = (HornetQDestination)topic;
+
+ if (jbdest.isQueue())
+ {
+ throw new InvalidDestinationException("Cannot create a subscriber on a
queue");
+ }
return createConsumer(jbdest, name, messageSelector, noLocal);
}
@@ -486,7 +489,7 @@
final String subscriptionName,
String selectorString,
final boolean noLocal) throws
JMSException
- {
+ {
try
{
selectorString = "".equals(selectorString) ? null : selectorString;
@@ -520,8 +523,8 @@
SimpleString autoDeleteQueueName = null;
- if (dest instanceof Queue)
- {
+ if (dest.isQueue())
+ {
QueueQuery response = session.queueQuery(dest.getSimpleAddress());
if (!response.isExists())
@@ -568,7 +571,7 @@
throw new InvalidDestinationException("Cannot create a durable
subscription on a temporary topic");
}
- queueName = new
SimpleString(HornetQTopic.createQueueNameForDurableSubscription(connection.getClientID(),
+ queueName = new
SimpleString(HornetQDestination.createQueueNameForDurableSubscription(connection.getClientID(),
subscriptionName));
QueueQuery subResponse = session.queueQuery(queueName);
@@ -654,7 +657,7 @@
{
throw new InvalidDestinationException("Cannot create a browser with a null
queue");
}
- if (!(queue instanceof HornetQQueue))
+ if (!(queue instanceof HornetQDestination))
{
throw new InvalidDestinationException("Not a HornetQQueue:" + queue);
}
@@ -673,7 +676,12 @@
throw JMSExceptionHelper.convertFromHornetQException(e);
}
- HornetQQueue jbq = (HornetQQueue)queue;
+ HornetQDestination jbq = (HornetQDestination)queue;
+
+ if (!jbq.isQueue())
+ {
+ throw new InvalidDestinationException("Cannot create a browser on a
topic");
+ }
try
{
@@ -700,11 +708,9 @@
throw new IllegalStateException("Cannot create a temporary queue using a
TopicSession");
}
- String queueName = UUID.randomUUID().toString();
-
try
{
- HornetQTemporaryQueue queue = new HornetQTemporaryQueue(this, queueName);
+ HornetQDestination queue = HornetQDestination.createTemporaryQueue(this);
SimpleString simpleAddress = queue.getSimpleAddress();
@@ -728,11 +734,9 @@
throw new IllegalStateException("Cannot create a temporary topic on a
QueueSession");
}
- String topicName = UUID.randomUUID().toString();
-
try
{
- HornetQTemporaryTopic topic = new HornetQTemporaryTopic(this, topicName);
+ HornetQDestination topic = HornetQDestination.createTemporaryTopic(this);
SimpleString simpleAddress = topic.getSimpleAddress();
@@ -761,7 +765,7 @@
throw new IllegalStateException("Cannot unsubscribe using a
QueueSession");
}
- SimpleString queueName = new
SimpleString(HornetQTopic.createQueueNameForDurableSubscription(connection.getClientID(),
+ SimpleString queueName = new
SimpleString(HornetQDestination.createQueueNameForDurableSubscription(connection.getClientID(),
name));
try
@@ -876,8 +880,13 @@
this.recoverCalled = recoverCalled;
}
- public void deleteTemporaryTopic(final HornetQTemporaryTopic tempTopic) throws
JMSException
+ public void deleteTemporaryTopic(final HornetQDestination tempTopic) throws
JMSException
{
+ if (!tempTopic.isTemporary())
+ {
+ throw new InvalidDestinationException("Not a temporary topic " +
tempTopic);
+ }
+
try
{
BindingQuery response = session.bindingQuery(tempTopic.getSimpleAddress());
@@ -906,8 +915,12 @@
}
}
- public void deleteTemporaryQueue(final HornetQTemporaryQueue tempQueue) throws
JMSException
+ public void deleteTemporaryQueue(final HornetQDestination tempQueue) throws
JMSException
{
+ if (!tempQueue.isTemporary())
+ {
+ throw new InvalidDestinationException("Not a temporary queue " +
tempQueue);
+ }
try
{
QueueQuery response = session.queueQuery(tempQueue.getSimpleAddress());
Deleted: trunk/src/main/org/hornetq/jms/client/HornetQTemporaryQueue.java
===================================================================
--- trunk/src/main/org/hornetq/jms/client/HornetQTemporaryQueue.java 2010-01-29 13:43:32
UTC (rev 8858)
+++ trunk/src/main/org/hornetq/jms/client/HornetQTemporaryQueue.java 2010-01-29 18:51:42
UTC (rev 8859)
@@ -1,81 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat 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.hornetq.jms.client;
-
-import javax.jms.JMSException;
-import javax.jms.TemporaryQueue;
-
-
-/**
- * HornetQ implementation of a JMS TemporaryQueue.
- * <br>
- * This class can be instantiated directly.
- *
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 3569 $</tt>
- *
- * $Id: HornetQQueue.java 3569 2008-01-15 21:14:04Z timfox $
- */
-public class HornetQTemporaryQueue extends HornetQQueue implements TemporaryQueue
-{
- // Constants -----------------------------------------------------
-
- private static final long serialVersionUID = -4624930377557954624L;
-
- public static final String JMS_TEMP_QUEUE_ADDRESS_PREFIX =
"jms.tempqueue.";
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private final transient HornetQSession session;
-
- // Constructors --------------------------------------------------
-
- public HornetQTemporaryQueue(final HornetQSession session, final String name)
- {
- super(HornetQTemporaryQueue.JMS_TEMP_QUEUE_ADDRESS_PREFIX + name, name);
-
- this.session = session;
- }
-
- // TemporaryQueue implementation ------------------------------------------
-
- public void delete() throws JMSException
- {
- session.deleteTemporaryQueue(this);
- }
-
- // Public --------------------------------------------------------
-
- @Override
- public boolean isTemporary()
- {
- return true;
- }
-
- @Override
- public String toString()
- {
- return "HornetQTemporaryQueue[" + name + "]";
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/src/main/org/hornetq/jms/client/HornetQTemporaryTopic.java
===================================================================
--- trunk/src/main/org/hornetq/jms/client/HornetQTemporaryTopic.java 2010-01-29 13:43:32
UTC (rev 8858)
+++ trunk/src/main/org/hornetq/jms/client/HornetQTemporaryTopic.java 2010-01-29 18:51:42
UTC (rev 8859)
@@ -1,81 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat 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.hornetq.jms.client;
-
-import javax.jms.JMSException;
-import javax.jms.TemporaryTopic;
-
-
-/**
- * HornetQ implementation of a JMS TemporaryTopic.
- * <br>
- * This class can be instantiated directly.
- *
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 3569 $</tt>
- *
- * $Id: HornetQQueue.java 3569 2008-01-15 21:14:04Z timfox $
- */
-public class HornetQTemporaryTopic extends HornetQTopic implements TemporaryTopic
-{
- // Constants -----------------------------------------------------
-
- private static final long serialVersionUID = 845450764835635266L;
-
- public static final String JMS_TEMP_TOPIC_ADDRESS_PREFIX =
"jms.temptopic.";
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private final transient HornetQSession session;
-
- // Constructors --------------------------------------------------
-
- public HornetQTemporaryTopic(final HornetQSession session, final String name)
- {
- super(HornetQTemporaryTopic.JMS_TEMP_TOPIC_ADDRESS_PREFIX + name, name);
-
- this.session = session;
- }
-
- // TemporaryTopic implementation ------------------------------------------
-
- public void delete() throws JMSException
- {
- session.deleteTemporaryTopic(this);
- }
-
- // Public --------------------------------------------------------
-
- @Override
- public boolean isTemporary()
- {
- return true;
- }
-
- @Override
- public String toString()
- {
- return "HornetQTemporaryTopic[" + name + "]";
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/src/main/org/hornetq/jms/client/HornetQTopic.java
===================================================================
--- trunk/src/main/org/hornetq/jms/client/HornetQTopic.java 2010-01-29 13:43:32 UTC (rev
8858)
+++ trunk/src/main/org/hornetq/jms/client/HornetQTopic.java 2010-01-29 18:51:42 UTC (rev
8859)
@@ -1,146 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat 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.hornetq.jms.client;
-
-import javax.jms.JMSException;
-import javax.jms.Topic;
-
-import org.hornetq.api.core.Pair;
-import org.hornetq.api.core.SimpleString;
-import org.hornetq.jms.client.HornetQDestination;
-
-/**
- * HornetQ implementation of a JMS Topic.
- * <br>
- * This class can be instantiated directly.
- *
- * @author <a href="mailto:ovidiu@feodorov.com">Ovidiu
Feodorov</a>
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class HornetQTopic extends HornetQDestination implements Topic
-{
- // Constants -----------------------------------------------------
-
- private static final long serialVersionUID = 7873614001276404156L;
-
- public static final String JMS_TOPIC_ADDRESS_PREFIX = "jms.topic.";
-
- private static final char SEPARATOR = '.';
-
- // Static --------------------------------------------------------
-
- public static String createQueueNameForDurableSubscription(final String clientID,
final String subscriptionName)
- {
- return HornetQDestination.escape(clientID) + HornetQTopic.SEPARATOR +
HornetQDestination.escape(subscriptionName);
- }
-
- public static Pair<String, String>
decomposeQueueNameForDurableSubscription(final String queueName)
- {
- StringBuffer[] parts = new StringBuffer[2];
- int currentPart = 0;
-
- parts[0] = new StringBuffer();
- parts[1] = new StringBuffer();
-
- int pos = 0;
- while (pos < queueName.length())
- {
- char ch = queueName.charAt(pos);
- pos++;
-
- if (ch == HornetQTopic.SEPARATOR)
- {
- currentPart++;
- if (currentPart >= parts.length)
- {
- throw new IllegalArgumentException("Invalid message queue name:
" + queueName);
- }
-
- continue;
- }
-
- if (ch == '\\')
- {
- if (pos >= queueName.length())
- {
- throw new IllegalArgumentException("Invalid message queue name:
" + queueName);
- }
- ch = queueName.charAt(pos);
- pos++;
- }
-
- parts[currentPart].append(ch);
- }
-
- if (currentPart != 1)
- {
- throw new IllegalArgumentException("Invalid message queue name: " +
queueName);
- }
-
- Pair<String, String> pair = new Pair<String,
String>(parts[0].toString(), parts[1].toString());
-
- return pair;
- }
-
- public static SimpleString createAddressFromName(final String name)
- {
- return new SimpleString(HornetQTopic.JMS_TOPIC_ADDRESS_PREFIX + name);
- }
-
- // Attributes ----------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public HornetQTopic(final String name)
- {
- super(HornetQTopic.JMS_TOPIC_ADDRESS_PREFIX + name, name);
- }
-
- protected HornetQTopic(final String address, final String name)
- {
- super(address, name);
- }
-
- // Topic implementation ------------------------------------------
-
- public String getTopicName() throws JMSException
- {
- return name;
- }
-
- // Public --------------------------------------------------------
-
- @Override
- public boolean isTemporary()
- {
- return false;
- }
-
- @Override
- public String toString()
- {
- return "HornetQTopic[" + name + "]";
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Modified: trunk/src/main/org/hornetq/jms/management/impl/JMSQueueControlImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/management/impl/JMSQueueControlImpl.java 2010-01-29
13:43:32 UTC (rev 8858)
+++ trunk/src/main/org/hornetq/jms/management/impl/JMSQueueControlImpl.java 2010-01-29
18:51:42 UTC (rev 8859)
@@ -27,8 +27,8 @@
import org.hornetq.core.management.impl.MBeanInfoHelper;
import org.hornetq.core.messagecounter.MessageCounter;
import org.hornetq.core.messagecounter.impl.MessageCounterHelper;
+import org.hornetq.jms.client.HornetQDestination;
import org.hornetq.jms.client.HornetQMessage;
-import org.hornetq.jms.client.HornetQQueue;
import org.hornetq.jms.client.SelectorTranslator;
import org.hornetq.utils.json.JSONArray;
import org.hornetq.utils.json.JSONObject;
@@ -47,7 +47,7 @@
// Attributes ----------------------------------------------------
- private final HornetQQueue managedQueue;
+ private final HornetQDestination managedQueue;
private final QueueControl coreQueueControl;
@@ -83,7 +83,7 @@
// Constructors --------------------------------------------------
- public JMSQueueControlImpl(final HornetQQueue managedQueue,
+ public JMSQueueControlImpl(final HornetQDestination managedQueue,
final QueueControl coreQueueControl,
final String jndiBinding,
final MessageCounter counter) throws Exception
@@ -275,7 +275,7 @@
public boolean moveMessage(final String messageID, final String otherQueueName) throws
Exception
{
String filter = JMSQueueControlImpl.createFilterForJMSMessageID(messageID);
- HornetQQueue otherQueue = (HornetQQueue)
HornetQJMSClient.createQueue(otherQueueName);
+ HornetQDestination otherQueue = HornetQDestination.createQueue(otherQueueName);
int moved = coreQueueControl.moveMessages(filter, otherQueue.getAddress());
if (moved != 1)
{
@@ -288,7 +288,7 @@
public int moveMessages(final String filterStr, final String otherQueueName) throws
Exception
{
String filter = JMSQueueControlImpl.createFilterFromJMSSelector(filterStr);
- HornetQQueue otherQueue = (HornetQQueue)
HornetQJMSClient.createQueue(otherQueueName);
+ HornetQDestination otherQueue = HornetQDestination.createQueue(otherQueueName);
return coreQueueControl.moveMessages(filter, otherQueue.getAddress());
}
Modified: trunk/src/main/org/hornetq/jms/management/impl/JMSTopicControlImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/management/impl/JMSTopicControlImpl.java 2010-01-29
13:43:32 UTC (rev 8858)
+++ trunk/src/main/org/hornetq/jms/management/impl/JMSTopicControlImpl.java 2010-01-29
18:51:42 UTC (rev 8859)
@@ -31,8 +31,8 @@
import org.hornetq.core.logging.Logger;
import org.hornetq.core.management.impl.MBeanInfoHelper;
import org.hornetq.core.server.management.ManagementService;
+import org.hornetq.jms.client.HornetQDestination;
import org.hornetq.jms.client.HornetQMessage;
-import org.hornetq.jms.client.HornetQTopic;
import org.hornetq.jms.client.SelectorTranslator;
import org.hornetq.utils.json.JSONArray;
import org.hornetq.utils.json.JSONObject;
@@ -51,7 +51,7 @@
// Attributes ----------------------------------------------------
- private final HornetQTopic managedTopic;
+ private final HornetQDestination managedTopic;
private final String binding;
@@ -69,7 +69,7 @@
// Constructors --------------------------------------------------
- public JMSTopicControlImpl(final HornetQTopic topic,
+ public JMSTopicControlImpl(final HornetQDestination topic,
final AddressControl addressControl,
final String jndiBinding,
final ManagementService managementService) throws
Exception
@@ -191,7 +191,7 @@
public int countMessagesForSubscription(final String clientID, final String
subscriptionName, final String filterStr) throws Exception
{
- String queueName = HornetQTopic.createQueueNameForDurableSubscription(clientID,
subscriptionName);
+ String queueName =
HornetQDestination.createQueueNameForDurableSubscription(clientID, subscriptionName);
QueueControl coreQueueControl =
(QueueControl)managementService.getResource(ResourceNames.CORE_QUEUE + queueName);
if (coreQueueControl == null)
{
@@ -217,7 +217,7 @@
public void dropDurableSubscription(final String clientID, final String
subscriptionName) throws Exception
{
- String queueName = HornetQTopic.createQueueNameForDurableSubscription(clientID,
subscriptionName);
+ String queueName =
HornetQDestination.createQueueNameForDurableSubscription(clientID, subscriptionName);
QueueControl coreQueueControl =
(QueueControl)managementService.getResource(ResourceNames.CORE_QUEUE + queueName);
if (coreQueueControl == null)
{
@@ -255,7 +255,7 @@
if (queue.isDurable())
{
- Pair<String, String> pair =
HornetQTopic.decomposeQueueNameForDurableSubscription(queue.getName()
+ Pair<String, String> pair =
HornetQDestination.decomposeQueueNameForDurableSubscription(queue.getName()
.toString());
clientID = pair.a;
subName = pair.b;
@@ -287,7 +287,7 @@
if (queue.isDurable())
{
- Pair<String, String> pair =
HornetQTopic.decomposeQueueNameForDurableSubscription(queue.getName()
+ Pair<String, String> pair =
HornetQDestination.decomposeQueueNameForDurableSubscription(queue.getName()
.toString());
clientID = pair.a;
subName = pair.b;
Modified: trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java 2010-01-29
13:43:32 UTC (rev 8858)
+++ trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java 2010-01-29
18:51:42 UTC (rev 8859)
@@ -36,8 +36,7 @@
import org.hornetq.core.server.ActivateCallback;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.jms.client.HornetQConnectionFactory;
-import org.hornetq.jms.client.HornetQQueue;
-import org.hornetq.jms.client.HornetQTopic;
+import org.hornetq.jms.client.HornetQDestination;
import org.hornetq.jms.client.SelectorTranslator;
import org.hornetq.jms.server.JMSServerManager;
import org.hornetq.jms.server.config.ConnectionFactoryConfiguration;
@@ -258,7 +257,7 @@
final boolean durable) throws Exception
{
checkInitialised();
- HornetQQueue jBossQueue = new HornetQQueue(queueName);
+ HornetQDestination jBossQueue = HornetQDestination.createQueue(queueName);
// Convert from JMS selector to core filter
String coreFilterString = null;
@@ -287,7 +286,7 @@
public synchronized boolean createTopic(final String topicName, final String
jndiBinding) throws Exception
{
checkInitialised();
- HornetQTopic jBossTopic = new HornetQTopic(topicName);
+ HornetQDestination jBossTopic = HornetQDestination.createTopic(topicName);
// We create a dummy subscription on the topic, that never receives messages - this
is so we can perform JMS
// checks when routing messages to a topic that
// does not exist - otherwise we would not be able to distinguish from a non
existent topic and one with no
@@ -333,7 +332,7 @@
destinations.remove(name);
jmsManagementService.unregisterQueue(name);
-
server.getHornetQServerControl().destroyQueue(HornetQQueue.createAddressFromName(name).toString());
+
server.getHornetQServerControl().destroyQueue(HornetQDestination.createQueueAddressFromName(name).toString());
return true;
}
@@ -345,7 +344,7 @@
destinations.remove(name);
jmsManagementService.unregisterTopic(name);
-
server.getHornetQServerControl().destroyQueue(HornetQTopic.createAddressFromName(name).toString());
+
server.getHornetQServerControl().destroyQueue(HornetQDestination.createTopicAddressFromName(name).toString());
return true;
}
Modified: trunk/src/main/org/hornetq/jms/server/management/JMSManagementService.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/management/JMSManagementService.java 2010-01-29
13:43:32 UTC (rev 8858)
+++ trunk/src/main/org/hornetq/jms/server/management/JMSManagementService.java 2010-01-29
18:51:42 UTC (rev 8859)
@@ -17,8 +17,7 @@
import org.hornetq.api.jms.management.JMSServerControl;
import org.hornetq.jms.client.HornetQConnectionFactory;
-import org.hornetq.jms.client.HornetQQueue;
-import org.hornetq.jms.client.HornetQTopic;
+import org.hornetq.jms.client.HornetQDestination;
import org.hornetq.jms.server.JMSServerManager;
/**
@@ -33,11 +32,11 @@
void unregisterJMSServer() throws Exception;
- void registerQueue(HornetQQueue queue, String jndiBinding) throws Exception;
+ void registerQueue(HornetQDestination queue, String jndiBinding) throws Exception;
void unregisterQueue(String name) throws Exception;
- void registerTopic(HornetQTopic topic, String jndiBinding) throws Exception;
+ void registerTopic(HornetQDestination topic, String jndiBinding) throws Exception;
void unregisterTopic(String name) throws Exception;
Modified:
trunk/src/main/org/hornetq/jms/server/management/impl/JMSManagementServiceImpl.java
===================================================================
---
trunk/src/main/org/hornetq/jms/server/management/impl/JMSManagementServiceImpl.java 2010-01-29
13:43:32 UTC (rev 8858)
+++
trunk/src/main/org/hornetq/jms/server/management/impl/JMSManagementServiceImpl.java 2010-01-29
18:51:42 UTC (rev 8859)
@@ -28,8 +28,7 @@
import org.hornetq.core.messagecounter.MessageCounterManager;
import org.hornetq.core.server.management.ManagementService;
import org.hornetq.jms.client.HornetQConnectionFactory;
-import org.hornetq.jms.client.HornetQQueue;
-import org.hornetq.jms.client.HornetQTopic;
+import org.hornetq.jms.client.HornetQDestination;
import org.hornetq.jms.management.impl.JMSConnectionFactoryControlImpl;
import org.hornetq.jms.management.impl.JMSQueueControlImpl;
import org.hornetq.jms.management.impl.JMSServerControlImpl;
@@ -78,7 +77,7 @@
managementService.unregisterFromRegistry(ResourceNames.JMS_SERVER);
}
- public synchronized void registerQueue(final HornetQQueue queue, final String
jndiBinding) throws Exception
+ public synchronized void registerQueue(final HornetQDestination queue, final String
jndiBinding) throws Exception
{
QueueControl coreQueueControl =
(QueueControl)managementService.getResource(ResourceNames.CORE_QUEUE +
queue.getAddress());
MessageCounterManager messageCounterManager =
managementService.getMessageCounterManager();
@@ -102,7 +101,7 @@
managementService.unregisterFromRegistry(ResourceNames.JMS_QUEUE + name);
}
- public synchronized void registerTopic(final HornetQTopic topic, final String
jndiBinding) throws Exception
+ public synchronized void registerTopic(final HornetQDestination topic, final String
jndiBinding) throws Exception
{
ObjectName objectName =
managementService.getObjectNameBuilder().getJMSTopicObjectName(topic.getTopicName());
AddressControl addressControl =
(AddressControl)managementService.getResource(ResourceNames.CORE_ADDRESS +
topic.getAddress());
Modified: trunk/src/main/org/hornetq/ra/inflow/HornetQMessageHandler.java
===================================================================
--- trunk/src/main/org/hornetq/ra/inflow/HornetQMessageHandler.java 2010-01-29 13:43:32
UTC (rev 8858)
+++ trunk/src/main/org/hornetq/ra/inflow/HornetQMessageHandler.java 2010-01-29 18:51:42
UTC (rev 8859)
@@ -28,8 +28,8 @@
import org.hornetq.api.core.client.MessageHandler;
import org.hornetq.api.core.client.ClientSession.QueueQuery;
import org.hornetq.core.logging.Logger;
+import org.hornetq.jms.client.HornetQDestination;
import org.hornetq.jms.client.HornetQMessage;
-import org.hornetq.jms.client.HornetQTopic;
/**
* The message handler
@@ -95,7 +95,7 @@
throw new InvalidClientIDException("Cannot create durable subscription -
client ID has not been set");
}
- SimpleString queueName = new
SimpleString(HornetQTopic.createQueueNameForDurableSubscription(activation.getActivationSpec()
+ SimpleString queueName = new
SimpleString(HornetQDestination.createQueueNameForDurableSubscription(activation.getActivationSpec()
.getClientID(),
subscriptionName));
Modified: trunk/tests/jms-tests/src/org/hornetq/jms/tests/ReferenceableTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/hornetq/jms/tests/ReferenceableTest.java 2010-01-29
13:43:32 UTC (rev 8858)
+++ trunk/tests/jms-tests/src/org/hornetq/jms/tests/ReferenceableTest.java 2010-01-29
18:51:42 UTC (rev 8859)
@@ -26,8 +26,7 @@
import javax.naming.Referenceable;
import org.hornetq.jms.client.HornetQConnectionFactory;
-import org.hornetq.jms.client.HornetQQueue;
-import org.hornetq.jms.client.HornetQTopic;
+import org.hornetq.jms.client.HornetQDestination;
import org.hornetq.jms.referenceable.ConnectionFactoryObjectFactory;
import org.hornetq.jms.referenceable.DestinationObjectFactory;
import org.hornetq.jms.tests.util.ProxyAssertSupport;
@@ -104,9 +103,9 @@
Object instance = factory.getObjectInstance(queueRef, null, null, null);
- ProxyAssertSupport.assertTrue(instance instanceof HornetQQueue);
+ ProxyAssertSupport.assertTrue(instance instanceof HornetQDestination);
- HornetQQueue queue2 = (HornetQQueue)instance;
+ HornetQDestination queue2 = (HornetQDestination)instance;
ProxyAssertSupport.assertEquals(HornetQServerTestCase.queue1.getQueueName(),
queue2.getQueueName());
@@ -126,10 +125,10 @@
Object instance = factory.getObjectInstance(topicRef, null, null, null);
- ProxyAssertSupport.assertTrue(instance instanceof HornetQTopic);
+ ProxyAssertSupport.assertTrue(instance instanceof HornetQDestination);
+
+ HornetQDestination topic2 = (HornetQDestination)instance;
- HornetQTopic topic2 = (HornetQTopic)instance;
-
ProxyAssertSupport.assertEquals(HornetQServerTestCase.topic1.getTopicName(),
topic2.getTopicName());
simpleSendReceive(JMSTestCase.cf, topic2);
Added: trunk/tests/src/org/hornetq/tests/integration/jms/client/CreateQueueTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/client/CreateQueueTest.java
(rev 0)
+++
trunk/tests/src/org/hornetq/tests/integration/jms/client/CreateQueueTest.java 2010-01-29
18:51:42 UTC (rev 8859)
@@ -0,0 +1,204 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat 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.hornetq.tests.integration.jms.client;
+
+import javax.jms.Connection;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.Topic;
+
+import org.hornetq.core.logging.Logger;
+import org.hornetq.jms.client.HornetQDestination;
+import org.hornetq.tests.util.JMSTestBase;
+
+/**
+ *
+ * A CreateQueueTest
+ *
+ * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
+ *
+ *
+ */
+public class CreateQueueTest extends JMSTestBase
+{
+ // Constants -----------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(CreateQueueTest.class);
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public void testCreateQueueTempQueue() throws Exception
+ {
+ Connection conn = cf.createConnection();
+
+ try
+ {
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Queue tempQueue = session.createTemporaryQueue();
+
+ String tempQueueName = tempQueue.getQueueName();
+
+
assertFalse(tempQueueName.startsWith(HornetQDestination.JMS_QUEUE_ADDRESS_PREFIX));
+
+ Queue replyQueue = session.createQueue(tempQueueName);
+
+ MessageProducer producer = session.createProducer(replyQueue);
+
+ producer.send(session.createMessage());
+
+ MessageConsumer consumer= session.createConsumer(replyQueue);
+
+ conn.start();
+
+ assertNotNull(consumer.receive(10000));
+
+ }
+ finally
+ {
+ try
+ {
+ conn.close();
+ }
+ catch (Throwable igonred)
+ {
+ }
+ }
+ }
+
+ public void testCreateQueue() throws Exception
+ {
+ Connection conn = cf.createConnection();
+
+ try
+ {
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Queue queue = createQueue("TestQueue");
+
+ String queueName = queue.getQueueName();
+
+ log.info("queue name is " + queueName);
+
+ assertFalse(queueName.startsWith(HornetQDestination.JMS_QUEUE_ADDRESS_PREFIX));
+
+ Queue replyQueue = session.createQueue(queueName);
+
+ MessageProducer producer = session.createProducer(replyQueue);
+
+ producer.send(session.createMessage());
+
+ MessageConsumer consumer= session.createConsumer(replyQueue);
+
+ conn.start();
+
+ assertNotNull(consumer.receive(10000));
+
+ }
+ finally
+ {
+ try
+ {
+ conn.close();
+ }
+ catch (Throwable igonred)
+ {
+ }
+ }
+ }
+
+ public void testCreateTopic() throws Exception
+ {
+ Connection conn = cf.createConnection();
+
+ try
+ {
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Topic topic = createTopic("TestTopic");
+
+ String topicName = topic.getTopicName();
+
+ assertFalse(topicName.startsWith(HornetQDestination.JMS_TOPIC_ADDRESS_PREFIX));
+
+ Topic replyTopic = session.createTopic(topicName);
+
+ MessageConsumer consumer= session.createConsumer(replyTopic);
+
+ conn.start();
+
+ MessageProducer producer = session.createProducer(replyTopic);
+
+ producer.send(session.createMessage());
+
+ assertNotNull(consumer.receive(10000));
+ }
+ finally
+ {
+ try
+ {
+ conn.close();
+ }
+ catch (Throwable igonred)
+ {
+ }
+ }
+ }
+
+ public void testCreateTopicTempTopic() throws Exception
+ {
+ Connection conn = cf.createConnection();
+
+ try
+ {
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Topic tempTopic = session.createTemporaryTopic();
+
+ String tempTopicName = tempTopic.getTopicName();
+
+
assertFalse(tempTopicName.startsWith(HornetQDestination.JMS_TOPIC_ADDRESS_PREFIX));
+
+ Topic replyTopic = session.createTopic(tempTopicName);
+
+ MessageConsumer consumer= session.createConsumer(replyTopic);
+
+ conn.start();
+
+ MessageProducer producer = session.createProducer(replyTopic);
+
+ producer.send(session.createMessage());
+
+ assertNotNull(consumer.receive(10000));
+ }
+ finally
+ {
+ try
+ {
+ conn.close();
+ }
+ catch (Throwable igonred)
+ {
+ }
+ }
+ }
+}
Modified: trunk/tests/src/org/hornetq/tests/integration/jms/cluster/JMSFailoverTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/jms/cluster/JMSFailoverTest.java 2010-01-29
13:43:32 UTC (rev 8858)
+++
trunk/tests/src/org/hornetq/tests/integration/jms/cluster/JMSFailoverTest.java 2010-01-29
18:51:42 UTC (rev 8859)
@@ -43,7 +43,7 @@
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
import org.hornetq.jms.client.HornetQConnectionFactory;
-import org.hornetq.jms.client.HornetQQueue;
+import org.hornetq.jms.client.HornetQDestination;
import org.hornetq.jms.client.HornetQSession;
import org.hornetq.spi.core.protocol.RemotingConnection;
import org.hornetq.tests.util.RandomUtil;
@@ -113,7 +113,7 @@
RemotingConnection coreConn =
((ClientSessionInternal)coreSession).getConnection();
- SimpleString jmsQueueName = new SimpleString(HornetQQueue.JMS_QUEUE_ADDRESS_PREFIX
+ "myqueue");
+ SimpleString jmsQueueName = new
SimpleString(HornetQDestination.JMS_QUEUE_ADDRESS_PREFIX + "myqueue");
coreSession.createQueue(jmsQueueName, jmsQueueName, null, true);
@@ -192,7 +192,7 @@
RemotingConnection coreConnLive =
((ClientSessionInternal)coreSessionLive).getConnection();
- SimpleString jmsQueueName = new SimpleString(HornetQQueue.JMS_QUEUE_ADDRESS_PREFIX
+ "myqueue");
+ SimpleString jmsQueueName = new
SimpleString(HornetQDestination.JMS_QUEUE_ADDRESS_PREFIX + "myqueue");
coreSessionLive.createQueue(jmsQueueName, jmsQueueName, null, true);
Modified: trunk/tests/src/org/hornetq/tests/integration/jms/cluster/JMSReconnectTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/jms/cluster/JMSReconnectTest.java 2010-01-29
13:43:32 UTC (rev 8858)
+++
trunk/tests/src/org/hornetq/tests/integration/jms/cluster/JMSReconnectTest.java 2010-01-29
18:51:42 UTC (rev 8859)
@@ -41,9 +41,8 @@
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
import org.hornetq.jms.client.HornetQConnectionFactory;
-import org.hornetq.jms.client.HornetQQueue;
+import org.hornetq.jms.client.HornetQDestination;
import org.hornetq.jms.client.HornetQSession;
-import org.hornetq.jms.client.HornetQTopic;
import org.hornetq.spi.core.protocol.RemotingConnection;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.UnitTestCase;
@@ -120,7 +119,7 @@
RemotingConnection coreConn =
((ClientSessionInternal)coreSession).getConnection();
- SimpleString jmsQueueName = new SimpleString(HornetQQueue.JMS_QUEUE_ADDRESS_PREFIX
+ "myqueue");
+ SimpleString jmsQueueName = new
SimpleString(HornetQDestination.JMS_QUEUE_ADDRESS_PREFIX + "myqueue");
coreSession.createQueue(jmsQueueName, jmsQueueName, null, true);
@@ -145,8 +144,6 @@
conn.start();
- log.info("sent messages and started connection");
-
Thread.sleep(2000);
HornetQException me = new HornetQException(HornetQException.NOT_CONNECTED);
@@ -157,8 +154,6 @@
for (int i = 0; i < numMessages; i++)
{
- log.info("got message " + i);
-
BytesMessage bm = (BytesMessage)consumer.receive(1000);
Assert.assertNotNull(bm);
@@ -188,7 +183,7 @@
}
//Test that non durable JMS sub gets recreated in auto reconnect
- private void testReconnectSameNodeServerRestartedWithNonDurableSubOrTempQueue(final
boolean durableSub) throws Exception
+ private void testReconnectSameNodeServerRestartedWithNonDurableSubOrTempQueue(final
boolean nonDurableSub) throws Exception
{
HornetQConnectionFactory jbcf = (HornetQConnectionFactory)
HornetQJMSClient.createConnectionFactory(new
TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory"));
@@ -206,9 +201,9 @@
Destination dest;
- if (durableSub)
- {
- coreSession.createQueue(HornetQTopic.JMS_TOPIC_ADDRESS_PREFIX +
"mytopic", "blahblah", null, false);
+ if (nonDurableSub)
+ {
+ coreSession.createQueue(HornetQDestination.JMS_TOPIC_ADDRESS_PREFIX +
"mytopic", "blahblah", null, false);
dest = HornetQJMSClient.createTopic("mytopic");
}
@@ -229,8 +224,6 @@
//Allow client some time to reconnect
Thread.sleep(3000);
- log.info("now sending some messages");
-
final int numMessages = 100;
byte[] body = RandomUtil.randomBytes(1000);
@@ -277,7 +270,7 @@
ClientSession coreSession = ((HornetQSession)sess).getCoreSession();
- coreSession.createQueue(HornetQTopic.JMS_TOPIC_ADDRESS_PREFIX +
"mytopic", "blahblah", null, false);
+ coreSession.createQueue(HornetQDestination.JMS_TOPIC_ADDRESS_PREFIX +
"mytopic", "blahblah", null, false);
Topic topic = HornetQJMSClient.createTopic("mytopic");
Modified: trunk/tests/src/org/hornetq/tests/integration/jms/consumer/ConsumerTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/jms/consumer/ConsumerTest.java 2010-01-29
13:43:32 UTC (rev 8858)
+++
trunk/tests/src/org/hornetq/tests/integration/jms/consumer/ConsumerTest.java 2010-01-29
18:51:42 UTC (rev 8859)
@@ -30,7 +30,7 @@
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.Queue;
import org.hornetq.jms.client.HornetQConnectionFactory;
-import org.hornetq.jms.client.HornetQQueue;
+import org.hornetq.jms.client.HornetQDestination;
import org.hornetq.tests.util.JMSTestBase;
/**
@@ -42,7 +42,7 @@
private static final String Q_NAME = "ConsumerTestQueue";
- private HornetQQueue jBossQueue;
+ private javax.jms.Queue jBossQueue;
@Override
protected void setUp() throws Exception
@@ -65,7 +65,7 @@
{
Connection conn = cf.createConnection();
Session session = conn.createSession(false, HornetQJMSConstants.PRE_ACKNOWLEDGE);
- jBossQueue = (HornetQQueue) HornetQJMSClient.createQueue(ConsumerTest.Q_NAME);
+ jBossQueue = HornetQJMSClient.createQueue(ConsumerTest.Q_NAME);
MessageProducer producer = session.createProducer(jBossQueue);
MessageConsumer consumer = session.createConsumer(jBossQueue);
int noOfMessages = 100;
@@ -81,7 +81,7 @@
Assert.assertNotNull(m);
}
- SimpleString queueName = new SimpleString(HornetQQueue.JMS_QUEUE_ADDRESS_PREFIX +
ConsumerTest.Q_NAME);
+ SimpleString queueName = new
SimpleString(HornetQDestination.JMS_QUEUE_ADDRESS_PREFIX + ConsumerTest.Q_NAME);
Assert.assertEquals(0,
((Queue)server.getPostOffice().getBinding(queueName).getBindable()).getDeliveringCount());
Assert.assertEquals(0,
((Queue)server.getPostOffice().getBinding(queueName).getBindable()).getMessageCount());
conn.close();
@@ -93,7 +93,7 @@
Connection conn = cf.createConnection();
Session session = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- jBossQueue = (HornetQQueue) HornetQJMSClient.createQueue(ConsumerTest.Q_NAME);
+ jBossQueue = HornetQJMSClient.createQueue(ConsumerTest.Q_NAME);
MessageProducer producer = session.createProducer(jBossQueue);
MessageConsumer consumer = session.createConsumer(jBossQueue);
int noOfMessages = 100;
@@ -110,7 +110,7 @@
}
// Messages should all have been acked since we set pre ack on the cf
- SimpleString queueName = new SimpleString(HornetQQueue.JMS_QUEUE_ADDRESS_PREFIX +
ConsumerTest.Q_NAME);
+ SimpleString queueName = new
SimpleString(HornetQDestination.JMS_QUEUE_ADDRESS_PREFIX + ConsumerTest.Q_NAME);
Assert.assertEquals(0,
((Queue)server.getPostOffice().getBinding(queueName).getBindable()).getDeliveringCount());
Assert.assertEquals(0,
((Queue)server.getPostOffice().getBinding(queueName).getBindable()).getMessageCount());
conn.close();
@@ -122,7 +122,7 @@
Connection conn = cf.createConnection();
Session session = conn.createSession(false, HornetQJMSConstants.PRE_ACKNOWLEDGE);
- jBossQueue = (HornetQQueue) HornetQJMSClient.createQueue(ConsumerTest.Q_NAME);
+ jBossQueue = HornetQJMSClient.createQueue(ConsumerTest.Q_NAME);
MessageProducer producer = session.createProducer(jBossQueue);
MessageConsumer consumer = session.createConsumer(jBossQueue);
int noOfMessages = 1000;
@@ -152,7 +152,7 @@
((HornetQConnectionFactory)cf).setPreAcknowledge(true);
Connection conn = cf.createConnection();
Session session = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- jBossQueue = (HornetQQueue) HornetQJMSClient.createQueue(ConsumerTest.Q_NAME);
+ jBossQueue = HornetQJMSClient.createQueue(ConsumerTest.Q_NAME);
MessageProducer producer = session.createProducer(jBossQueue);
MessageConsumer consumer = session.createConsumer(jBossQueue);
int noOfMessages = 1000;
@@ -180,7 +180,7 @@
{
Connection conn = cf.createConnection();
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- jBossQueue = (HornetQQueue) HornetQJMSClient.createQueue(ConsumerTest.Q_NAME);
+ jBossQueue = HornetQJMSClient.createQueue(ConsumerTest.Q_NAME);
MessageConsumer consumer = session.createConsumer(jBossQueue);
consumer.setMessageListener(new MessageListener()
{
@@ -199,7 +199,7 @@
{
Connection conn = cf.createConnection();
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- jBossQueue = (HornetQQueue) HornetQJMSClient.createQueue(ConsumerTest.Q_NAME);
+ jBossQueue = HornetQJMSClient.createQueue(ConsumerTest.Q_NAME);
MessageConsumer consumer = session.createConsumer(jBossQueue);
consumer.setMessageListener(new MessageListener()
{
Modified:
trunk/tests/src/org/hornetq/tests/integration/jms/divert/DivertAndACKClientTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/jms/divert/DivertAndACKClientTest.java 2010-01-29
13:43:32 UTC (rev 8858)
+++
trunk/tests/src/org/hornetq/tests/integration/jms/divert/DivertAndACKClientTest.java 2010-01-29
18:51:42 UTC (rev 8859)
@@ -19,6 +19,7 @@
import javax.jms.Connection;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
+import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
@@ -27,7 +28,6 @@
import org.hornetq.api.core.Pair;
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.client.HornetQClient;
-import org.hornetq.jms.client.HornetQQueue;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.server.cluster.DivertConfiguration;
import org.hornetq.tests.util.JMSTestBase;
@@ -56,8 +56,8 @@
public void testAutoACK() throws Exception
{
- HornetQQueue queueSource = (HornetQQueue)createQueue("Source");
- HornetQQueue queueTarget = (HornetQQueue)createQueue("Dest");
+ Queue queueSource = createQueue("Source");
+ Queue queueTarget = createQueue("Dest");
Connection connection = cf.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -79,8 +79,8 @@
public void testClientACK() throws Exception
{
- HornetQQueue queueSource = (HornetQQueue)createQueue("Source");
- HornetQQueue queueTarget = (HornetQQueue)createQueue("Dest");
+ Queue queueSource = createQueue("Source");
+ Queue queueTarget = createQueue("Dest");
Connection connection = cf.createConnection();
Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
Modified:
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSQueueControlTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSQueueControlTest.java 2010-01-29
13:43:32 UTC (rev 8858)
+++
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSQueueControlTest.java 2010-01-29
18:51:42 UTC (rev 8859)
@@ -39,7 +39,7 @@
import org.hornetq.core.server.HornetQServers;
import org.hornetq.core.settings.impl.AddressSettings;
import org.hornetq.jms.client.HornetQConnectionFactory;
-import org.hornetq.jms.client.HornetQQueue;
+import org.hornetq.jms.client.HornetQDestination;
import org.hornetq.jms.server.impl.JMSServerManagerImpl;
import org.hornetq.tests.integration.management.ManagementControlHelper;
import org.hornetq.tests.integration.management.ManagementTestBase;
@@ -66,7 +66,7 @@
private JMSServerManagerImpl serverManager;
- protected HornetQQueue queue;
+ protected HornetQDestination queue;
protected Context context;
@@ -416,7 +416,7 @@
{
JMSQueueControl queueControl = createManagementControl();
String expiryQueueName = RandomUtil.randomString();
- HornetQQueue expiryQueue = (HornetQQueue)
HornetQJMSClient.createQueue(expiryQueueName);
+ HornetQDestination expiryQueue =
(HornetQDestination)HornetQJMSClient.createQueue(expiryQueueName);
serverManager.createQueue(expiryQueueName, expiryQueueName, null, true);
queueControl.setExpiryAddress(expiryQueue.getAddress());
@@ -545,7 +545,7 @@
{
String deadLetterQueue = RandomUtil.randomString();
serverManager.createQueue(deadLetterQueue, deadLetterQueue, null, true);
- HornetQQueue dlq = (HornetQQueue) HornetQJMSClient.createQueue(deadLetterQueue);
+ HornetQDestination dlq =
(HornetQDestination)HornetQJMSClient.createQueue(deadLetterQueue);
Connection conn = createConnection();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -606,7 +606,7 @@
String deadLetterQueue = RandomUtil.randomString();
serverManager.createQueue(deadLetterQueue, deadLetterQueue, null, true);
- HornetQQueue dlq = (HornetQQueue) HornetQJMSClient.createQueue(deadLetterQueue);
+ HornetQDestination dlq =
(HornetQDestination)HornetQJMSClient.createQueue(deadLetterQueue);
Connection conn = createConnection();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -648,7 +648,7 @@
String otherQueueName = RandomUtil.randomString();
serverManager.createQueue(otherQueueName, otherQueueName, null, true);
- HornetQQueue otherQueue = (HornetQQueue)
HornetQJMSClient.createQueue(otherQueueName);
+ HornetQDestination otherQueue =
(HornetQDestination)HornetQJMSClient.createQueue(otherQueueName);
// send on queue
JMSUtil.sendMessages(queue, 2);
@@ -695,7 +695,7 @@
String otherQueueName = RandomUtil.randomString();
serverManager.createQueue(otherQueueName, otherQueueName, null, true);
- HornetQQueue otherQueue = (HornetQQueue)
HornetQJMSClient.createQueue(otherQueueName);
+ HornetQDestination otherQueue =
(HornetQDestination)HornetQJMSClient.createQueue(otherQueueName);
Connection connection =
JMSUtil.createConnection(InVMConnectorFactory.class.getName());
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -730,7 +730,7 @@
String otherQueueName = RandomUtil.randomString();
serverManager.createQueue(otherQueueName, otherQueueName, null, true);
- HornetQQueue otherQueue = (HornetQQueue)
HornetQJMSClient.createQueue(otherQueueName);
+ HornetQDestination otherQueue =
(HornetQDestination)HornetQJMSClient.createQueue(otherQueueName);
String[] messageIDs = JMSUtil.sendMessages(queue, 1);
@@ -834,7 +834,7 @@
String queueName = RandomUtil.randomString();
serverManager.createQueue(queueName, queueName, null, true);
- queue = (HornetQQueue) HornetQJMSClient.createQueue(queueName);
+ queue = (HornetQDestination)HornetQJMSClient.createQueue(queueName);
}
@Override
@@ -866,7 +866,7 @@
private Connection createConnection() throws JMSException
{
- HornetQConnectionFactory cf = (HornetQConnectionFactory)
HornetQJMSClient.createConnectionFactory(new
TransportConfiguration(InVMConnectorFactory.class.getName()));
+ HornetQConnectionFactory cf =
(HornetQConnectionFactory)HornetQJMSClient.createConnectionFactory(new
TransportConfiguration(InVMConnectorFactory.class.getName()));
cf.setBlockOnDurableSend(true);
Modified:
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSQueueControlUsingJMSTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSQueueControlUsingJMSTest.java 2010-01-29
13:43:32 UTC (rev 8858)
+++
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSQueueControlUsingJMSTest.java 2010-01-29
18:51:42 UTC (rev 8859)
@@ -22,10 +22,10 @@
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.management.ResourceNames;
import org.hornetq.api.jms.HornetQJMSClient;
-import org.hornetq.jms.client.HornetQConnectionFactory;
-import org.hornetq.jms.client.HornetQQueue;
import org.hornetq.api.jms.management.JMSQueueControl;
import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
+import org.hornetq.jms.client.HornetQConnectionFactory;
+import org.hornetq.jms.client.HornetQDestination;
/**
*
@@ -77,7 +77,7 @@
@Override
protected JMSQueueControl createManagementControl() throws Exception
{
- HornetQQueue managementQueue = (HornetQQueue)
HornetQJMSClient.createQueue("hornetq.management");
+ HornetQDestination managementQueue = (HornetQDestination)
HornetQJMSClient.createQueue("hornetq.management");
final JMSMessagingProxy proxy = new JMSMessagingProxy(session,
managementQueue,
Modified:
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java 2010-01-29
13:43:32 UTC (rev 8858)
+++
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java 2010-01-29
18:51:42 UTC (rev 8859)
@@ -22,11 +22,10 @@
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.management.ResourceNames;
import org.hornetq.api.jms.HornetQJMSClient;
-import org.hornetq.jms.client.HornetQConnectionFactory;
-import org.hornetq.jms.client.HornetQQueue;
import org.hornetq.api.jms.management.JMSServerControl;
-import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
+import org.hornetq.jms.client.HornetQConnectionFactory;
+import org.hornetq.jms.client.HornetQDestination;
/**
* A JMSServerControlUsingCoreTest
@@ -86,7 +85,7 @@
@Override
protected JMSServerControl createManagementControl() throws Exception
{
- HornetQQueue managementQueue = (HornetQQueue)
HornetQJMSClient.createQueue("hornetq.management");
+ HornetQDestination managementQueue = (HornetQDestination)
HornetQJMSClient.createQueue("hornetq.management");
final JMSMessagingProxy proxy = new JMSMessagingProxy(session, managementQueue,
ResourceNames.JMS_SERVER);
return new JMSServerControl()
Modified:
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/TopicControlTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/TopicControlTest.java 2010-01-29
13:43:32 UTC (rev 8858)
+++
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/TopicControlTest.java 2010-01-29
18:51:42 UTC (rev 8859)
@@ -30,7 +30,7 @@
import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
-import org.hornetq.jms.client.HornetQTopic;
+import org.hornetq.jms.client.HornetQDestination;
import org.hornetq.jms.server.impl.JMSServerManagerImpl;
import org.hornetq.tests.integration.management.ManagementControlHelper;
import org.hornetq.tests.integration.management.ManagementTestBase;
@@ -61,7 +61,7 @@
private String subscriptionName;
- protected HornetQTopic topic;
+ protected HornetQDestination topic;
// Static --------------------------------------------------------
@@ -338,8 +338,8 @@
JMSUtil.sendMessages(topic, 3);
TopicControl topicControl = createManagementControl();
- Map<String, Object>[] messages =
topicControl.listMessagesForSubscription(HornetQTopic.createQueueNameForDurableSubscription(clientID,
-
subscriptionName));
+ Map<String, Object>[] messages =
topicControl.listMessagesForSubscription(HornetQDestination.createQueueNameForDurableSubscription(clientID,
+
subscriptionName));
Assert.assertEquals(3, messages.length);
connection.close();
@@ -354,8 +354,8 @@
String[] ids = JMSUtil.sendMessages(topic, 3);
TopicControl topicControl = createManagementControl();
- String jsonString =
topicControl.listMessagesForSubscriptionAsJSON(HornetQTopic.createQueueNameForDurableSubscription(clientID,
-
subscriptionName));
+ String jsonString =
topicControl.listMessagesForSubscriptionAsJSON(HornetQDestination.createQueueNameForDurableSubscription(clientID,
+
subscriptionName));
Assert.assertNotNull(jsonString);
JSONArray array = new JSONArray(jsonString);
Assert.assertEquals(3, array.length());
@@ -375,8 +375,8 @@
try
{
-
topicControl.listMessagesForSubscription(HornetQTopic.createQueueNameForDurableSubscription(unknownClientID,
-
subscriptionName));
+
topicControl.listMessagesForSubscription(HornetQDestination.createQueueNameForDurableSubscription(unknownClientID,
+
subscriptionName));
Assert.fail();
}
catch (Exception e)
@@ -392,8 +392,8 @@
try
{
-
topicControl.listMessagesForSubscription(HornetQTopic.createQueueNameForDurableSubscription(clientID,
-
unknownSubscription));
+
topicControl.listMessagesForSubscription(HornetQDestination.createQueueNameForDurableSubscription(clientID,
+
unknownSubscription));
Assert.fail();
}
catch (Exception e)
@@ -428,7 +428,7 @@
String topicName = RandomUtil.randomString();
serverManager.createTopic(topicName, topicName);
- topic = (HornetQTopic) HornetQJMSClient.createTopic(topicName);
+ topic = (HornetQDestination)HornetQJMSClient.createTopic(topicName);
}
@Override
Modified:
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/TopicControlUsingJMSTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/TopicControlUsingJMSTest.java 2010-01-29
13:43:32 UTC (rev 8858)
+++
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/TopicControlUsingJMSTest.java 2010-01-29
18:51:42 UTC (rev 8859)
@@ -30,8 +30,7 @@
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
import org.hornetq.jms.client.HornetQConnectionFactory;
-import org.hornetq.jms.client.HornetQQueue;
-import org.hornetq.jms.client.HornetQTopic;
+import org.hornetq.jms.client.HornetQDestination;
import org.hornetq.jms.server.impl.JMSServerManagerImpl;
import org.hornetq.tests.integration.management.ManagementTestBase;
import org.hornetq.tests.util.RandomUtil;
@@ -51,7 +50,7 @@
private String subscriptionName;
- protected HornetQTopic topic;
+ protected HornetQDestination topic;
protected JMSMessagingProxy proxy;
@@ -288,7 +287,7 @@
JMSUtil.sendMessages(topic, 3);
Object[] data =
(Object[])proxy.invokeOperation("listMessagesForSubscription",
-
HornetQTopic.createQueueNameForDurableSubscription(clientID,
+
HornetQDestination.createQueueNameForDurableSubscription(clientID,
subscriptionName));
Assert.assertEquals(3, data.length);
@@ -302,7 +301,7 @@
try
{
proxy.invokeOperation("listMessagesForSubscription",
-
HornetQTopic.createQueueNameForDurableSubscription(unknownClientID, subscriptionName));
+
HornetQDestination.createQueueNameForDurableSubscription(unknownClientID,
subscriptionName));
Assert.fail();
}
catch (Exception e)
@@ -317,7 +316,7 @@
try
{
proxy.invokeOperation("listMessagesForSubscription",
-
HornetQTopic.createQueueNameForDurableSubscription(clientID, unknownSubscription));
+
HornetQDestination.createQueueNameForDurableSubscription(clientID, unknownSubscription));
Assert.fail();
}
catch (Exception e)
@@ -352,14 +351,14 @@
String topicName = RandomUtil.randomString();
serverManager.createTopic(topicName, topicName);
- topic = (HornetQTopic)HornetQJMSClient.createTopic(topicName);
+ topic = (HornetQDestination)HornetQJMSClient.createTopic(topicName);
HornetQConnectionFactory cf =
(HornetQConnectionFactory)HornetQJMSClient.createConnectionFactory(new
TransportConfiguration(InVMConnectorFactory.class.getName()));
connection = cf.createQueueConnection();
session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
connection.start();
- HornetQQueue managementQueue =
(HornetQQueue)HornetQJMSClient.createQueue("hornetq.management");
+ HornetQDestination managementQueue =
(HornetQDestination)HornetQJMSClient.createQueue("hornetq.management");
proxy = new JMSMessagingProxy(session, managementQueue, ResourceNames.JMS_TOPIC +
topic.getTopicName());
}
Modified: trunk/tests/src/org/hornetq/tests/unit/jms/HornetQDestinationTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/jms/HornetQDestinationTest.java 2010-01-29
13:43:32 UTC (rev 8858)
+++ trunk/tests/src/org/hornetq/tests/unit/jms/HornetQDestinationTest.java 2010-01-29
18:51:42 UTC (rev 8859)
@@ -14,18 +14,11 @@
package org.hornetq.tests.unit.jms;
import javax.jms.Queue;
-import javax.jms.TemporaryQueue;
-import javax.jms.TemporaryTopic;
import javax.jms.Topic;
import junit.framework.Assert;
-import org.hornetq.jms.*;
import org.hornetq.jms.client.HornetQDestination;
-import org.hornetq.jms.client.HornetQQueue;
-import org.hornetq.jms.client.HornetQTemporaryQueue;
-import org.hornetq.jms.client.HornetQTemporaryTopic;
-import org.hornetq.jms.client.HornetQTopic;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.UnitTestCase;
@@ -50,7 +43,7 @@
public void testEquals() throws Exception
{
String destinationName = RandomUtil.randomString();
- String address = HornetQQueue.JMS_QUEUE_ADDRESS_PREFIX + destinationName;
+ String address = HornetQDestination.JMS_QUEUE_ADDRESS_PREFIX + destinationName;
HornetQDestination destination = (HornetQDestination)
HornetQDestination.fromAddress(address);
HornetQDestination sameDestination = (HornetQDestination)
HornetQDestination.fromAddress(address);
HornetQDestination differentDestination = (HornetQDestination)
HornetQDestination.fromAddress(address + RandomUtil.randomString());
@@ -64,7 +57,7 @@
public void testFromAddressWithQueueAddressPrefix() throws Exception
{
String destinationName = RandomUtil.randomString();
- String address = HornetQQueue.JMS_QUEUE_ADDRESS_PREFIX + destinationName;
+ String address = HornetQDestination.JMS_QUEUE_ADDRESS_PREFIX + destinationName;
HornetQDestination destination = (HornetQDestination)
HornetQDestination.fromAddress(address);
Assert.assertTrue(destination instanceof Queue);
Assert.assertEquals(destinationName, ((Queue)destination).getQueueName());
@@ -73,30 +66,12 @@
public void testFromAddressWithTopicAddressPrefix() throws Exception
{
String destinationName = RandomUtil.randomString();
- String address = HornetQTopic.JMS_TOPIC_ADDRESS_PREFIX + destinationName;
+ String address = HornetQDestination.JMS_TOPIC_ADDRESS_PREFIX + destinationName;
HornetQDestination destination = (HornetQDestination)
HornetQDestination.fromAddress(address);
Assert.assertTrue(destination instanceof Topic);
Assert.assertEquals(destinationName, ((Topic)destination).getTopicName());
}
-
- public void testFromAddressWithTemporaryQueueAddressPrefix() throws Exception
- {
- String destinationName = RandomUtil.randomString();
- String address = HornetQTemporaryQueue.JMS_TEMP_QUEUE_ADDRESS_PREFIX +
destinationName;
- HornetQDestination destination = (HornetQDestination)
HornetQDestination.fromAddress(address);
- Assert.assertTrue(destination instanceof TemporaryQueue);
- Assert.assertEquals(destinationName,
((TemporaryQueue)destination).getQueueName());
- }
-
- public void testFromAddressWithTemporaryTopicAddressPrefix() throws Exception
- {
- String destinationName = RandomUtil.randomString();
- String address = HornetQTemporaryTopic.JMS_TEMP_TOPIC_ADDRESS_PREFIX +
destinationName;
- HornetQDestination destination = (HornetQDestination)
HornetQDestination.fromAddress(address);
- Assert.assertTrue(destination instanceof TemporaryTopic);
- Assert.assertEquals(destinationName,
((TemporaryTopic)destination).getTopicName());
- }
-
+
public void testFromAddressWithInvalidPrefix() throws Exception
{
String invalidPrefix = "junk";
Deleted: trunk/tests/src/org/hornetq/tests/unit/jms/HornetQQueueTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/jms/HornetQQueueTest.java 2010-01-29 13:43:32
UTC (rev 8858)
+++ trunk/tests/src/org/hornetq/tests/unit/jms/HornetQQueueTest.java 2010-01-29 18:51:42
UTC (rev 8859)
@@ -1,61 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat 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.hornetq.tests.unit.jms;
-
-import junit.framework.Assert;
-
-import org.hornetq.api.jms.HornetQJMSClient;
-import org.hornetq.jms.client.HornetQQueue;
-import org.hornetq.tests.util.RandomUtil;
-import org.hornetq.tests.util.UnitTestCase;
-
-/**
- * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
- *
- * @version <tt>$Revision$</tt>
- *
- */
-public class HornetQQueueTest extends UnitTestCase
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public void testIsTemporary() throws Exception
- {
- HornetQQueue queue = (HornetQQueue)
HornetQJMSClient.createQueue(RandomUtil.randomString());
- Assert.assertFalse(queue.isTemporary());
- }
-
- public void testGetQueueName() throws Exception
- {
- String queueName = RandomUtil.randomString();
- HornetQQueue queue = (HornetQQueue) HornetQJMSClient.createQueue(queueName);
- Assert.assertEquals(queueName, queue.getQueueName());
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/tests/src/org/hornetq/tests/unit/jms/HornetQTopicTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/jms/HornetQTopicTest.java 2010-01-29 13:43:32
UTC (rev 8858)
+++ trunk/tests/src/org/hornetq/tests/unit/jms/HornetQTopicTest.java 2010-01-29 18:51:42
UTC (rev 8859)
@@ -1,97 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat 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.hornetq.tests.unit.jms;
-
-import junit.framework.Assert;
-
-import org.hornetq.api.core.Pair;
-import org.hornetq.api.jms.HornetQJMSClient;
-import org.hornetq.jms.client.HornetQTopic;
-import org.hornetq.tests.util.RandomUtil;
-import org.hornetq.tests.util.UnitTestCase;
-
-/**
- * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
- *
- * @version <tt>$Revision$</tt>
- *
- */
-public class HornetQTopicTest extends UnitTestCase
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public void testIsTemporary() throws Exception
- {
- HornetQTopic topic = (HornetQTopic)
HornetQJMSClient.createTopic(RandomUtil.randomString());
- Assert.assertFalse(topic.isTemporary());
- }
-
- public void testGetTopicName() throws Exception
- {
- String topicName = RandomUtil.randomString();
- HornetQTopic queue = (HornetQTopic) HornetQJMSClient.createTopic(topicName);
- Assert.assertEquals(topicName, queue.getTopicName());
- }
-
- public void testDecomposeQueueNameForDurableSubscription() throws Exception
- {
- String clientID = RandomUtil.randomString();
- String subscriptionName = RandomUtil.randomString();
-
- Pair<String, String> pair =
HornetQTopic.decomposeQueueNameForDurableSubscription(clientID + '.' +
-
subscriptionName);
- Assert.assertEquals(clientID, pair.a);
- Assert.assertEquals(subscriptionName, pair.b);
- }
-
- public void testdDecomposeQueueNameForDurableSubscriptionWithInvalidQueueName() throws
Exception
- {
- try
- {
-
HornetQTopic.decomposeQueueNameForDurableSubscription("queueNameHasNoDot");
- Assert.fail("IllegalArgumentException");
- }
- catch (IllegalArgumentException e)
- {
- }
- }
-
- public void testdDcomposeQueueNameForDurableSubscriptionWithInvalidQueueName_2()
throws Exception
- {
- try
- {
-
HornetQTopic.decomposeQueueNameForDurableSubscription("queueName.HasTooMany.Dots");
- Assert.fail("IllegalArgumentException");
- }
- catch (IllegalArgumentException e)
- {
- }
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Modified:
trunk/tests/src/org/hornetq/tests/unit/jms/referenceable/DestinationObjectFactoryTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/unit/jms/referenceable/DestinationObjectFactoryTest.java 2010-01-29
13:43:32 UTC (rev 8858)
+++
trunk/tests/src/org/hornetq/tests/unit/jms/referenceable/DestinationObjectFactoryTest.java 2010-01-29
18:51:42 UTC (rev 8859)
@@ -19,7 +19,6 @@
import org.hornetq.api.jms.HornetQJMSClient;
import org.hornetq.jms.client.HornetQDestination;
-import org.hornetq.jms.client.HornetQQueue;
import org.hornetq.jms.referenceable.DestinationObjectFactory;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.UnitTestCase;
@@ -44,7 +43,7 @@
public void testReference() throws Exception
{
- HornetQDestination queue = (HornetQQueue)
HornetQJMSClient.createQueue(RandomUtil.randomString());
+ HornetQDestination queue = (HornetQDestination)
HornetQJMSClient.createQueue(RandomUtil.randomString());
Reference reference = queue.getReference();
DestinationObjectFactory factory = new DestinationObjectFactory();
Modified: trunk/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java 2010-01-29 13:43:32
UTC (rev 8858)
+++ trunk/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java 2010-01-29 18:51:42
UTC (rev 8859)
@@ -35,11 +35,11 @@
import org.hornetq.api.core.client.ClientSessionFactory;
import org.hornetq.api.core.client.HornetQClient;
import org.hornetq.api.jms.HornetQJMSClient;
-import org.hornetq.jms.client.HornetQConnectionFactory;
-import org.hornetq.jms.client.HornetQQueue;
import org.hornetq.core.remoting.impl.invm.InVMConnector;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.integration.transports.netty.NettyConnector;
+import org.hornetq.jms.client.HornetQConnectionFactory;
+import org.hornetq.jms.client.HornetQDestination;
import org.hornetq.ra.ConnectionFactoryProperties;
import org.hornetq.ra.HornetQRAManagedConnectionFactory;
import org.hornetq.ra.HornetQResourceAdapter;
@@ -387,7 +387,7 @@
ClientSessionFactory factory = createInVMFactory();
ClientSession session = factory.createSession(false, false, false);
- HornetQQueue queue = (HornetQQueue)
HornetQJMSClient.createQueue("test");
+ HornetQDestination queue = (HornetQDestination)
HornetQJMSClient.createQueue("test");
session.createQueue(queue.getSimpleAddress(), queue.getSimpleAddress(), true);
session.close();
Modified: trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java 2010-01-29 13:43:32 UTC (rev
8858)
+++ trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java 2010-01-29 18:51:42 UTC (rev
8859)
@@ -18,6 +18,7 @@
import javax.jms.ConnectionFactory;
import javax.jms.Queue;
+import javax.jms.Topic;
import javax.naming.NamingException;
import org.hornetq.api.core.Pair;
@@ -88,7 +89,14 @@
return (Queue)context.lookup("/jms/" + name);
}
+
+ protected Topic createTopic(final String name) throws Exception, NamingException
+ {
+ jmsServer.createTopic(name, "/jms/" + name);
+ return (Topic)context.lookup("/jms/" + name);
+ }
+
@Override
protected void setUp() throws Exception
{