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 2014/02/12 16:51:13 UTC
svn commit: r1567657 - in /qpid/jms/trunk/src:
main/java/org/apache/qpid/jms/impl/ClientProperties.java
main/java/org/apache/qpid/jms/impl/MessageImpl.java
test/java/org/apache/qpid/jms/impl/MessageImplTest.java
Author: robbie
Date: Wed Feb 12 15:51:13 2014
New Revision: 1567657
URL: http://svn.apache.org/r1567657
Log:
QPIDJMS-9: implement get/setJMSType methods
Modified:
qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/ClientProperties.java
qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/MessageImpl.java
qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/MessageImplTest.java
Modified: qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/ClientProperties.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/ClientProperties.java?rev=1567657&r1=1567656&r2=1567657&view=diff
==============================================================================
--- qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/ClientProperties.java (original)
+++ qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/ClientProperties.java Wed Feb 12 15:51:13 2014
@@ -27,4 +27,5 @@ public class ClientProperties
//Message Annotation Names
public static final String X_OPT_APP_CORRELATION_ID = "x-opt-app-correlation-id";
+ public static final String X_OPT_JMS_TYPE = "x-opt-jms-type";
}
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=1567657&r1=1567656&r2=1567657&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 Wed Feb 12 15:51:13 2014
@@ -428,15 +428,13 @@ public abstract class MessageImpl<T exte
@Override
public String getJMSType() throws JMSException
{
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Not Implemented");
+ return (String) _amqpMessage.getMessageAnnotation(ClientProperties.X_OPT_JMS_TYPE);
}
@Override
public void setJMSType(String type) throws JMSException
{
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Not Implemented");
+ _amqpMessage.setMessageAnnotation(ClientProperties.X_OPT_JMS_TYPE, type);
}
@Override
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=1567657&r1=1567656&r2=1567657&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 Wed Feb 12 15:51:13 2014
@@ -1202,6 +1202,26 @@ public class MessageImplTest extends Qpi
}
/**
+ * Test that {@link MessageImpl#getJMSCorrelationID()} returns the expected value for an
+ * application-specific string when the {@link ClientProperties#X_OPT_APP_CORRELATION_ID}
+ * message annotation is set true.
+ */
+ @Test
+ public void testGetJMSCorrelationIDWithReceivedMessageWithAppSpecificString() throws Exception
+ {
+ String appSpecific = "app-specific";
+ _testAmqpMessage.setMessageAnnotation(ClientProperties.X_OPT_APP_CORRELATION_ID, true);
+ _testAmqpMessage.setCorrelationId(appSpecific);
+
+ _testMessage = TestMessageImpl.createReceivedMessage(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
+
+ String jmsCorrelationID = _testMessage.getJMSCorrelationID();
+ assertNotNull("expected JMSCorrelationID to be app-specific string", jmsCorrelationID);
+ assertFalse("expected JMSCorrelationID to be app-specific string, should not contain ID: prefix", jmsCorrelationID.startsWith(MessageIdHelper.JMS_ID_PREFIX));
+ assertEquals("expected JMSCorrelationID to be app-specific string", appSpecific, jmsCorrelationID);
+ }
+
+ /**
* Test that receiving a message with a string typed correlation-id value results in the
* expected JMSCorrelationID value being returned, i.e. the base string plus the JMS "ID:" prefix.
*/
@@ -1350,6 +1370,74 @@ public class MessageImplTest extends Qpi
assertNull("expected correlationId value to be cleared", _testMessage.getJMSCorrelationIDAsBytes());
}
+ // ====== JMSType =======
+
+ @Test
+ public void testGetJMSTypeIsNullOnNewMessage() throws Exception
+ {
+ assertNull("did not expect a JMSType value to be present", _testMessage.getJMSType());
+ }
+
+ /**
+ * Test that {@link MessageImpl#setJMSType(String)} sets the expected message
+ * annotation on the underlying message to the given value
+ */
+ @Test
+ public void testSetJMSTypeSetsUnderlyingMessageAnnotation() throws Exception
+ {
+ String jmsType = "myJJMSType";
+
+ _testMessage.setJMSType(jmsType);
+
+ assertTrue("MessageAnnotation should exist to hold JMSType value",
+ _testAmqpMessage.messageAnnotationExists(ClientProperties.X_OPT_JMS_TYPE));
+ assertEquals("MessageAnnotation should be set to the provded JMSType string", jmsType,
+ _testAmqpMessage.getMessageAnnotation(ClientProperties.X_OPT_JMS_TYPE));
+ }
+
+ /**
+ * Test that {@link MessageImpl#setJMSType(String)} sets the expected message
+ * annotation on the underlying message to the given value
+ */
+ @Test
+ public void testSetGetJMSTypeOnNewMessage() throws Exception
+ {
+ String jmsType = "myJJMSType";
+
+ _testMessage.setJMSType(jmsType);
+
+ assertEquals("JMSType value was not as expected", jmsType, _testMessage.getJMSType());
+ }
+
+ /**
+ * Test that {@link MessageImpl#setJMSType(String)} sets the expected message
+ * annotation on the underlying message to the given value
+ */
+ @Test
+ public void testSetJMSTypeNullClearsExistingValue() throws Exception
+ {
+ String jmsType = "myJJMSType";
+
+ _testMessage.setJMSType(jmsType);
+ _testMessage.setJMSType(null);
+ assertNull("JMSType value was not as expected", _testMessage.getJMSType());
+ }
+
+ /**
+ * Test that {@link MessageImpl#getJMSType()} returns the expected value for a message
+ * received with the {@link ClientProperties#X_OPT_JMS_TYPE} message annotation set.
+ */
+ @Test
+ public void testGetJMSTypeWithReceivedMessage() throws Exception
+ {
+ String myJMSType = "myJMSType";
+ _testAmqpMessage.setMessageAnnotation(ClientProperties.X_OPT_JMS_TYPE, myJMSType);
+
+ _testMessage = TestMessageImpl.createReceivedMessage(_testAmqpMessage, _mockSessionImpl, _mockConnectionImpl, null);
+
+ assertEquals("JMSType value was not as expected", myJMSType, _testMessage.getJMSType());
+ }
+
// ====== JMS_AMQP_TTL property =======
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org