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 2013/11/20 15:34:56 UTC

svn commit: r1543828 [2/3] - in /qpid/jms/trunk/src: main/java/org/apache/qpid/jms/engine/ main/java/org/apache/qpid/jms/impl/ test/java/org/apache/qpid/jms/ test/java/org/apache/qpid/jms/engine/ test/java/org/apache/qpid/jms/impl/ test/java/org/apache...

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/engine/AmqpMessageFactoryTest.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/engine/AmqpMessageFactoryTest.java?rev=1543828&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/engine/AmqpMessageFactoryTest.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/engine/AmqpMessageFactoryTest.java Wed Nov 20 14:34:55 2013
@@ -0,0 +1,279 @@
+/*
+ *
+ * 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.engine;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.qpid.jms.engine.AmqpMessage;
+import org.apache.qpid.jms.engine.AmqpTextMessage;
+import org.apache.qpid.proton.Proton;
+import org.apache.qpid.proton.amqp.Binary;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.messaging.AmqpValue;
+import org.apache.qpid.proton.amqp.messaging.Data;
+import org.apache.qpid.proton.amqp.messaging.MessageAnnotations;
+import org.apache.qpid.proton.engine.Delivery;
+import org.apache.qpid.proton.message.Message;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+public class AmqpMessageFactoryTest
+{
+   private AmqpConnection _mockAmqpConnection;
+   private Delivery _mockDelivery;
+   private AmqpMessageFactory _amqpMessageFactory;
+
+   @Before
+   public void setUp() throws Exception
+   {
+       _mockAmqpConnection = Mockito.mock(AmqpConnection.class);
+       _mockDelivery = Mockito.mock(Delivery.class);
+       _amqpMessageFactory = new AmqpMessageFactory();
+   }
+
+   // =============== No Body =============
+   // =====================================
+
+   /**
+    * Test that a message with no body section, but with the content type set to
+    * {@value AmqpBytesMessage#CONTENT_TYPE} results in a bytes message
+    */
+   @Test
+   public void testCreateAmqpBytesMessageFromNoBodySectionAndContentType() throws Exception
+   {
+       //TODO: this test only required if we decide that not sending a content body is legal
+       Message message = Proton.message();
+       message.setContentType(AmqpBytesMessage.CONTENT_TYPE);
+
+       AmqpMessage amqpMessage = _amqpMessageFactory.createAmqpMessage(_mockDelivery, message, _mockAmqpConnection);
+       assertEquals(AmqpBytesMessage.class, amqpMessage.getClass());
+   }
+
+   /**
+    * Test that a message with no body section, and no content-type
+    * results in a bytes message
+    */
+   @Test
+   public void testCreateAmqpBytesMessageFromNoBodySectionAndNoContentType() throws Exception
+   {
+       //TODO: this test only required if we decide that not sending a content body is legal
+       Message message = Proton.message();
+       assertNull(message.getContentType());
+
+       AmqpMessage amqpMessage = _amqpMessageFactory.createAmqpMessage(_mockDelivery, message, _mockAmqpConnection);
+       assertEquals(AmqpBytesMessage.class, amqpMessage.getClass());
+   }
+
+   /**
+    * Test that a message with no body section, but with the content type set to
+    * {@value AmqpObjectMessage#CONTENT_TYPE} results in a object message
+    */
+   @Test
+   public void testCreateAmqpObjectMessageFromNoBodySectionAndContentType() throws Exception
+   {
+       //TODO: this test only required if we decide that not sending a content body is legal
+       Message message = Proton.message();
+       message.setContentType(AmqpObjectMessage.CONTENT_TYPE);
+
+       AmqpMessage amqpMessage = _amqpMessageFactory.createAmqpMessage(_mockDelivery, message, _mockAmqpConnection);
+       assertEquals(AmqpObjectMessage.class, amqpMessage.getClass());
+   }
+
+   /**
+    * Test that a message with no body section, but with the content type set to
+    * {@value AmqpTextMessage#CONTENT_TYPE} results in a text message
+    */
+   @Test
+   public void testCreateAmqpTextMessageFromNoBodySectionAndContentType() throws Exception
+   {
+       //TODO: this test only required if we decide that not sending a content body is legal
+       Message message = Proton.message();
+       message.setContentType(AmqpTextMessage.CONTENT_TYPE);
+
+       AmqpMessage amqpMessage = _amqpMessageFactory.createAmqpMessage(_mockDelivery, message, _mockAmqpConnection);
+       assertEquals(AmqpTextMessage.class, amqpMessage.getClass());
+   }
+
+   // =============== data ================
+   // =====================================
+
+   /**
+    * Test that a data body containing nothing, but with the content type set to
+    * {@value AmqpBytesMessage#CONTENT_TYPE} results in a bytes message
+    */
+   @Test
+   public void testCreateAmqpBytesMessageFromDataWithEmptyBinaryAndContentType() throws Exception
+   {
+       Message message = Proton.message();
+       Binary binary = new Binary(new byte[0]);
+       message.setBody(new Data(binary));
+       message.setContentType(AmqpBytesMessage.CONTENT_TYPE);
+
+       AmqpMessage amqpMessage = _amqpMessageFactory.createAmqpMessage(_mockDelivery, message, _mockAmqpConnection);
+       assertEquals(AmqpBytesMessage.class, amqpMessage.getClass());
+   }
+
+   /**
+    * Test that a data body containing nothing and with no content type set
+    * results in a text message
+    */
+   @Test
+   public void testCreateAmqpBytesMessageFromDataWithEmptyBinaryAndNoContentType() throws Exception
+   {
+       Message message = Proton.message();
+       Binary binary = new Binary(new byte[0]);
+       message.setBody(new Data(binary));
+       assertNull(message.getContentType());
+
+       AmqpMessage amqpMessage = _amqpMessageFactory.createAmqpMessage(_mockDelivery, message, _mockAmqpConnection);
+       assertEquals(AmqpBytesMessage.class, amqpMessage.getClass());
+   }
+
+   /**
+    * Test that a data body containing nothing, but with the content type set to
+    * {@value AmqpObjectMessage#CONTENT_TYPE} results in a object message
+    */
+   @Test
+   public void testCreateAmqpObjectMessageFromDataWithEmptyBinaryAndContentType() throws Exception
+   {
+       Message message = Proton.message();
+       Binary binary = new Binary(new byte[0]);
+       message.setBody(new Data(binary));
+       message.setContentType(AmqpObjectMessage.CONTENT_TYPE);
+
+       AmqpMessage amqpMessage = _amqpMessageFactory.createAmqpMessage(_mockDelivery, message, _mockAmqpConnection);
+       assertEquals(AmqpObjectMessage.class, amqpMessage.getClass());
+   }
+
+   /**
+    * Test that a data body containing nothing, but with the content type set to
+    * {@value AmqpTextMessage#CONTENT_TYPE} results in a text message
+    */
+   @Test
+   public void testCreateAmqpTextMessageFromDataWithEmptyBinaryAndContentType() throws Exception
+   {
+       Message message = Proton.message();
+       Binary binary = new Binary(new byte[0]);
+       message.setBody(new Data(binary));
+       message.setContentType(AmqpTextMessage.CONTENT_TYPE);
+
+       AmqpMessage amqpMessage = _amqpMessageFactory.createAmqpMessage(_mockDelivery, message, _mockAmqpConnection);
+       assertEquals(AmqpTextMessage.class, amqpMessage.getClass());
+   }
+
+   // ============= amqp-value ============
+   // =====================================
+
+   /**
+    * Test that an amqp-value body containing a string results in a text message
+    */
+   @Test
+   public void testCreateAmqpTextMessageFromAmqpValueWithString() throws Exception
+   {
+       Message message = Proton.message();
+       message.setBody(new AmqpValue("content"));
+       AmqpMessage amqpMessage = _amqpMessageFactory.createAmqpMessage(_mockDelivery, message, _mockAmqpConnection);
+       assertEquals(AmqpTextMessage.class, amqpMessage.getClass());
+   }
+
+   /**
+    * Test that an amqp-value body containing a null, but with the
+    * {@value AmqpTextMessage#MESSAGE_ANNOTATION_TYPE_KEY_NAME} message annotation
+    * set to {@value AmqpTextMessage#MSG_TYPE_ANNOTATION_VALUE} results in a text message
+    */
+   @Test
+   public void testCreateAmqpTextMessageFromAmqpValueWithNullAndMessageTypeAnnotation() throws Exception
+   {
+       Map<Symbol,Object> annotationsMap = new HashMap<Symbol, Object>();
+       annotationsMap.put(Symbol.valueOf(AmqpMessage.MESSAGE_ANNOTATION_TYPE_KEY_NAME),
+               AmqpTextMessage.MSG_TYPE_ANNOTATION_VALUE);
+
+       Message message = Proton.message();
+       message.setBody(new AmqpValue(null));
+       message.setMessageAnnotations(new MessageAnnotations(annotationsMap));
+
+       AmqpMessage amqpMessage = _amqpMessageFactory.createAmqpMessage(_mockDelivery, message, _mockAmqpConnection);
+       assertEquals(AmqpTextMessage.class, amqpMessage.getClass());
+   }
+
+   /**
+    * Test that an amqp-value body containing a null, but WITHOUT the
+    * {@value AmqpTextMessage#MESSAGE_ANNOTATION_TYPE_KEY_NAME} message
+    * annotation set results in a generic message being created (as
+    * we can't assume it is text).
+    */
+   @Test
+   public void testCreateAmqpGenericMessageFromAmqpValueWithNullAndNoDifferentiator() throws Exception
+   {
+       Message message = Proton.message();
+       message.setBody(new AmqpValue(null));
+
+       AmqpMessage amqpMessage = _amqpMessageFactory.createAmqpMessage(_mockDelivery, message, _mockAmqpConnection);
+       assertEquals(AmqpGenericMessage.class, amqpMessage.getClass());
+   }
+
+   /**
+    * Test that an amqp-value body containing a map results in a map message
+    */
+   @Test
+   public void testCreateAmqpMapMessageFromAmqpValueWithMap() throws Exception
+   {
+       Message message = Proton.message();
+       Map<String,String> map = new HashMap<String,String>();
+       message.setBody(new AmqpValue(map));
+       AmqpMessage amqpMessage = _amqpMessageFactory.createAmqpMessage(_mockDelivery, message, _mockAmqpConnection);
+       assertEquals(AmqpMapMessage.class, amqpMessage.getClass());
+   }
+
+   /**
+    * Test that an amqp-value body containing a list results in a list message
+    * (which will be used as the basis of the JMS StreamMessage)
+    */
+   @Test
+   public void testCreateAmqpListMessageFromAmqpValueWithList() throws Exception
+   {
+       Message message = Proton.message();
+       List<String> list = new ArrayList<String>();
+       message.setBody(new AmqpValue(list));
+       AmqpMessage amqpMessage = _amqpMessageFactory.createAmqpMessage(_mockDelivery, message, _mockAmqpConnection);
+       assertEquals(AmqpListMessage.class, amqpMessage.getClass());
+   }
+
+   /**
+    * Test that an amqp-value body containing a binary value results in a bytes message
+    */
+   @Test
+   public void testCreateAmqpBytesMessageFromAmqpValueWithBinary() throws Exception
+   {
+       Message message = Proton.message();
+       Binary binary = new Binary(new byte[0]);
+       message.setBody(new Data(binary));
+       AmqpMessage amqpMessage = _amqpMessageFactory.createAmqpMessage(_mockDelivery, message, _mockAmqpConnection);
+       assertEquals(AmqpBytesMessage.class, amqpMessage.getClass());
+   }
+}
+

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/MessageFactoryImplTest.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/MessageFactoryImplTest.java?rev=1543828&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/MessageFactoryImplTest.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/MessageFactoryImplTest.java Wed Nov 20 14:34:55 2013
@@ -0,0 +1,117 @@
+/*
+ *
+ * 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.impl;
+
+import static org.junit.Assert.*;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+
+import org.apache.qpid.jms.engine.AmqpBytesMessage;
+import org.apache.qpid.jms.engine.AmqpGenericMessage;
+import org.apache.qpid.jms.engine.AmqpListMessage;
+import org.apache.qpid.jms.engine.AmqpMapMessage;
+import org.apache.qpid.jms.engine.AmqpMessage;
+import org.apache.qpid.jms.engine.AmqpObjectMessage;
+import org.apache.qpid.jms.engine.AmqpTextMessage;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+public class MessageFactoryImplTest
+{
+
+    private ConnectionImpl _mockConnection;
+    private SessionImpl _mockSession;
+    private MessageFactoryImpl _messageFactoryImpl;
+
+    @Before
+    public void setUp() throws Exception
+    {
+        _mockConnection = Mockito.mock(ConnectionImpl.class);
+        _mockSession = Mockito.mock(SessionImpl.class);
+        _messageFactoryImpl = new MessageFactoryImpl();
+    }
+
+    @Test
+    public void testCreateJmsMessageWithAmqpGenericMessage() throws Exception
+    {
+        AmqpMessage amqpMessage = Mockito.mock(AmqpGenericMessage.class);
+        Message jmsMessage = _messageFactoryImpl.createJmsMessage(amqpMessage, _mockSession, _mockConnection);
+        assertEquals(GenericAmqpMessageImpl.class, jmsMessage.getClass());
+    }
+
+    @Test
+    public void testCreateJmsMessageWithAmqpTextMessage() throws Exception
+    {
+        AmqpMessage amqpMessage = Mockito.mock(AmqpTextMessage.class);
+        Message jmsMessage = _messageFactoryImpl.createJmsMessage(amqpMessage, _mockSession, _mockConnection);
+        assertEquals(TextMessageImpl.class, jmsMessage.getClass());
+    }
+
+    @Test
+    public void testCreateJmsMessageWithAmqpBytesMessage() throws Exception
+    {
+        AmqpMessage amqpMessage = Mockito.mock(AmqpBytesMessage.class);
+        Message jmsMessage = _messageFactoryImpl.createJmsMessage(amqpMessage, _mockSession, _mockConnection);
+        assertEquals(BytesMessageImpl.class, jmsMessage.getClass());
+    }
+
+    @Test
+    public void testCreateJmsMessageWithAmqpObjectMessage() throws Exception
+    {
+        AmqpMessage amqpMessage = Mockito.mock(AmqpObjectMessage.class);
+        Message jmsMessage = _messageFactoryImpl.createJmsMessage(amqpMessage, _mockSession, _mockConnection);
+        assertEquals(ObjectMessageImpl.class, jmsMessage.getClass());
+    }
+
+    @Test
+    public void testCreateJmsMessageWithAmqpListMessage() throws Exception
+    {
+        AmqpMessage amqpMessage = Mockito.mock(AmqpListMessage.class);
+        Message jmsMessage = _messageFactoryImpl.createJmsMessage(amqpMessage, _mockSession, _mockConnection);
+        assertEquals(StreamMessageImpl.class, jmsMessage.getClass());
+    }
+
+    @Test
+    public void testCreateJmsMessageWithAmqpMapMessage() throws Exception
+    {
+        AmqpMessage amqpMessage = Mockito.mock(AmqpMapMessage.class);
+        Message jmsMessage = _messageFactoryImpl.createJmsMessage(amqpMessage, _mockSession, _mockConnection);
+        assertEquals(MapMessageImpl.class, jmsMessage.getClass());
+    }
+
+    @Test
+    public void testCreateJmsMessageWithUnknownMessageTypeThrowsException() throws Exception
+    {
+        //AmqpMessage is the abstract supertype, factory doesn't expect it, so using a mock of it
+        AmqpMessage amqpMessage = Mockito.mock(AmqpMessage.class);
+        try
+        {
+            _messageFactoryImpl.createJmsMessage(amqpMessage, _mockSession, _mockConnection);
+            fail("expected exception was not thrown");
+        }
+        catch(JMSException jmse)
+        {
+            //expected
+        }
+    }
+}

Modified: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/ReceiverImplTest.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/ReceiverImplTest.java?rev=1543828&r1=1543827&r2=1543828&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/ReceiverImplTest.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/impl/ReceiverImplTest.java Wed Nov 20 14:34:55 2013
@@ -23,21 +23,34 @@ package org.apache.qpid.jms.impl;
 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 javax.jms.Message;
 import javax.jms.Session;
 
 import org.apache.qpid.jms.QpidJmsTestCase;
+import org.apache.qpid.jms.engine.AmqpGenericMessage;
 import org.apache.qpid.jms.engine.AmqpMessage;
 import org.apache.qpid.jms.engine.AmqpReceiver;
+import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
 
 public class ReceiverImplTest extends QpidJmsTestCase
 {
-    private final ConnectionImpl _mockConnection = Mockito.mock(ConnectionImpl.class);
-    private final AmqpReceiver _mockAmqpReceiver = Mockito.mock(AmqpReceiver.class);
-    private final SessionImpl _mockSession = Mockito.mock(SessionImpl.class);
-    private final AmqpMessage _mockAmqpMessage = Mockito.mock(AmqpMessage.class);
+    private ConnectionImpl _mockConnection;
+    private AmqpReceiver _mockAmqpReceiver;
+    private SessionImpl _mockSession;
+    private AmqpMessage _mockAmqpMessage;
+
+    @Before
+    public void setUp() throws Exception
+    {
+        _mockConnection = Mockito.mock(ConnectionImpl.class);
+        _mockAmqpReceiver = Mockito.mock(AmqpReceiver.class);
+        _mockSession = Mockito.mock(SessionImpl.class);
+        _mockAmqpMessage = Mockito.mock(AmqpGenericMessage.class);
+    }
 
     @Test
     public void testNoMessageReceivedWhenConnectionNotStarted() throws Exception
@@ -64,8 +77,9 @@ public class ReceiverImplTest extends Qp
 
         ReceiverImpl receiver = new ReceiverImpl(_mockConnection, _mockSession, _mockAmqpReceiver);
 
-        MessageImpl messageImpl = (MessageImpl) receiver.receive(1);
-        assertNotNull("Should not receive a message when connection is not started", messageImpl);
-        assertEquals("Underlying AmqpMessage should be the one provided", _mockAmqpMessage, messageImpl.getAmqpMessage());
+        Message message = receiver.receive(1);
+        assertNotNull("Should receive a message when connection is started", message);
+        assertTrue("Unexpected message implementation", message instanceof MessageImpl<?>);
+        assertEquals("Underlying AmqpMessage should be the one provided", _mockAmqpMessage, ((MessageImpl<?>)message).getUnderlyingAmqpMessage(false));
     }
 }

Modified: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/AbstractFrameFieldAndPayloadMatchingHandler.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/AbstractFrameFieldAndPayloadMatchingHandler.java?rev=1543828&r1=1543827&r2=1543828&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/AbstractFrameFieldAndPayloadMatchingHandler.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/AbstractFrameFieldAndPayloadMatchingHandler.java Wed Nov 20 14:34:55 2013
@@ -72,8 +72,8 @@ public abstract class AbstractFrameField
     @Override
     protected void verifyFrame(List<Object> described, Binary payload)
     {
-        verifyPayload(payload);
         verifyFields(described);
+        verifyPayload(payload);
     }
 
     protected void verifyFields(List<Object> described)

Modified: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/ListDescribedType.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/ListDescribedType.java?rev=1543828&r1=1543827&r2=1543828&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/ListDescribedType.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/ListDescribedType.java Wed Nov 20 14:34:55 2013
@@ -34,7 +34,23 @@ public abstract class ListDescribedType 
     @Override
     public Object getDescribed()
     {
-        return Arrays.asList(_fields);
+        //Return a List containing only the 'used fields' (i.e up to the highest field used)
+        int numUsedFields = 0;
+        for(int i = 0; i < _fields.length; i++)
+        {
+            if(_fields[i] != null)
+            {
+                numUsedFields = i + 1;
+            }
+        }
+
+        Object[] usedFields = new Object[numUsedFields];
+        for(int j = 0; j < numUsedFields; j++)
+        {
+            usedFields[j] = _fields[j];
+        }
+
+        return Arrays.asList(usedFields);
     }
 
     protected Object[] getFields()

Copied: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/MapDescribedType.java (from r1529205, qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/ListDescribedType.java)
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/MapDescribedType.java?p2=qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/MapDescribedType.java&p1=qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/ListDescribedType.java&r1=1529205&r2=1543828&rev=1543828&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/ListDescribedType.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/MapDescribedType.java Wed Nov 20 14:34:55 2013
@@ -18,26 +18,22 @@
  */
 package org.apache.qpid.jms.test.testpeer;
 
