summaryrefslogtreecommitdiff
path: root/java/client/src
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2007-11-07 12:36:36 +0000
committerMartin Ritchie <ritchiem@apache.org>2007-11-07 12:36:36 +0000
commit793a6b31f7ad6b27f0683eef52ae92e05d7f8fee (patch)
tree0bbd157b996c54e27bfbaadf6de6f0153909d630 /java/client/src
parentc346e8d12bd8a287695f9a427e22e9c837b866cb (diff)
downloadqpid-python-793a6b31f7ad6b27f0683eef52ae92e05d7f8fee.tar.gz
QPID-160 Addition of JMSXUserID to all messages through the java broker.
As this will cause the headers to be re-encoded it can be disabled in the config.xml. Default is enabled as the sample config.xml should have all features enabled so that testing can observe the interactions. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2.1@592729 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/client/src')
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/CustomJMSXProperty.java9
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java26
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java35
3 files changed, 45 insertions, 25 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/client/CustomJMSXProperty.java b/java/client/src/main/java/org/apache/qpid/client/CustomJMSXProperty.java
index a5e89ef4fc..07d5d5dd32 100644
--- a/java/client/src/main/java/org/apache/qpid/client/CustomJMSXProperty.java
+++ b/java/client/src/main/java/org/apache/qpid/client/CustomJMSXProperty.java
@@ -29,9 +29,10 @@ import org.apache.qpid.framing.AMQShortString;
public enum CustomJMSXProperty
{
JMS_AMQP_NULL,
- JMS_QPID_DESTTYPE,
+ JMS_QPID_DESTTYPE,
JMSXGroupID,
- JMSXGroupSeq;
+ JMSXGroupSeq,
+ JMSXUserID;
private final AMQShortString _nameAsShortString;
@@ -47,7 +48,7 @@ public enum CustomJMSXProperty
}
private static Enumeration _names;
-
+
public static synchronized Enumeration asEnumeration()
{
if(_names == null)
@@ -60,6 +61,6 @@ public enum CustomJMSXProperty
}
_names = Collections.enumeration(nameList);
}
- return _names;
+ return _names;
}
}
diff --git a/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java b/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java
index 2dfeb19268..b029770946 100644
--- a/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java
+++ b/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java
@@ -73,11 +73,11 @@ public abstract class AbstractJMSMessage extends AMQMessage implements org.apach
_headerAdapter = new JMSHeaderAdapter(((BasicContentHeaderProperties) _contentHeaderProperties).getHeaders());
_strictAMQP =
- Boolean.parseBoolean(System.getProperties().getProperty(AMQSession.STRICT_AMQP, AMQSession.STRICT_AMQP_DEFAULT));
+ Boolean.parseBoolean(System.getProperties().getProperty(AMQSession.STRICT_AMQP, AMQSession.STRICT_AMQP_DEFAULT));
}
protected AbstractJMSMessage(long deliveryTag, BasicContentHeaderProperties contentHeader, AMQShortString exchange,
- AMQShortString routingKey, ByteBuffer data) throws AMQException
+ AMQShortString routingKey, ByteBuffer data) throws AMQException
{
this(contentHeader, deliveryTag);
@@ -201,7 +201,7 @@ public abstract class AbstractJMSMessage extends AMQMessage implements org.apach
if (!(destination instanceof AMQDestination))
{
throw new IllegalArgumentException(
- "ReplyTo destination may only be an AMQDestination - passed argument was type " + destination.getClass());
+ "ReplyTo destination may only be an AMQDestination - passed argument was type " + destination.getClass());
}
final AMQDestination amqd = (AMQDestination) destination;
@@ -391,12 +391,26 @@ public abstract class AbstractJMSMessage extends AMQMessage implements org.apach
public String getStringProperty(String propertyName) throws JMSException
{
- if (_strictAMQP)
+
+ if (propertyName.startsWith("JMSX"))
{
- throw new UnsupportedOperationException("JMS Proprerties not supported in AMQP");
+ //NOTE: if the JMSX Property is a non AMQP property then we must check _strictAMQP and throw as below.
+ if (propertyName.equals(CustomJMSXProperty.JMSXUserID.toString()))
+ {
+ return ((BasicContentHeaderProperties) _contentHeaderProperties).getUserIdAsString();
+ }
+
+ return null;
}
+ else
+ {
+ if (_strictAMQP)
+ {
+ throw new UnsupportedOperationException("JMS Proprerties not supported in AMQP");
+ }
- return getJmsHeaders().getString(propertyName);
+ return getJmsHeaders().getString(propertyName);
+ }
}
public Object getObjectProperty(String propertyName) throws JMSException
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java
index dce9667ff2..d2a7ba301b 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java
@@ -59,6 +59,7 @@ public class PropertyValueTest extends TestCase implements MessageListener
private final List<String> messages = new ArrayList<String>();
private int _count = 1;
public String _connectionString = "vm://:1";
+ private static final String USERNAME = "guest";
protected void setUp() throws Exception
{
@@ -109,7 +110,7 @@ public class PropertyValueTest extends TestCase implements MessageListener
_logger.error("Run Number:" + run++);
try
{
- init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "test"));
+ init(new AMQConnection(_connectionString, USERNAME, "guest", randomize("Client"), "test"));
}
catch (Exception e)
{
@@ -175,7 +176,7 @@ public class PropertyValueTest extends TestCase implements MessageListener
_logger.trace("Message:" + m);
Assert.assertEquals("Check temp queue has been set correctly", m.getJMSReplyTo().toString(),
- m.getStringProperty("TempQueue"));
+ m.getStringProperty("TempQueue"));
m.setJMSType("Test");
m.setLongProperty("UnsignedInt", (long) 4294967295L);
@@ -210,7 +211,7 @@ public class PropertyValueTest extends TestCase implements MessageListener
try
{
((AMQMessage) m).setDecimalProperty(new AMQShortString("decimal-bad-scale"),
- bd.setScale(Byte.MAX_VALUE + 1));
+ bd.setScale(Byte.MAX_VALUE + 1));
fail("UnsupportedOperationException should be thrown as scale can't be correctly transmitted");
}
catch (UnsupportedOperationException uoe)
@@ -248,47 +249,51 @@ public class PropertyValueTest extends TestCase implements MessageListener
Assert.assertEquals("Check Boolean properties are correctly transported", true, m.getBooleanProperty("Bool"));
Assert.assertEquals("Check Byte properties are correctly transported", (byte) Byte.MAX_VALUE,
- m.getByteProperty("Byte"));
+ m.getByteProperty("Byte"));
Assert.assertEquals("Check Double properties are correctly transported", (double) Double.MAX_VALUE,
- m.getDoubleProperty("Double"));
+ m.getDoubleProperty("Double"));
Assert.assertEquals("Check Float properties are correctly transported", (float) Float.MAX_VALUE,
- m.getFloatProperty("Float"));
+ m.getFloatProperty("Float"));
Assert.assertEquals("Check Int properties are correctly transported", (int) Integer.MAX_VALUE,
- m.getIntProperty("Int"));
+ m.getIntProperty("Int"));
Assert.assertEquals("Check CorrelationID properties are correctly transported", "Correlation",
- m.getJMSCorrelationID());
+ m.getJMSCorrelationID());
Assert.assertEquals("Check Priority properties are correctly transported", 8, m.getJMSPriority());
// Queue
Assert.assertEquals("Check ReplyTo properties are correctly transported", m.getStringProperty("TempQueue"),
- m.getJMSReplyTo().toString());
+ m.getJMSReplyTo().toString());
Assert.assertEquals("Check Type properties are correctly transported", "Test", m.getJMSType());
Assert.assertEquals("Check Short properties are correctly transported", (short) Short.MAX_VALUE,
- m.getShortProperty("Short"));
+ m.getShortProperty("Short"));
Assert.assertEquals("Check UnsignedInt properties are correctly transported", (long) 4294967295L,
- m.getLongProperty("UnsignedInt"));
+ m.getLongProperty("UnsignedInt"));
Assert.assertEquals("Check Long properties are correctly transported", (long) Long.MAX_VALUE,
- m.getLongProperty("Long"));
+ m.getLongProperty("Long"));
Assert.assertEquals("Check String properties are correctly transported", "Test", m.getStringProperty("String"));
// AMQP Tests Specific values
Assert.assertEquals("Check Timestamp properties are correctly transported", m.getStringProperty("time-str"),
- ((AMQMessage) m).getTimestampProperty(new AMQShortString("time")).toString());
+ ((AMQMessage) m).getTimestampProperty(new AMQShortString("time")).toString());
// Decimal
BigDecimal bd = new BigDecimal(Integer.MAX_VALUE);
Assert.assertEquals("Check decimal properties are correctly transported", bd.setScale(Byte.MAX_VALUE),
- ((AMQMessage) m).getDecimalProperty(new AMQShortString("decimal")));
+ ((AMQMessage) m).getDecimalProperty(new AMQShortString("decimal")));
// Void
((AMQMessage) m).setVoidProperty(new AMQShortString("void"));
Assert.assertTrue("Check void properties are correctly transported",
- ((AMQMessage) m).getPropertyHeaders().containsKey("void"));
+ ((AMQMessage) m).getPropertyHeaders().containsKey("void"));
+
+ //JMSXUserID
+ Assert.assertEquals("Check 'JMSXUserID' is supported ", USERNAME,
+ m.getStringProperty("JMSXUserID"));
}
received.clear();