summaryrefslogtreecommitdiff
path: root/qpid/java/client/src/test
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
commit1d6bec9c7ea9f4ea71a919e59010fd0744581ac9 (patch)
tree23f30d77d0953588cb84178c38d73657e59f1c82 /qpid/java/client/src/test
parentab8d563c9ac1f7f82a4b417ca02b210d2e51245a (diff)
downloadqpid-python-1d6bec9c7ea9f4ea71a919e59010fd0744581ac9.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@535819 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/client/src/test')
-rw-r--r--qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java64
-rw-r--r--qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java8
2 files changed, 66 insertions, 6 deletions
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java
index fd997e3abd..90784b0772 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java
+++ b/qpid/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/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java b/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
index ab0d26b0e0..588c82221e 100644
--- a/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
+++ b/qpid/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()