From 7017c40cad9469b647e936b3ce2313f0b8f15a9b 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@1391567 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/qpid/client/AMQConnectionUnitTest.java | 21 +++++++++++++++++++-- .../org/apache/qpid/client/AMQSession_0_10Test.java | 10 ++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'qpid/java/client/src/test') diff --git a/qpid/java/client/src/test/java/org/apache/qpid/client/AMQConnectionUnitTest.java b/qpid/java/client/src/test/java/org/apache/qpid/client/AMQConnectionUnitTest.java index d186a440da..891cb9581c 100644 --- a/qpid/java/client/src/test/java/org/apache/qpid/client/AMQConnectionUnitTest.java +++ b/qpid/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 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/qpid/java/client/src/test/java/org/apache/qpid/client/AMQSession_0_10Test.java b/qpid/java/client/src/test/java/org/apache/qpid/client/AMQSession_0_10Test.java index d0cd24adf6..59181c3a13 100644 --- a/qpid/java/client/src/test/java/org/apache/qpid/client/AMQSession_0_10Test.java +++ b/qpid/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