From 8f935dc92559526fdc23e3fdad8a655b7f0f767c Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Fri, 28 Sep 2012 17:28:00 +0000 Subject: 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 --- .../java/org/apache/qpid/client/AMQSession.java | 4 ++-- .../apache/qpid/client/AMQConnectionUnitTest.java | 21 +++++++++++++++++++-- .../org/apache/qpid/client/AMQSession_0_10Test.java | 10 ++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) (limited to 'java/client') 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 receivedException = new AtomicReference(); 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 -- cgit v1.2.1