You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2013/11/29 18:00:36 UTC
svn commit: r1546610 - in /qpid/jms/trunk/src:
main/java/org/apache/qpid/jms/engine/ main/java/org/apache/qpid/jms/impl/
test/java/org/apache/qpid/jms/ test/java/org/apache/qpid/jms/impl/
Author: robbie
Date: Fri Nov 29 17:00:36 2013
New Revision: 1546610
URL: http://svn.apache.org/r1546610
Log:
QPIDJMS-9: expand Destination impl somewhat, begin tramsitting and using type information to allow fully reproducing the Destination objects
Added:
qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/DestinationImpl.java
- copied, changed from r1546609, qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/QueueImpl.java
qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/TopicImpl.java
- copied, changed from r1546609, qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/QueueImpl.java
qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/TopicImplTest.java
Modified:
qpid/jms/trunk/src/main/java/org/apache/qpid/jms/engine/AmqpMessage.java
qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/ConnectionImpl.java
qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/DestinationHelper.java
qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/MessageImpl.java
qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/QueueImpl.java
qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/SessionImpl.java
qpid/jms/trunk/src/test/java/org/apache/qpid/jms/MessageIntegrationTest.java
qpid/jms/trunk/src/test/java/org/apache/qpid/jms/SenderIntegrationTest.java
qpid/jms/trunk/src/test/java/org/apache/qpid/jms/SessionIntegrationTest.java
qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/DestinationHelperTest.java
qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/MessageImplTest.java
qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/SenderImplTest.java
Modified: qpid/jms/trunk/src/main/java/org/apache/qpid/jms/engine/AmqpMessage.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/main/java/org/apache/qpid/jms/engine/AmqpMessage.java?rev=1546610&r1=1546609&r2=1546610&view=diff
==============================================================================
--- qpid/jms/trunk/src/main/java/org/apache/qpid/jms/engine/AmqpMessage.java (original)
+++ qpid/jms/trunk/src/main/java/org/apache/qpid/jms/engine/AmqpMessage.java Fri Nov 29 17:00:36 2013
@@ -22,7 +22,6 @@ package org.apache.qpid.jms.engine;
import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -35,10 +34,6 @@ import org.apache.qpid.proton.engine.Del
import org.apache.qpid.proton.engine.impl.DeliveryImpl;
import org.apache.qpid.proton.message.Message;
-/**
- * Thread-safe (all state is guarded by the corresponding {@link AmqpConnection} monitor)
- *
- */
public abstract class AmqpMessage
{
private final Delivery _delivery;
Modified: qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/ConnectionImpl.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/ConnectionImpl.java?rev=1546610&r1=1546609&r2=1546610&view=diff
==============================================================================
--- qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/ConnectionImpl.java (original)
+++ qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/ConnectionImpl.java Fri Nov 29 17:00:36 2013
@@ -62,6 +62,8 @@ public class ConnectionImpl implements C
private volatile boolean _isStarted;
+ private DestinationHelper _destinationHelper;
+
/**
* TODO: accept a client id
* TODO: defer connection to the broker if client has not been set. Defer it until any other method is called.
@@ -93,6 +95,8 @@ public class ConnectionImpl implements C
{
throw new QpidJmsException("Unable to create connection", e);
}
+
+ _destinationHelper = new DestinationHelper();
}
void waitUntil(Predicate condition, long timeoutMillis) throws JmsTimeoutException, JmsInterruptedException
@@ -283,7 +287,7 @@ public class ConnectionImpl implements C
{
AmqpSession amqpSession = _amqpConnection.createSession();
- SessionImpl session = new SessionImpl(acknowledgeMode, amqpSession, this);
+ SessionImpl session = new SessionImpl(acknowledgeMode, amqpSession, this, _destinationHelper);
stateChanged();
session.establish();
Modified: qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/DestinationHelper.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/DestinationHelper.java?rev=1546610&r1=1546609&r2=1546610&view=diff
==============================================================================
--- qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/DestinationHelper.java (original)
+++ qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/DestinationHelper.java Fri Nov 29 17:00:36 2013
@@ -20,6 +20,7 @@
*/
package org.apache.qpid.jms.impl;
+import java.util.HashSet;
import java.util.Set;
import javax.jms.Destination;
@@ -31,20 +32,38 @@ import javax.jms.Topic;
public class DestinationHelper
{
- //TODO: this only deals with Queues currently as that is all that is implemented so far. This will
- //eventually need to distinguish Queues, Topics, and possibly 'Destinations' that are neither.
+ public static final String TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME = "x-opt-to-type";
+
+ static final String QUEUE_ATTRIBUTE = "queue";
+ static final String TOPIC_ATTRIBUTE = "topic";
+ static final String TEMPORARY_ATTRIBUTE = "temporary";
+
+ public static final String QUEUE_ATTRIBUTES_STRING = QUEUE_ATTRIBUTE;
+ public static final String TOPIC_ATTRIBUTES_STRING = TOPIC_ATTRIBUTE;
+ public static final String TEMP_QUEUE_ATTRIBUTES_STRING = QUEUE_ATTRIBUTE + "," + TEMPORARY_ATTRIBUTE;
+ public static final String TEMP_TOPIC_ATTRIBUTES_STRING = TOPIC_ATTRIBUTE + "," + TEMPORARY_ATTRIBUTE;
+
public DestinationHelper()
{
}
+ public Queue createQueue(String address)
+ {
+ return new QueueImpl(address);
+ }
+
+ public Topic createTopic(String address)
+ {
+ return new TopicImpl(address);
+ }
+
public Destination decodeDestination(String address, String typeString)
{
Set<String> typeSet = null;
if(typeString != null)
{
- //TODO
- throw new IllegalArgumentException("Support for type classification not yet present");
+ typeSet = splitAttributes(typeString);
}
return createDestination(address, typeSet);
@@ -57,13 +76,40 @@ public class DestinationHelper
return null;
}
- if(typeSet != null)
+ if(typeSet == null || typeSet.isEmpty())
{
- //TODO
- throw new IllegalArgumentException("Support for type classification not yet present");
+ //TODO: characterise Destination used to create the receiver, and create that type
+ }
+ else
+ {
+ if(typeSet.contains(QUEUE_ATTRIBUTE))
+ {
+ if(typeSet.contains(TEMPORARY_ATTRIBUTE))
+ {
+ //TODO
+ throw new IllegalArgumentException("TemporaryQueue not yet supported");
+ }
+ else
+ {
+ return createQueue(address);
+ }
+ }
+ else if(typeSet.contains(TOPIC_ATTRIBUTE))
+ {
+ if(typeSet.contains(TEMPORARY_ATTRIBUTE))
+ {
+ //TODO
+ throw new IllegalArgumentException("TemporaryTopic not yet supported");
+ }
+ else
+ {
+ return createTopic(address);
+ }
+ }
}
- return new QueueImpl(address);
+ //fall back to a straight Destination
+ return new DestinationImpl(address);
}
public Destination convertToQpidDestination(Destination dest) throws JMSException
@@ -73,7 +119,11 @@ public class DestinationHelper
return null;
}
- if(!(isQpidDestination(dest)))
+ if(isQpidDestination(dest))
+ {
+ return dest;
+ }
+ else
{
if(dest instanceof TemporaryQueue)
{
@@ -87,28 +137,22 @@ public class DestinationHelper
}
else if(dest instanceof Queue)
{
- return createDestination(((Queue) dest).getQueueName(), null);
+ return createQueue(((Queue) dest).getQueueName());
}
else if(dest instanceof Topic)
{
- //TODO
- throw new IllegalArgumentException("Unsupported Destination type: " + dest.getClass().getName());
+ return createTopic(((Topic) dest).getTopicName());
}
else
{
throw new IllegalArgumentException("Unsupported Destination type: " + dest.getClass().getName());
}
}
- else
- {
- return dest;
- }
}
public boolean isQpidDestination(Destination dest)
{
- //TODO: support other destination types when implemented
- return dest instanceof QueueImpl;
+ return dest instanceof DestinationImpl;
}
public String decodeAddress(Destination destination) throws JMSException
@@ -123,10 +167,72 @@ public class DestinationHelper
destination = convertToQpidDestination(destination);
}
- if(destination instanceof QueueImpl)
+ if(destination instanceof Queue)
+ {
+ return ((Queue) destination).getQueueName();
+ }
+ else if(destination instanceof Topic)
{
- return ((QueueImpl) destination).getQueueName();
+ return ((Topic) destination).getTopicName();
}
- throw new IllegalArgumentException("Support for those destinations not yet implemented");
+ else
+ {
+ throw new IllegalArgumentException("Support for those destinations not yet implemented");
+ }
+ }
+
+ /**
+ * @return the annotation type string, or null if the supplied destination is null or can't be classified
+ */
+ public String decodeTypeString(Destination destination)
+ {
+ if(destination == null)
+ {
+ return null;
+ }
+
+ if(destination instanceof TemporaryQueue)
+ {
+ return TEMP_QUEUE_ATTRIBUTES_STRING;
+ }
+ else if(destination instanceof Queue)
+ {
+ return QUEUE_ATTRIBUTES_STRING;
+ }
+ else if(destination instanceof TemporaryTopic)
+ {
+ return TEMP_TOPIC_ATTRIBUTES_STRING;
+ }
+ else if(destination instanceof Topic)
+ {
+ return TOPIC_ATTRIBUTES_STRING;
+ }
+ else
+ {
+ //unable to classify
+ return null;
+ }
+ }
+
+ Set<String> splitAttributes(String typeString)
+ {
+ if( typeString == null )
+ {
+ return null;
+ }
+
+ HashSet<String> typeSet = new HashSet<String>();
+
+ //Split string on commas and their surrounding whitespace
+ for( String attr : typeString.split("\\s*,\\s*") )
+ {
+ //ignore empty values
+ if(!attr.equals(""))
+ {
+ typeSet.add(attr);
+ }
+ }
+
+ return typeSet;
}
}
Copied: qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/DestinationImpl.java (from r1546609, qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/QueueImpl.java)
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/DestinationImpl.java?p2=qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/DestinationImpl.java&p1=qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/QueueImpl.java&r1=1546609&r2=1546610&rev=1546610&view=diff
==============================================================================
--- qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/QueueImpl.java (original)
+++ qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/DestinationImpl.java Fri Nov 29 17:00:36 2013
@@ -1,4 +1,5 @@
/*
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,42 +16,41 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
+ *
*/
package org.apache.qpid.jms.impl;
-import javax.jms.JMSException;
-import javax.jms.Queue;
+import javax.jms.Destination;
-class QueueImpl implements Queue
+public class DestinationImpl implements Destination
{
- private final String _queueName;
+ private String _address;
- public QueueImpl(String queueName)
+ public DestinationImpl(String address)
{
- if(queueName == null)
+ if(address == null)
{
- throw new IllegalArgumentException("Queue name must be specified");
+ throw new IllegalArgumentException("Destination address must not be null");
}
- _queueName = queueName;
+ _address = address;
}
- @Override
- public String getQueueName() throws JMSException
+ public String getAddress()
{
- return _queueName;
+ return _address;
}
@Override
public String toString()
{
- return _queueName;
+ return getAddress();
}
@Override
public int hashCode()
{
- return _queueName.hashCode();
+ return getAddress().hashCode();
}
@Override
@@ -61,11 +61,13 @@ class QueueImpl implements Queue
return true;
}
- if (o == null || getClass() != o.getClass())
+ if (o != null && getClass() == o.getClass())
+ {
+ return getAddress().equals(((DestinationImpl)o).getAddress());
+ }
+ else
{
return false;
}
-
- return _queueName.equals(((QueueImpl)o)._queueName);
}
}
Modified: qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/MessageImpl.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/MessageImpl.java?rev=1546610&r1=1546609&r2=1546610&view=diff
==============================================================================
--- qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/MessageImpl.java (original)
+++ qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/MessageImpl.java Fri Nov 29 17:00:36 2013
@@ -32,16 +32,19 @@ import org.apache.qpid.jms.engine.AmqpMe
public abstract class MessageImpl<T extends AmqpMessage> implements Message
{
private final T _amqpMessage;
+ private final SessionImpl _sessionImpl;
private Destination _destination;
public MessageImpl(T amqpMessage, SessionImpl sessionImpl, ConnectionImpl connectionImpl)
{
_amqpMessage = amqpMessage;
+ _sessionImpl = sessionImpl;
+
String to = _amqpMessage.getTo();
if(to != null)
{
- //TODO: don't create a new DestinationHelper for every call.
- _destination = new DestinationHelper().decodeDestination(to, null);
+ String typeString = (String) _amqpMessage.getMessageAnnotation(DestinationHelper.TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
+ _destination = sessionImpl.getDestinationHelper().decodeDestination(to, typeString);
}
else
{
@@ -192,22 +195,23 @@ public abstract class MessageImpl<T exte
@Override
public void setJMSDestination(final Destination destination) throws JMSException
{
- //TODO: don't create a new DestinationHelper for every call.
- DestinationHelper destinationHelper = new DestinationHelper();
-
_destination = destination;
- Destination dest = destination;
- if(dest != null && !destinationHelper.isQpidDestination(dest))
+ String to = _sessionImpl.getDestinationHelper().decodeAddress(destination);
+ String typeString = _sessionImpl.getDestinationHelper().decodeTypeString(destination);
+
+ _amqpMessage.setTo(to);
+
+ if(to == null || typeString == null)
{
- dest = destinationHelper.convertToQpidDestination(destination);
+ _amqpMessage.clearMessageAnnotation(DestinationHelper.TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
+ }
+ else
+ {
+ _amqpMessage.setMessageAnnotation(DestinationHelper.TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME, typeString);
}
- String to = destinationHelper.decodeAddress(destination);
-
- _amqpMessage.setTo(to);
- //TODO: set the x-opt-to-type message annotation
}
@Override
Modified: qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/QueueImpl.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/QueueImpl.java?rev=1546610&r1=1546609&r2=1546610&view=diff
==============================================================================
--- qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/QueueImpl.java (original)
+++ qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/QueueImpl.java Fri Nov 29 17:00:36 2013
@@ -21,51 +21,16 @@ package org.apache.qpid.jms.impl;
import javax.jms.JMSException;
import javax.jms.Queue;
-class QueueImpl implements Queue
+class QueueImpl extends DestinationImpl implements Queue
{
- private final String _queueName;
-
public QueueImpl(String queueName)
{
- if(queueName == null)
- {
- throw new IllegalArgumentException("Queue name must be specified");
- }
-
- _queueName = queueName;
+ super(queueName);
}
@Override
public String getQueueName() throws JMSException
{
- return _queueName;
- }
-
- @Override
- public String toString()
- {
- return _queueName;
- }
-
- @Override
- public int hashCode()
- {
- return _queueName.hashCode();
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
-
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- return _queueName.equals(((QueueImpl)o)._queueName);
+ return getAddress();
}
}
Modified: qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/SessionImpl.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/SessionImpl.java?rev=1546610&r1=1546609&r2=1546610&view=diff
==============================================================================
--- qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/SessionImpl.java (original)
+++ qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/SessionImpl.java Fri Nov 29 17:00:36 2013
@@ -51,15 +51,17 @@ public class SessionImpl implements Sess
{
private static final int INITIAL_RECEIVER_CREDIT = 1;
- private int _acknowledgeMode;
- private AmqpSession _amqpSession;
- private ConnectionImpl _connectionImpl;
+ private final int _acknowledgeMode;
+ private final AmqpSession _amqpSession;
+ private final ConnectionImpl _connectionImpl;
+ private final DestinationHelper _destinationHelper;
- public SessionImpl(int acknowledgeMode, AmqpSession amqpSession, ConnectionImpl connectionImpl)
+ public SessionImpl(int acknowledgeMode, AmqpSession amqpSession, ConnectionImpl connectionImpl, DestinationHelper destinationHelper)
{
_acknowledgeMode = acknowledgeMode;
_amqpSession = amqpSession;
_connectionImpl = connectionImpl;
+ _destinationHelper = destinationHelper;
}
void establish() throws JmsTimeoutException, JmsInterruptedException
@@ -122,6 +124,11 @@ public class SessionImpl implements Sess
}
}
+ DestinationHelper getDestinationHelper()
+ {
+ return _destinationHelper;
+ }
+
//======= JMS Methods =======
@@ -337,7 +344,7 @@ public class SessionImpl implements Sess
@Override
public Queue createQueue(String queueName) throws JMSException
{
- return new QueueImpl(queueName);
+ return _destinationHelper.createQueue(queueName);
}
@Override
Copied: qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/TopicImpl.java (from r1546609, qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/QueueImpl.java)
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/TopicImpl.java?p2=qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/TopicImpl.java&p1=qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/QueueImpl.java&r1=1546609&r2=1546610&rev=1546610&view=diff
==============================================================================
--- qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/QueueImpl.java (original)
+++ qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/TopicImpl.java Fri Nov 29 17:00:36 2013
@@ -1,4 +1,5 @@
/*
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,57 +16,24 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
+ *
*/
package org.apache.qpid.jms.impl;
import javax.jms.JMSException;
-import javax.jms.Queue;
+import javax.jms.Topic;
-class QueueImpl implements Queue
+public class TopicImpl extends DestinationImpl implements Topic
{
- private final String _queueName;
-
- public QueueImpl(String queueName)
+ public TopicImpl(String topicName)
{
- if(queueName == null)
- {
- throw new IllegalArgumentException("Queue name must be specified");
- }
-
- _queueName = queueName;
+ super(topicName);
}
@Override
- public String getQueueName() throws JMSException
+ public String getTopicName() throws JMSException
{
- return _queueName;
+ return getAddress();
}
- @Override
- public String toString()
- {
- return _queueName;
- }
-
- @Override
- public int hashCode()
- {
- return _queueName.hashCode();
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
-
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- return _queueName.equals(((QueueImpl)o)._queueName);
- }
}
Modified: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/MessageIntegrationTest.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/MessageIntegrationTest.java?rev=1546610&r1=1546609&r2=1546610&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/MessageIntegrationTest.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/MessageIntegrationTest.java Fri Nov 29 17:00:36 2013
@@ -37,6 +37,7 @@ import org.apache.qpid.jms.test.testpeer
import org.apache.qpid.jms.test.testpeer.describedtypes.sections.AmqpValueDescribedType;
import org.apache.qpid.jms.test.testpeer.describedtypes.sections.ApplicationPropertiesDescribedType;
import org.apache.qpid.jms.test.testpeer.matchers.sections.ApplicationPropertiesSectionMatcher;
+import org.apache.qpid.jms.test.testpeer.matchers.sections.MessageAnnotationsSectionMatcher;
import org.apache.qpid.jms.test.testpeer.matchers.sections.MessageHeaderSectionMatcher;
import org.apache.qpid.jms.test.testpeer.matchers.sections.MessagePropertiesSectionMatcher;
import org.apache.qpid.jms.test.testpeer.matchers.sections.TransferPayloadCompositeMatcher;
@@ -94,10 +95,13 @@ public class MessageIntegrationTest exte
MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true).withDurable(equalTo(true));
+ MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true);
+
MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true).withTo(equalTo(queueName));
TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
messageMatcher.setHeadersMatcher(headersMatcher);
+ messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher);
messageMatcher.setPropertiesMatcher(propsMatcher);
messageMatcher.setApplicationPropertiesMatcher(appPropsMatcher);
messageMatcher.setMessageContentMatcher(new EncodedAmqpValueMatcher(null));
Modified: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/SenderIntegrationTest.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/SenderIntegrationTest.java?rev=1546610&r1=1546609&r2=1546610&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/SenderIntegrationTest.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/SenderIntegrationTest.java Fri Nov 29 17:00:36 2013
@@ -32,11 +32,14 @@ import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
+import org.apache.qpid.jms.impl.DestinationHelper;
import org.apache.qpid.jms.test.testpeer.TestAmqpPeer;
+import org.apache.qpid.jms.test.testpeer.matchers.sections.MessageAnnotationsSectionMatcher;
import org.apache.qpid.jms.test.testpeer.matchers.sections.MessageHeaderSectionMatcher;
import org.apache.qpid.jms.test.testpeer.matchers.sections.MessagePropertiesSectionMatcher;
import org.apache.qpid.jms.test.testpeer.matchers.sections.TransferPayloadCompositeMatcher;
import org.apache.qpid.jms.test.testpeer.matchers.types.EncodedAmqpValueMatcher;
+import org.apache.qpid.proton.amqp.Symbol;
import org.junit.Test;
public class SenderIntegrationTest extends QpidJmsTestCase
@@ -57,9 +60,11 @@ public class SenderIntegrationTest exten
MessageProducer producer = session.createProducer(queue);
//Create and transfer a new message
- TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true).withDurable(equalTo(true));
+ MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true);
+ TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
messageMatcher.setHeadersMatcher(headersMatcher);
+ messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher);
testPeer.expectTransfer(messageMatcher);
Message message = session.createTextMessage();
@@ -86,9 +91,11 @@ public class SenderIntegrationTest exten
//Create and transfer a new message, explicitly setting the deliveryMode on the
//message (which applications shouldn't) to NON_PERSISTENT and sending it to check
//that the producer ignores this value and sends the message as PERSISTENT(/durable)
- TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true).withDurable(equalTo(true));
+ MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true);
+ TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
messageMatcher.setHeadersMatcher(headersMatcher);
+ messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher);
testPeer.expectTransfer(messageMatcher);
Message message = session.createTextMessage();
@@ -117,9 +124,11 @@ public class SenderIntegrationTest exten
String text = "myMessage";
MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true).withDurable(equalTo(true));
+ MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true).withEntry(Symbol.valueOf(DestinationHelper.TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME), equalTo(DestinationHelper.QUEUE_ATTRIBUTES_STRING));
MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true).withTo(equalTo(queueName));
TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
messageMatcher.setHeadersMatcher(headersMatcher);
+ messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher);
messageMatcher.setPropertiesMatcher(propsMatcher);
messageMatcher.setMessageContentMatcher(new EncodedAmqpValueMatcher(text));
testPeer.expectTransfer(messageMatcher);
@@ -147,9 +156,11 @@ public class SenderIntegrationTest exten
Date currentTime = Calendar.getInstance().getTime();
String text = "myMessage";
MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true).withDurable(equalTo(true));
+ MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true);
MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true).withCreationTime(greaterThanOrEqualTo(currentTime));
TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
messageMatcher.setHeadersMatcher(headersMatcher);
+ messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher);
messageMatcher.setPropertiesMatcher(propsMatcher);
messageMatcher.setMessageContentMatcher(new EncodedAmqpValueMatcher(text));
testPeer.expectTransfer(messageMatcher);
Modified: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/SessionIntegrationTest.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/SessionIntegrationTest.java?rev=1546610&r1=1546609&r2=1546610&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/SessionIntegrationTest.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/SessionIntegrationTest.java Fri Nov 29 17:00:36 2013
@@ -40,6 +40,7 @@ import org.apache.qpid.jms.test.testpeer
import org.apache.qpid.jms.test.testpeer.describedtypes.sections.AmqpValueDescribedType;
import org.apache.qpid.jms.test.testpeer.describedtypes.sections.DataDescribedType;
import org.apache.qpid.jms.test.testpeer.describedtypes.sections.PropertiesDescribedType;
+import org.apache.qpid.jms.test.testpeer.matchers.sections.MessageAnnotationsSectionMatcher;
import org.apache.qpid.jms.test.testpeer.matchers.sections.MessageHeaderSectionMatcher;
import org.apache.qpid.jms.test.testpeer.matchers.sections.MessagePropertiesSectionMatcher;
import org.apache.qpid.jms.test.testpeer.matchers.sections.TransferPayloadCompositeMatcher;
@@ -85,9 +86,11 @@ public class SessionIntegrationTest exte
String text = "myMessage";
MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true).withDurable(equalTo(true));
+ MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true);
MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true);
TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
messageMatcher.setHeadersMatcher(headersMatcher);
+ messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher);
messageMatcher.setPropertiesMatcher(propsMatcher);
messageMatcher.setMessageContentMatcher(new EncodedAmqpValueMatcher(text));
testPeer.expectTransfer(messageMatcher);
@@ -143,9 +146,11 @@ public class SessionIntegrationTest exte
MessageProducer producer = session.createProducer(queue);
MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true).withDurable(equalTo(true));
+ MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true);
MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true);
TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
messageMatcher.setHeadersMatcher(headersMatcher);
+ messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher);
messageMatcher.setPropertiesMatcher(propsMatcher);
messageMatcher.setMessageContentMatcher(new EncodedAmqpValueMatcher(null));
testPeer.expectTransfer(messageMatcher);
@@ -201,10 +206,12 @@ public class SessionIntegrationTest exte
byte[] content = "myBytes".getBytes();
MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true).withDurable(equalTo(true));
+ MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true);
MessagePropertiesSectionMatcher propertiesMatcher = new MessagePropertiesSectionMatcher(true);
propertiesMatcher.withContentType(equalTo(Symbol.valueOf(AmqpBytesMessage.CONTENT_TYPE)));
TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
messageMatcher.setHeadersMatcher(headersMatcher);
+ messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher);
messageMatcher.setPropertiesMatcher(propertiesMatcher);
messageMatcher.setMessageContentMatcher(new EncodedDataMatcher(new Binary(content)));
Modified: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/DestinationHelperTest.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/DestinationHelperTest.java?rev=1546610&r1=1546609&r2=1546610&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/DestinationHelperTest.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/DestinationHelperTest.java Fri Nov 29 17:00:36 2013
@@ -25,9 +25,16 @@ import static org.junit.Assert.assertNot
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.HashSet;
+import java.util.Set;
import javax.jms.Destination;
import javax.jms.Queue;
+import javax.jms.TemporaryQueue;
+import javax.jms.TemporaryTopic;
+import javax.jms.Topic;
import org.apache.qpid.jms.QpidJmsTestCase;
import org.junit.Before;
@@ -53,21 +60,107 @@ public class DestinationHelperTest exten
Destination dest = _helper.decodeDestination(testAddress, null);
assertNotNull(dest);
- //TODO: this probably wont be true in future
+ //TODO: this test will need to expand for classification of receiver type in future
+ assertTrue(dest instanceof DestinationImpl);
+ }
+
+ @Test
+ public void testDecodeDestinationWithQueueTypeAnnotation() throws Exception
+ {
+ String testAddress = "testAddress";
+ String testTypeAnnotation = "queue";
+
+ Destination dest = _helper.decodeDestination(testAddress, testTypeAnnotation);
+ assertNotNull(dest);
+ assertTrue(dest instanceof DestinationImpl);
+ assertTrue(dest instanceof QueueImpl);
assertTrue(dest instanceof Queue);
+ assertEquals(testAddress, ((Queue) dest).getQueueName());
+ }
+
+ @Test
+ public void testDecodeDestinationWithTopicTypeAnnotation() throws Exception
+ {
+ String testAddress = "testAddress";
+ String testTypeAnnotation = "topic";
+
+ Destination dest = _helper.decodeDestination(testAddress, testTypeAnnotation);
+ assertNotNull(dest);
+ assertTrue(dest instanceof DestinationImpl);
+ assertTrue(dest instanceof TopicImpl);
+ assertTrue(dest instanceof Topic);
+ assertEquals(testAddress, ((Topic) dest).getTopicName());
+ }
+
+ @Test
+ public void testDecodeDestinationWithTempTopicTypeAnnotationThrowsIAE() throws Exception
+ {
+ //TODO: complete implementation when TempTopics implemented
+ String testAddress = "testAddress";
+ String testTypeAnnotation = "topic,temporary";
+ String testTypeAnnotationBackwards = "temporary,topic";
+
+ try
+ {
+ Destination dest = _helper.decodeDestination(testAddress, testTypeAnnotation);
+ fail("expected exceptionnow thrown");
+ }
+ catch(IllegalArgumentException iae)
+ {
+ //expected
+ }
+
+ try
+ {
+ Destination dest = _helper.decodeDestination(testAddress, testTypeAnnotationBackwards);
+ fail("expected exceptionnow thrown");
+ }
+ catch(IllegalArgumentException iae)
+ {
+ //expected
+ }
+ }
+
+ @Test
+ public void testDecodeDestinationWithTempQueueTypeAnnotationThrowsIAE() throws Exception
+ {
+ //TODO: complete implementation when TempQueues implemented
+ String testAddress = "testAddress";
+ String testTypeAnnotation = "queue,temporary";
+ String testTypeAnnotationBackwards = "temporary,queue";
+
+ try
+ {
+ Destination dest = _helper.decodeDestination(testAddress, testTypeAnnotation);
+ fail("expected exceptionnow thrown");
+ }
+ catch(IllegalArgumentException iae)
+ {
+ //expected
+ }
+
+ try
+ {
+ Destination dest = _helper.decodeDestination(testAddress, testTypeAnnotationBackwards);
+ fail("expected exceptionnow thrown");
+ }
+ catch(IllegalArgumentException iae)
+ {
+ //expected
+ }
}
@Test
- public void testConvertToQpidDestinationWithNull() throws Exception
+ public void testConvertToQpidDestinationWithNullReturnsNull() throws Exception
{
assertNull(_helper.convertToQpidDestination(null));
}
@Test
- public void testConvertToQpidDestinationWithQpidDestination() throws Exception
+ public void testConvertToQpidDestinationWithQpidDestinationReturnsSameObject() throws Exception
{
String testAddress = "testAddress";
- Queue queue = new QueueImpl(testAddress);
+ Queue queue = _helper.createQueue(testAddress);
Destination dest = _helper.convertToQpidDestination(queue);
assertNotNull(dest);
@@ -88,7 +181,58 @@ public class DestinationHelperTest exten
}
@Test
- public void testDecodeAddressWithNull() throws Exception
+ public void testConvertToQpidDestinationWithNonQpidTopic() throws Exception
+ {
+ String testAddress = "testAddress";
+ Topic mockTopic = Mockito.mock(Topic.class);
+ Mockito.when(mockTopic.getTopicName()).thenReturn(testAddress);
+
+ Destination dest = _helper.convertToQpidDestination(mockTopic);
+ assertNotNull(dest);
+ assertTrue(dest instanceof Topic);
+ assertEquals(testAddress, ((Topic)dest).getTopicName());
+ }
+
+ @Test
+ public void testConvertToQpidDestinationWithNonQpidTempQueueThrowsIAE() throws Exception
+ {
+ //TODO: complete implementation when TempQueues implemented
+ String testAddress = "testAddress";
+ TemporaryQueue mockTempQueue = Mockito.mock(TemporaryQueue.class);
+ Mockito.when(mockTempQueue.getQueueName()).thenReturn(testAddress);
+
+ try
+ {
+ Destination dest = _helper.convertToQpidDestination(mockTempQueue);
+ fail("excepted exception not thrown");
+ }
+ catch(IllegalArgumentException iae)
+ {
+ //expected
+ }
+ }
+
+ @Test
+ public void testConvertToQpidDestinationWithNonQpidTempTopic() throws Exception
+ {
+ //TODO: complete implementation when TempTopics implemented
+ String testAddress = "testAddress";
+ TemporaryTopic mockTempTopic = Mockito.mock(TemporaryTopic.class);
+ Mockito.when(mockTempTopic.getTopicName()).thenReturn(testAddress);
+
+ try
+ {
+ Destination dest = _helper.convertToQpidDestination(mockTempTopic);
+ fail("excepted exception not thrown");
+ }
+ catch(IllegalArgumentException iae)
+ {
+ //expected
+ }
+ }
+
+ @Test
+ public void testDecodeAddressWithNullReturnsNull() throws Exception
{
assertNull(_helper.decodeAddress(null));
}
@@ -97,13 +241,13 @@ public class DestinationHelperTest exten
public void testDecodeAddressWithQpidQueue() throws Exception
{
String testAddress = "testAddress";
- Queue queue = new QueueImpl(testAddress);
+ Queue queue = _helper.createQueue(testAddress);
assertEquals(testAddress, _helper.decodeAddress(queue));
}
@Test
- public void testDecodeAddressWithNonQpidQueue() throws Exception
+ public void testDecodeAddressWithNonQpidQueueReturnsConvertedAddress() throws Exception
{
String testAddress = "testAddress";
Queue mockQueue = Mockito.mock(Queue.class);
@@ -111,4 +255,42 @@ public class DestinationHelperTest exten
assertEquals(testAddress, _helper.decodeAddress(mockQueue));
}
+
+ @Test
+ public void testSplitAttributeWithExtranerousCommas() throws Exception
+ {
+ Set<String> set = new HashSet<String>();
+ set.add(DestinationHelper.QUEUE_ATTRIBUTE);
+ set.add(DestinationHelper.TEMPORARY_ATTRIBUTE);
+
+ //test a single comma separator produces expected set
+ assertEquals(set, _helper.splitAttributes(DestinationHelper.QUEUE_ATTRIBUTES_STRING
+ + ","
+ + DestinationHelper.TEMPORARY_ATTRIBUTE));
+
+ //test trailing comma doesn't alter produced set
+ assertEquals(set, _helper.splitAttributes(DestinationHelper.QUEUE_ATTRIBUTES_STRING
+ + ","
+ + DestinationHelper.TEMPORARY_ATTRIBUTE
+ + ","));
+ //test leading comma doesn't alter produced set
+ assertEquals(set, _helper.splitAttributes(","
+ + DestinationHelper.QUEUE_ATTRIBUTES_STRING
+ + ","
+ + DestinationHelper.TEMPORARY_ATTRIBUTE));
+ //test consecutive central commas don't alter produced set
+ assertEquals(set, _helper.splitAttributes(DestinationHelper.QUEUE_ATTRIBUTES_STRING
+ + ",,"
+ + DestinationHelper.TEMPORARY_ATTRIBUTE));
+ //test consecutive trailing commas don't alter produced set
+ assertEquals(set, _helper.splitAttributes(DestinationHelper.QUEUE_ATTRIBUTES_STRING
+ + ","
+ + DestinationHelper.TEMPORARY_ATTRIBUTE
+ + ",,"));
+ //test consecutive leading commas don't alter produced set
+ assertEquals(set, _helper.splitAttributes(","
+ + DestinationHelper.QUEUE_ATTRIBUTES_STRING
+ + ","
+ + DestinationHelper.TEMPORARY_ATTRIBUTE));
+ }
}
Modified: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/MessageImplTest.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/MessageImplTest.java?rev=1546610&r1=1546609&r2=1546610&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/MessageImplTest.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/MessageImplTest.java Fri Nov 29 17:00:36 2013
@@ -24,9 +24,11 @@ import static org.junit.Assert.*;
import java.util.Enumeration;
+import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageFormatException;
import javax.jms.Queue;
+import javax.jms.Topic;
import org.apache.qpid.jms.QpidJmsTestCase;
import org.apache.qpid.jms.engine.TestAmqpMessage;
@@ -42,6 +44,8 @@ public class MessageImplTest extends Qpi
private TestAmqpMessage _testAmqpMessage;
private String _mockQueueName;
private Queue _mockQueue;
+ private String _mockTopicName;
+ private Topic _mockTopic;
@Before
@Override
@@ -56,6 +60,10 @@ public class MessageImplTest extends Qpi
_mockQueueName = "mockQueueName";
_mockQueue = Mockito.mock(Queue.class);
Mockito.when(_mockQueue.getQueueName()).thenReturn(_mockQueueName);
+
+ _mockTopicName = "mockTopicName";
+ _mockTopic = Mockito.mock(Topic.class);
+ Mockito.when(_mockTopic.getTopicName()).thenReturn(_mockTopicName);
}
@Test
@@ -450,34 +458,107 @@ public class MessageImplTest extends Qpi
}
@Test
- public void testSetJMSDestinationOnNewMessage() throws Exception
+ public void testSetJMSDestinationOnNewMessageUsingQueue() throws Exception
{
+ Mockito.when(_mockSessionImpl.getDestinationHelper()).thenReturn(new DestinationHelper());
+
assertNull(_testAmqpMessage.getTo());
_testMessage.setJMSDestination(_mockQueue);
assertNotNull(_testAmqpMessage.getTo());
assertEquals(_mockQueueName, _testAmqpMessage.getTo());
+
+ assertTrue(_testAmqpMessage.messageAnnotationExists(DestinationHelper.TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME));
+ assertEquals(DestinationHelper.QUEUE_ATTRIBUTES_STRING,
+ _testAmqpMessage.getMessageAnnotation(DestinationHelper.TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME));
+ }
+
+ @Test
+ public void testSetJMSDestinationOnNewMessageUsingTopic() throws Exception
+ {
+ Mockito.when(_mockSessionImpl.getDestinationHelper()).thenReturn(new DestinationHelper());
+
+ assertNull(_testAmqpMessage.getTo());
+
+ _testMessage.setJMSDestination(_mockTopic);
+
+ assertNotNull(_testAmqpMessage.getTo());
+ assertEquals(_mockTopicName, _testAmqpMessage.getTo());
+
+ assertTrue(_testAmqpMessage.messageAnnotationExists(DestinationHelper.TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME));
+ assertEquals(DestinationHelper.TOPIC_ATTRIBUTES_STRING,
+ _testAmqpMessage.getMessageAnnotation(DestinationHelper.TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME));
+ }
+
+ @Test
+ public void testSetJMSDestinationNullOnRecievedMessageWithToAndTypeAnnotationClearsTheAnnotation() throws Exception
+ {
+ Mockito.when(_mockSessionImpl.getDestinationHelper()).thenReturn(new DestinationHelper());
+ _testAmqpMessage.setTo(_mockTopicName);
+ _testAmqpMessage.setMessageAnnotation(DestinationHelper.TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME,
+ DestinationHelper.TOPIC_ATTRIBUTES_STRING);
+ _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl);
+
+ assertNotNull("expected JMSDestination value not present", _testMessage.getJMSDestination());
+ assertTrue(_testAmqpMessage.messageAnnotationExists(DestinationHelper.TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME));
+
+ _testMessage.setJMSDestination(null);
+
+ assertNull("expected JMSDestination value to be null", _testMessage.getJMSDestination());
+ assertFalse(_testAmqpMessage.messageAnnotationExists(DestinationHelper.TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME));
}
@Test
public void testSetGetJMSDestinationOnNewMessage() throws Exception
{
+ Mockito.when(_mockSessionImpl.getDestinationHelper()).thenReturn(new DestinationHelper());
_testMessage.setJMSDestination(_mockQueue);
assertNotNull(_testMessage.getJMSDestination());
assertSame(_mockQueue, _testMessage.getJMSDestination());
}
@Test
- public void testGetJMSDestinationOnRecievedMessageWithTo() throws Exception
+ public void testGetJMSDestinationOnRecievedMessageWithToButWithoutToTypeAnnotation() throws Exception
+ {
+ Mockito.when(_mockSessionImpl.getDestinationHelper()).thenReturn(new DestinationHelper());
+ _testAmqpMessage.setTo(_mockQueueName);
+ _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl);
+
+ assertNotNull("expected JMSDestination value not present", _testMessage.getJMSDestination());
+
+ Destination newDestinationExpected = new DestinationImpl(_mockQueueName);
+ assertEquals(newDestinationExpected, _testMessage.getJMSDestination());
+ }
+
+ @Test
+ public void testGetJMSDestinationOnRecievedMessageWithToAndTypeAnnotationForTopic() throws Exception
+ {
+ Mockito.when(_mockSessionImpl.getDestinationHelper()).thenReturn(new DestinationHelper());
+ _testAmqpMessage.setTo(_mockTopicName);
+ _testAmqpMessage.setMessageAnnotation(DestinationHelper.TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME,
+ DestinationHelper.TOPIC_ATTRIBUTES_STRING);
+ _testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl);
+
+ assertNotNull("expected JMSDestination value not present", _testMessage.getJMSDestination());
+
+ Topic newDestinationExpected = new DestinationHelper().createTopic(_mockTopicName);
+ assertEquals(newDestinationExpected, _testMessage.getJMSDestination());
+ }
+
+ @Test
+ public void testGetJMSDestinationOnRecievedMessageWithToAndTypeAnnotationForQueue() throws Exception
{
+ Mockito.when(_mockSessionImpl.getDestinationHelper()).thenReturn(new DestinationHelper());
_testAmqpMessage.setTo(_mockQueueName);
+ _testAmqpMessage.setMessageAnnotation(DestinationHelper.TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME,
+ DestinationHelper.QUEUE_ATTRIBUTES_STRING);
_testMessage = new TestMessageImpl(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl);
assertNotNull("expected JMSDestination value not present", _testMessage.getJMSDestination());
- QueueImpl newQueueExpected = new QueueImpl(_mockQueueName);
- assertEquals(newQueueExpected, _testMessage.getJMSDestination());
+ Queue newDestinationExpected = new DestinationHelper().createQueue(_mockQueueName);
+ assertEquals(newDestinationExpected, _testMessage.getJMSDestination());
}
// ====== JMSTimestamp =======
Modified: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/SenderImplTest.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/SenderImplTest.java?rev=1546610&r1=1546609&r2=1546610&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/SenderImplTest.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/SenderImplTest.java Fri Nov 29 17:00:36 2013
@@ -53,6 +53,7 @@ public class SenderImplTest extends Qpid
_mockConnection = Mockito.mock(ConnectionImpl.class);
_mockAmqpSender = Mockito.mock(AmqpSender.class);
_mockSession = Mockito.mock(SessionImpl.class);
+ Mockito.when(_mockSession.getDestinationHelper()).thenReturn(new DestinationHelper());
_mockQueueName = "mockQueueName";
_mockQueue = Mockito.mock(Queue.class);
@@ -71,7 +72,7 @@ public class SenderImplTest extends Qpid
SenderImpl senderImpl = new SenderImpl(_mockSession, _mockConnection, _mockAmqpSender, _mockQueue);
TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
- TestMessageImpl testMessage = new TestMessageImpl(testAmqpMessage, null, null);
+ TestMessageImpl testMessage = new TestMessageImpl(testAmqpMessage, _mockSession, null);
testMessage.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
assertEquals(DeliveryMode.NON_PERSISTENT, testMessage.getJMSDeliveryMode());
@@ -93,7 +94,7 @@ public class SenderImplTest extends Qpid
SenderImpl senderImpl = new SenderImpl(_mockSession, _mockConnection, _mockAmqpSender, _mockQueue);
TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
- TestMessageImpl testMessage = new TestMessageImpl(testAmqpMessage, null, null);
+ TestMessageImpl testMessage = new TestMessageImpl(testAmqpMessage, _mockSession, null);
assertNull(testMessage.getJMSDestination());
@@ -114,7 +115,7 @@ public class SenderImplTest extends Qpid
SenderImpl senderImpl = new SenderImpl(_mockSession, _mockConnection, _mockAmqpSender, _mockQueue);
TestAmqpMessage testAmqpMessage = new TestAmqpMessage();
- TestMessageImpl testMessage = new TestMessageImpl(testAmqpMessage, null, null);
+ TestMessageImpl testMessage = new TestMessageImpl(testAmqpMessage, _mockSession, null);
assertEquals(0, testMessage.getJMSTimestamp());
long timestamp = System.currentTimeMillis();
Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/TopicImplTest.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/TopicImplTest.java?rev=1546610&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/TopicImplTest.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/TopicImplTest.java Fri Nov 29 17:00:36 2013
@@ -0,0 +1,70 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.jms.impl;
+
+import static org.junit.Assert.*;
+
+import javax.jms.Topic;
+
+import org.apache.qpid.jms.QpidJmsTestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TopicImplTest extends QpidJmsTestCase
+{
+ private String _testTopicName;
+ private TopicImpl _testTopic;
+
+ @Before
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ _testTopicName = "testTopicName";
+ _testTopic = new TopicImpl(_testTopicName);
+ }
+
+ @Test
+ public void testGetTopicName() throws Exception
+ {
+ assertEquals(_testTopicName, _testTopic.getTopicName());
+ }
+
+ @Test
+ public void testToString() throws Exception
+ {
+ assertEquals(_testTopicName, _testTopic.toString());
+ }
+
+ @Test
+ public void testEqualsAndHashCode() throws Exception
+ {
+ Topic anotherEqualTopic = new TopicImpl(_testTopicName);
+ Topic unequalTopic = new TopicImpl("otherName");
+
+ assertFalse(_testTopic == anotherEqualTopic);
+ assertFalse(_testTopic.equals(unequalTopic));
+
+ assertTrue(_testTopic.equals(anotherEqualTopic));
+ assertEquals(_testTopic.hashCode(), anotherEqualTopic.hashCode());
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org