You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2014/11/14 12:03:21 UTC
[12/50] [abbrv] qpid-proton git commit: PROTON-711: add support
(disabled by default) for using a byte value for destination type annotations
during outbound transformation
PROTON-711: add support (disabled by default) for using a byte value for destination type annotations during outbound transformation
git-svn-id: https://svn.apache.org/repos/asf/qpid/proton/trunk@1631794 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/72b7beba
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/72b7beba
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/72b7beba
Branch: refs/heads/examples
Commit: 72b7beba08f6eda64f9ce7d46d04f8d4e05f99c5
Parents: c87fc8a
Author: Robert Gemmell <ro...@apache.org>
Authored: Tue Oct 14 15:33:34 2014 +0000
Committer: Robert Gemmell <ro...@apache.org>
Committed: Tue Oct 14 15:33:34 2014 +0000
----------------------------------------------------------------------
.../proton/jms/AutoOutboundTransformer.java | 6 +
.../jms/JMSMappingOutboundTransformer.java | 44 ++++--
.../org/apache/qpid/proton/jms/JMSVendor.java | 16 +-
.../qpid/proton/jms/OutboundTransformer.java | 14 +-
.../jms/JMSMappingOutboundTransformerTest.java | 149 +++++++++++++++++--
5 files changed, 197 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/72b7beba/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AutoOutboundTransformer.java
----------------------------------------------------------------------
diff --git a/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AutoOutboundTransformer.java b/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AutoOutboundTransformer.java
index f62760b..0440709 100644
--- a/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AutoOutboundTransformer.java
+++ b/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AutoOutboundTransformer.java
@@ -46,4 +46,10 @@ public class AutoOutboundTransformer extends JMSMappingOutboundTransformer {
}
}
+ @Override
+ public void setUseByteDestinationTypeAnnotations(boolean useByteDestinationTypeAnnotations)
+ {
+ super.setUseByteDestinationTypeAnnotations(useByteDestinationTypeAnnotations);
+ transformer.setUseByteDestinationTypeAnnotations(useByteDestinationTypeAnnotations);
+ }
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/72b7beba/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSMappingOutboundTransformer.java
----------------------------------------------------------------------
diff --git a/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSMappingOutboundTransformer.java b/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSMappingOutboundTransformer.java
index ba91f0a..38c9aac 100644
--- a/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSMappingOutboundTransformer.java
+++ b/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSMappingOutboundTransformer.java
@@ -224,21 +224,39 @@ public class JMSMappingOutboundTransformer extends OutboundTransformer {
return (ProtonJMessage) org.apache.qpid.proton.message.Message.Factory.create(header, da, ma, props, ap, body, footer);
}
- private static String destinationAttributes(Destination destination) {
- if( destination instanceof Queue ) {
- if( destination instanceof TemporaryQueue ) {
- return "temporary,queue";
- } else {
- return "queue";
+ private Object destinationAttributes(Destination destination) {
+ if(isUseByteDestinationTypeAnnotations()) {
+ if( destination instanceof Queue ) {
+ if( destination instanceof TemporaryQueue ) {
+ return JMSVendor.TEMP_QUEUE_TYPE;
+ } else {
+ return JMSVendor.QUEUE_TYPE;
+ }
}
- }
- if( destination instanceof Topic ) {
- if( destination instanceof TemporaryTopic ) {
- return "temporary,topic";
- } else {
- return "topic";
+ if( destination instanceof Topic ) {
+ if( destination instanceof TemporaryTopic ) {
+ return JMSVendor.TEMP_TOPIC_TYPE;
+ } else {
+ return JMSVendor.TOPIC_TYPE;
+ }
+ }
+ return JMSVendor.QUEUE_TYPE;
+ } else {
+ if( destination instanceof Queue ) {
+ if( destination instanceof TemporaryQueue ) {
+ return "temporary,queue";
+ } else {
+ return "queue";
+ }
+ }
+ if( destination instanceof Topic ) {
+ if( destination instanceof TemporaryTopic ) {
+ return "temporary,topic";
+ } else {
+ return "topic";
+ }
}
+ return "";
}
- return "";
}
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/72b7beba/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSVendor.java
----------------------------------------------------------------------
diff --git a/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSVendor.java b/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSVendor.java
index 5d02069..b1a9b25 100644
--- a/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSVendor.java
+++ b/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSVendor.java
@@ -1,15 +1,23 @@
package org.apache.qpid.proton.jms;
-import javax.jms.*;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
+import javax.jms.BytesMessage;
+import javax.jms.Destination;
+import javax.jms.MapMessage;
+import javax.jms.Message;
+import javax.jms.ObjectMessage;
+import javax.jms.StreamMessage;
+import javax.jms.TextMessage;
/**
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/
abstract public class JMSVendor {
+ public static final byte QUEUE_TYPE = 0x00;
+ public static final byte TOPIC_TYPE = 0x01;
+ public static final byte TEMP_QUEUE_TYPE = 0x02;
+ public static final byte TEMP_TOPIC_TYPE = 0x03;
+
public abstract BytesMessage createBytesMessage();
public abstract StreamMessage createStreamMessage();
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/72b7beba/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/OutboundTransformer.java
----------------------------------------------------------------------
diff --git a/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/OutboundTransformer.java b/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/OutboundTransformer.java
index 09a6e15..596a4ed 100644
--- a/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/OutboundTransformer.java
+++ b/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/OutboundTransformer.java
@@ -16,8 +16,6 @@
*/
package org.apache.qpid.proton.jms;
-import org.apache.qpid.proton.engine.Delivery;
-
import javax.jms.Message;
/**
@@ -43,7 +41,7 @@ public abstract class OutboundTransformer {
String replyToGroupIDKey;
String prefixFooterKey;
-
+ private boolean useByteDestinationTypeAnnotations;
public OutboundTransformer(JMSVendor vendor) {
this.vendor = vendor;
@@ -52,6 +50,16 @@ public abstract class OutboundTransformer {
public abstract EncodedMessage transform(Message jms) throws Exception;
+ public boolean isUseByteDestinationTypeAnnotations()
+ {
+ return useByteDestinationTypeAnnotations;
+ }
+
+ public void setUseByteDestinationTypeAnnotations(boolean useByteDestinationTypeAnnotations)
+ {
+ this.useByteDestinationTypeAnnotations = useByteDestinationTypeAnnotations;
+ }
+
public String getPrefixVendor() {
return prefixVendor;
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/72b7beba/contrib/proton-jms/src/test/java/org/apache/qpid/proton/jms/JMSMappingOutboundTransformerTest.java
----------------------------------------------------------------------
diff --git a/contrib/proton-jms/src/test/java/org/apache/qpid/proton/jms/JMSMappingOutboundTransformerTest.java b/contrib/proton-jms/src/test/java/org/apache/qpid/proton/jms/JMSMappingOutboundTransformerTest.java
index 1b14627..2bb5209 100644
--- a/contrib/proton-jms/src/test/java/org/apache/qpid/proton/jms/JMSMappingOutboundTransformerTest.java
+++ b/contrib/proton-jms/src/test/java/org/apache/qpid/proton/jms/JMSMappingOutboundTransformerTest.java
@@ -54,13 +54,34 @@ public class JMSMappingOutboundTransformerTest
assertEquals(contentString, ((AmqpValue) amqp.getBody()).getValue());
}
+ @Test
+ public void testDefaultsTolStringDestinationTypeAnnotationValues()
+ {
+ JMSVendor mockVendor = createMockVendor();
+ JMSMappingOutboundTransformer transformer = new JMSMappingOutboundTransformer(mockVendor);
+
+ assertFalse("Expected the older string style annotation values to be used by default", transformer.isUseByteDestinationTypeAnnotations());
+ }
+
+ @Test
+ public void testSetGetIsUseByteDestinationTypeAnnotations()
+ {
+ JMSVendor mockVendor = createMockVendor();
+ JMSMappingOutboundTransformer transformer = new JMSMappingOutboundTransformer(mockVendor);
+
+ assertFalse(transformer.isUseByteDestinationTypeAnnotations());
+ transformer.setUseByteDestinationTypeAnnotations(true);
+ assertTrue(transformer.isUseByteDestinationTypeAnnotations());
+ }
+
// ======= JMSDestination Handling =========
// =========================================
+ // --- String type annotation ---
@Test
public void testConvertMessageWithJMSDestinationNull() throws Exception
{
- doTestConvertMessageWithJMSDestination(null, null);
+ doTestConvertMessageWithJMSDestination(null, null, false);
}
@Test
@@ -68,7 +89,7 @@ public class JMSMappingOutboundTransformerTest
{
Queue mockDest = Mockito.mock(Queue.class);
- doTestConvertMessageWithJMSDestination(mockDest, "queue");
+ doTestConvertMessageWithJMSDestination(mockDest, "queue", false);
}
@Test
@@ -76,7 +97,7 @@ public class JMSMappingOutboundTransformerTest
{
TemporaryQueue mockDest = Mockito.mock(TemporaryQueue.class);
- doTestConvertMessageWithJMSDestination(mockDest, "temporary,queue");
+ doTestConvertMessageWithJMSDestination(mockDest, "temporary,queue", false);
}
@Test
@@ -84,7 +105,7 @@ public class JMSMappingOutboundTransformerTest
{
Topic mockDest = Mockito.mock(Topic.class);
- doTestConvertMessageWithJMSDestination(mockDest, "topic");
+ doTestConvertMessageWithJMSDestination(mockDest, "topic", false);
}
@Test
@@ -92,10 +113,58 @@ public class JMSMappingOutboundTransformerTest
{
TemporaryTopic mockDest = Mockito.mock(TemporaryTopic.class);
- doTestConvertMessageWithJMSDestination(mockDest, "temporary,topic");
+ doTestConvertMessageWithJMSDestination(mockDest, "temporary,topic", false);
}
- private void doTestConvertMessageWithJMSDestination(Destination jmsDestination, Object expectedAnnotationValue) throws Exception
+ // --- byte type annotation ---
+
+ @Test
+ public void testConvertMessageWithJMSDestinationNullUsingByteAnnotation() throws Exception
+ {
+ doTestConvertMessageWithJMSDestination(null, null, true);
+ }
+
+ @Test
+ public void testConvertMessageWithJMSDestinationQueueUsingByteAnnotation() throws Exception
+ {
+ Queue mockDest = Mockito.mock(Queue.class);
+
+ doTestConvertMessageWithJMSDestination(mockDest, JMSVendor.QUEUE_TYPE, true);
+ }
+
+ @Test
+ public void testConvertMessageWithJMSDestinationTemporaryQueueUsingByteAnnotation() throws Exception
+ {
+ TemporaryQueue mockDest = Mockito.mock(TemporaryQueue.class);
+
+ doTestConvertMessageWithJMSDestination(mockDest, JMSVendor.TEMP_QUEUE_TYPE, true);
+ }
+
+ @Test
+ public void testConvertMessageWithJMSDestinationTopicUsingByteAnnotation() throws Exception
+ {
+ Topic mockDest = Mockito.mock(Topic.class);
+
+ doTestConvertMessageWithJMSDestination(mockDest, JMSVendor.TOPIC_TYPE, true);
+ }
+
+ @Test
+ public void testConvertMessageWithJMSDestinationTemporaryTopicUsingByteAnnotation() throws Exception
+ {
+ TemporaryTopic mockDest = Mockito.mock(TemporaryTopic.class);
+
+ doTestConvertMessageWithJMSDestination(mockDest, JMSVendor.TEMP_TOPIC_TYPE, true);
+ }
+
+ @Test
+ public void testConvertMessageWithJMSDestinationUnkownUsingByteAnnotation() throws Exception
+ {
+ Destination mockDest = Mockito.mock(Destination.class);
+
+ doTestConvertMessageWithJMSDestination(mockDest, JMSVendor.QUEUE_TYPE, true);
+ }
+
+ private void doTestConvertMessageWithJMSDestination(Destination jmsDestination, Object expectedAnnotationValue, boolean byteType) throws Exception
{
TextMessage mockTextMessage = createMockTextMessage();
Mockito.when(mockTextMessage.getText()).thenReturn("myTextMessageContent");
@@ -109,6 +178,10 @@ public class JMSMappingOutboundTransformerTest
}
JMSMappingOutboundTransformer transformer = new JMSMappingOutboundTransformer(mockVendor);
+ if(byteType)
+ {
+ transformer.setUseByteDestinationTypeAnnotations(true);
+ }
Message amqp = transformer.convert(mockTextMessage);
@@ -133,10 +206,11 @@ public class JMSMappingOutboundTransformerTest
// ======= JMSReplyTo Handling =========
// =====================================
+ // --- String type annotation ---
@Test
public void testConvertMessageWithJMSReplyToNull() throws Exception
{
- doTestConvertMessageWithJMSReplyTo(null, null);
+ doTestConvertMessageWithJMSReplyTo(null, null, false);
}
@Test
@@ -144,7 +218,7 @@ public class JMSMappingOutboundTransformerTest
{
Queue mockDest = Mockito.mock(Queue.class);
- doTestConvertMessageWithJMSReplyTo(mockDest, "queue");
+ doTestConvertMessageWithJMSReplyTo(mockDest, "queue", false);
}
@Test
@@ -152,7 +226,7 @@ public class JMSMappingOutboundTransformerTest
{
TemporaryQueue mockDest = Mockito.mock(TemporaryQueue.class);
- doTestConvertMessageWithJMSReplyTo(mockDest, "temporary,queue");
+ doTestConvertMessageWithJMSReplyTo(mockDest, "temporary,queue", false);
}
@Test
@@ -160,7 +234,7 @@ public class JMSMappingOutboundTransformerTest
{
Topic mockDest = Mockito.mock(Topic.class);
- doTestConvertMessageWithJMSReplyTo(mockDest, "topic");
+ doTestConvertMessageWithJMSReplyTo(mockDest, "topic", false);
}
@Test
@@ -168,10 +242,57 @@ public class JMSMappingOutboundTransformerTest
{
TemporaryTopic mockDest = Mockito.mock(TemporaryTopic.class);
- doTestConvertMessageWithJMSReplyTo(mockDest, "temporary,topic");
+ doTestConvertMessageWithJMSReplyTo(mockDest, "temporary,topic", false);
+ }
+
+ // --- byte type annotation ---
+ @Test
+ public void testConvertMessageWithJMSReplyToNullUsingByteAnnotation() throws Exception
+ {
+ doTestConvertMessageWithJMSReplyTo(null, null, true);
+ }
+
+ @Test
+ public void testConvertMessageWithJMSReplyToQueueUsingByteAnnotation() throws Exception
+ {
+ Queue mockDest = Mockito.mock(Queue.class);
+
+ doTestConvertMessageWithJMSReplyTo(mockDest, JMSVendor.QUEUE_TYPE, true);
+ }
+
+ @Test
+ public void testConvertMessageWithJMSReplyToTemporaryQueueUsingByteAnnotation() throws Exception
+ {
+ TemporaryQueue mockDest = Mockito.mock(TemporaryQueue.class);
+
+ doTestConvertMessageWithJMSReplyTo(mockDest, JMSVendor.TEMP_QUEUE_TYPE, true);
+ }
+
+ @Test
+ public void testConvertMessageWithJMSReplyToTopicUsingByteAnnotation() throws Exception
+ {
+ Topic mockDest = Mockito.mock(Topic.class);
+
+ doTestConvertMessageWithJMSReplyTo(mockDest, JMSVendor.TOPIC_TYPE, true);
+ }
+
+ @Test
+ public void testConvertMessageWithJMSReplyToTemporaryTopicUsingByteAnnotation() throws Exception
+ {
+ TemporaryTopic mockDest = Mockito.mock(TemporaryTopic.class);
+
+ doTestConvertMessageWithJMSReplyTo(mockDest, JMSVendor.TEMP_TOPIC_TYPE, true);
+ }
+
+ @Test
+ public void testConvertMessageWithJMSReplyToUnkownUsingByteAnnotation() throws Exception
+ {
+ Destination mockDest = Mockito.mock(Destination.class);
+
+ doTestConvertMessageWithJMSReplyTo(mockDest, JMSVendor.QUEUE_TYPE, true);
}
- private void doTestConvertMessageWithJMSReplyTo(Destination jmsReplyTo, Object expectedAnnotationValue) throws Exception
+ private void doTestConvertMessageWithJMSReplyTo(Destination jmsReplyTo, Object expectedAnnotationValue, boolean byteType) throws Exception
{
TextMessage mockTextMessage = createMockTextMessage();
Mockito.when(mockTextMessage.getText()).thenReturn("myTextMessageContent");
@@ -185,6 +306,10 @@ public class JMSMappingOutboundTransformerTest
}
JMSMappingOutboundTransformer transformer = new JMSMappingOutboundTransformer(mockVendor);
+ if(byteType)
+ {
+ transformer.setUseByteDestinationTypeAnnotations(true);
+ }
Message amqp = transformer.convert(mockTextMessage);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org