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/21 13:34:23 UTC
svn commit: r1544160 - in /qpid/jms/trunk/src:
main/java/org/apache/qpid/jms/engine/ test/java/org/apache/qpid/jms/
test/java/org/apache/qpid/jms/engine/
Author: robbie
Date: Thu Nov 21 12:34:22 2013
New Revision: 1544160
URL: http://svn.apache.org/r1544160
Log:
QPIDJMS-9: simplify null TextMessage content to just use an amqp-value section containing null
Modified:
qpid/jms/trunk/src/main/java/org/apache/qpid/jms/engine/AmqpMessage.java
qpid/jms/trunk/src/main/java/org/apache/qpid/jms/engine/AmqpMessageFactory.java
qpid/jms/trunk/src/main/java/org/apache/qpid/jms/engine/AmqpTextMessage.java
qpid/jms/trunk/src/test/java/org/apache/qpid/jms/SessionIntegrationTest.java
qpid/jms/trunk/src/test/java/org/apache/qpid/jms/engine/AmqpMessageFactoryTest.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=1544160&r1=1544159&r2=1544160&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 Thu Nov 21 12:34:22 2013
@@ -36,8 +36,6 @@ import org.apache.qpid.proton.message.Me
*/
public abstract class AmqpMessage
{
- public static final String MESSAGE_ANNOTATION_TYPE_KEY_NAME = "x-opt-jms-message-type";
-
private final Delivery _delivery;
private final Message _message;
private final AmqpConnection _amqpConnection;
Modified: qpid/jms/trunk/src/main/java/org/apache/qpid/jms/engine/AmqpMessageFactory.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/main/java/org/apache/qpid/jms/engine/AmqpMessageFactory.java?rev=1544160&r1=1544159&r2=1544160&view=diff
==============================================================================
--- qpid/jms/trunk/src/main/java/org/apache/qpid/jms/engine/AmqpMessageFactory.java (original)
+++ qpid/jms/trunk/src/main/java/org/apache/qpid/jms/engine/AmqpMessageFactory.java Thu Nov 21 12:34:22 2013
@@ -22,7 +22,6 @@ import java.util.List;
import java.util.Map;
import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.Symbol;
import org.apache.qpid.proton.amqp.messaging.AmqpValue;
import org.apache.qpid.proton.amqp.messaging.Data;
import org.apache.qpid.proton.amqp.messaging.Section;
@@ -31,25 +30,13 @@ import org.apache.qpid.proton.message.Me
public class AmqpMessageFactory
{
- //TODO: use switch statements
- @SuppressWarnings("unchecked")
AmqpMessage createAmqpMessage(Delivery delivery, Message message, AmqpConnection amqpConnection)
{
Section body = message.getBody();
- Map<Object,Object> messageAnnotationsMap = null;
- if(message.getMessageAnnotations() != null)
- {
- messageAnnotationsMap = message.getMessageAnnotations().getValue();
- };
-
if(body == null)
{
- if(isJMSMessageType(AmqpTextMessage.MSG_TYPE_ANNOTATION_VALUE, messageAnnotationsMap))
- {
- return new AmqpTextMessage(delivery, message, amqpConnection);
- }
- else if(isContentType(AmqpTextMessage.CONTENT_TYPE, message))
+ if(isContentType(AmqpTextMessage.CONTENT_TYPE, message))
{
return new AmqpTextMessage(delivery, message, amqpConnection);
}
@@ -81,14 +68,7 @@ public class AmqpMessageFactory
{
Object value = ((AmqpValue) body).getValue();
- if(value == null)
- {
- if(isJMSMessageType(AmqpTextMessage.MSG_TYPE_ANNOTATION_VALUE, messageAnnotationsMap))
- {
- return new AmqpTextMessage(delivery, message, amqpConnection);
- }
- }
- else if(value instanceof String)
+ if(value == null || value instanceof String)
{
return new AmqpTextMessage(delivery, message, amqpConnection);
}
@@ -110,24 +90,6 @@ public class AmqpMessageFactory
return new AmqpGenericMessage(delivery, message, amqpConnection);
}
- private boolean isJMSMessageType(String messageType, Map<Object, Object> messageAnnotationsMap)
- {
- Symbol key = Symbol.valueOf(AmqpMessage.MESSAGE_ANNOTATION_TYPE_KEY_NAME);
- Object value = getAnnotation(messageAnnotationsMap, key);
-
- return messageType.equals(value);
- }
-
- private Object getAnnotation(Map<Object,Object> annotations, Symbol symbolKey)
- {
- if(annotations == null || !annotations.containsKey(symbolKey))
- {
- return null;
- }
-
- return annotations.get(symbolKey);
- }
-
private boolean isContentType(String contentType, Message message)
{
if(contentType == null)
Modified: qpid/jms/trunk/src/main/java/org/apache/qpid/jms/engine/AmqpTextMessage.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/main/java/org/apache/qpid/jms/engine/AmqpTextMessage.java?rev=1544160&r1=1544159&r2=1544160&view=diff
==============================================================================
--- qpid/jms/trunk/src/main/java/org/apache/qpid/jms/engine/AmqpTextMessage.java (original)
+++ qpid/jms/trunk/src/main/java/org/apache/qpid/jms/engine/AmqpTextMessage.java Thu Nov 21 12:34:22 2013
@@ -18,7 +18,6 @@
*/
package org.apache.qpid.jms.engine;
-import org.apache.qpid.proton.amqp.Symbol;
import org.apache.qpid.proton.amqp.messaging.AmqpValue;
import org.apache.qpid.proton.amqp.messaging.Data;
import org.apache.qpid.proton.amqp.messaging.Section;
@@ -54,16 +53,6 @@ public class AmqpTextMessage extends Amq
{
AmqpValue body = new AmqpValue(text);
getMessage().setBody(body);
-
- Symbol msgTypeAnnotationKey = Symbol.valueOf(MESSAGE_ANNOTATION_TYPE_KEY_NAME);
- if(text == null && !messageAnnotationExists(msgTypeAnnotationKey))
- {
- setMessageAnnotation(msgTypeAnnotationKey, MSG_TYPE_ANNOTATION_VALUE);
- }
- else if(text != null && messageAnnotationExists(msgTypeAnnotationKey))
- {
- clearMessageAnnotation(msgTypeAnnotationKey);
- }
}
public String getText()
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=1544160&r1=1544159&r2=1544160&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 Thu Nov 21 12:34:22 2013
@@ -138,9 +138,6 @@ public class SessionIntegrationTest exte
MessageProducer producer = session.createProducer(queue);
TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
- MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true)
- .withEntry(Symbol.valueOf(AmqpMessage.MESSAGE_ANNOTATION_TYPE_KEY_NAME), equalTo(AmqpTextMessage.MSG_TYPE_ANNOTATION_VALUE));
- messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher);
messageMatcher.setMessageContentMatcher(new EncodedAmqpValueMatcher(null));
testPeer.expectTransfer(messageMatcher);
@@ -163,12 +160,10 @@ public class SessionIntegrationTest exte
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue("myQueue");
- MessageAnnotationsDescribedType msgAnnotations = new MessageAnnotationsDescribedType();
- msgAnnotations.setSymbolKeyedAnnotation(AmqpMessage.MESSAGE_ANNOTATION_TYPE_KEY_NAME, AmqpTextMessage.MSG_TYPE_ANNOTATION_VALUE);
DescribedType amqpValueNullContent = new AmqpValueDescribedType(null);
testPeer.expectReceiverAttach();
- testPeer.expectLinkFlowRespondWithTransfer(null, msgAnnotations, null, amqpValueNullContent);
+ testPeer.expectLinkFlowRespondWithTransfer(null, null, null, amqpValueNullContent);
testPeer.expectDispositionThatIsAcceptedAndSettled();
MessageConsumer messageConsumer = session.createConsumer(queue);
Modified: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/engine/AmqpMessageFactoryTest.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/engine/AmqpMessageFactoryTest.java?rev=1544160&r1=1544159&r2=1544160&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/engine/AmqpMessageFactoryTest.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/engine/AmqpMessageFactoryTest.java Thu Nov 21 12:34:22 2013
@@ -201,42 +201,18 @@ public class AmqpMessageFactoryTest
}
/**
- * Test that an amqp-value body containing a null, but with the
- * {@value AmqpTextMessage#MESSAGE_ANNOTATION_TYPE_KEY_NAME} message annotation
- * set to {@value AmqpTextMessage#MSG_TYPE_ANNOTATION_VALUE} results in a text message
+ * Test that an amqp-value body containing a null results in a text message
*/
@Test
- public void testCreateAmqpTextMessageFromAmqpValueWithNullAndMessageTypeAnnotation() throws Exception
+ public void testCreateAmqpTextMessageFromAmqpValueWithNull() throws Exception
{
- Map<Symbol,Object> annotationsMap = new HashMap<Symbol, Object>();
- annotationsMap.put(Symbol.valueOf(AmqpMessage.MESSAGE_ANNOTATION_TYPE_KEY_NAME),
- AmqpTextMessage.MSG_TYPE_ANNOTATION_VALUE);
-
Message message = Proton.message();
message.setBody(new AmqpValue(null));
- message.setMessageAnnotations(new MessageAnnotations(annotationsMap));
-
AmqpMessage amqpMessage = _amqpMessageFactory.createAmqpMessage(_mockDelivery, message, _mockAmqpConnection);
assertEquals(AmqpTextMessage.class, amqpMessage.getClass());
}
/**
- * Test that an amqp-value body containing a null, but WITHOUT the
- * {@value AmqpTextMessage#MESSAGE_ANNOTATION_TYPE_KEY_NAME} message
- * annotation set results in a generic message being created (as
- * we can't assume it is text).
- */
- @Test
- public void testCreateAmqpGenericMessageFromAmqpValueWithNullAndNoDifferentiator() throws Exception
- {
- Message message = Proton.message();
- message.setBody(new AmqpValue(null));
-
- AmqpMessage amqpMessage = _amqpMessageFactory.createAmqpMessage(_mockDelivery, message, _mockAmqpConnection);
- assertEquals(AmqpGenericMessage.class, amqpMessage.getClass());
- }
-
- /**
* Test that an amqp-value body containing a map results in a map message
*/
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org