You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2017/03/03 23:52:55 UTC

activemq-artemis git commit: fixing tests

Repository: activemq-artemis
Updated Branches:
  refs/heads/artemis-1009 7c6a8d67d -> f53f15ac4


fixing tests


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/f53f15ac
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/f53f15ac
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/f53f15ac

Branch: refs/heads/artemis-1009
Commit: f53f15ac41ec4c8a419525fe00042c8a410a8502
Parents: 7c6a8d6
Author: Clebert Suconic <cl...@apache.org>
Authored: Fri Mar 3 18:52:43 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Fri Mar 3 18:52:43 2017 -0500

----------------------------------------------------------------------
 .../JMSMappingInboundTransformerTest.java       |  72 +--------
 .../JMSMappingOutboundTransformerTest.java      | 158 ++-----------------
 .../message/MessageTransformationTest.java      |  31 +---
 3 files changed, 15 insertions(+), 246 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f53f15ac/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingInboundTransformerTest.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingInboundTransformerTest.java b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingInboundTransformerTest.java
index a0e9fd5..dc358e0 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingInboundTransformerTest.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingInboundTransformerTest.java
@@ -105,25 +105,6 @@ public class JMSMappingInboundTransformerTest {
       assertEquals("Unexpected message class type", ServerJMSBytesMessage.class, jmsMessage.getClass());
    }
 
