You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2014/12/22 17:56:19 UTC
[11/16] qpid-jms git commit: remove tmp module with old client work
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/6f106f64/qpid-jms-client-tmp/src/test/java/org/apache/qpid/jms/MapMessageIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client-tmp/src/test/java/org/apache/qpid/jms/MapMessageIntegrationTest.java b/qpid-jms-client-tmp/src/test/java/org/apache/qpid/jms/MapMessageIntegrationTest.java
deleted file mode 100644
index ed37407..0000000
--- a/qpid-jms-client-tmp/src/test/java/org/apache/qpid/jms/MapMessageIntegrationTest.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * 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
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.jms;
-
-import static org.hamcrest.Matchers.equalTo;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Arrays;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import javax.jms.Connection;
-import javax.jms.MapMessage;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-
-import org.apache.qpid.jms.impl.ClientProperties;
-import org.apache.qpid.jms.test.testpeer.TestAmqpPeer;
-import org.apache.qpid.jms.test.testpeer.describedtypes.sections.AmqpValueDescribedType;
-import org.apache.qpid.jms.test.testpeer.describedtypes.sections.MessageAnnotationsDescribedType;
-import org.apache.qpid.jms.test.testpeer.matchers.sections.MessageAnnotationsSectionMatcher;
-import org.apache.qpid.jms.test.testpeer.matchers.sections.MessageHeaderSectionMatcher;
-import org.apache.qpid.jms.test.testpeer.matchers.sections.MessagePropertiesSectionMatcher;
-import org.apache.qpid.jms.test.testpeer.matchers.sections.TransferPayloadCompositeMatcher;
-import org.apache.qpid.jms.test.testpeer.matchers.types.EncodedAmqpValueMatcher;
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.DescribedType;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.junit.Test;
-
-public class MapMessageIntegrationTest extends QpidJmsTestCase
-{
- private final IntegrationTestFixture _testFixture = new IntegrationTestFixture();
-
- /**
- * Test that a message received from the test peer with an AmqpValue section containing
- * a map which holds entries of the various supported entry types is returned as a
- * {@link MapMessage}, and verify the values can all be retrieved as expected.
- */
- @Test
- public void testReceiveBasicMapMessage() throws Exception
- {
- try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
- {
- Connection connection = _testFixture.establishConnecton(testPeer);
- connection.start();
-
- testPeer.expectBegin(true);
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = session.createQueue("myQueue");
-
- //Prepare an AMQP message for the test peer to send, containing an
- //AmqpValue section holding a map with entries for each supported type,
- //and annotated as a JMS map message.
- String myBoolKey = "myBool";
- boolean myBool = true;
- String myByteKey = "myByte";
- byte myByte = 4;
- String myBytesKey = "myBytes";
- byte[] myBytes = myBytesKey.getBytes();
- String myCharKey = "myChar";
- char myChar = 'd';
- String myDoubleKey = "myDouble";
- double myDouble = 1234567890123456789.1234;
- String myFloatKey = "myFloat";
- float myFloat = 1.1F;
- String myIntKey = "myInt";
- int myInt = Integer.MAX_VALUE;
- String myLongKey = "myLong";
- long myLong = Long.MAX_VALUE;
- String myShortKey = "myShort";
- short myShort = 25;
- String myStringKey = "myString";
- String myString = myStringKey;
-
- Map<String,Object> map = new LinkedHashMap<String,Object>();
- map.put(myBoolKey, myBool);
- map.put(myByteKey, myByte);
- map.put(myBytesKey, new Binary(myBytes));//the underlying AMQP message uses Binary rather than byte[] directly.
- map.put(myCharKey, myChar);
- map.put(myDoubleKey, myDouble);
- map.put(myFloatKey, myFloat);
- map.put(myIntKey, myInt);
- map.put(myLongKey, myLong);
- map.put(myShortKey, myShort);
- map.put(myStringKey, myString);
-
- MessageAnnotationsDescribedType msgAnnotations = new MessageAnnotationsDescribedType();
- msgAnnotations.setSymbolKeyedAnnotation(ClientProperties.X_OPT_JMS_MSG_TYPE, ClientProperties.MAP_MESSAGE_TYPE);
-
- DescribedType amqpValueSectionContent = new AmqpValueDescribedType(map);
-
- //receive the message from the test peer
- testPeer.expectReceiverAttach();
- testPeer.expectLinkFlowRespondWithTransfer(null, msgAnnotations, null, null, amqpValueSectionContent);
- testPeer.expectDispositionThatIsAcceptedAndSettled();
-
- MessageConsumer messageConsumer = session.createConsumer(queue);
- Message receivedMessage = messageConsumer.receive(1000);
- testPeer.waitForAllHandlersToComplete(3000);
-
- //verify the content is as expected
- assertNotNull("Message was not received", receivedMessage);
- assertTrue("Message was not a MapMessage", receivedMessage instanceof MapMessage);
- MapMessage receivedMapMessage = (MapMessage) receivedMessage;
-
- assertEquals("Unexpected boolean value", myBool, receivedMapMessage.getBoolean(myBoolKey));
- assertEquals("Unexpected byte value", myByte, receivedMapMessage.getByte(myByteKey));
- byte[] readBytes = receivedMapMessage.getBytes(myBytesKey);
- assertTrue("Read bytes were not as expected: " + Arrays.toString(readBytes), Arrays.equals(myBytes, readBytes));
- assertEquals("Unexpected char value", myChar, receivedMapMessage.getChar(myCharKey));
- assertEquals("Unexpected double value", myDouble, receivedMapMessage.getDouble(myDoubleKey), 0.0);
- assertEquals("Unexpected float value", myFloat, receivedMapMessage.getFloat(myFloatKey), 0.0);
- assertEquals("Unexpected int value", myInt, receivedMapMessage.getInt(myIntKey));
- assertEquals("Unexpected long value", myLong, receivedMapMessage.getLong(myLongKey));
- assertEquals("Unexpected short value", myShort, receivedMapMessage.getShort(myShortKey));
- assertEquals("Unexpected UTF value", myString, receivedMapMessage.getString(myStringKey));
- }
- }
-
-/*
- * TODO: decide what to do about this
- *
- * The test below fails if a char is added, because the DataImpl-based decoder used by the test peer
- * decodes the char to an Integer object and thus the EncodedAmqpValueMatcher fails the comparison
- * of its contained map due to the differing types. This doesn't happen in the above test as the
- * reversed roles mean it is DecoderImpl doing the decoding and it casts the output to a char.
- *
- * The below change to alter DataImpl's output makes the test pass, as would making the test 'expect an int'.
-----START PATCH-----
-diff --git proton-j/src/main/java/org/apache/qpid/proton/codec/impl/CharElement.java proton-j/src/main/java/org/apache/qpid/proton/codec/impl/CharElement.java
-index 808d43e..6cdf84c 100644
---- proton-j/src/main/java/org/apache/qpid/proton/codec/impl/CharElement.java
-+++ proton-j/src/main/java/org/apache/qpid/proton/codec/impl/CharElement.java
-@@ -25,9 +25,8 @@ import java.nio.ByteBuffer;
-
- import org.apache.qpid.proton.codec.Data;
-
--class CharElement extends AtomicElement<Integer>
-+class CharElement extends AtomicElement<Character>
- {
--
- private final int _value;
-
- CharElement(Element parent, Element prev, int i)
-@@ -43,9 +42,9 @@ class CharElement extends AtomicElement<Integer>
- }
-
- @Override
-- public Integer getValue()
-+ public Character getValue()
- {
-- return _value;
-+ return (char)_value;
- }
-
- @Override
-----END PATCH-----
-*/
- /**
- * Test that sending a map message to the test peer results in receipt of a message with
- * an AmqpValue section containing a map which holds entries of the various supported entry
- * types with the expected values.
- */
- @SuppressWarnings("unused") // TODO - Remove once Char tests re-added
- @Test
- public void testSendBasicMapMessage() throws Exception
- {
- try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
- {
- Connection connection = _testFixture.establishConnecton(testPeer);
- testPeer.expectBegin(true);
- testPeer.expectSenderAttach();
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = session.createQueue("myQueue");
- MessageProducer producer = session.createProducer(queue);
-
-
- String myBoolKey = "myBool";
- boolean myBool = true;
- String myByteKey = "myByte";
- byte myByte = 4;
- String myBytesKey = "myBytes";
- byte[] myBytes = myBytesKey.getBytes();
- String myCharKey = "myChar";
- char myChar = 'd';
- String myDoubleKey = "myDouble";
- double myDouble = 1234567890123456789.1234;
- String myFloatKey = "myFloat";
- float myFloat = 1.1F;
- String myIntKey = "myInt";
- int myInt = Integer.MAX_VALUE;
- String myLongKey = "myLong";
- long myLong = Long.MAX_VALUE;
- String myShortKey = "myShort";
- short myShort = 25;
- String myStringKey = "myString";
- String myString = myStringKey;
-
- //Prepare a MapMessage to send to the test peer to send
- MapMessage mapMessage = session.createMapMessage();
-
- mapMessage.setBoolean(myBoolKey, myBool);
- mapMessage.setByte(myByteKey, myByte);
- mapMessage.setBytes(myBytesKey, myBytes);
- //TODO: see note above: mapMessage.setChar(myCharKey, myChar);
- mapMessage.setDouble(myDoubleKey, myDouble);
- mapMessage.setFloat(myFloatKey, myFloat);
- mapMessage.setInt(myIntKey, myInt);
- mapMessage.setLong(myLongKey, myLong);
- mapMessage.setShort(myShortKey, myShort);
- mapMessage.setString(myStringKey, myString);
-
- //prepare a matcher for the test peer to use to receive and verify the message
- Map<String,Object> map = new LinkedHashMap<String,Object>();
- map.put(myBoolKey, myBool);
- map.put(myByteKey, myByte);
- map.put(myBytesKey, new Binary(myBytes));//the underlying AMQP message uses Binary rather than byte[] directly.
- //TODO: see note above: map.put(myCharKey, myChar);
- map.put(myDoubleKey, myDouble);
- map.put(myFloatKey, myFloat);
- map.put(myIntKey, myInt);
- map.put(myLongKey, myLong);
- map.put(myShortKey, myShort);
- map.put(myStringKey, myString);
-
- MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true).withDurable(equalTo(true));
- MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true);
- msgAnnotationsMatcher.withEntry(Symbol.valueOf(ClientProperties.X_OPT_JMS_MSG_TYPE), equalTo(ClientProperties.MAP_MESSAGE_TYPE));
- MessagePropertiesSectionMatcher propertiesMatcher = new MessagePropertiesSectionMatcher(true);
- TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
- messageMatcher.setHeadersMatcher(headersMatcher);
- messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher);
- messageMatcher.setPropertiesMatcher(propertiesMatcher);
- messageMatcher.setMessageContentMatcher(new EncodedAmqpValueMatcher(map));
-
- //send the message
- testPeer.expectTransfer(messageMatcher);
- producer.send(mapMessage);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/6f106f64/qpid-jms-client-tmp/src/test/java/org/apache/qpid/jms/MessageIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client-tmp/src/test/java/org/apache/qpid/jms/MessageIntegrationTest.java b/qpid-jms-client-tmp/src/test/java/org/apache/qpid/jms/MessageIntegrationTest.java
deleted file mode 100644
index e5c9ff5..0000000
--- a/qpid-jms-client-tmp/src/test/java/org/apache/qpid/jms/MessageIntegrationTest.java
+++ /dev/null
@@ -1,947 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * 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
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.jms;
-
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.nullValue;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-
-import java.math.BigInteger;
-import java.nio.ByteBuffer;
-import java.util.Date;
-import java.util.UUID;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-
-import org.apache.qpid.jms.impl.ClientProperties;
-import org.apache.qpid.jms.impl.DestinationHelper;
-import org.apache.qpid.jms.impl.MessageIdHelper;
-import org.apache.qpid.jms.test.testpeer.TestAmqpPeer;
-import org.apache.qpid.jms.test.testpeer.describedtypes.sections.AmqpValueDescribedType;
-import org.apache.qpid.jms.test.testpeer.describedtypes.sections.ApplicationPropertiesDescribedType;
-import org.apache.qpid.jms.test.testpeer.describedtypes.sections.MessageAnnotationsDescribedType;
-import org.apache.qpid.jms.test.testpeer.describedtypes.sections.PropertiesDescribedType;
-import org.apache.qpid.jms.test.testpeer.matchers.sections.ApplicationPropertiesSectionMatcher;
-import org.apache.qpid.jms.test.testpeer.matchers.sections.MessageAnnotationsSectionMatcher;
-import org.apache.qpid.jms.test.testpeer.matchers.sections.MessageHeaderSectionMatcher;
-import org.apache.qpid.jms.test.testpeer.matchers.sections.MessagePropertiesSectionMatcher;
-import org.apache.qpid.jms.test.testpeer.matchers.sections.TransferPayloadCompositeMatcher;
-import org.apache.qpid.jms.test.testpeer.matchers.types.EncodedAmqpValueMatcher;
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.DescribedType;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.apache.qpid.proton.amqp.UnsignedInteger;
-import org.apache.qpid.proton.amqp.UnsignedLong;
-import org.junit.Test;
-
-public class MessageIntegrationTest extends QpidJmsTestCase
-{
- private static final String NULL_STRING_PROP = "nullStringProperty";
- private static final String NULL_STRING_PROP_VALUE = null;
- private static final String STRING_PROP = "stringProperty";
- private static final String STRING_PROP_VALUE = "string";
- private static final String BOOLEAN_PROP = "booleanProperty";
- private static final boolean BOOLEAN_PROP_VALUE = true;
- private static final String BYTE_PROP = "byteProperty";
- private static final byte BYTE_PROP_VALUE = (byte)1;
- private static final String SHORT_PROP = "shortProperty";
- private static final short SHORT_PROP_VALUE = (short)1;
- private static final String INT_PROP = "intProperty";
- private static final int INT_PROP_VALUE = Integer.MAX_VALUE;
- private static final String LONG_PROP = "longProperty";
- private static final long LONG_PROP_VALUE = Long.MAX_VALUE;
- private static final String FLOAT_PROP = "floatProperty";
- private static final float FLOAT_PROP_VALUE = Float.MAX_VALUE;
- private static final String DOUBLE_PROP = "doubleProperty";
- private static final double DOUBLE_PROP_VALUE = Double.MAX_VALUE;
-
- private final IntegrationTestFixture _testFixture = new IntegrationTestFixture();
-
- @Test
- public void testSendTextMessageWithApplicationProperties() throws Exception
- {
- try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
- {
- Connection connection = _testFixture.establishConnecton(testPeer);
- testPeer.expectBegin(true);
- testPeer.expectSenderAttach();
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- String queueName = "myQueue";
- Queue queue = session.createQueue(queueName);
- MessageProducer producer = session.createProducer(queue);
-
- ApplicationPropertiesSectionMatcher appPropsMatcher = new ApplicationPropertiesSectionMatcher(true);
- appPropsMatcher.withEntry(NULL_STRING_PROP, nullValue());
- appPropsMatcher.withEntry(STRING_PROP, equalTo(STRING_PROP_VALUE));
- appPropsMatcher.withEntry(BOOLEAN_PROP, equalTo(BOOLEAN_PROP_VALUE));
- appPropsMatcher.withEntry(BYTE_PROP, equalTo(BYTE_PROP_VALUE));
- appPropsMatcher.withEntry(SHORT_PROP, equalTo(SHORT_PROP_VALUE));
- appPropsMatcher.withEntry(INT_PROP, equalTo(INT_PROP_VALUE));
- appPropsMatcher.withEntry(LONG_PROP, equalTo(LONG_PROP_VALUE));
- appPropsMatcher.withEntry(FLOAT_PROP, equalTo(FLOAT_PROP_VALUE));
- appPropsMatcher.withEntry(DOUBLE_PROP, equalTo(DOUBLE_PROP_VALUE));
-
- MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true).withDurable(equalTo(true));
-
- MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true);
-
- MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true).withTo(equalTo(queueName));
-
- TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
- messageMatcher.setHeadersMatcher(headersMatcher);
- messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher);
- messageMatcher.setPropertiesMatcher(propsMatcher);
- messageMatcher.setApplicationPropertiesMatcher(appPropsMatcher);
- messageMatcher.setMessageContentMatcher(new EncodedAmqpValueMatcher(null));
- testPeer.expectTransfer(messageMatcher);
-
- Message message = session.createTextMessage();
- message.setStringProperty(NULL_STRING_PROP, NULL_STRING_PROP_VALUE);
- message.setStringProperty(STRING_PROP, STRING_PROP_VALUE);
- message.setBooleanProperty(BOOLEAN_PROP, BOOLEAN_PROP_VALUE);
- message.setByteProperty(BYTE_PROP, BYTE_PROP_VALUE);
- message.setShortProperty(SHORT_PROP, SHORT_PROP_VALUE);
- message.setIntProperty(INT_PROP, INT_PROP_VALUE);
- message.setLongProperty(LONG_PROP, LONG_PROP_VALUE);
- message.setFloatProperty(FLOAT_PROP, FLOAT_PROP_VALUE);
- message.setDoubleProperty(DOUBLE_PROP, DOUBLE_PROP_VALUE);
-
- producer.send(message);
-
- testPeer.waitForAllHandlersToComplete(1000);
- }
- }
-
- @Test
- public void testReceiveTextMessageWithApplicationProperties() throws Exception
- {
- try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
- {
- Connection connection = _testFixture.establishConnecton(testPeer);
- connection.start();
-
- testPeer.expectBegin(true);
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = session.createQueue("myQueue");
-
- ApplicationPropertiesDescribedType appProperties = new ApplicationPropertiesDescribedType();
- appProperties.setApplicationProperty(STRING_PROP, STRING_PROP_VALUE);
- appProperties.setApplicationProperty(NULL_STRING_PROP, NULL_STRING_PROP_VALUE);
- appProperties.setApplicationProperty(BOOLEAN_PROP, BOOLEAN_PROP_VALUE);
- appProperties.setApplicationProperty(BYTE_PROP, BYTE_PROP_VALUE);
- appProperties.setApplicationProperty(SHORT_PROP, SHORT_PROP_VALUE);
- appProperties.setApplicationProperty(INT_PROP, INT_PROP_VALUE);
- appProperties.setApplicationProperty(LONG_PROP, LONG_PROP_VALUE);
- appProperties.setApplicationProperty(FLOAT_PROP, FLOAT_PROP_VALUE);
- appProperties.setApplicationProperty(DOUBLE_PROP, DOUBLE_PROP_VALUE);
-
- DescribedType amqpValueNullContent = new AmqpValueDescribedType(null);
-
- testPeer.expectReceiverAttach();
- testPeer.expectLinkFlowRespondWithTransfer(null, null, null, appProperties, amqpValueNullContent);
- testPeer.expectDispositionThatIsAcceptedAndSettled();
-
- MessageConsumer messageConsumer = session.createConsumer(queue);
- Message receivedMessage = messageConsumer.receive(1000);
- testPeer.waitForAllHandlersToComplete(3000);
-
- assertNotNull(receivedMessage);
- assertTrue(receivedMessage instanceof TextMessage);
- assertNull(((TextMessage)receivedMessage).getText());
-
- assertTrue(receivedMessage.propertyExists(STRING_PROP));
- assertTrue(receivedMessage.propertyExists(NULL_STRING_PROP));
- assertTrue(receivedMessage.propertyExists(BYTE_PROP));
- assertTrue(receivedMessage.propertyExists(BOOLEAN_PROP));
- assertTrue(receivedMessage.propertyExists(SHORT_PROP));
- assertTrue(receivedMessage.propertyExists(INT_PROP));
- assertTrue(receivedMessage.propertyExists(LONG_PROP));
- assertTrue(receivedMessage.propertyExists(FLOAT_PROP));
- assertTrue(receivedMessage.propertyExists(DOUBLE_PROP));
- assertNull(receivedMessage.getStringProperty(NULL_STRING_PROP));
- assertEquals(STRING_PROP_VALUE, receivedMessage.getStringProperty(STRING_PROP));
- assertEquals(STRING_PROP_VALUE, receivedMessage.getStringProperty(STRING_PROP));
- assertEquals(BOOLEAN_PROP_VALUE, receivedMessage.getBooleanProperty(BOOLEAN_PROP));
- assertEquals(BYTE_PROP_VALUE, receivedMessage.getByteProperty(BYTE_PROP));
- assertEquals(SHORT_PROP_VALUE, receivedMessage.getShortProperty(SHORT_PROP));
- assertEquals(INT_PROP_VALUE, receivedMessage.getIntProperty(INT_PROP));
- assertEquals(LONG_PROP_VALUE, receivedMessage.getLongProperty(LONG_PROP));
- assertEquals(FLOAT_PROP_VALUE, receivedMessage.getFloatProperty(FLOAT_PROP), 0.0);
- assertEquals(DOUBLE_PROP_VALUE, receivedMessage.getDoubleProperty(DOUBLE_PROP), 0.0);
- }
- }
-
- /**
- * Tests that the {@link DestinationHelper#TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME} set on a message to
- * indicate its 'to' address represents a Topic results in the JMSDestination object being a
- * Topic. Ensure the consumers destination is not used by consuming from a Queue.
- */
- @Test
- public void testReceivedMessageFromQueueWithToTypeAnnotationForTopic() throws Exception
- {
- try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
- {
- Connection connection = _testFixture.establishConnecton(testPeer);
- connection.start();
-
- testPeer.expectBegin(true);
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = session.createQueue("myQueue");
-
- MessageAnnotationsDescribedType msgAnnotations = new MessageAnnotationsDescribedType();
- msgAnnotations.setSymbolKeyedAnnotation(DestinationHelper.TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME, DestinationHelper.TOPIC_ATTRIBUTES_STRING);
-
- PropertiesDescribedType props = new PropertiesDescribedType();
- String myTopicAddress = "myTopicAddress";
- props.setTo(myTopicAddress );
- DescribedType amqpValueNullContent = new AmqpValueDescribedType(null);
-
- testPeer.expectReceiverAttach();
- testPeer.expectLinkFlowRespondWithTransfer(null, msgAnnotations, props, null, amqpValueNullContent);
- testPeer.expectDispositionThatIsAcceptedAndSettled();
-
- MessageConsumer messageConsumer = session.createConsumer(queue);
- Message receivedMessage = messageConsumer.receive(1000);
- testPeer.waitForAllHandlersToComplete(3000);
-
- assertNotNull(receivedMessage);
-
- Destination dest = receivedMessage.getJMSDestination();
- assertTrue(dest instanceof Topic);
- assertEquals(myTopicAddress, ((Topic)dest).getTopicName());
- }
- }
-
- /**
- * Tests that the lack of a 'to' in the Properties section of the incoming message (e.g
- * one sent by a non-JMS client) is handled by making the JMSDestination method simply
- * return the Destination used to create the consumer that received the message.
- */
- @Test
- public void testReceivedMessageFromQueueWithoutToResultsInUseOfConsumerDestination() throws Exception
- {
- try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
- {
- Connection connection = _testFixture.establishConnecton(testPeer);
- connection.start();
-
- testPeer.expectBegin(true);
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- String queueName = "myQueue";
- Queue queue = session.createQueue(queueName);
-
- DescribedType amqpValueNullContent = new AmqpValueDescribedType(null);
-
- testPeer.expectReceiverAttach();
- testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, amqpValueNullContent);
- testPeer.expectDispositionThatIsAcceptedAndSettled();
-
- MessageConsumer messageConsumer = session.createConsumer(queue);
- Message receivedMessage = messageConsumer.receive(1000);
- testPeer.waitForAllHandlersToComplete(3000);
-
- assertNotNull(receivedMessage);
-
- Destination dest = receivedMessage.getJMSDestination();
- assertTrue(dest instanceof Queue);
- assertEquals(queueName, ((Queue)dest).getQueueName());
- }
- }
-
- /**
- * Tests that the {@link DestinationHelper#REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME} set on a message to
- * indicate its 'reply-to' address represents a Topic results in the JMSReplyTo object being a
- * Topic. Ensure the consumers destination is not used by consuming from a Queue.
- */
- @Test
- public void testReceivedMessageFromQueueWithReplyToTypeAnnotationForTopic() throws Exception
- {
- try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
- {
- Connection connection = _testFixture.establishConnecton(testPeer);
- connection.start();
-
- testPeer.expectBegin(true);
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = session.createQueue("myQueue");
-
- MessageAnnotationsDescribedType msgAnnotations = new MessageAnnotationsDescribedType();
- msgAnnotations.setSymbolKeyedAnnotation(DestinationHelper.REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME, DestinationHelper.TOPIC_ATTRIBUTES_STRING);
-
- PropertiesDescribedType props = new PropertiesDescribedType();
- String myTopicAddress = "myTopicAddress";
- props.setReplyTo(myTopicAddress);
- DescribedType amqpValueNullContent = new AmqpValueDescribedType(null);
-
- testPeer.expectReceiverAttach();
- testPeer.expectLinkFlowRespondWithTransfer(null, msgAnnotations, props, null, amqpValueNullContent);
- testPeer.expectDispositionThatIsAcceptedAndSettled();
-
- MessageConsumer messageConsumer = session.createConsumer(queue);
- Message receivedMessage = messageConsumer.receive(1000);
- testPeer.waitForAllHandlersToComplete(3000);
-
- assertNotNull(receivedMessage);
-
- Destination dest = receivedMessage.getJMSReplyTo();
- assertTrue(dest instanceof Topic);
- assertEquals(myTopicAddress, ((Topic)dest).getTopicName());
- }
- }
-
- /**
- * Tests that lack of the {@link DestinationHelper#REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME} set on a
- * message to indicate type of its 'reply-to' address results in it being classed as the same
- * type as the destination used to create the consumer.
- */
- @Test
- public void testReceivedMessageFromQueueWithReplyToWithoutTypeAnnotationResultsInUseOfConsumerDestinationType() throws Exception
- {
- try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
- {
- Connection connection = _testFixture.establishConnecton(testPeer);
- connection.start();
-
- testPeer.expectBegin(true);
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = session.createQueue("myQueue");
-
- String myOtherQueueAddress = "myOtherQueueAddress";
- PropertiesDescribedType props = new PropertiesDescribedType();
- props.setReplyTo(myOtherQueueAddress);
-
- DescribedType amqpValueNullContent = new AmqpValueDescribedType(null);
-
- testPeer.expectReceiverAttach();
- testPeer.expectLinkFlowRespondWithTransfer(null, null, props, null, amqpValueNullContent);
- testPeer.expectDispositionThatIsAcceptedAndSettled();
-
- MessageConsumer messageConsumer = session.createConsumer(queue);
- Message receivedMessage = messageConsumer.receive(1000);
- testPeer.waitForAllHandlersToComplete(3000);
-
- assertNotNull(receivedMessage);
-
- Destination dest = receivedMessage.getJMSReplyTo();
- assertTrue(dest instanceof Queue);
- assertEquals(myOtherQueueAddress, ((Queue)dest).getQueueName());
- }
- }
-
- /**
- * Tests that lack of the reply-to set on a message results in it returning null for JMSReplyTo
- * and not the consumer destination as happens for JMSDestination.
- */
- @Test
- public void testReceivedMessageFromQueueWithNoReplyToReturnsNull() throws Exception
- {
- try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
- {
- Connection connection = _testFixture.establishConnecton(testPeer);
- connection.start();
-
- testPeer.expectBegin(true);
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = session.createQueue("myQueue");
-
- DescribedType amqpValueNullContent = new AmqpValueDescribedType(null);
-
- testPeer.expectReceiverAttach();
- testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, amqpValueNullContent);
- testPeer.expectDispositionThatIsAcceptedAndSettled();
-
- MessageConsumer messageConsumer = session.createConsumer(queue);
- Message receivedMessage = messageConsumer.receive(1000);
- testPeer.waitForAllHandlersToComplete(3000);
-
- assertNotNull(receivedMessage);
- assertNull(receivedMessage.getJMSReplyTo());
- }
- }
-
- /**
- * Tests that lack of the absolute-expiry-time and ttl fields on a message results
- * in it returning 0 for for JMSExpiration
- */
- @Test
- public void testReceivedMessageFromQueueWithNoAbsoluteExpiryOrTtlReturnsJMSExpirationZero() throws Exception
- {
- try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
- {
- Connection connection = _testFixture.establishConnecton(testPeer);
- connection.start();
-
- testPeer.expectBegin(true);
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = session.createQueue("myQueue");
-
- DescribedType amqpValueNullContent = new AmqpValueDescribedType(null);
-
- testPeer.expectReceiverAttach();
- testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, amqpValueNullContent);
- testPeer.expectDispositionThatIsAcceptedAndSettled();
-
- MessageConsumer messageConsumer = session.createConsumer(queue);
- Message receivedMessage = messageConsumer.receive(1000);
- testPeer.waitForAllHandlersToComplete(3000);
-
- assertNotNull(receivedMessage);
- assertEquals(0L, receivedMessage.getJMSExpiration());
- }
- }
-
- /**
- * Tests that setting a non-zero value in the absolute-expiry-time field on a
- * message results in it returning this value for JMSExpiration
- */
- @Test
- public void testReceivedMessageFromQueueWithAbsoluteExpiryReturnsJMSExpirationNonZero() throws Exception
- {
- try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
- {
- Connection connection = _testFixture.establishConnecton(testPeer);
- connection.start();
-
- testPeer.expectBegin(true);
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = session.createQueue("myQueue");
-
- long timestamp = System.currentTimeMillis();
-
- PropertiesDescribedType props = new PropertiesDescribedType();
- props.setAbsoluteExpiryTime(new Date(timestamp));
- DescribedType amqpValueNullContent = new AmqpValueDescribedType(null);
-
- testPeer.expectReceiverAttach();
- testPeer.expectLinkFlowRespondWithTransfer(null, null, props, null, amqpValueNullContent);
- testPeer.expectDispositionThatIsAcceptedAndSettled();
-
- MessageConsumer messageConsumer = session.createConsumer(queue);
- Message receivedMessage = messageConsumer.receive(1000);
- testPeer.waitForAllHandlersToComplete(3000);
-
- assertNotNull(receivedMessage);
- assertEquals(timestamp, receivedMessage.getJMSExpiration());
- }
- }
-
- /**
- * Tests that receiving a message with a string typed message-id results in returning the
- * expected value for JMSMessageId where the JMS "ID:" prefix has been added.
- */
- @Test
- public void testReceivedMessageWithStringMessageIdReturnsExpectedJMSMessageID() throws Exception
- {
- receivedMessageWithMessageIdTestImpl("myTestMessageIdString");
- }
-
- /**
- * Tests that receiving a message with a UUID typed message-id results in returning the
- * expected value for JMSMessageId where the JMS "ID:" prefix has been added to the UUID.tostring()
- */
- @Test
- public void testReceivedMessageWithUUIDMessageIdReturnsExpectedJMSMessageID() throws Exception
- {
- receivedMessageWithMessageIdTestImpl(UUID.randomUUID());
- }
-
- /**
- * Tests that receiving a message with a ulong typed message-id results in returning the
- * expected value for JMSMessageId where the JMS "ID:" prefix has been added to the UUID.tostring()
- */
- @Test
- public void testReceivedMessageWithLongMessageIdReturnsExpectedJMSMessageID() throws Exception
- {
- receivedMessageWithMessageIdTestImpl(BigInteger.valueOf(123456789L));
- }
-
- private void receivedMessageWithMessageIdTestImpl(Object messageIdForAmqpMessageClass) throws Exception
- {
- try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
- {
- Connection connection = _testFixture.establishConnecton(testPeer);
- connection.start();
-
- testPeer.expectBegin(true);
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = session.createQueue("myQueue");
-
- Object underlyingAmqpMessageId = classifyUnderlyingIdType(messageIdForAmqpMessageClass);
-
- PropertiesDescribedType props = new PropertiesDescribedType();
- props.setMessageId(underlyingAmqpMessageId);
- DescribedType amqpValueNullContent = new AmqpValueDescribedType(null);
-
- testPeer.expectReceiverAttach();
- testPeer.expectLinkFlowRespondWithTransfer(null, null, props, null, amqpValueNullContent);
- testPeer.expectDispositionThatIsAcceptedAndSettled();
-
- MessageConsumer messageConsumer = session.createConsumer(queue);
- Message receivedMessage = messageConsumer.receive(1000);
- testPeer.waitForAllHandlersToComplete(3000);
-
- assertNotNull(receivedMessage);
- String expectedBaseIdString = new MessageIdHelper().toBaseMessageIdString(messageIdForAmqpMessageClass);
-
- assertEquals("ID:" + expectedBaseIdString, receivedMessage.getJMSMessageID());
- }
- }
-
- /**
- * Tests that receiving a message with a string typed correlation-id results in returning the
- * expected value for JMSCorrelationID where the JMS "ID:" prefix has been added.
- */
- @Test
- public void testReceivedMessageWithStringCorrelationIdReturnsExpectedJMSCorrelationID() throws Exception
- {
- receivedMessageWithCorrelationIdTestImpl("myTestCorrelationIdString", false);
- }
-
- /**
- * Tests that receiving a message with a string typed correlation-id, which is indicated to be an
- * application-specific value, results in returning the expected value for JMSCorrelationID
- * where the JMS "ID:" prefix has NOT been added.
- */
- @Test
- public void testReceivedMessageWithAppSpecificStringCorrelationIdReturnsExpectedJMSCorrelationID() throws Exception
- {
- receivedMessageWithCorrelationIdTestImpl("myTestCorrelationIdString", true);
- }
-
- /**
- * Tests that receiving a message with a UUID typed correlation-id results in returning the
- * expected value for JMSCorrelationID where the JMS "ID:" prefix has been added to the UUID.tostring()
- */
- @Test
- public void testReceivedMessageWithUUIDCorrelationIdReturnsExpectedJMSCorrelationID() throws Exception
- {
- receivedMessageWithCorrelationIdTestImpl(UUID.randomUUID(), false);
- }
-
- /**
- * Tests that receiving a message with a UUID typed correlation-id results in returning the
- * expected value for JMSCorrelationID where the JMS "ID:" prefix has been added to the UUID.tostring()
- */
- @Test
- public void testReceivedMessageWithLongCorrelationIdReturnsExpectedJMSCorrelationID() throws Exception
- {
- receivedMessageWithCorrelationIdTestImpl(BigInteger.valueOf(123456789L), false);
- }
-
- private void receivedMessageWithCorrelationIdTestImpl(Object correlationIdForAmqpMessageClass, boolean appSpecific) throws Exception
- {
- try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
- {
- Connection connection = _testFixture.establishConnecton(testPeer);
- connection.start();
-
- testPeer.expectBegin(true);
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = session.createQueue("myQueue");
-
- Object underlyingAmqpCorrelationId = classifyUnderlyingIdType(correlationIdForAmqpMessageClass);
-
- PropertiesDescribedType props = new PropertiesDescribedType();
- DescribedType amqpValueNullContent = new AmqpValueDescribedType(null);
- MessageAnnotationsDescribedType ann = null;
-
- props.setCorrelationId(underlyingAmqpCorrelationId);
- if(appSpecific)
- {
- ann = new MessageAnnotationsDescribedType();
- ann.setSymbolKeyedAnnotation(ClientProperties.X_OPT_APP_CORRELATION_ID, true);
- }
-
- testPeer.expectReceiverAttach();
- testPeer.expectLinkFlowRespondWithTransfer(null, ann, props, null, amqpValueNullContent);
- testPeer.expectDispositionThatIsAcceptedAndSettled();
-
- MessageConsumer messageConsumer = session.createConsumer(queue);
- Message receivedMessage = messageConsumer.receive(1000);
- testPeer.waitForAllHandlersToComplete(3000);
-
- assertNotNull(receivedMessage);
- String expectedBaseIdString = new MessageIdHelper().toBaseMessageIdString(correlationIdForAmqpMessageClass);
- String expected = expectedBaseIdString;
- if(!appSpecific)
- {
- expected = "ID:" + expected;
- }
-
- assertEquals(expected, receivedMessage.getJMSCorrelationID());
- }
- }
-
- /**
- * Tests that sending a message with a uuid typed correlation-id value which is a
- * message-id results in an AMQP message with the expected encoding of the correlation-id,
- * where the type is uuid, the "ID:" prefix of the JMSCorrelationID value is (obviously) not present, and there is
- * no presence of the message annotation to indicate an app-specific correlation-id.
- */
- @Test
- public void testSentMessageWithUUIDCorrelationId() throws Exception
- {
- UUID uuid = UUID.randomUUID();
- String stringCorrelationId = MessageIdHelper.JMS_ID_PREFIX + MessageIdHelper.AMQP_UUID_PREFIX + uuid.toString();
- sentMessageWithCorrelationIdTestImpl(stringCorrelationId, uuid, false);
- }
-
- /**
- * Tests that sending a message with a binary typed correlation-id value which is a
- * message-id results in an AMQP message with the expected encoding of the correlation-id,
- * where the type is binary, the "ID:" prefix of the JMSCorrelationID value is (obviously) not present, and there is
- * no presence of the message annotation to indicate an app-specific correlation-id.
- */
- @Test
- public void testSentMessageWithBinaryCorrelationId() throws Exception
- {
- ByteBuffer bin = ByteBuffer.wrap(new byte[]{(byte)0x01, (byte)0x23, (byte) 0xAF, (byte) 0x00});
- String stringCorrelationId = MessageIdHelper.JMS_ID_PREFIX + MessageIdHelper.AMQP_BINARY_PREFIX + "0123af00";
- sentMessageWithCorrelationIdTestImpl(stringCorrelationId, bin, false);
- }
-
- /**
- * Tests that sending a message with a ulong typed correlation-id value which is a
- * message-id results in an AMQP message with the expected encoding of the correlation-id,
- * where the type is ulong, the "ID:" prefix of the JMSCorrelationID value is (obviously) not present, and there is
- * no presence of the message annotation to indicate an app-specific correlation-id.
- */
- @Test
- public void testSentMessageWithUlongCorrelationId() throws Exception
- {
- BigInteger ulong = BigInteger.valueOf(Long.MAX_VALUE).add(BigInteger.TEN);
- String stringCorrelationId = MessageIdHelper.JMS_ID_PREFIX + MessageIdHelper.AMQP_ULONG_PREFIX + ulong.toString();
- sentMessageWithCorrelationIdTestImpl(stringCorrelationId, ulong, false);
- }
-
- /**
- * Tests that sending a message with a string typed correlation-id value which is a
- * message-id results in an AMQP message with the expected encoding of the correlation-id,
- * where the "ID:" prefix of the JMSCorrelationID value is not present, and there is
- * no presence of the message annotation to indicate an app-specific correlation-id.
- */
- @Test
- public void testSentMessageWithStringCorrelationId() throws Exception
- {
-
- String stringCorrelationId = "ID:myTestMessageIdString";
- String underlyingCorrelationId = "myTestMessageIdString";
- sentMessageWithCorrelationIdTestImpl(stringCorrelationId, underlyingCorrelationId, false);
- }
-
- /**
- * Tests that sending a message with a string typed correlation-id value which is a
- * app-specific results in an AMQP message with the expected encoding of the correlation-id,
- * and the presence of the message annotation to indicate an app-specific correlation-id.
- */
- @Test
- public void testSentMessageWithAppSpecificStringCorrelationId() throws Exception
- {
- String stringCorrelationId = "myTestAppSpecificString";
- sentMessageWithCorrelationIdTestImpl(stringCorrelationId, stringCorrelationId, true);
- }
-
- private void sentMessageWithCorrelationIdTestImpl(String stringCorrelationId, Object correlationIdForAmqpMessageClass, boolean appSpecific) throws Exception
- {
- try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
- {
- Connection connection = _testFixture.establishConnecton(testPeer);
- testPeer.expectBegin(true);
- testPeer.expectSenderAttach();
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- String queueName = "myQueue";
- Queue queue = session.createQueue(queueName);
- MessageProducer producer = session.createProducer(queue);
-
- MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true);
- MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true);
- MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true);
-
- //Set matcher to validate the correlation-id, and the annotation
- //presence+value if it is application-specific
- Object underlyingAmqpCorrelationId = classifyUnderlyingIdType(correlationIdForAmqpMessageClass);
- propsMatcher.withCorrelationId(equalTo(underlyingAmqpCorrelationId));
- if(appSpecific)
- {
- msgAnnotationsMatcher.withEntry(Symbol.valueOf(ClientProperties.X_OPT_APP_CORRELATION_ID), equalTo(Boolean.TRUE));
- }
-
- TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
- messageMatcher.setHeadersMatcher(headersMatcher);
- messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher);
- messageMatcher.setPropertiesMatcher(propsMatcher);
- messageMatcher.setMessageContentMatcher(new EncodedAmqpValueMatcher(null));
- testPeer.expectTransfer(messageMatcher);
-
- Message message = session.createTextMessage();
- message.setJMSCorrelationID(stringCorrelationId);
-
- producer.send(message);
-
- testPeer.waitForAllHandlersToComplete(3000);
-
- //validate the annotation was not present if the value was a message-id
- if(!appSpecific)
- {
- assertFalse(msgAnnotationsMatcher.keyExistsInReceivedAnnotations(Symbol.valueOf(ClientProperties.X_OPT_APP_CORRELATION_ID)));
- }
- }
- }
-
- /**
- * Tests that receiving a message with a string typed message-id, and then sending a message which
- * uses the result of calling getJMSMessageID as the value for setJMSCorrelationId results in
- * transmission of the expected AMQP message content.
- */
- @Test
- public void testReceivedMessageWithStringMessageIdAndSendValueAsCorrelationId() throws Exception
- {
- recieveMessageIdSendCorrelationIdTestImpl("myStringMessageId");
- }
-
- /**
- * Tests that receiving a message with a UUID typed message-id, and then sending a message which
- * uses the result of calling getJMSMessageID as the value for setJMSCorrelationId results in
- * transmission of the expected AMQP message content.
- */
- @Test
- public void testReceivedMessageWithUUIDMessageIdAndSendValueAsCorrelationId() throws Exception
- {
- recieveMessageIdSendCorrelationIdTestImpl(UUID.randomUUID());
- }
-
- /**
- * Tests that receiving a message with a ulong typed message-id, and then sending a message which
- * uses the result of calling getJMSMessageID as the value for setJMSCorrelationId results in
- * transmission of the expected AMQP message content.
- */
- @Test
- public void testReceivedMessageWithUlongMessageIdAndSendValueAsCorrelationId() throws Exception
- {
- recieveMessageIdSendCorrelationIdTestImpl(BigInteger.valueOf(123456789L));
- }
-
- /**
- * Tests that receiving a message with a binary typed message-id, and then sending a message which
- * uses the result of calling getJMSMessageID as the value for setJMSCorrelationId results in
- * transmission of the expected AMQP message content.
- */
- @Test
- public void testReceivedMessageWithBinaryMessageIdAndSendValueAsCorrelationId() throws Exception
- {
- recieveMessageIdSendCorrelationIdTestImpl(ByteBuffer.wrap(new byte[]{(byte)0x00, (byte)0xCD, (byte) 0xEF, (byte) 0x01}));
- }
-
- private void recieveMessageIdSendCorrelationIdTestImpl(Object idForAmqpMessageClass) throws Exception
- {
- try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
- {
- Connection connection = _testFixture.establishConnecton(testPeer);
- connection.start();
-
- testPeer.expectBegin(true);
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = session.createQueue("myQueue");
-
- Object underlyingAmqpMessageId = classifyUnderlyingIdType(idForAmqpMessageClass);
-
- PropertiesDescribedType props = new PropertiesDescribedType();
- props.setMessageId(underlyingAmqpMessageId);
- DescribedType amqpValueNullContent = new AmqpValueDescribedType(null);
-
- testPeer.expectReceiverAttach();
- testPeer.expectLinkFlowRespondWithTransfer(null, null, props, null, amqpValueNullContent);
- testPeer.expectDispositionThatIsAcceptedAndSettled();
-
- MessageConsumer messageConsumer = session.createConsumer(queue);
- Message receivedMessage = messageConsumer.receive(1000);
- testPeer.waitForAllHandlersToComplete(3000);
-
- assertNotNull(receivedMessage);
- String expectedBaseIdString = new MessageIdHelper().toBaseMessageIdString(idForAmqpMessageClass);
-
- String jmsMessageID = receivedMessage.getJMSMessageID();
- assertEquals("ID:" + expectedBaseIdString, jmsMessageID);
-
- //Now take the received JMSMessageID, and send a message with it set
- //as the JMSCorrelationID and verify we get the same AMQP id as we started with.
-
- testPeer.expectSenderAttach();
- MessageProducer producer = session.createProducer(queue);
-
- MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true);
- MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true);
- MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true);
-
- //Set matcher to validate the correlation-id matches the previous message-id
- propsMatcher.withCorrelationId(equalTo(underlyingAmqpMessageId));
-
- TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
- messageMatcher.setHeadersMatcher(headersMatcher);
- messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher);
- messageMatcher.setPropertiesMatcher(propsMatcher);
- messageMatcher.setMessageContentMatcher(new EncodedAmqpValueMatcher(null));
- testPeer.expectTransfer(messageMatcher);
-
- Message message = session.createTextMessage();
- message.setJMSCorrelationID(jmsMessageID);
-
- producer.send(message);
-
- testPeer.waitForAllHandlersToComplete(3000);
- }
- }
-
- private Object classifyUnderlyingIdType(Object idForAmqpMessageClass)
- {
- Object underlyingAmqpMessageId = idForAmqpMessageClass;
-
- if(underlyingAmqpMessageId instanceof BigInteger)
- {
- //Proton uses UnsignedLong
- underlyingAmqpMessageId = UnsignedLong.valueOf((BigInteger)underlyingAmqpMessageId);
- }
- else if(underlyingAmqpMessageId instanceof ByteBuffer)
- {
- //Proton uses Binary
- underlyingAmqpMessageId = Binary.create((ByteBuffer)underlyingAmqpMessageId);
- }
-
- return underlyingAmqpMessageId;
- }
-
- /**
- * Tests that when receiving a message with the group-id, reply-to-group-id, and group-sequence
- * fields of the AMQP properties section set, that the expected values are returned when getting
- * the appropriate JMSX or JMS_AMQP properties from the JMS message.
- */
- @Test
- public void testReceivedMessageWithGroupRelatedPropertiesSet() throws Exception
- {
- try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
- {
- Connection connection = _testFixture.establishConnecton(testPeer);
- connection.start();
-
- testPeer.expectBegin(true);
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = session.createQueue("myQueue");
-
- PropertiesDescribedType props = new PropertiesDescribedType();
- DescribedType amqpValueNullContent = new AmqpValueDescribedType(null);
- MessageAnnotationsDescribedType ann = null;
-
- String expectedGroupId = "myGroupId123";
- int expectedGroupSeq = 1;
- String expectedReplyToGroupId = "myReplyToGroupId456";
-
- props.setGroupId(expectedGroupId);
- props.setGroupSequence(UnsignedInteger.valueOf(expectedGroupSeq));
- props.setReplyToGroupId(expectedReplyToGroupId);
-
- testPeer.expectReceiverAttach();
- testPeer.expectLinkFlowRespondWithTransfer(null, ann, props, null, amqpValueNullContent);
- testPeer.expectDispositionThatIsAcceptedAndSettled();
-
- MessageConsumer messageConsumer = session.createConsumer(queue);
- Message receivedMessage = messageConsumer.receive(1000);
- testPeer.waitForAllHandlersToComplete(3000);
-
- assertNotNull("did not receive the message", receivedMessage);
- assertEquals("did not get the expected JMSXGroupID", expectedGroupId, receivedMessage.getStringProperty(ClientProperties.JMSXGROUPID));
- assertEquals("did not get the expected JMSXGroupSeq", expectedGroupSeq, receivedMessage.getIntProperty(ClientProperties.JMSXGROUPSEQ));
- assertEquals("did not get the expected JMS_AMQP_REPLY_TO_GROUP_ID", expectedReplyToGroupId, receivedMessage.getStringProperty(ClientProperties.JMS_AMQP_REPLY_TO_GROUP_ID));
- }
- }
-
- /**
- * Tests that when sending a message with the JMSXGroupID, JMSXGroupSeq, and JMS_AMQP_REPLY_TO_GROUP_ID
- * properties of the JMS message set, that the expected values are included in the fields of
- * the AMQP message emitted.
- */
- @Test
- public void testSendMessageWithGroupRelatedPropertiesSet() throws Exception
- {
- try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
- {
- Connection connection = _testFixture.establishConnecton(testPeer);
- testPeer.expectBegin(true);
- testPeer.expectSenderAttach();
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- String queueName = "myQueue";
- Queue queue = session.createQueue(queueName);
- MessageProducer producer = session.createProducer(queue);
-
- MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true).withDurable(equalTo(true));
- MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true);
-
- String expectedGroupId = "myGroupId123";
- int expectedGroupSeq = 1;
- String expectedReplyToGroupId = "myReplyToGroupId456";
-
- MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true);
- propsMatcher.withGroupId(equalTo(expectedGroupId));
- propsMatcher.withReplyToGroupId(equalTo(expectedReplyToGroupId));
- propsMatcher.withGroupSequence(equalTo(UnsignedInteger.valueOf(expectedGroupSeq)));
-
- TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
- messageMatcher.setHeadersMatcher(headersMatcher);
- messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher);
- messageMatcher.setPropertiesMatcher(propsMatcher);
- messageMatcher.setMessageContentMatcher(new EncodedAmqpValueMatcher(null));
- testPeer.expectTransfer(messageMatcher);
-
- Message message = session.createTextMessage();
- message.setStringProperty(ClientProperties.JMSXGROUPID, expectedGroupId);
- message.setIntProperty(ClientProperties.JMSXGROUPSEQ, expectedGroupSeq);
- message.setStringProperty(ClientProperties.JMS_AMQP_REPLY_TO_GROUP_ID, expectedReplyToGroupId);
-
- producer.send(message);
-
- testPeer.waitForAllHandlersToComplete(1000);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/6f106f64/qpid-jms-client-tmp/src/test/java/org/apache/qpid/jms/ObjectMessageIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client-tmp/src/test/java/org/apache/qpid/jms/ObjectMessageIntegrationTest.java b/qpid-jms-client-tmp/src/test/java/org/apache/qpid/jms/ObjectMessageIntegrationTest.java
deleted file mode 100644
index 246d1b4..0000000
--- a/qpid-jms-client-tmp/src/test/java/org/apache/qpid/jms/ObjectMessageIntegrationTest.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * 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
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.jms;
-
-import static org.hamcrest.Matchers.equalTo;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectOutputStream;
-import java.util.HashMap;
-
-import javax.jms.Connection;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.Session;
-
-import org.apache.qpid.jms.engine.AmqpObjectMessageSerializedDelegate;
-import org.apache.qpid.jms.impl.ClientProperties;
-import org.apache.qpid.jms.test.testpeer.TestAmqpPeer;
-import org.apache.qpid.jms.test.testpeer.describedtypes.sections.AmqpValueDescribedType;
-import org.apache.qpid.jms.test.testpeer.describedtypes.sections.DataDescribedType;
-import org.apache.qpid.jms.test.testpeer.describedtypes.sections.MessageAnnotationsDescribedType;
-import org.apache.qpid.jms.test.testpeer.describedtypes.sections.PropertiesDescribedType;
-import org.apache.qpid.jms.test.testpeer.matchers.sections.MessageAnnotationsSectionMatcher;
-import org.apache.qpid.jms.test.testpeer.matchers.sections.MessageHeaderSectionMatcher;
-import org.apache.qpid.jms.test.testpeer.matchers.sections.MessagePropertiesSectionMatcher;
-import org.apache.qpid.jms.test.testpeer.matchers.sections.TransferPayloadCompositeMatcher;
-import org.apache.qpid.jms.test.testpeer.matchers.types.EncodedAmqpValueMatcher;
-import org.apache.qpid.jms.test.testpeer.matchers.types.EncodedDataMatcher;
-import org.apache.qpid.proton.amqp.Binary;
-import org.apache.qpid.proton.amqp.DescribedType;
-import org.apache.qpid.proton.amqp.Symbol;
-import org.junit.Test;
-
-public class ObjectMessageIntegrationTest extends QpidJmsTestCase
-{
- private final IntegrationTestFixture _testFixture = new IntegrationTestFixture();
-
- //==== Java serialization encoding ====
-
- @Test
- public void testSendBasicObjectMessageWithSerializedContent() throws Exception
- {
- try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
- {
- Connection connection = _testFixture.establishConnecton(testPeer);
- testPeer.expectBegin(true);
- testPeer.expectSenderAttach();
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = session.createQueue("myQueue");
- MessageProducer producer = session.createProducer(queue);
-
- String content = "myObjectString";
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(content);
- oos.flush();
- oos.close();
- byte[] bytes = baos.toByteArray();
-
- MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true).withDurable(equalTo(true));
- MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true);
- msgAnnotationsMatcher.withEntry(Symbol.valueOf(ClientProperties.X_OPT_JMS_MSG_TYPE), equalTo(ClientProperties.OBJECT_MESSSAGE_TYPE));
- MessagePropertiesSectionMatcher propertiesMatcher = new MessagePropertiesSectionMatcher(true);
- propertiesMatcher.withContentType(equalTo(Symbol.valueOf(AmqpObjectMessageSerializedDelegate.CONTENT_TYPE)));
- TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
- messageMatcher.setHeadersMatcher(headersMatcher);
- messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher);
- messageMatcher.setPropertiesMatcher(propertiesMatcher);
- messageMatcher.setMessageContentMatcher(new EncodedDataMatcher(new Binary(bytes)));
-
- testPeer.expectTransfer(messageMatcher);
-
- ObjectMessage message = session.createObjectMessage();
- message.setObject(content);
-
- producer.send(message);
-
- testPeer.waitForAllHandlersToComplete(3000);
- }
- }
-
- @Test
- public void testReceiveBasicObjectMessageWithSerializedContent() throws Exception
- {
- try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
- {
- Connection connection = _testFixture.establishConnecton(testPeer);
- connection.start();
-
- testPeer.expectBegin(true);
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = session.createQueue("myQueue");
-
- PropertiesDescribedType properties = new PropertiesDescribedType();
- properties.setContentType(Symbol.valueOf(AmqpObjectMessageSerializedDelegate.CONTENT_TYPE));
-
- String expectedContent = "expectedContent";
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(expectedContent);
- oos.flush();
- oos.close();
- byte[] bytes = baos.toByteArray();
-
- MessageAnnotationsDescribedType msgAnnotations = new MessageAnnotationsDescribedType();
- msgAnnotations.setSymbolKeyedAnnotation(ClientProperties.X_OPT_JMS_MSG_TYPE, ClientProperties.OBJECT_MESSSAGE_TYPE);
-
- DescribedType dataContent = new DataDescribedType(new Binary(bytes));
-
- testPeer.expectReceiverAttach();
- testPeer.expectLinkFlowRespondWithTransfer(null, msgAnnotations, properties, null, dataContent);
- testPeer.expectDispositionThatIsAcceptedAndSettled();
-
- MessageConsumer messageConsumer = session.createConsumer(queue);
- Message receivedMessage = messageConsumer.receive(1000);
- testPeer.waitForAllHandlersToComplete(3000);
-
- assertNotNull(receivedMessage);
- assertTrue(receivedMessage instanceof ObjectMessage);
- ObjectMessage objectMessage = (ObjectMessage)receivedMessage;
-
- Object object = objectMessage.getObject();
- assertNotNull("Expected object but got null", object);
- assertEquals("Message body object was not as expected", expectedContent, object);
- }
- }
-
- @Test
- public void testReceiveAndThenResendBasicObjectMessageWithSerializedContent() throws Exception
- {
- try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
- {
- Connection connection = _testFixture.establishConnecton(testPeer);
- connection.start();
-
- testPeer.expectBegin(true);
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = session.createQueue("myQueue");
-
- MessageAnnotationsDescribedType msgAnnotations = new MessageAnnotationsDescribedType();
- msgAnnotations.setSymbolKeyedAnnotation(ClientProperties.X_OPT_JMS_MSG_TYPE, ClientProperties.OBJECT_MESSSAGE_TYPE);
- PropertiesDescribedType properties = new PropertiesDescribedType();
- properties.setContentType(Symbol.valueOf(AmqpObjectMessageSerializedDelegate.CONTENT_TYPE));
-
- String expectedContent = "expectedContent";
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(expectedContent);
- oos.flush();
- oos.close();
- byte[] bytes = baos.toByteArray();
-
- DescribedType dataContent = new DataDescribedType(new Binary(bytes));
-
- testPeer.expectReceiverAttach();
- testPeer.expectLinkFlowRespondWithTransfer(null, msgAnnotations, properties, null, dataContent);
- testPeer.expectDispositionThatIsAcceptedAndSettled();
-
- MessageConsumer messageConsumer = session.createConsumer(queue);
- Message receivedMessage = messageConsumer.receive(1000);
- testPeer.waitForAllHandlersToComplete(3000);
-
- assertNotNull(receivedMessage);
- assertTrue(receivedMessage instanceof ObjectMessage);
-
- testPeer.expectSenderAttach();
- MessageProducer producer = session.createProducer(queue);
-
- MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true).withDurable(equalTo(true));
- MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true);
- msgAnnotationsMatcher.withEntry(Symbol.valueOf(ClientProperties.X_OPT_JMS_MSG_TYPE), equalTo(ClientProperties.OBJECT_MESSSAGE_TYPE));
- MessagePropertiesSectionMatcher propertiesMatcher = new MessagePropertiesSectionMatcher(true);
- propertiesMatcher.withContentType(equalTo(Symbol.valueOf(AmqpObjectMessageSerializedDelegate.CONTENT_TYPE)));
- TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
- messageMatcher.setHeadersMatcher(headersMatcher);
- messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher);
- messageMatcher.setPropertiesMatcher(propertiesMatcher);
- messageMatcher.setMessageContentMatcher(new EncodedDataMatcher(new Binary(bytes)));
-
- testPeer.expectTransfer(messageMatcher);
-
- producer.send(receivedMessage);
-
- testPeer.waitForAllHandlersToComplete(3000);
- }
- }
-
- //==== AMQP type system encoding ====
-
- @Test
- public void testSendBasicObjectMessageWithAmqpTypedContent() throws Exception
- {
- try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
- {
- Connection connection = _testFixture.establishConnecton(testPeer);
- testPeer.expectBegin(true);
- testPeer.expectSenderAttach();
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = session.createQueue("myQueue");
- MessageProducer producer = session.createProducer(queue);
-
- HashMap<String,String> map = new HashMap<String,String>();
- map.put("key", "myObjectString");
-
- MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true).withDurable(equalTo(true));
- MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true);
- msgAnnotationsMatcher.withEntry(Symbol.valueOf(ClientProperties.X_OPT_JMS_MSG_TYPE), equalTo(ClientProperties.OBJECT_MESSSAGE_TYPE));
- MessagePropertiesSectionMatcher propertiesMatcher = new MessagePropertiesSectionMatcher(true);
- //TODO: fix this, shouldn't be true for AMQP typed messages (unless they use a Data section)
- propertiesMatcher.withContentType(equalTo(Symbol.valueOf(AmqpObjectMessageSerializedDelegate.CONTENT_TYPE)));
- TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
- messageMatcher.setHeadersMatcher(headersMatcher);
- messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher);
- messageMatcher.setPropertiesMatcher(propertiesMatcher);
- messageMatcher.setMessageContentMatcher(new EncodedAmqpValueMatcher(map));
-
- testPeer.expectTransfer(messageMatcher);
-
- ObjectMessage message = session.createObjectMessage();
- message.setBooleanProperty(ClientProperties.JMS_AMQP_TYPED_ENCODING, true);
- message.setObject(map);
-
- producer.send(message);
-
- testPeer.waitForAllHandlersToComplete(3000);
- }
- }
-
- @Test
- public void testRecieveBasicObjectMessageWithAmqpTypedContentAndJMSMessageTypeAnnotation() throws Exception
- {
- try(TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);)
- {
- Connection connection = _testFixture.establishConnecton(testPeer);
- connection.start();
-
- testPeer.expectBegin(true);
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = session.createQueue("myQueue");
-
- MessageAnnotationsDescribedType msgAnnotations = new MessageAnnotationsDescribedType();
- msgAnnotations.setSymbolKeyedAnnotation(ClientProperties.X_OPT_JMS_MSG_TYPE, ClientProperties.OBJECT_MESSSAGE_TYPE);
-
- HashMap<String,String> map = new HashMap<String,String>();
- map.put("key", "myObjectString");
-
- DescribedType amqpValueContent = new AmqpValueDescribedType(map);
-
- testPeer.expectReceiverAttach();
- testPeer.expectLinkFlowRespondWithTransfer(null, msgAnnotations, null, null, amqpValueContent);
- testPeer.expectDispositionThatIsAcceptedAndSettled();
-
- MessageConsumer messageConsumer = session.createConsumer(queue);
- Message receivedMessage = messageConsumer.receive(1000);
- testPeer.waitForAllHandlersToComplete(3000);
-
- assertNotNull(receivedMessage);
- assertTrue("Expected ObjectMessage instance, but got: " + receivedMessage.getClass().getName(), receivedMessage instanceof ObjectMessage);
- ObjectMessage objectMessage = (ObjectMessage)receivedMessage;
-
- Object object = objectMessage.getObject();
- assertNotNull("Expected object but got null", object);
- assertEquals("Message body object was not as expected", map, object);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/6f106f64/qpid-jms-client-tmp/src/test/java/org/apache/qpid/jms/QpidJmsTestCase.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client-tmp/src/test/java/org/apache/qpid/jms/QpidJmsTestCase.java b/qpid-jms-client-tmp/src/test/java/org/apache/qpid/jms/QpidJmsTestCase.java
deleted file mode 100644
index fdf7fbc..0000000
--- a/qpid-jms-client-tmp/src/test/java/org/apache/qpid/jms/QpidJmsTestCase.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * 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
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.qpid.jms;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Logger;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-
-public class QpidJmsTestCase
-{
- private final Logger _logger = Logger.getLogger(getClass().getName());
-
- private final Map<String, String> _propertiesSetForTest = new HashMap<String, String>();
-
- @Rule public TestName _testName = new TestName();
-
- /**
- * Set a System property for duration of this test only. The tearDown will
- * guarantee to reset the property to its previous value after the test
- * completes.
- *
- * @param property The property to set
- * @param value the value to set it to, if null, the property will be cleared
- */
- protected void setTestSystemProperty(final String property, final String value)
- {
- if (!_propertiesSetForTest.containsKey(property))
- {
- // Record the current value so we can revert it later.
- _propertiesSetForTest.put(property, System.getProperty(property));
- }
-
- if (value == null)
- {
- System.clearProperty(property);
- _logger.info("Set system property '" + property + "' to be cleared");
- }
- else
- {
- System.setProperty(property, value);
- _logger.info("Set system property '" + property + "' to: '" + value + "'");
- }
-
- }
-
- /**
- * Restore the System property values that were set by this test run.
- */
- protected void revertTestSystemProperties()
- {
- if(!_propertiesSetForTest.isEmpty())
- {
- for (String key : _propertiesSetForTest.keySet())
- {
- String value = _propertiesSetForTest.get(key);
- if (value != null)
- {
- System.setProperty(key, value);
- _logger.info("Reverted system property '" + key + "' to: '" + value + "'");
- }
- else
- {
- System.clearProperty(key);
- _logger.info("Reverted system property '" + key + "' to be cleared");
- }
- }
-
- _propertiesSetForTest.clear();
- }
- }
-
- @After
- public void tearDown() throws java.lang.Exception
- {
- _logger.info("========== tearDown " + getTestName() + " ==========");
- revertTestSystemProperties();
- }
-
- @Before
- public void setUp() throws Exception
- {
- _logger.info("========== start " + getTestName() + " ==========");
- }
-
- protected String getTestName()
- {
- return getClass().getSimpleName() + "." +_testName.getMethodName();
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org