summaryrefslogtreecommitdiff
path: root/java/client
diff options
context:
space:
mode:
authorRajith Muditha Attapattu <rajith@apache.org>2012-09-28 17:28:00 +0000
committerRajith Muditha Attapattu <rajith@apache.org>2012-09-28 17:28:00 +0000
commit8f935dc92559526fdc23e3fdad8a655b7f0f767c (patch)
treeea5cf4bb4b375fbd25e1f88d44ed17163435553f /java/client
parent094385e90bfd976833c6c8bc0d08e8d6708f20f5 (diff)
downloadqpid-python-8f935dc92559526fdc23e3fdad8a655b7f0f767c.tar.gz
QPID-3906 Fixed an error with the default. Added unit tests for testing
StreamMessage encoding defaults. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1391567 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/client')
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQSession.java4
-rw-r--r--java/client/src/test/java/org/apache/qpid/client/AMQConnectionUnitTest.java21
-rw-r--r--java/client/src/test/java/org/apache/qpid/client/AMQSession_0_10Test.java10
3 files changed, 31 insertions, 4 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 2aef0625bf..49964639e4 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
@@ -402,7 +402,7 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic
MessageFactoryRegistry messageFactoryRegistry, int defaultPrefetchHighMark, int defaultPrefetchLowMark)
{
_useAMQPEncodedMapMessage = con == null ? true : !con.isUseLegacyMapMessageFormat();
- _useAMQPEncodedStreamMessage = con == null ? true : !con.isUseLegacyStreamMessageFormat();
+ _useAMQPEncodedStreamMessage = con == null ? false : !con.isUseLegacyStreamMessageFormat();
_strictAMQP = Boolean.parseBoolean(System.getProperties().getProperty(STRICT_AMQP, STRICT_AMQP_DEFAULT));
_strictAMQPFATAL =
Boolean.parseBoolean(System.getProperties().getProperty(STRICT_AMQP_FATAL, STRICT_AMQP_FATAL_DEFAULT));
@@ -1367,7 +1367,7 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic
public StreamMessage createStreamMessage() throws JMSException
{
checkNotClosed();
- if (_useAMQPEncodedMapMessage)
+ if (_useAMQPEncodedStreamMessage)
{
AMQPEncodedListMessage msg = new AMQPEncodedListMessage(getMessageDelegateFactory());
msg.setAMQSession(this);
diff --git a/java/client/src/test/java/org/apache/qpid/client/AMQConnectionUnitTest.java b/java/client/src/test/java/org/apache/qpid/client/AMQConnectionUnitTest.java
index d186a440da..891cb9581c 100644
--- a/java/client/src/test/java/org/apache/qpid/client/AMQConnectionUnitTest.java
+++ b/java/client/src/test/java/org/apache/qpid/client/AMQConnectionUnitTest.java
@@ -30,15 +30,15 @@ import java.util.concurrent.atomic.AtomicReference;
public class AMQConnectionUnitTest extends TestCase
{
+ String _url = "amqp://guest:guest@/test?brokerlist='tcp://localhost:5672'";
public void testExceptionReceived()
{
- String url = "amqp://guest:guest@/test?brokerlist='tcp://localhost:5672'";
AMQInvalidArgumentException expectedException = new AMQInvalidArgumentException("Test", null);
final AtomicReference<JMSException> receivedException = new AtomicReference<JMSException>();
try
{
- MockAMQConnection connection = new MockAMQConnection(url);
+ MockAMQConnection connection = new MockAMQConnection(_url);
connection.setExceptionListener(new ExceptionListener()
{
@@ -62,4 +62,21 @@ public class AMQConnectionUnitTest extends TestCase
assertEquals("JMSException linked exception is incorrect", expectedException, exception.getLinkedException());
}
+ /**
+ * This should expand to test all the defaults.
+ */
+ public void testDefaultStreamMessageEncoding() throws Exception
+ {
+ MockAMQConnection connection = new MockAMQConnection(_url);
+ assertTrue("Legacy Stream message encoding should be the default",connection.isUseLegacyStreamMessageFormat());
+ }
+
+ /**
+ * This should expand to test all the connection properties.
+ */
+ public void testStreamMessageEncodingProperty() throws Exception
+ {
+ MockAMQConnection connection = new MockAMQConnection(_url + "&use_legacy_stream_msg_format='false'");
+ assertFalse("Stream message encoding should be amqp/list",connection.isUseLegacyStreamMessageFormat());
+ }
}
diff --git a/java/client/src/test/java/org/apache/qpid/client/AMQSession_0_10Test.java b/java/client/src/test/java/org/apache/qpid/client/AMQSession_0_10Test.java
index d0cd24adf6..59181c3a13 100644
--- a/java/client/src/test/java/org/apache/qpid/client/AMQSession_0_10Test.java
+++ b/java/client/src/test/java/org/apache/qpid/client/AMQSession_0_10Test.java
@@ -18,6 +18,7 @@
*/
package org.apache.qpid.client;
+import org.apache.qpid.client.message.AMQPEncodedListMessage;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.test.utils.QpidTestCase;
import org.apache.qpid.transport.*;
@@ -28,6 +29,8 @@ import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.MessageProducer;
+import javax.jms.StreamMessage;
+
import java.util.ArrayList;
import java.util.List;
@@ -459,6 +462,13 @@ public class AMQSession_0_10Test extends QpidTestCase
assertNotNull("ExchangeDeclare event was not sent", event);
}
+ public void testCreateStreamMessage() throws Exception
+ {
+ AMQSession_0_10 session = createAMQSession_0_10();
+ StreamMessage m = session.createStreamMessage();
+ assertTrue("Legacy Stream message encoding should be the default" + m.getClass(),!(m instanceof AMQPEncodedListMessage));
+ }
+
public void testGetQueueDepthWithSync()
{
// slow down a flush thread