-import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.apache.qpid.proton.amqp.DescribedType;
 
-public abstract class ListDescribedType implements DescribedType
+public abstract class MapDescribedType implements DescribedType
 {
-    private final Object[] _fields;
+    private final Map<Object,Object> _fields;
 
-    public ListDescribedType(int numberOfFields)
+    public MapDescribedType()
     {
-        _fields = new Object[numberOfFields];
+        _fields = new HashMap<Object,Object>();
     }
 
     @Override
-    public Object getDescribed()
-    {
-        return Arrays.asList(_fields);
-    }
-
-    protected Object[] getFields()
+    public Map<Object, Object> getDescribed()
     {
         return _fields;
     }
@@ -45,6 +41,6 @@ public abstract class ListDescribedType 
     @Override
     public String toString()
     {
-        return "ListDescribedType [descriptor=" + getDescriptor() + " fields=" + Arrays.toString(_fields) + "]";
+        return "MapDescribedType [descriptor=" + getDescriptor() + " fields=" + _fields + "]";
     }
 }
\ No newline at end of file

Modified: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java?rev=1543828&r1=1543827&r2=1543828&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java Wed Nov 20 14:34:55 2013
@@ -40,6 +40,9 @@ import org.apache.qpid.jms.test.testpeer
 import org.apache.qpid.jms.test.testpeer.describedtypes.SaslMechanismsFrame;
 import org.apache.qpid.jms.test.testpeer.describedtypes.SaslOutcomeFrame;
 import org.apache.qpid.jms.test.testpeer.describedtypes.TransferFrame;
