summaryrefslogtreecommitdiff
path: root/java/client
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2007-05-07 09:40:58 +0000
committerMartin Ritchie <ritchiem@apache.org>2007-05-07 09:40:58 +0000
commit582a91714ddfb865614b6a335a3da2841299e07e (patch)
tree95c161afd1106bda92065c2286a961eb2cd77d6c /java/client
parentfab9010708e162ad54a42eb0fbd2829f06c94481 (diff)
downloadqpid-python-582a91714ddfb865614b6a335a3da2841299e07e.tar.gz
Merged revisions 534897-534902,534904-535253,535255-535809 via svnmerge from
https://svn.apache.org/repos/asf/incubator/qpid/branches/M2 ........ r534897 | bhupendrab | 2007-05-03 15:53:20 +0100 (Thu, 03 May 2007) | 1 line Attribute details background made same as other displays. ........ r535309 | ritchiem | 2007-05-04 17:12:59 +0100 (Fri, 04 May 2007) | 2 lines QPID-466 Changes to FieldTable along with corresponding PropertyValueTest to limit the Java client to only AMQP 0-8 compliant values. ........ r535809 | ritchiem | 2007-05-07 10:28:15 +0100 (Mon, 07 May 2007) | 5 lines QPID-466 Updated FieldTable to ensure no Decimal value is set that is larger than can be transmitted over AMQP. That is a max scale value of Byte.MAX_VALUE and value of up to Integer.MAX_VALUE. Additional tests to ensure this is the case. ........ git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@535819 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/client')
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQSession.java7
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/message/AMQMessage.java72
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java151
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/message/JMSHeaderAdapter.java22
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java64
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java8
6 files changed, 258 insertions, 66 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQSession.java b/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
index 10101976eb..b7615c5b7b 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
@@ -443,7 +443,7 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
_strictAMQP = Boolean.parseBoolean(System.getProperties().getProperty(STRICT_AMQP, STRICT_AMQP_DEFAULT));
_strictAMQPFATAL = Boolean.parseBoolean(System.getProperties().getProperty(STRICT_AMQP_FATAL, STRICT_AMQP_FATAL_DEFAULT));
- _immediatePrefetch = Boolean.parseBoolean(System.getProperties().getProperty(IMMEDIATE_PREFETCH, IMMEDIATE_PREFETCH_DEFAULT));
+ _immediatePrefetch = _strictAMQP || Boolean.parseBoolean(System.getProperties().getProperty(IMMEDIATE_PREFETCH, IMMEDIATE_PREFETCH_DEFAULT));
_connection = con;
_transacted = transacted;
@@ -491,7 +491,6 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
}
-
AMQSession(AMQConnection con, int channelId, boolean transacted, int acknowledgeMode, int defaultPrefetchHigh, int defaultPrefetchLow)
{
this(con, channelId, transacted, acknowledgeMode, MessageFactoryRegistry.newDefaultRegistry(), defaultPrefetchHigh, defaultPrefetchLow);
@@ -785,7 +784,7 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
amqe = new AMQException("Closing session forcibly", e);
}
_connection.deregisterSession(_channelId);
- closeProducersAndConsumers(amqe);
+ closeProducersAndConsumers(amqe);
}
}
@@ -2021,7 +2020,7 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
synchronized void startDistpatcherIfNecessary()
{
- // If IMMEDIATE_PREFETCH is not set then we need to start fetching
+ // If IMMEDIATE_PREFETCH is not set then we need to start fetching
if (!_immediatePrefetch)
{
// We do this now if this is the first call on a started connection
diff --git a/java/client/src/main/java/org/apache/qpid/client/message/AMQMessage.java b/java/client/src/main/java/org/apache/qpid/client/message/AMQMessage.java
index feb58678b9..8741a1cbb6 100644
--- a/java/client/src/main/java/org/apache/qpid/client/message/AMQMessage.java
+++ b/java/client/src/main/java/org/apache/qpid/client/message/AMQMessage.java
@@ -24,14 +24,17 @@ import javax.jms.JMSException;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.framing.ContentHeaderProperties;
+import org.apache.qpid.framing.BasicContentHeaderProperties;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.FieldTable;
+
+import java.math.BigDecimal;
public class AMQMessage
{
protected ContentHeaderProperties _contentHeaderProperties;
- /**
- * If the acknowledge mode is CLIENT_ACKNOWLEDGE the session is required
- */
+ /** If the acknowledge mode is CLIENT_ACKNOWLEDGE the session is required */
protected AMQSession _session;
protected final long _deliveryTag;
@@ -48,8 +51,9 @@ public class AMQMessage
}
/**
- * The session is set when CLIENT_ACKNOWLEDGE mode is used so that the CHANNEL ACK can be sent when the user
- * calls acknowledge()
+ * The session is set when CLIENT_ACKNOWLEDGE mode is used so that the CHANNEL ACK can be sent when the user calls
+ * acknowledge()
+ *
* @param s the AMQ session that delivered this message
*/
public void setAMQSession(AMQSession s)
@@ -64,6 +68,7 @@ public class AMQMessage
/**
* Get the AMQ message number assigned to this message
+ *
* @return the message number
*/
public long getDeliveryTag()
@@ -71,11 +76,60 @@ public class AMQMessage
return _deliveryTag;
}
- /**
- * Invoked prior to sending the message. Allows the message to be modified if necessary before
- * sending.
- */
+ /** Invoked prior to sending the message. Allows the message to be modified if necessary before sending. */
public void prepareForSending() throws JMSException
{
}
+
+ public FieldTable getPropertyHeaders()
+ {
+ return ((BasicContentHeaderProperties) _contentHeaderProperties).getHeaders();
+ }
+
+ public void setDecimalProperty(AMQShortString propertyName, BigDecimal bd) throws JMSException
+ {
+ getPropertyHeaders().setDecimal(propertyName, bd);
+ }
+
+ public void setIntProperty(AMQShortString propertyName, int i) throws JMSException
+ {
+ getPropertyHeaders().setInteger(propertyName, new Integer(i));
+ }
+
+ public void setLongStringProperty(AMQShortString propertyName, String value)
+ {
+ getPropertyHeaders().setString(propertyName, value);
+ }
+
+ public void setTimestampProperty(AMQShortString propertyName, long value)
+ {
+ getPropertyHeaders().setTimestamp(propertyName, value);
+ }
+
+ public void setVoidProperty(AMQShortString propertyName)
+ {
+ getPropertyHeaders().setVoid(propertyName);
+ }
+
+ //** Getters
+
+ public BigDecimal getDecimalProperty(AMQShortString propertyName) throws JMSException
+ {
+ return getPropertyHeaders().getDecimal(propertyName);
+ }
+
+ public int getIntegerProperty(AMQShortString propertyName) throws JMSException
+ {
+ return getPropertyHeaders().getInteger(propertyName);
+ }
+
+ public String getLongStringProperty(AMQShortString propertyName)
+ {
+ return getPropertyHeaders().getString(propertyName);
+ }
+
+ public Long getTimestampProperty(AMQShortString propertyName)
+ {
+ return getPropertyHeaders().getTimestamp(propertyName);
+ }
}
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 f87b4027f6..11102e0925 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
@@ -54,6 +54,7 @@ public abstract class AbstractJMSMessage extends AMQMessage implements org.apach
private Destination _destination;
private JMSHeaderAdapter _headerAdapter;
private BasicMessageConsumer _consumer;
+ private boolean _strictAMQP;
protected AbstractJMSMessage(ByteBuffer data)
{
@@ -68,6 +69,8 @@ public abstract class AbstractJMSMessage extends AMQMessage implements org.apach
_readableMessage = (data != null);
_changedData = (data == null);
_headerAdapter = new JMSHeaderAdapter(((BasicContentHeaderProperties) _contentHeaderProperties).getHeaders());
+
+ _strictAMQP = Boolean.parseBoolean(System.getProperties().getProperty(AMQSession.STRICT_AMQP, AMQSession.STRICT_AMQP_DEFAULT));
}
protected AbstractJMSMessage(long deliveryTag, BasicContentHeaderProperties contentHeader, AMQShortString exchange,
@@ -289,85 +292,116 @@ public abstract class AbstractJMSMessage extends AMQMessage implements org.apach
public boolean propertyExists(AMQShortString propertyName) throws JMSException
{
- checkPropertyName(propertyName);
-
return getJmsHeaders().propertyExists(propertyName);
}
public boolean propertyExists(String propertyName) throws JMSException
{
- checkPropertyName(propertyName);
-
return getJmsHeaders().propertyExists(propertyName);
}
public boolean getBooleanProperty(AMQShortString propertyName) throws JMSException
{
- checkPropertyName(propertyName);
+ if (_strictAMQP)
+ {
+ throw new UnsupportedOperationException("JMS Proprerties not supported in AMQP");
+ }
return getJmsHeaders().getBoolean(propertyName);
}
public boolean getBooleanProperty(String propertyName) throws JMSException
{
- checkPropertyName(propertyName);
+ if (_strictAMQP)
+ {
+ throw new UnsupportedOperationException("JMS Proprerties not supported in AMQP");
+ }
return getJmsHeaders().getBoolean(propertyName);
}
public byte getByteProperty(String propertyName) throws JMSException
{
- checkPropertyName(propertyName);
+ if (_strictAMQP)
+ {
+ throw new UnsupportedOperationException("JMS Proprerties not supported in AMQP");
+ }
return getJmsHeaders().getByte(propertyName);
}
+ public byte[] getBytesProperty(AMQShortString propertyName) throws JMSException
+ {
+ if (_strictAMQP)
+ {
+ throw new UnsupportedOperationException("JMS Proprerties not supported in AMQP");
+ }
+
+ return getJmsHeaders().getBytes(propertyName);
+ }
+
public short getShortProperty(String propertyName) throws JMSException
{
- checkPropertyName(propertyName);
+ if (_strictAMQP)
+ {
+ throw new UnsupportedOperationException("JMS Proprerties not supported in AMQP");
+ }
return getJmsHeaders().getShort(propertyName);
}
public int getIntProperty(String propertyName) throws JMSException
{
- checkPropertyName(propertyName);
+ if (_strictAMQP)
+ {
+ throw new UnsupportedOperationException("JMS Proprerties not supported in AMQP");
+ }
return getJmsHeaders().getInteger(propertyName);
}
public long getLongProperty(String propertyName) throws JMSException
{
- checkPropertyName(propertyName);
+ if (_strictAMQP)
+ {
+ throw new UnsupportedOperationException("JMS Proprerties not supported in AMQP");
+ }
return getJmsHeaders().getLong(propertyName);
}
public float getFloatProperty(String propertyName) throws JMSException
{
- checkPropertyName(propertyName);
+ if (_strictAMQP)
+ {
+ throw new UnsupportedOperationException("JMS Proprerties not supported in AMQP");
+ }
return getJmsHeaders().getFloat(propertyName);
}
public double getDoubleProperty(String propertyName) throws JMSException
{
- checkPropertyName(propertyName);
+ if (_strictAMQP)
+ {
+ throw new UnsupportedOperationException("JMS Proprerties not supported in AMQP");
+ }
return getJmsHeaders().getDouble(propertyName);
}
public String getStringProperty(String propertyName) throws JMSException
{
- checkPropertyName(propertyName);
+ if (_strictAMQP)
+ {
+ throw new UnsupportedOperationException("JMS Proprerties not supported in AMQP");
+ }
return getJmsHeaders().getString(propertyName);
}
public Object getObjectProperty(String propertyName) throws JMSException
{
- checkPropertyName(propertyName);
-
return getJmsHeaders().getObject(propertyName);
}
@@ -378,83 +412,124 @@ public abstract class AbstractJMSMessage extends AMQMessage implements org.apach
public void setBooleanProperty(AMQShortString propertyName, boolean b) throws JMSException
{
+ if (_strictAMQP)
+ {
+ throw new UnsupportedOperationException("JMS Proprerties not supported in AMQP");
+ }
+
checkWritableProperties();
- checkPropertyName(propertyName);
getJmsHeaders().setBoolean(propertyName, b);
}
public void setBooleanProperty(String propertyName, boolean b) throws JMSException
{
+ if (_strictAMQP)
+ {
+ throw new UnsupportedOperationException("JMS Proprerties not supported in AMQP");
+ }
+
checkWritableProperties();
- checkPropertyName(propertyName);
getJmsHeaders().setBoolean(propertyName, b);
}
public void setByteProperty(String propertyName, byte b) throws JMSException
{
+ if (_strictAMQP)
+ {
+ throw new UnsupportedOperationException("JMS Proprerties not supported in AMQP");
+ }
+
checkWritableProperties();
- checkPropertyName(propertyName);
getJmsHeaders().setByte(propertyName, new Byte(b));
}
+ public void setBytesProperty(AMQShortString propertyName, byte[] bytes) throws JMSException
+ {
+ if (_strictAMQP)
+ {
+ throw new UnsupportedOperationException("JMS Proprerties not supported in AMQP");
+ }
+
+ checkWritableProperties();
+ getJmsHeaders().setBytes(propertyName, bytes);
+ }
+
public void setShortProperty(String propertyName, short i) throws JMSException
{
+ if (_strictAMQP)
+ {
+ throw new UnsupportedOperationException("JMS Proprerties not supported in AMQP");
+ }
+
checkWritableProperties();
- checkPropertyName(propertyName);
getJmsHeaders().setShort(propertyName, new Short(i));
}
public void setIntProperty(String propertyName, int i) throws JMSException
{
+ if (_strictAMQP)
+ {
+ throw new UnsupportedOperationException("JMS Proprerties not supported in AMQP");
+ }
+
checkWritableProperties();
- checkPropertyName(propertyName);
- getJmsHeaders().setInteger(propertyName, new Integer(i));
+ JMSHeaderAdapter.checkPropertyName(propertyName);
+ super.setIntProperty(new AMQShortString(propertyName), new Integer(i));
}
public void setLongProperty(String propertyName, long l) throws JMSException
{
+ if (_strictAMQP)
+ {
+ throw new UnsupportedOperationException("JMS Proprerties not supported in AMQP");
+ }
+
checkWritableProperties();
- checkPropertyName(propertyName);
getJmsHeaders().setLong(propertyName, new Long(l));
}
public void setFloatProperty(String propertyName, float f) throws JMSException
{
+ if (_strictAMQP)
+ {
+ throw new UnsupportedOperationException("JMS Proprerties not supported in AMQP");
+ }
+
checkWritableProperties();
- checkPropertyName(propertyName);
getJmsHeaders().setFloat(propertyName, new Float(f));
}
public void setDoubleProperty(String propertyName, double v) throws JMSException
{
+ if (_strictAMQP)
+ {
+ throw new UnsupportedOperationException("JMS Proprerties not supported in AMQP");
+ }
+
checkWritableProperties();
- checkPropertyName(propertyName);
getJmsHeaders().setDouble(propertyName, new Double(v));
}
public void setStringProperty(String propertyName, String value) throws JMSException
{
checkWritableProperties();
- checkPropertyName(propertyName);
- getJmsHeaders().setString(propertyName, value);
+ JMSHeaderAdapter.checkPropertyName(propertyName);
+ super.setLongStringProperty(new AMQShortString(propertyName), value);
}
public void setObjectProperty(String propertyName, Object object) throws JMSException
{
checkWritableProperties();
- checkPropertyName(propertyName);
getJmsHeaders().setObject(propertyName, object);
}
protected void removeProperty(AMQShortString propertyName) throws JMSException
{
- checkPropertyName(propertyName);
getJmsHeaders().remove(propertyName);
}
protected void removeProperty(String propertyName) throws JMSException
{
- checkPropertyName(propertyName);
getJmsHeaders().remove(propertyName);
}
@@ -544,17 +619,6 @@ public abstract class AbstractJMSMessage extends AMQMessage implements org.apach
getContentHeaderProperties().setHeaders(messageProperties);
}
- private void checkPropertyName(CharSequence propertyName)
- {
- if (propertyName == null)
- {
- throw new IllegalArgumentException("Property name must not be null");
- }
- else if (propertyName.length() == 0)
- {
- throw new IllegalArgumentException("Property name must not be the empty string");
- }
- }
public JMSHeaderAdapter getJmsHeaders()
{
@@ -625,11 +689,4 @@ public abstract class AbstractJMSMessage extends AMQMessage implements org.apach
_consumer = basicMessageConsumer;
}
- public byte[] getBytesProperty(AMQShortString propertyName) throws JMSException
- {
- checkPropertyName(propertyName);
-
- return getJmsHeaders().getBytes(propertyName);
-
- }
}
diff --git a/java/client/src/main/java/org/apache/qpid/client/message/JMSHeaderAdapter.java b/java/client/src/main/java/org/apache/qpid/client/message/JMSHeaderAdapter.java
index 348a0bd152..39b4e1e27b 100644
--- a/java/client/src/main/java/org/apache/qpid/client/message/JMSHeaderAdapter.java
+++ b/java/client/src/main/java/org/apache/qpid/client/message/JMSHeaderAdapter.java
@@ -48,6 +48,7 @@ public final class JMSHeaderAdapter
public boolean getBoolean(String string) throws JMSException
{
+ checkPropertyName(string);
Boolean b = getHeaders().getBoolean(string);
if (b == null)
@@ -76,6 +77,7 @@ public final class JMSHeaderAdapter
public boolean getBoolean(AMQShortString string) throws JMSException
{
+ checkPropertyName(string);
Boolean b = getHeaders().getBoolean(string);
if (b == null)
@@ -104,6 +106,7 @@ public final class JMSHeaderAdapter
public char getCharacter(String string) throws JMSException
{
+ checkPropertyName(string);
Character c = getHeaders().getCharacter(string);
if (c == null)
@@ -130,6 +133,8 @@ public final class JMSHeaderAdapter
public byte[] getBytes(AMQShortString string) throws JMSException
{
+ checkPropertyName(string);
+
byte[] bs = getHeaders().getBytes(string);
if (bs == null)
@@ -144,6 +149,7 @@ public final class JMSHeaderAdapter
public byte getByte(String string) throws JMSException
{
+ checkPropertyName(string);
Byte b = getHeaders().getByte(string);
if (b == null)
{
@@ -171,6 +177,7 @@ public final class JMSHeaderAdapter
public short getShort(String string) throws JMSException
{
+ checkPropertyName(string);
Short s = getHeaders().getShort(string);
if (s == null)
@@ -183,6 +190,7 @@ public final class JMSHeaderAdapter
public int getInteger(String string) throws JMSException
{
+ checkPropertyName(string);
Integer i = getHeaders().getInteger(string);
if (i == null)
@@ -195,6 +203,7 @@ public final class JMSHeaderAdapter
public long getLong(String string) throws JMSException
{
+ checkPropertyName(string);
Long l = getHeaders().getLong(string);
if (l == null)
@@ -207,6 +216,7 @@ public final class JMSHeaderAdapter
public float getFloat(String string) throws JMSException
{
+ checkPropertyName(string);
Float f = getHeaders().getFloat(string);
if (f == null)
@@ -236,6 +246,7 @@ public final class JMSHeaderAdapter
public double getDouble(String string) throws JMSException
{
+ checkPropertyName(string);
Double d = getHeaders().getDouble(string);
if (d == null)
@@ -248,6 +259,7 @@ public final class JMSHeaderAdapter
public String getString(String string) throws JMSException
{
+ checkPropertyName(string);
String s = getHeaders().getString(string);
if (s == null)
@@ -278,6 +290,7 @@ public final class JMSHeaderAdapter
public Object getObject(String string) throws JMSException
{
+ checkPropertyName(string);
return getHeaders().getObject(string);
}
@@ -301,16 +314,19 @@ public final class JMSHeaderAdapter
public Object setBytes(AMQShortString string, byte[] bytes)
{
+ checkPropertyName(string);
return getHeaders().setBytes(string, bytes);
}
public Object setBytes(String string, byte[] bytes)
{
+ checkPropertyName(string);
return getHeaders().setBytes(string, bytes);
}
public Object setBytes(String string, byte[] bytes, int start, int length)
{
+ checkPropertyName(string);
return getHeaders().setBytes(string, bytes, start, length);
}
@@ -392,6 +408,7 @@ public final class JMSHeaderAdapter
public boolean itemExists(String string) throws JMSException
{
+ checkPropertyName(string);
return getHeaders().containsKey(string);
}
@@ -407,26 +424,31 @@ public final class JMSHeaderAdapter
public boolean propertyExists(AMQShortString propertyName)
{
+ checkPropertyName(propertyName);
return getHeaders().propertyExists(propertyName);
}
public boolean propertyExists(String propertyName)
{
+ checkPropertyName(propertyName);
return getHeaders().propertyExists(propertyName);
}
public Object put(Object key, Object value)
{
+ checkPropertyName(key.toString());
return getHeaders().setObject(key.toString(), value);
}
public Object remove(AMQShortString propertyName)
{
+ checkPropertyName(propertyName);
return getHeaders().remove(propertyName);
}
public Object remove(String propertyName)
{
+ checkPropertyName(propertyName);
return getHeaders().remove(propertyName);
}
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 fd997e3abd..90784b0772 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
@@ -23,6 +23,7 @@ package org.apache.qpid.test.unit.basic;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.math.BigDecimal;
import javax.jms.Destination;
import javax.jms.JMSException;
@@ -41,6 +42,8 @@ import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.message.JMSTextMessage;
+import org.apache.qpid.client.message.AMQMessage;
+import org.apache.qpid.framing.AMQShortString;
public class PropertyValueTest extends TestCase implements MessageListener
{
@@ -53,7 +56,7 @@ public class PropertyValueTest extends TestCase implements MessageListener
private AMQSession _session;
private final List<JMSTextMessage> received = new ArrayList<JMSTextMessage>();
private final List<String> messages = new ArrayList<String>();
- private int _count = 100;
+ private int _count = 1;
public String _connectionString = "vm://:1";
protected void setUp() throws Exception
@@ -118,7 +121,7 @@ public class PropertyValueTest extends TestCase implements MessageListener
check();
_logger.info("Completed without failure");
- Thread.sleep(10);
+ Thread.sleep(10);
_connection.close();
_logger.error("End Run Number:" + (run - 1));
@@ -180,6 +183,44 @@ public class PropertyValueTest extends TestCase implements MessageListener
m.setShortProperty("Short", (short) Short.MAX_VALUE);
m.setStringProperty("String", "Test");
+ //AMQP Specific values
+
+ // Timestamp
+ long nano = System.nanoTime();
+ m.setStringProperty("time-str", String.valueOf(nano));
+ ((AMQMessage) m).setTimestampProperty(new AMQShortString("time"), nano);
+
+ //Decimal
+ BigDecimal bd = new BigDecimal(Integer.MAX_VALUE);
+ ((AMQMessage) m).setDecimalProperty(new AMQShortString("decimal"), bd.setScale(Byte.MAX_VALUE));
+
+
+ bd = new BigDecimal((long) Integer.MAX_VALUE + 1L);
+
+ try
+ {
+ ((AMQMessage) m).setDecimalProperty(new AMQShortString("decimal-bad-value"), bd.setScale(Byte.MAX_VALUE));
+ fail("UnsupportedOperationException should be thrown as value can't be correctly transmitted");
+ }
+ catch (UnsupportedOperationException uoe)
+ {
+ // normal path.
+ }
+
+
+ try
+ {
+ ((AMQMessage) m).setDecimalProperty(new AMQShortString("decimal-bad-scale"), bd.setScale(Byte.MAX_VALUE + 1));
+ fail("UnsupportedOperationException should be thrown as scale can't be correctly transmitted");
+ }
+ catch (UnsupportedOperationException uoe)
+ {
+ // normal path.
+ }
+
+ //Void
+ ((AMQMessage) m).setVoidProperty(new AMQShortString("void"));
+
_logger.debug("Sending Msg:" + m);
producer.send(m);
}
@@ -235,6 +276,25 @@ public class PropertyValueTest extends TestCase implements MessageListener
(long) Long.MAX_VALUE, 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());
+
+ //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")));
+
+ //Void
+ ((AMQMessage) m).setVoidProperty(new AMQShortString("void"));
+
+ Assert.assertTrue("Check void properties are correctly transported",
+ ((AMQMessage) m).getPropertyHeaders().containsKey("void"));
}
received.clear();
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
index ab0d26b0e0..588c82221e 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
@@ -7,9 +7,9 @@
* 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
@@ -47,12 +47,12 @@ public class ConnectionTest extends TestCase
protected void setUp() throws Exception
{
super.setUp();
- TransportConnection.createVMBroker(1);
+// TransportConnection.createVMBroker(1);
}
protected void tearDown() throws Exception
{
- TransportConnection.killVMBroker(1);
+// TransportConnection.killVMBroker(1);
}
public void testSimpleConnection()