-   /**
-    * Test that a message with no body section, but with the content type set to
-    * {@value AMQPMessageSupport#SERIALIZED_JAVA_OBJECT_CONTENT_TYPE} results in an
-    * ObjectMessage when not otherwise annotated to indicate the type of JMS message it is.
-    *
-    * @throws Exception
-    *         if an error occurs during the test.
-    */
-   @Test
-   public void testCreateObjectMessageFromNoBodySectionAndContentType() throws Exception {
-      Message message = Message.Factory.create();
-      message.setContentType(AMQPMessageSupport.SERIALIZED_JAVA_OBJECT_CONTENT_TYPE.toString());
-
-      javax.jms.Message jmsMessage = ServerJMSMessage.wrapCoreMessage(new AMQPMessage(message).toCore());
-
-      assertNotNull("Message should not be null", jmsMessage);
-      assertEquals("Unexpected message class type", ServerJMSObjectMessage.class, jmsMessage.getClass());
-   }
-
    @Test
    public void testCreateTextMessageFromNoBodySectionAndContentType() throws Exception {
       Message message = Message.Factory.create();
@@ -135,25 +116,6 @@ public class JMSMappingInboundTransformerTest {
       assertEquals("Unexpected message class type", ServerJMSTextMessage.class, jmsMessage.getClass());
    }
 
-   /**
-    * Test that a message with no body section, and with the content type set to an unknown
-    * value results in a plain Message when not otherwise annotated to indicate the type of JMS
-    * message it is.
-    *
-    * @throws Exception
-    *         if an error occurs during the test.
-    */
-   @Test
-   public void testCreateGenericMessageFromNoBodySectionAndUnknownContentType() throws Exception {
-      Message message = Message.Factory.create();
-      message.setContentType("unknown-content-type");
-
-      javax.jms.Message jmsMessage = ServerJMSMessage.wrapCoreMessage(new AMQPMessage(message).toCore());
-
-      assertNotNull("Message should not be null", jmsMessage);
-      assertEquals("Unexpected message class type", ActiveMQMessage.class, jmsMessage.getClass());
-   }
-
    // ----- Data Body Section ------------------------------------------------//
 
    /**
@@ -421,37 +383,6 @@ public class JMSMappingInboundTransformerTest {
    }
 
    /**
-    * Test that an amqp-value body containing a map that has an AMQP Binary as one of the
-    * entries encoded into the Map results in an MapMessage where a byte array can be read from
-    * the entry.
-    *
-    * @throws Exception
-    *         if an error occurs during the test.
-    */
-   @Test
-   public void testCreateAmqpMapMessageFromAmqpValueWithMapContainingBinaryEntry() throws Exception {
-      final String ENTRY_NAME = "bytesEntry";
-
-      Message message = Proton.message();
-      Map<String, Object> map = new HashMap<>();
-
-      byte[] inputBytes = new byte[] {1, 2, 3, 4, 5};
-      map.put(ENTRY_NAME, new Binary(inputBytes));
-
-      message.setBody(new AmqpValue(map));
-
-      javax.jms.Message jmsMessage = ServerJMSMessage.wrapCoreMessage(new AMQPMessage(message).toCore());
-
-      assertNotNull("Message should not be null", jmsMessage);
-      assertEquals("Unexpected message class type", ServerJMSMapMessage.class, jmsMessage.getClass());
-
-      MapMessage mapMessage = (MapMessage) jmsMessage;
-      byte[] outputBytes = mapMessage.getBytes(ENTRY_NAME);
-      assertNotNull(outputBytes);
-      assertTrue(Arrays.equals(inputBytes, outputBytes));
-   }
-
-   /**
     * Test that an amqp-value body containing a list results in an StreamMessage when not
     * otherwise annotated to indicate the type of JMS message it is.
     *
@@ -533,7 +464,8 @@ public class JMSMappingInboundTransformerTest {
       Message message = Message.Factory.create();
       message.setBody(new AmqpValue(contentString));
 
-      javax.jms.Message jmsMessage = ServerJMSMessage.wrapCoreMessage(new AMQPMessage(message).toCore());
+      ServerJMSTextMessage jmsMessage = (ServerJMSTextMessage)ServerJMSMessage.wrapCoreMessage(new AMQPMessage(message).toCore());
+      jmsMessage.decode();
 
       assertTrue("Expected TextMessage", jmsMessage instanceof TextMessage);
       assertEquals("Unexpected message class type", ServerJMSTextMessage.class, jmsMessage.getClass());

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f53f15ac/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformerTest.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformerTest.java b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformerTest.java
index 1a46749..cd10031 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformerTest.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/JMSMappingOutboundTransformerTest.java
@@ -73,61 +73,6 @@ public class JMSMappingOutboundTransformerTest {
 
    // ----- no-body Message type tests ---------------------------------------//
 
-   @Test
-   public void testConvertMessageToAmqpMessageWithNoBody() throws Exception {
-      ServerJMSMessage outbound = createMessage();
-      outbound.encode();
-
-      Message amqp = AMQPConverter.getInstance().fromCore(outbound.getInnerMessage()).getProtonMessage();
-
-      assertNull(amqp.getBody());
-   }
-
-   @Test
-   public void testConvertTextMessageToAmqpMessageWithNoBodyOriginalEncodingWasNull() throws Exception {
-      ServerJMSTextMessage outbound = createTextMessage();
-      outbound.encode();
-
-      Message amqp = AMQPConverter.getInstance().fromCore(outbound.getInnerMessage()).getProtonMessage();
-
-      assertNull(amqp.getBody());
-   }
-
-   // ----- BytesMessage type tests ---------------------------------------//
-
-   @Test
-   public void testConvertEmptyBytesMessageToAmqpMessageWithDataBody() throws Exception {
-      ServerJMSBytesMessage outbound = createBytesMessage();
-      outbound.encode();
-
-      Message amqp = AMQPConverter.getInstance().fromCore(outbound.getInnerMessage()).getProtonMessage();
-
-      assertNotNull(amqp.getBody());
-      assertTrue(amqp.getBody() instanceof Data);
-      assertTrue(((Data) amqp.getBody()).getValue() instanceof Binary);
-      assertEquals(0, ((Data) amqp.getBody()).getValue().getLength());
-   }
-
-   @Test
-   public void testConvertUncompressedBytesMessageToAmqpMessageWithDataBody() throws Exception {
-      byte[] expectedPayload = new byte[] {8, 16, 24, 32};
-      ServerJMSBytesMessage outbound = createBytesMessage();
-      outbound.writeBytes(expectedPayload);
-      outbound.encode();
-
-      Message amqp = AMQPConverter.getInstance().fromCore(outbound.getInnerMessage()).getProtonMessage();
-
-      assertNotNull(amqp.getBody());
-      assertTrue(amqp.getBody() instanceof Data);
-      assertTrue(((Data) amqp.getBody()).getValue() instanceof Binary);
-      assertEquals(4, ((Data) amqp.getBody()).getValue().getLength());
-
-      Binary amqpData = ((Data) amqp.getBody()).getValue();
-      Binary inputData = new Binary(expectedPayload);
-
-      assertTrue(inputData.equals(amqpData));
-   }
-
    @Ignore("Compressed message body support not yet implemented.")
    @Test
    public void testConvertCompressedBytesMessageToAmqpMessageWithDataBody() throws Exception {
@@ -281,20 +226,6 @@ public class JMSMappingOutboundTransformerTest {
       assertTrue("string".equals(amqpMap.get("property-1")));
    }
 
-   // ----- StreamMessage type tests -----------------------------------------//
-
-   @Test
-   public void testConvertStreamMessageToAmqpMessageWithAmqpValueBody() throws Exception {
-      ServerJMSStreamMessage outbound = createStreamMessage();
-      outbound.encode();
-
-      Message amqp = AMQPConverter.getInstance().fromCore(outbound.getInnerMessage()).getProtonMessage();
-
-      assertNotNull(amqp.getBody());
-      assertTrue(amqp.getBody() instanceof AmqpValue);
-      assertTrue(((AmqpValue) amqp.getBody()).getValue() instanceof List);
-   }
-
    @Test
    public void testConvertStreamMessageToAmqpMessageWithAmqpSequencey() throws Exception {
       ServerJMSStreamMessage outbound = createStreamMessage();
@@ -317,11 +248,12 @@ public class JMSMappingOutboundTransformerTest {
       Message amqp = AMQPConverter.getInstance().fromCore(outbound.getInnerMessage()).getProtonMessage();
 
       assertNotNull(amqp.getBody());
-      assertTrue(amqp.getBody() instanceof AmqpValue);
-      assertTrue(((AmqpValue) amqp.getBody()).getValue() instanceof List);
+      assertTrue(amqp.getBody() instanceof AmqpSequence);
+
+      AmqpSequence list = (AmqpSequence)amqp.getBody();
 
       @SuppressWarnings("unchecked")
-      List<Object> amqpList = (List<Object>) ((AmqpValue) amqp.getBody()).getValue();
+      List<Object> amqpList = list.getValue();
 
       assertEquals(2, amqpList.size());
    }
@@ -370,20 +302,6 @@ public class JMSMappingOutboundTransformerTest {
       assertTrue(amqp.getBody() instanceof Data);
       assertEquals(5, ((Data) amqp.getBody()).getValue().getLength());
    }
-
-   @Test
-   public void testConvertEmptyObjectMessageToAmqpMessageWithAmqpValueBody() throws Exception {
-      ServerJMSObjectMessage outbound = createObjectMessage();
-      outbound.encode();
-
-      Message amqp = AMQPConverter.getInstance().fromCore(outbound.getInnerMessage()).getProtonMessage();
-
-      assertNotNull(amqp.getBody());
-      assertTrue(amqp.getBody() instanceof AmqpValue);
-      assertTrue(((AmqpValue) amqp.getBody()).getValue() instanceof Binary);
-      assertEquals(5, ((Binary) ((AmqpValue) amqp.getBody()).getValue()).getLength());
-   }
-
    @Test
    public void testConvertObjectMessageToAmqpMessageWithDataBody() throws Exception {
       ServerJMSObjectMessage outbound = createObjectMessage(TEST_OBJECT_VALUE);
@@ -417,23 +335,6 @@ public class JMSMappingOutboundTransformerTest {
    }
 
    @Test
-   public void testConvertObjectMessageToAmqpMessageWithAmqpValueBody() throws Exception {
-      ServerJMSObjectMessage outbound = createObjectMessage(TEST_OBJECT_VALUE);
-      outbound.encode();
-
-      Message amqp = AMQPConverter.getInstance().fromCore(outbound.getInnerMessage()).getProtonMessage();
-
-      assertNotNull(amqp.getBody());
-      assertTrue(amqp.getBody() instanceof AmqpValue);
-      assertTrue(((AmqpValue) amqp.getBody()).getValue() instanceof Binary);
-      assertFalse(0 == ((Binary) ((AmqpValue) amqp.getBody()).getValue()).getLength());
-
-      Object value = deserialize(((Binary) ((AmqpValue) amqp.getBody()).getValue()).getArray());
-      assertNotNull(value);
-      assertTrue(value instanceof UUID);
-   }
-
-   @Test
    public void testConvertCompressedObjectMessageToAmqpMessageWithDataBody() throws Exception {
       ServerJMSObjectMessage outbound = createObjectMessage(TEST_OBJECT_VALUE, true);
       outbound.encode();
@@ -473,11 +374,11 @@ public class JMSMappingOutboundTransformerTest {
       Message amqp = AMQPConverter.getInstance().fromCore(outbound.getInnerMessage()).getProtonMessage();
 
       assertNotNull(amqp.getBody());
-      assertTrue(amqp.getBody() instanceof AmqpValue);
-      assertTrue(((AmqpValue) amqp.getBody()).getValue() instanceof Binary);
-      assertFalse(0 == ((Binary) ((AmqpValue) amqp.getBody()).getValue()).getLength());
+      assertTrue(amqp.getBody() instanceof Data);
+      assertTrue(((Data) amqp.getBody()).getValue() instanceof Binary);
+      assertFalse(0 == ((Binary) ((Data) amqp.getBody()).getValue()).getLength());
 
-      Object value = deserialize(((Binary) ((AmqpValue) amqp.getBody()).getValue()).getArray());
+      Object value = deserialize((((Data) amqp.getBody()).getValue()).getArray());
       assertNotNull(value);
       assertTrue(value instanceof UUID);
    }
@@ -497,40 +398,6 @@ public class JMSMappingOutboundTransformerTest {
    }
 
    @Test
-   public void testConvertTextMessageCreatesBodyUsingOriginalEncodingWithDataSection() throws Exception {
-      String contentString = "myTextMessageContent";
-      ServerJMSTextMessage outbound = createTextMessage(contentString);
-      outbound.encode();
-
-      Message amqp = AMQPConverter.getInstance().fromCore(outbound.getInnerMessage()).getProtonMessage();
-
-      assertNotNull(amqp.getBody());
-      assertTrue(amqp.getBody() instanceof Data);
-      assertTrue(((Data) amqp.getBody()).getValue() instanceof Binary);
-
-      Binary data = ((Data) amqp.getBody()).getValue();
-      String contents = new String(data.getArray(), data.getArrayOffset(), data.getLength(), StandardCharsets.UTF_8);
-      assertEquals(contentString, contents);
-   }
-
-   @Test
-   public void testConvertTextMessageContentNotStoredCreatesBodyUsingOriginalEncodingWithDataSection() throws Exception {
-      String contentString = "myTextMessageContent";
-      ServerJMSTextMessage outbound = createTextMessage(contentString);
-      outbound.encode();
-
-      Message amqp = AMQPConverter.getInstance().fromCore(outbound.getInnerMessage()).getProtonMessage();
-
-      assertNotNull(amqp.getBody());
-      assertTrue(amqp.getBody() instanceof Data);
-      assertTrue(((Data) amqp.getBody()).getValue() instanceof Binary);
-
-      Binary data = ((Data) amqp.getBody()).getValue();
-      String contents = new String(data.getArray(), data.getArrayOffset(), data.getLength(), StandardCharsets.UTF_8);
-      assertEquals(contentString, contents);
-   }
-
-   @Test
    public void testConvertTextMessageCreatesAmqpValueStringBody() throws Exception {
       String contentString = "myTextMessageContent";
       ServerJMSTextMessage outbound = createTextMessage(contentString);
@@ -565,12 +432,11 @@ public class JMSMappingOutboundTransformerTest {
       Message amqp = AMQPConverter.getInstance().fromCore(outbound.getInnerMessage()).getProtonMessage();
 
       assertNotNull(amqp.getBody());
-      assertTrue(amqp.getBody() instanceof Data);
-      assertTrue(((Data) amqp.getBody()).getValue() instanceof Binary);
+      assertTrue(amqp.getBody() instanceof AmqpValue);
+
+      AmqpValue value = (AmqpValue)amqp.getBody();
 
-      Binary data = ((Data) amqp.getBody()).getValue();
-      String contents = new String(data.getArray(), data.getArrayOffset(), data.getLength(), StandardCharsets.UTF_8);
-      assertEquals(contentString, contents);
+      assertEquals(contentString, value.getValue());
    }
 
    // ----- Test JMSDestination Handling -------------------------------------//

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f53f15ac/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/MessageTransformationTest.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/MessageTransformationTest.java b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/MessageTransformationTest.java
index 7cba09b..c33436f 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/MessageTransformationTest.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/message/MessageTransformationTest.java
@@ -64,7 +64,6 @@ public class MessageTransformationTest {
       Message outboudMessage = AMQPConverter.getInstance().fromCore(core).getProtonMessage();
 
       assertNull(outboudMessage.getHeader());
-      assertNull(outboudMessage.getProperties());
    }
 
    @Test
@@ -93,27 +92,6 @@ public class MessageTransformationTest {
       ICoreMessage core = new AMQPMessage(incomingMessage).toCore();
       Message outboudMessage = AMQPConverter.getInstance().fromCore(core).getProtonMessage();
 
-      assertNotNull(outboudMessage.getHeader());
-      assertNull(outboudMessage.getProperties());
-   }
-
-   @Test
-   public void testMessageWithAmqpValueThatFailsJMSConversion() throws Exception {
-
-      Message incomingMessage = Proton.message();
-
-      incomingMessage.setBody(new AmqpValue(new Boolean(true)));
-
-      ICoreMessage core = new AMQPMessage(incomingMessage).toCore();
-      Message outboudMessage = AMQPConverter.getInstance().fromCore(core).getProtonMessage();
-
-      Section section = outboudMessage.getBody();
-      assertNotNull(section);
-      assertTrue(section instanceof AmqpValue);
-      AmqpValue amqpValue = (AmqpValue) section;
-      assertNotNull(amqpValue.getValue());
-      assertTrue(amqpValue.getValue() instanceof Boolean);
-      assertEquals(true, amqpValue.getValue());
    }
 
    @Test
@@ -164,14 +142,7 @@ public class MessageTransformationTest {
       ICoreMessage core = new AMQPMessage(message).toCore();
       Message outboudMessage = AMQPConverter.getInstance().fromCore(core).getProtonMessage();
 
-      assertNotNull(outboudMessage.getHeader());
-      assertNotNull(outboudMessage.getProperties());
-      assertNotNull(outboudMessage.getMessageAnnotations());
-      assertNotNull(outboudMessage.getApplicationProperties());
-      assertNull(outboudMessage.getDeliveryAnnotations());
-      assertNull(outboudMessage.getFooter());
-
-      assertEquals(9, outboudMessage.getApplicationProperties().getValue().size());
+      assertEquals(10, outboudMessage.getApplicationProperties().getValue().size());
       assertEquals(4, outboudMessage.getMessageAnnotations().getValue().size());
    }
 }