+import org.apache.qpid.jms.test.testpeer.describedtypes.sections.HeaderDescribedType;
+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.AttachMatcher;
 import org.apache.qpid.jms.test.testpeer.matchers.BeginMatcher;
 import org.apache.qpid.jms.test.testpeer.matchers.CloseMatcher;
@@ -100,7 +103,7 @@ public class TestAmqpPeer implements Aut
     }
 
     /**
-     * Shuts down the test peer, throwing any Exception
+     * Shuts down the test peer, throwing any Throwable
      * that occurred on the peer, or validating that no
      * unused matchers remain.
      */
@@ -119,7 +122,8 @@ public class TestAmqpPeer implements Aut
         }
         finally
         {
-            if(getException() == null)
+            Throwable throwable = getThrowable();
+            if(throwable == null)
             {
                 synchronized(_handlersLock)
                 {
@@ -128,12 +132,13 @@ public class TestAmqpPeer implements Aut
             }
             else
             {
-                throw getException();
+                //AutoClosable can't handle throwing Throwables, so we wrap it.
+                throw new RuntimeException("TestPeer caught throwable during run", throwable);
             }
         }
     }
 
-    public Exception getException()
+    public Throwable getThrowable()
     {
         return _driverRunnable.getException();
     }
@@ -206,19 +211,17 @@ public class TestAmqpPeer implements Aut
         }
     }
 
-    public void waitForAllHandlersToComplete() throws InterruptedException
+    public void waitForAllHandlersToComplete(int timeoutMillis) throws InterruptedException
     {
-        final int timeoutSeconds = 5;
-
         synchronized(_handlersLock)
         {
             _handlersCompletedLatch = new CountDownLatch(_handlers.size());
         }
 
-        boolean countedDownOk = _handlersCompletedLatch.await(timeoutSeconds, TimeUnit.SECONDS);
+        boolean countedDownOk = _handlersCompletedLatch.await(timeoutMillis, TimeUnit.MILLISECONDS);
 
         Assert.assertTrue(
-                "All handlers should have completed within the " + timeoutSeconds + "s timeout", countedDownOk);
+                "All handlers should have completed within the " + timeoutMillis + "ms timeout", countedDownOk);
     }
 
     void sendHeader(byte[] header)
@@ -404,7 +407,10 @@ public class TestAmqpPeer implements Aut
         addHandler(attachMatcher);
     }
 
-    public void expectLinkFlowRespondWithTransfer()
+    public void expectLinkFlowRespondWithTransfer(final HeaderDescribedType headerDescribedType,
+                                                  final MessageAnnotationsDescribedType messageAnnotationsDescribedType,
+                                                  final PropertiesDescribedType propertiesDescribedType,
+                                                  final DescribedType content)
     {
         final FlowMatcher flowMatcher = new FlowMatcher()
                         .withLinkCredit(Matchers.greaterThan(UnsignedInteger.ZERO));
@@ -418,21 +424,26 @@ public class TestAmqpPeer implements Aut
 
         Data payloadData = Proton.data(1024);
 
-        // TODO: create an actual AmqpValue described type?
-        payloadData.putDescribedType(new DescribedType()
+        if(headerDescribedType != null)
         {
-            @Override
-            public Object getDescriptor()
-            {
-                return  Symbol.valueOf("amqp:amqp-value:*");
-            }
+            payloadData.putDescribedType(headerDescribedType);
+        }
+
+        if(messageAnnotationsDescribedType != null)
+        {
+            payloadData.putDescribedType(messageAnnotationsDescribedType);
+        }
+
+        if(propertiesDescribedType != null)
+        {
+            payloadData.putDescribedType(propertiesDescribedType);
+        }
+
+        if(content != null)
+        {
+            payloadData.putDescribedType(content);
+        }
 
-            @Override
-            public Object getDescribed()
-            {
-                return "Hello World";
-            }
-        });
         Binary payload = payloadData.encode();
 
         FrameSender transferResponseSender = new FrameSender(

Modified: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeerRunner.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeerRunner.java?rev=1543828&r1=1543827&r2=1543828&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeerRunner.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeerRunner.java Wed Nov 20 14:34:55 2013
@@ -41,7 +41,7 @@ class TestAmqpPeerRunner implements Runn
     private final Object _inputHandlingLock = new Object();
     private final TestFrameParser _testFrameParser;
 
-    private volatile Exception _exception;
+    private volatile Throwable _throwable;
 
     public TestAmqpPeerRunner(int port, TestAmqpPeer peer) throws IOException
     {
@@ -82,16 +82,16 @@ class TestAmqpPeerRunner implements Runn
 
             _logger.finest("Exited read loop");
         }
-        catch (Exception e)
+        catch (Throwable t)
         {
             if(!_serverSocket.isClosed())
             {
-                _logger.log(Level.SEVERE, "Problem in peer", e);
-                _exception = e;
+                _logger.log(Level.SEVERE, "Problem in peer", t);
+                _throwable = t;
             }
             else
             {
-                _logger.fine("Caught exception, ignoring as socket is closed: " + e);
+                _logger.fine("Caught throwable, ignoring as socket is closed: " + t);
             }
         }
         finally
@@ -145,8 +145,8 @@ class TestAmqpPeerRunner implements Runn
         }
     }
 
-    public Exception getException()
+    public Throwable getException()
     {
-        return _exception;
+        return _throwable;
     }
 }

Copied: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/AmqpValueDescribedType.java (from r1529205, qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/ListDescribedType.java)
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/AmqpValueDescribedType.java?p2=qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/AmqpValueDescribedType.java&p1=qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/ListDescribedType.java&r1=1529205&r2=1543828&rev=1543828&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/ListDescribedType.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/AmqpValueDescribedType.java Wed Nov 20 14:34:55 2013
@@ -1,4 +1,5 @@
 /*
+ *
  * 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
@@ -15,36 +16,33 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
+ *
  */
-package org.apache.qpid.jms.test.testpeer;
-
-import java.util.Arrays;
+package org.apache.qpid.jms.test.testpeer.describedtypes.sections;
 
 import org.apache.qpid.proton.amqp.DescribedType;
+import org.apache.qpid.proton.amqp.Symbol;
 
-public abstract class ListDescribedType implements DescribedType
+public class AmqpValueDescribedType implements DescribedType
 {
-    private final Object[] _fields;
+    private static final Symbol DESCIPTOR_SYMBOL = Symbol.valueOf("amqp:amqp-value:*");
+    private Object _described;
 
-    public ListDescribedType(int numberOfFields)
+    public AmqpValueDescribedType(Object described)
     {
-        _fields = new Object[numberOfFields];
+        _described = described;
     }
 
     @Override
-    public Object getDescribed()
+    public Object getDescriptor()
     {
-        return Arrays.asList(_fields);
-    }
-
-    protected Object[] getFields()
-    {
-        return _fields;
+        return DESCIPTOR_SYMBOL;
     }
 
     @Override
-    public String toString()
+    public Object getDescribed()
     {
-        return "ListDescribedType [descriptor=" + getDescriptor() + " fields=" + Arrays.toString(_fields) + "]";
+        return _described;
     }
-}
\ No newline at end of file
+
+}

Copied: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/DataDescribedType.java (from r1529205, qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/ListDescribedType.java)
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/DataDescribedType.java?p2=qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/DataDescribedType.java&p1=qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/ListDescribedType.java&r1=1529205&r2=1543828&rev=1543828&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/ListDescribedType.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/DataDescribedType.java Wed Nov 20 14:34:55 2013
@@ -1,4 +1,5 @@
 /*
+ *
  * 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
@@ -15,36 +16,34 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
+ *
  */
-package org.apache.qpid.jms.test.testpeer;
-
-import java.util.Arrays;
+package org.apache.qpid.jms.test.testpeer.describedtypes.sections;
 
+import org.apache.qpid.proton.amqp.Binary;
 import org.apache.qpid.proton.amqp.DescribedType;
+import org.apache.qpid.proton.amqp.Symbol;
 
-public abstract class ListDescribedType implements DescribedType
+public class DataDescribedType implements DescribedType
 {
-    private final Object[] _fields;
+    private static final Symbol DESCIPTOR_SYMBOL = Symbol.valueOf("amqp:data:binary");
+    private Binary _described;
 
-    public ListDescribedType(int numberOfFields)
+    public DataDescribedType(Binary described)
     {
-        _fields = new Object[numberOfFields];
+        _described = described;
     }
 
     @Override
-    public Object getDescribed()
+    public Object getDescriptor()
     {
-        return Arrays.asList(_fields);
-    }
-
-    protected Object[] getFields()
-    {
-        return _fields;
+        return DESCIPTOR_SYMBOL;
     }
 
     @Override
-    public String toString()
+    public Object getDescribed()
     {
-        return "ListDescribedType [descriptor=" + getDescriptor() + " fields=" + Arrays.toString(_fields) + "]";
+        return _described;
     }
-}
\ No newline at end of file
+
+}

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/HeaderDescribedType.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/HeaderDescribedType.java?rev=1543828&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/HeaderDescribedType.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/HeaderDescribedType.java Wed Nov 20 14:34:55 2013
@@ -0,0 +1,89 @@
+/*
+ * 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.test.testpeer.describedtypes.sections;
+
+import org.apache.qpid.jms.test.testpeer.ListDescribedType;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+
+/**
+ * Generated by generate-list-sections.xsl, which resides in this package.
+ */
+public class HeaderDescribedType extends ListDescribedType
+{
+    public static final Symbol DESCRIPTOR_SYMBOL = Symbol.valueOf("amqp:header:list");
+    public static final UnsignedLong DESCRIPTOR_CODE = UnsignedLong.valueOf(0x0000000000000070L);
+
+
+    private static final int FIELD_DURABLE = 0;
+    private static final int FIELD_PRIORITY = 1;
+    private static final int FIELD_TTL = 2;
+    private static final int FIELD_FIRST_ACQUIRER = 3;
+    private static final int FIELD_DELIVERY_COUNT = 4;
+
+    public HeaderDescribedType(Object... fields)
+    {
+        super(5);
+        int i = 0;
+        for(Object field : fields)
+        {
+            getFields()[i++] = field;
+        }
+    }
+
+    @Override
+    public Symbol getDescriptor()
+    {
+        return DESCRIPTOR_SYMBOL;
+    }
+
+    public HeaderDescribedType setDurable(Object o)
+    {
+        getFields()[FIELD_DURABLE] = o;
+        return this;
+    }
+
+    public HeaderDescribedType setPriority(Object o)
+    {
+        getFields()[FIELD_PRIORITY] = o;
+        return this;
+    }
+
+    public HeaderDescribedType setTtl(Object o)
+    {
+        getFields()[FIELD_TTL] = o;
+        return this;
+    }
+
+    public HeaderDescribedType setFirstAcquirer(Object o)
+    {
+        getFields()[FIELD_FIRST_ACQUIRER] = o;
+        return this;
+    }
+
+    public HeaderDescribedType setDeliveryCount(Object o)
+    {
+        getFields()[FIELD_DELIVERY_COUNT] = o;
+        return this;
+    }
+
+}
+

Copied: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/MessageAnnotationsDescribedType.java (from r1529205, qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/ListDescribedType.java)
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/MessageAnnotationsDescribedType.java?p2=qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/MessageAnnotationsDescribedType.java&p1=qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/ListDescribedType.java&r1=1529205&r2=1543828&rev=1543828&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/ListDescribedType.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/MessageAnnotationsDescribedType.java Wed Nov 20 14:34:55 2013
@@ -1,4 +1,5 @@
 /*
+ *
  * 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
@@ -15,36 +16,31 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
+ *
  */
-package org.apache.qpid.jms.test.testpeer;
+package org.apache.qpid.jms.test.testpeer.describedtypes.sections;
 
-import java.util.Arrays;
+import org.apache.qpid.jms.test.testpeer.MapDescribedType;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
 
-import org.apache.qpid.proton.amqp.DescribedType;
-
-public abstract class ListDescribedType implements DescribedType
+public class MessageAnnotationsDescribedType extends MapDescribedType
 {
-    private final Object[] _fields;
-
-    public ListDescribedType(int numberOfFields)
-    {
-        _fields = new Object[numberOfFields];
-    }
+    private static final Symbol DESCIPTOR_SYMBOL = Symbol.valueOf("amqp:message-annotations:map");
 
     @Override
-    public Object getDescribed()
+    public Object getDescriptor()
     {
-        return Arrays.asList(_fields);
+        return DESCIPTOR_SYMBOL;
     }
 
-    protected Object[] getFields()
+    public void setSymbolKeyedAnnotation(String name, Object value)
     {
-        return _fields;
+        getDescribed().put(Symbol.valueOf(name), value);
     }
 
-    @Override
-    public String toString()
+    public void setUnsignedLongKeyedAnnotation(UnsignedLong name, Object value)
     {
-        return "ListDescribedType [descriptor=" + getDescriptor() + " fields=" + Arrays.toString(_fields) + "]";
+        throw new UnsupportedOperationException("UnsignedLong keys are currently reserved");
     }
-}
\ No newline at end of file
+}

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/PropertiesDescribedType.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/PropertiesDescribedType.java?rev=1543828&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/PropertiesDescribedType.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/PropertiesDescribedType.java Wed Nov 20 14:34:55 2013
@@ -0,0 +1,145 @@
+/*
+ * 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.test.testpeer.describedtypes.sections;
+
+import org.apache.qpid.jms.test.testpeer.ListDescribedType;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+
+/**
+ * Generated by generate-list-sections.xsl, which resides in this package.
+ */
+public class PropertiesDescribedType extends ListDescribedType
+{
+    public static final Symbol DESCRIPTOR_SYMBOL = Symbol.valueOf("amqp:properties:list");
+    public static final UnsignedLong DESCRIPTOR_CODE = UnsignedLong.valueOf(0x0000000000000073L);
+
+
+    private static final int FIELD_MESSAGE_ID = 0;
+    private static final int FIELD_USER_ID = 1;
+    private static final int FIELD_TO = 2;
+    private static final int FIELD_SUBJECT = 3;
+    private static final int FIELD_REPLY_TO = 4;
+    private static final int FIELD_CORRELATION_ID = 5;
+    private static final int FIELD_CONTENT_TYPE = 6;
+    private static final int FIELD_CONTENT_ENCODING = 7;
+    private static final int FIELD_ABSOLUTE_EXPIRY_TIME = 8;
+    private static final int FIELD_CREATION_TIME = 9;
+    private static final int FIELD_GROUP_ID = 10;
+    private static final int FIELD_GROUP_SEQUENCE = 11;
+    private static final int FIELD_REPLY_TO_GROUP_ID = 12;
+
+    public PropertiesDescribedType(Object... fields)
+    {
+        super(13);
+        int i = 0;
+        for(Object field : fields)
+        {
+            getFields()[i++] = field;
+        }
+    }
+
+    @Override
+    public Symbol getDescriptor()
+    {
+        return DESCRIPTOR_SYMBOL;
+    }
+
+    public PropertiesDescribedType setMessageId(Object o)
+    {
+        getFields()[FIELD_MESSAGE_ID] = o;
+        return this;
+    }
+
+    public PropertiesDescribedType setUserId(Object o)
+    {
+        getFields()[FIELD_USER_ID] = o;
+        return this;
+    }
+
+    public PropertiesDescribedType setTo(Object o)
+    {
+        getFields()[FIELD_TO] = o;
+        return this;
+    }
+
+    public PropertiesDescribedType setSubject(Object o)
+    {
+        getFields()[FIELD_SUBJECT] = o;
+        return this;
+    }
+
+    public PropertiesDescribedType setReplyTo(Object o)
+    {
+        getFields()[FIELD_REPLY_TO] = o;
+        return this;
+    }
+
+    public PropertiesDescribedType setCorrelationId(Object o)
+    {
+        getFields()[FIELD_CORRELATION_ID] = o;
+        return this;
+    }
+
+    public PropertiesDescribedType setContentType(Object o)
+    {
+        getFields()[FIELD_CONTENT_TYPE] = o;
+        return this;
+    }
+
+    public PropertiesDescribedType setContentEncoding(Object o)
+    {
+        getFields()[FIELD_CONTENT_ENCODING] = o;
+        return this;
+    }
+
+    public PropertiesDescribedType setAbsoluteExpiryTime(Object o)
+    {
+        getFields()[FIELD_ABSOLUTE_EXPIRY_TIME] = o;
+        return this;
+    }
+
+    public PropertiesDescribedType setCreationTime(Object o)
+    {
+        getFields()[FIELD_CREATION_TIME] = o;
+        return this;
+    }
+
+    public PropertiesDescribedType setGroupId(Object o)
+    {
+        getFields()[FIELD_GROUP_ID] = o;
+        return this;
+    }
+
+    public PropertiesDescribedType setGroupSequence(Object o)
+    {
+        getFields()[FIELD_GROUP_SEQUENCE] = o;
+        return this;
+    }
+
+    public PropertiesDescribedType setReplyToGroupId(Object o)
+    {
+        getFields()[FIELD_REPLY_TO_GROUP_ID] = o;
+        return this;
+    }
+
+}
+

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/generate-list-sections.xsl
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/generate-list-sections.xsl?rev=1543828&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/generate-list-sections.xsl (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/describedtypes/sections/generate-list-sections.xsl Wed Nov 20 14:34:55 2013
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+                xmlns:exsl="http://exslt.org/common"
+                extension-element-prefixes="exsl">
+
+<!-- Used to generate the Java classes in this package.
+     Changes to these classes should be effected by modifying this stylesheet then re-running it,
+     using a stylesheet processor that understands the exsl directives such as xsltproc -->
+
+<xsl:template match="/">
+    <xsl:variable name="license">/*
+ * 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.
+ *
+ */
+</xsl:variable>
+
+    <xsl:for-each select="descendant-or-self::node()[name()='type']">
+        <xsl:variable name="classname"><xsl:call-template name="dashToCamel"><xsl:with-param name="input" select="@name"/></xsl:call-template>DescribedType</xsl:variable>
+        <xsl:if test="@provides = 'section'">
+            <xsl:if test="@name = 'header' or @name='properties'">
+              <xsl:call-template name="typeClass">
+                  <xsl:with-param name="license" select="$license"/>
+                  <xsl:with-param name="classname" select="$classname"/>
+              </xsl:call-template>
+            </xsl:if>
+        </xsl:if>
+
+    </xsl:for-each>
+</xsl:template>
+
+
+<!-- *************************************************************************************************************** -->
+
+<xsl:template name="typeClass">
+    <xsl:param name="license"/>
+    <xsl:param name="classname"/>
+  <exsl:document href="{$classname}.java" method="text">
+  <xsl:value-of select="$license"/>
+package org.apache.qpid.jms.test.testpeer.describedtypes.sections;
+
+import org.apache.qpid.jms.test.testpeer.ListDescribedType;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+
+/**
+ * Generated by generate-list-sections.xsl, which resides in this package.
+ */
+public class <xsl:value-of select="$classname"/> extends ListDescribedType
+{
+    public static final Symbol DESCRIPTOR_SYMBOL = Symbol.valueOf("<xsl:value-of select="descendant::node()[name()='descriptor']/@name"/>");
+    public static final UnsignedLong DESCRIPTOR_CODE = UnsignedLong.valueOf(<xsl:value-of select="concat(substring(descendant::node()[name()='descriptor']/@code,1,10),substring(descendant::node()[name()='descriptor']/@code,14))"/>L);
+
+<xsl:for-each select="descendant::node()[name()='field']">
+    private static final int FIELD_<xsl:call-template name="toUpperDashToUnderscore"><xsl:with-param name="input" select="@name"/></xsl:call-template> = <xsl:value-of select="count(preceding-sibling::node()[name()='field'])"/>;</xsl:for-each>
+
+    public <xsl:value-of select="$classname"/>(Object... fields)
+    {
+        super(<xsl:value-of select="count(descendant::node()[name()='field'])"/>);
+        int i = 0;
+        for(Object field : fields)
+        {
+            getFields()[i++] = field;
+        }
+    }
+
+    @Override
+    public Symbol getDescriptor()
+    {
+        return DESCRIPTOR_SYMBOL;
+    }
+<xsl:for-each select="descendant::node()[name()='field']">
+    public <xsl:value-of select="$classname"/> set<xsl:call-template name="dashToCamel"><xsl:with-param name="input" select="@name"/></xsl:call-template>(Object o)
+    {
+        getFields()[FIELD_<xsl:call-template name="toUpperDashToUnderscore"><xsl:with-param name="input" select="@name"/></xsl:call-template>] = o;
+        return this;
+    }
+</xsl:for-each>
+}
+
+</exsl:document>
+
+</xsl:template>
+
+<!-- *************************************************************************************************************** -->
+
+<xsl:template name="constructFromLiteral">
+    <xsl:param name="type"/>
+    <xsl:param name="value"/>
+    <xsl:choose>
+        <xsl:when test="$type = 'string'">"<xsl:value-of select="$value"/></xsl:when>
+        <xsl:when test="$type = 'symbol'">Symbol.valueOf("<xsl:value-of select="$value"/>")</xsl:when>
+        <xsl:when test="$type = 'ubyte'">UnsignedByte.valueOf((byte) <xsl:value-of select="$value"/>)</xsl:when>
+        <xsl:when test="$type = 'ushort'">UnsignedShort.valueOf((short) <xsl:value-of select="$value"/>)</xsl:when>
+        <xsl:when test="$type = 'uint'">UnsignedInteger.valueOf(<xsl:value-of select="$value"/>)</xsl:when>
+        <xsl:when test="$type = 'ulong'">UnsignedLong.valueOf(<xsl:value-of select="$value"/>L)</xsl:when>
+        <xsl:when test="$type = 'long'"><xsl:value-of select="$value"/>L</xsl:when>
+        <xsl:when test="$type = 'short'">(short)<xsl:value-of select="$value"/></xsl:when>
+        <xsl:when test="$type = 'short'">(byte)<xsl:value-of select="$value"/></xsl:when>
+        <xsl:otherwise><xsl:value-of select="$value"/></xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+<!-- *************************************************************************************************************** -->
+<xsl:template name="substringAfterLast"><xsl:param name="input"/><xsl:param name="arg"/>
+        <xsl:choose>
+            <xsl:when test="contains($input,$arg)"><xsl:call-template name="substringAfterLast"><xsl:with-param name="input"><xsl:value-of select="substring-after($input,$arg)"/></xsl:with-param><xsl:with-param name="arg"><xsl:value-of select="$arg"/></xsl:with-param></xsl:call-template></xsl:when>
+            <xsl:otherwise><xsl:value-of select="$input"/></xsl:otherwise>
+        </xsl:choose>
+    </xsl:template>
+
+    <xsl:template name="initCap"><xsl:param name="input"/><xsl:value-of select="translate(substring($input,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/><xsl:value-of select="substring($input,2)"/></xsl:template>
+
+    <xsl:template name="initLower"><xsl:param name="input"/><xsl:value-of select="translate(substring($input,1,1),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/><xsl:value-of select="substring($input,2)"/></xsl:template>
+
+    <xsl:template name="toUpper"><xsl:param name="input"/><xsl:value-of select="translate($input,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/></xsl:template>
+
+    <xsl:template name="toUpperDashToUnderscore"><xsl:param name="input"/><xsl:value-of select="translate($input,'abcdefghijklmnopqrstuvwxyz-','ABCDEFGHIJKLMNOPQRSTUVWXYZ_')"/></xsl:template>
+
+    <xsl:template name="dashToCamel">
+        <xsl:param name="input"/>
+        <xsl:choose>
+            <xsl:when test="contains($input,'-')"><xsl:call-template name="initCap"><xsl:with-param name="input" select="substring-before($input,'-')"/></xsl:call-template><xsl:call-template name="dashToCamel"><xsl:with-param name="input" select="substring-after($input,'-')"/></xsl:call-template></xsl:when>
+            <xsl:otherwise><xsl:call-template name="initCap"><xsl:with-param name="input" select="$input"/></xsl:call-template></xsl:otherwise>
+        </xsl:choose>
+    </xsl:template>
+
+    <xsl:template name="dashToLowerCamel">
+        <xsl:param name="input"/>
+        <xsl:call-template name="initLower"><xsl:with-param name="input"><xsl:call-template name="dashToCamel"><xsl:with-param name="input" select="$input"/></xsl:call-template></xsl:with-param></xsl:call-template>
+    </xsl:template>
+</xsl:stylesheet>

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/AbstractMessageSectionMatcher.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/AbstractMessageSectionMatcher.java?rev=1543828&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/AbstractMessageSectionMatcher.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/AbstractMessageSectionMatcher.java Wed Nov 20 14:34:55 2013
@@ -0,0 +1,137 @@
+/*
+ * 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.test.testpeer.matchers.sections;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.util.Map;
+import java.util.logging.Logger;
+
+import org.apache.qpid.proton.Proton;
+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.UnsignedLong;
+import org.apache.qpid.proton.codec.Data;
+import org.hamcrest.Matcher;
+
+public abstract class AbstractMessageSectionMatcher
+{
+    private final Logger _logger = Logger.getLogger(getClass().getName());
+
+    private final UnsignedLong _numericDescriptor;
+    private final Symbol _symbolicDescriptor;
+
+    private final Map<Object, Matcher<?>> _fieldMatchers;
+    private Map<Object, Object> _receivedFields;
+
+    private final boolean _expectTrailingBytes;
+
+    protected AbstractMessageSectionMatcher(UnsignedLong numericDescriptor,
+                                            Symbol symbolicDescriptor,
+                                            Map<Object, Matcher<?>> fieldMatchers,
+                                            boolean expectTrailingBytes)
+    {
+        _numericDescriptor = numericDescriptor;
+        _symbolicDescriptor = symbolicDescriptor;
+        _fieldMatchers = fieldMatchers;
+        _expectTrailingBytes = expectTrailingBytes;
+    }
+
+    protected Map<Object, Matcher<?>> getMatchers()
+    {
+        return _fieldMatchers;
+    }
+
+    protected Map<Object, Object> getReceivedFields()
+    {
+        return _receivedFields;
+    }
+
+    /**
+     * @return the number of bytes consumed from the provided Binary
+     * @throws RuntimeException if the provided Binary does not match expectation in some way
+     */
+    public int verify(Binary receivedBinary) throws RuntimeException
+    {
+        int length = receivedBinary.getLength();
+        Data data = Proton.data(length);
+        long decoded = data.decode(receivedBinary.asByteBuffer());
+        if(decoded > Integer.MAX_VALUE)
+        {
+            throw new IllegalStateException("Decoded more bytes than Binary supports holding");
+        }
+
+        if(decoded < length && !_expectTrailingBytes)
+        {
+            throw new IllegalArgumentException("Expected to consume all bytes, but trailing bytes remain: Got "
+                                        + length + ", consumed "+ decoded);
+        }
+
+        DescribedType decodedDescribedType = data.getDescribedType();
+        verifyReceivedDescribedType(decodedDescribedType);
+
+        //Need to cast to int, but verified earlier that it is < Integer.MAX_VALUE
+        return (int) decoded;
+    }
+
+    private void verifyReceivedDescribedType(DescribedType decodedDescribedType)
+    {
+        Object descriptor = decodedDescribedType.getDescriptor();
+        if(!(_symbolicDescriptor.equals(descriptor) || _numericDescriptor.equals(descriptor)))
+        {
+            throw new IllegalArgumentException("Unexpected section type descriptor. Expected "
+                    + _symbolicDescriptor + " or " + _numericDescriptor + ", but got: " + descriptor);
+        }
+
+        verifyReceivedDescribedObject(decodedDescribedType.getDescribed());
+    }
+
+    /**
+     * sub-classes should implement depending on the expected content of the particular section type.
+     */
+    protected abstract void verifyReceivedDescribedObject(Object describedObject);
+
+    /**
+     * Utility method for use by sub-classes that expect field-based sections, i.e lists or maps.
+     */
+    protected void verifyReceivedFields(Map<Object, Object> valueMap)
+    {
+        _receivedFields = valueMap;
+
+        _logger.fine("About to check the fields of the section."
+                + "\n  Received:" + valueMap
+                + "\n  Expectations: " + _fieldMatchers);
+        for(Map.Entry<Object, Matcher<?>> entry : _fieldMatchers.entrySet())
+        {
+            @SuppressWarnings("unchecked")
+            Matcher<Object> matcher = (Matcher<Object>) entry.getValue();
+            Object field = entry.getKey();
+            assertThat("Field " + field + " value should match", valueMap.get(field), matcher);
+        }
+    }
+
+    /**
+     * Intended to be overridden in most cases that use the above method (but not necessarily all - hence not marked as abstract)
+     */
+    protected Enum<?> getField(int fieldIndex)
+    {
+        throw new UnsupportedOperationException("getFieldName is expected to be overridden by subclass if it is required");
+    }
+}
\ No newline at end of file

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/MessageAnnotationsSectionMatcher.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/MessageAnnotationsSectionMatcher.java?rev=1543828&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/MessageAnnotationsSectionMatcher.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/MessageAnnotationsSectionMatcher.java Wed Nov 20 14:34:55 2013
@@ -0,0 +1,48 @@
+/*
+ * 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.test.testpeer.matchers.sections;
+
+import java.util.HashMap;
+
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.hamcrest.Matcher;
+
+public class MessageAnnotationsSectionMatcher extends MessageMapSectionMatcher
+{
+    public static final Symbol DESCRIPTOR_SYMBOL = Symbol.valueOf("amqp:message-annotations:map");
+    public static final UnsignedLong DESCRIPTOR_CODE = UnsignedLong.valueOf(0x0000000000000072L);
+
+    public MessageAnnotationsSectionMatcher(boolean expectTrailingBytes)
+    {
+        super(DESCRIPTOR_CODE,
+              DESCRIPTOR_SYMBOL,
+              new HashMap<Object, Matcher<?>>(),
+              expectTrailingBytes);
+    }
+
+    @Override
+    public MessageAnnotationsSectionMatcher withEntry(Object key, Matcher<?> m)
+    {
+        return (MessageAnnotationsSectionMatcher) super.withEntry(key, m);
+    }
+}
+

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/MessageHeaderSectionMatcher.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/MessageHeaderSectionMatcher.java?rev=1543828&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/MessageHeaderSectionMatcher.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/MessageHeaderSectionMatcher.java Wed Nov 20 14:34:55 2013
@@ -0,0 +1,118 @@
+/*
+ * 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.test.testpeer.matchers.sections;
+
+import java.util.HashMap;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.jms.test.testpeer.matchers.sections.MessageListSectionMatcher;
+import org.hamcrest.Matcher;
+
+/**
+ * Generated by generate-message-section-matchers.xsl, which resides in this package.
+ */
+public class MessageHeaderSectionMatcher extends MessageListSectionMatcher
+{
+
+    public static final Symbol DESCRIPTOR_SYMBOL = Symbol.valueOf("amqp:header:list");
+    public static final UnsignedLong DESCRIPTOR_CODE = UnsignedLong.valueOf(0x0000000000000070L);
+
+    /** Note that the ordinals of the Field enums match the order specified in the AMQP spec */
+    public enum Field
+    {
+        DURABLE,
+        PRIORITY,
+        TTL,
+        FIRST_ACQUIRER,
+        DELIVERY_COUNT,
+    }
+
+    public MessageHeaderSectionMatcher(boolean expectTrailingBytes)
+    {
+        super(DESCRIPTOR_CODE,
+              DESCRIPTOR_SYMBOL,
+              new HashMap<Object, Matcher<?>>(),
+              expectTrailingBytes);
+    }
+
+
+    public MessageHeaderSectionMatcher withDurable(Matcher<?> m)
+    {
+        getMatchers().put(Field.DURABLE, m);
+        return this;
+    }
+
+    public MessageHeaderSectionMatcher withPriority(Matcher<?> m)
+    {
+        getMatchers().put(Field.PRIORITY, m);
+        return this;
+    }
+
+    public MessageHeaderSectionMatcher withTtl(Matcher<?> m)
+    {
+        getMatchers().put(Field.TTL, m);
+        return this;
+    }
+
+    public MessageHeaderSectionMatcher withFirstAcquirer(Matcher<?> m)
+    {
+        getMatchers().put(Field.FIRST_ACQUIRER, m);
+        return this;
+    }
+
+    public MessageHeaderSectionMatcher withDeliveryCount(Matcher<?> m)
+    {
+        getMatchers().put(Field.DELIVERY_COUNT, m);
+        return this;
+    }
+
+    public Object getReceivedDurable()
+    {
+        return getReceivedFields().get(Field.DURABLE);
+    }
+
+    public Object getReceivedPriority()
+    {
+        return getReceivedFields().get(Field.PRIORITY);
+    }
+
+    public Object getReceivedTtl()
+    {
+        return getReceivedFields().get(Field.TTL);
+    }
+
+    public Object getReceivedFirstAcquirer()
+    {
+        return getReceivedFields().get(Field.FIRST_ACQUIRER);
+    }
+
+    public Object getReceivedDeliveryCount()
+    {
+        return getReceivedFields().get(Field.DELIVERY_COUNT);
+    }
+
+    @Override
+    protected Enum<?> getField(int fieldIndex)
+    {
+        return Field.values()[fieldIndex];
+    }
+}
+

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/MessageListSectionMatcher.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/MessageListSectionMatcher.java?rev=1543828&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/MessageListSectionMatcher.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/MessageListSectionMatcher.java Wed Nov 20 14:34:55 2013
@@ -0,0 +1,58 @@
+/*
+ * 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.test.testpeer.matchers.sections;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.hamcrest.Matcher;
+
+public abstract class MessageListSectionMatcher extends AbstractMessageSectionMatcher
+{
+    public MessageListSectionMatcher(UnsignedLong numericDescriptor,
+                                            Symbol symbolicDescriptor,
+                                            Map<Object, Matcher<?>> fieldMatchers,
+                                            boolean expectTrailingBytes)
+    {
+        super(numericDescriptor, symbolicDescriptor, fieldMatchers, expectTrailingBytes);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    protected void verifyReceivedDescribedObject(Object described)
+    {
+        if(!(described instanceof List))
+        {
+            throw new IllegalArgumentException("Unexpected section contents. Expected List, but got: "
+                                              + (described == null ? "null" : described.getClass()));
+        }
+
+        int fieldNumber = 0;
+        Map<Object, Object> valueMap = new HashMap<Object, Object>();
+        for(Object value : (List<Object>)described)
+        {
+            valueMap.put(getField(fieldNumber++), value);
+        }
+
+        verifyReceivedFields(valueMap);
+    }
+}
\ No newline at end of file

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/MessageMapSectionMatcher.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/MessageMapSectionMatcher.java?rev=1543828&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/MessageMapSectionMatcher.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/MessageMapSectionMatcher.java Wed Nov 20 14:34:55 2013
@@ -0,0 +1,55 @@
+/*
+ * 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.test.testpeer.matchers.sections;
+
+import java.util.Map;
+
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.hamcrest.Matcher;
+
+public abstract class MessageMapSectionMatcher extends AbstractMessageSectionMatcher
+{
+    public MessageMapSectionMatcher(UnsignedLong numericDescriptor,
+                                            Symbol symbolicDescriptor,
+                                            Map<Object, Matcher<?>> fieldMatchers,
+                                            boolean expectTrailingBytes)
+    {
+        super(numericDescriptor, symbolicDescriptor, fieldMatchers, expectTrailingBytes);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    protected void verifyReceivedDescribedObject(Object described)
+    {
+        if(!(described instanceof Map))
+        {
+            throw new IllegalArgumentException("Unexpected section contents. Expected Map, but got: "
+                                              + (described == null ? "null" : described.getClass()));
+        }
+
+        verifyReceivedFields((Map<Object,Object>) described);
+    }
+
+    public MessageMapSectionMatcher withEntry(Object key, Matcher<?> m)
+    {
+        getMatchers().put(key, m);
+        return this;
+    }
+}
\ No newline at end of file

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/MessagePropertiesSectionMatcher.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/MessagePropertiesSectionMatcher.java?rev=1543828&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/MessagePropertiesSectionMatcher.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/MessagePropertiesSectionMatcher.java Wed Nov 20 14:34:55 2013
@@ -0,0 +1,214 @@
+/*
+ * 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.test.testpeer.matchers.sections;
+
+import java.util.HashMap;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.apache.qpid.jms.test.testpeer.matchers.sections.MessageListSectionMatcher;
+import org.hamcrest.Matcher;
+
+/**
+ * Generated by generate-message-section-matchers.xsl, which resides in this package.
+ */
+public class MessagePropertiesSectionMatcher extends MessageListSectionMatcher
+{
+
+    public static final Symbol DESCRIPTOR_SYMBOL = Symbol.valueOf("amqp:properties:list");
+    public static final UnsignedLong DESCRIPTOR_CODE = UnsignedLong.valueOf(0x0000000000000073L);
+
+    /** Note that the ordinals of the Field enums match the order specified in the AMQP spec */
+    public enum Field
+    {
+        MESSAGE_ID,
+        USER_ID,
+        TO,
+        SUBJECT,
+        REPLY_TO,
+        CORRELATION_ID,
+        CONTENT_TYPE,
+        CONTENT_ENCODING,
+        ABSOLUTE_EXPIRY_TIME,
+        CREATION_TIME,
+        GROUP_ID,
+        GROUP_SEQUENCE,
+        REPLY_TO_GROUP_ID,
+    }
+
+    public MessagePropertiesSectionMatcher(boolean expectTrailingBytes)
+    {
+        super(DESCRIPTOR_CODE,
+              DESCRIPTOR_SYMBOL,
+              new HashMap<Object, Matcher<?>>(),
+              expectTrailingBytes);
+    }
+
+
+    public MessagePropertiesSectionMatcher withMessageId(Matcher<?> m)
+    {
+        getMatchers().put(Field.MESSAGE_ID, m);
+        return this;
+    }
+
+    public MessagePropertiesSectionMatcher withUserId(Matcher<?> m)
+    {
+        getMatchers().put(Field.USER_ID, m);
+        return this;
+    }
+
+    public MessagePropertiesSectionMatcher withTo(Matcher<?> m)
+    {
+        getMatchers().put(Field.TO, m);
+        return this;
+    }
+
+    public MessagePropertiesSectionMatcher withSubject(Matcher<?> m)
+    {
+        getMatchers().put(Field.SUBJECT, m);
+        return this;
+    }
+
+    public MessagePropertiesSectionMatcher withReplyTo(Matcher<?> m)
+    {
+        getMatchers().put(Field.REPLY_TO, m);
+        return this;
+    }
+
+    public MessagePropertiesSectionMatcher withCorrelationId(Matcher<?> m)
+    {
+        getMatchers().put(Field.CORRELATION_ID, m);
+        return this;
+    }
+
+    public MessagePropertiesSectionMatcher withContentType(Matcher<?> m)
+    {
+        getMatchers().put(Field.CONTENT_TYPE, m);
+        return this;
+    }
+
+    public MessagePropertiesSectionMatcher withContentEncoding(Matcher<?> m)
+    {
+        getMatchers().put(Field.CONTENT_ENCODING, m);
+        return this;
+    }
+
+    public MessagePropertiesSectionMatcher withAbsoluteExpiryTime(Matcher<?> m)
+    {
+        getMatchers().put(Field.ABSOLUTE_EXPIRY_TIME, m);
+        return this;
+    }
+
+    public MessagePropertiesSectionMatcher withCreationTime(Matcher<?> m)
+    {
+        getMatchers().put(Field.CREATION_TIME, m);
+        return this;
+    }
+
+    public MessagePropertiesSectionMatcher withGroupId(Matcher<?> m)
+    {
+        getMatchers().put(Field.GROUP_ID, m);
+        return this;
+    }
+
+    public MessagePropertiesSectionMatcher withGroupSequence(Matcher<?> m)
+    {
+        getMatchers().put(Field.GROUP_SEQUENCE, m);
+        return this;
+    }
+
+    public MessagePropertiesSectionMatcher withReplyToGroupId(Matcher<?> m)
+    {
+        getMatchers().put(Field.REPLY_TO_GROUP_ID, m);
+        return this;
+    }
+
+    public Object getReceivedMessageId()
+    {
+        return getReceivedFields().get(Field.MESSAGE_ID);
+    }
+
+    public Object getReceivedUserId()
+    {
+        return getReceivedFields().get(Field.USER_ID);
+    }
+
+    public Object getReceivedTo()
+    {
+        return getReceivedFields().get(Field.TO);
+    }
+
+    public Object getReceivedSubject()
+    {
+        return getReceivedFields().get(Field.SUBJECT);
+    }
+
+    public Object getReceivedReplyTo()
+    {
+        return getReceivedFields().get(Field.REPLY_TO);
+    }
+
+    public Object getReceivedCorrelationId()
+    {
+        return getReceivedFields().get(Field.CORRELATION_ID);
+    }
+
+    public Object getReceivedContentType()
+    {
+        return getReceivedFields().get(Field.CONTENT_TYPE);
+    }
+
+    public Object getReceivedContentEncoding()
+    {
+        return getReceivedFields().get(Field.CONTENT_ENCODING);
+    }
+
+    public Object getReceivedAbsoluteExpiryTime()
+    {
+        return getReceivedFields().get(Field.ABSOLUTE_EXPIRY_TIME);
+    }
+
+    public Object getReceivedCreationTime()
+    {
+        return getReceivedFields().get(Field.CREATION_TIME);
+    }
+
+    public Object getReceivedGroupId()
+    {
+        return getReceivedFields().get(Field.GROUP_ID);
+    }
+
+    public Object getReceivedGroupSequence()
+    {
+        return getReceivedFields().get(Field.GROUP_SEQUENCE);
+    }
+
+    public Object getReceivedReplyToGroupId()
+    {
+        return getReceivedFields().get(Field.REPLY_TO_GROUP_ID);
+    }
+
+    @Override
+    protected Enum<?> getField(int fieldIndex)
+    {
+        return Field.values()[fieldIndex];
+    }
+}
+

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/TransferPayloadCompositeMatcher.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/TransferPayloadCompositeMatcher.java?rev=1543828&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/TransferPayloadCompositeMatcher.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/sections/TransferPayloadCompositeMatcher.java Wed Nov 20 14:34:55 2013
@@ -0,0 +1,160 @@
+/*
+ *
+ * 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.test.testpeer.matchers.sections;
+
+
+import org.apache.qpid.proton.amqp.Binary;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.StringDescription;
+import org.hamcrest.TypeSafeMatcher;
+
+/**
+ * Used to verify the Transfer frame payload, i.e the sections of the AMQP message
+ * such as the header, properties, and body sections.
+ */
+public class TransferPayloadCompositeMatcher extends TypeSafeMatcher<Binary>
+{
+    private MessageAnnotationsSectionMatcher _msgAnnotationsMatcher;
+    private String _msgAnnotationsMatcherFailureDescription;
+    private MessagePropertiesSectionMatcher _propsMatcher;
+    private String _propsMatcherFailureDescription;
+    private Matcher<Binary> _msgContentMatcher;
+    private String _msgContentMatcherFailureDescription;
+
+    public TransferPayloadCompositeMatcher()
+    {
+    }
+
+    @Override
+    protected boolean matchesSafely(final Binary receivedBinary)
+    {
+        int origLength = receivedBinary.getLength();
+        int bytesConsumed = 0;
+
+        //MessageAnnotations Section
+        if(_msgAnnotationsMatcher != null)
+        {
+            Binary msgAnnotationsEtcSubBinary = receivedBinary.subBinary(bytesConsumed, origLength - bytesConsumed);
+            try
+            {
+                bytesConsumed += _msgAnnotationsMatcher.verify(msgAnnotationsEtcSubBinary);
+            }
+            catch(Throwable t)
+            {
+                _propsMatcherFailureDescription = "\nActual encoded form of remaining bytes passed to MessageAnnotationsMatcher: " + msgAnnotationsEtcSubBinary;
+                _propsMatcherFailureDescription += "\nMessageAnnotationsMatcher generated throwable: " + t;
+
+                return false;
+            }
+        }
+
+        //Properties Section
+        if(_propsMatcher != null)
+        {
+            Binary propsEtcSubBinary = receivedBinary.subBinary(bytesConsumed, origLength - bytesConsumed);
+            try
+            {
+                bytesConsumed += _propsMatcher.verify(propsEtcSubBinary);
+            }
+            catch(Throwable t)
+            {
+                _propsMatcherFailureDescription = "\nActual encoded form of remaining bytes passed to PropertiesMatcher: " + propsEtcSubBinary;
+                _propsMatcherFailureDescription += "\nPropertiesMatcher generated throwable: " + t;
+
+                return false;
+            }
+        }
+
+        //Message Content Body Section, already a Matcher<Binary>
+        if(_msgContentMatcher != null)
+        {
+            Binary msgContentBodyEtcSubBinary = receivedBinary.subBinary(bytesConsumed, origLength - bytesConsumed);
+            boolean contentMatches = _msgContentMatcher.matches(msgContentBodyEtcSubBinary);
+            if(!contentMatches)
+            {
+                Description desc = new StringDescription();
+                _msgContentMatcher.describeTo(desc);
+                _msgContentMatcher.describeMismatch(msgContentBodyEtcSubBinary, desc);
+
+                _msgContentMatcherFailureDescription = "\nMessageContentMatcher mismatch Description:";
+                _msgContentMatcherFailureDescription += desc.toString();
+
+                return false;
+            }
+        }
+
+        //TODO: we will need figure out a way to determine how many bytes the
+        //MessageContentMatcher did/should consume when it comes time to handle footers
+        return true;
+    }
+
+    @Override
+    public void describeTo(Description description)
+    {
+        description.appendText("a Binary encoding of a Transfer frames payload, containing an AMQP message");
+    }
+
+    @Override
+    protected void describeMismatchSafely(Binary item, Description mismatchDescription)
+    {
+        mismatchDescription.appendText("\nActual encoded form of the full Transfer frame payload: ").appendValue(item);
+
+        //MessageAnnotations Section
+        if(_msgAnnotationsMatcherFailureDescription != null)
+        {
+            mismatchDescription.appendText("\nMessageAnnotationsMatcherFailed!");
+            mismatchDescription.appendText(_msgAnnotationsMatcherFailureDescription);
+            return;
+        }
+
+        //Properties Section
+        if(_propsMatcherFailureDescription != null)
+        {
+            mismatchDescription.appendText("\nPropertiesMatcherFailed!");
+            mismatchDescription.appendText(_propsMatcherFailureDescription);
+            return;
+        }
+
+        //Message Content Body Section
+        if(_msgContentMatcherFailureDescription != null)
+        {
+            mismatchDescription.appendText("\nContentMatcherFailed!");
+            mismatchDescription.appendText(_msgContentMatcherFailureDescription);
+            return;
+        }
+    }
+
+    public void setMessageAnnotationsMatcher(MessageAnnotationsSectionMatcher msgAnnotationsMatcher)
+    {
+        _msgAnnotationsMatcher = msgAnnotationsMatcher;
+    }
+
+    public void setPropertiesMatcher(MessagePropertiesSectionMatcher propsMatcher)
+    {
+        _propsMatcher = propsMatcher;
+    }
+
+    public void setMessageContentMatcher(Matcher<Binary> msgContentMatcher)
+    {
+        _msgContentMatcher = msgContentMatcher;
+    }
+}
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org