qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From philharveyonl...@apache.org
Subject svn commit: r1511290 [1/2] - in /qpid/jms/trunk: ./ src/main/java/org/apache/qpid/jms/engine/ src/test/java/org/apache/qpid/jms/ src/test/java/org/apache/qpid/jms/test/ src/test/java/org/apache/qpid/jms/test/testpeer/ src/test/java/org/apache/qpid/jms/...
Date Wed, 07 Aug 2013 12:48:20 GMT
Author: philharveyonline
Date: Wed Aug  7 12:48:19 2013
New Revision: 1511290

URL: http://svn.apache.org/r1511290
Log:
QPIDJMS-3: Added TestAmqpPeer for use in integration tests, and the first cut of ConnectionIntegrationTest.
Also added generated frame and matchers classes (and the xsl
used to generate them for potential future use).

Added:
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/ConnectionIntegrationTest.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/AmqpDataFramer.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/AmqpPeerRunnable.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/Frame.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameHandler.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameMatchingHandler.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameSender.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameType.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameWithNoPayloadMatchingHandler.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/Handler.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/HeaderHandler.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/HeaderHandlerImpl.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeerRunner.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/TestFrameParser.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/AttachFrame.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/BeginFrame.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/CloseFrame.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/DetachFrame.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/DispositionFrame.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/EndFrame.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/FlowFrame.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/OpenFrame.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/SaslChallengeFrame.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/SaslInitFrame.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/SaslMechanismsFrame.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/SaslOutcomeFrame.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/SaslResponseFrame.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/TransferFrame.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/generate-frames.xsl
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/AttachMatcher.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/BeginMatcher.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/CloseMatcher.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/DetachMatcher.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/DispositionMatcher.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/EndMatcher.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/FlowMatcher.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/OpenMatcher.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/SaslChallengeMatcher.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/SaslInitMatcher.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/SaslMechanismsMatcher.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/SaslOutcomeMatcher.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/SaslResponseMatcher.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/TransferMatcher.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/matchers/generate-matchers.xsl
Modified:
    qpid/jms/trunk/pom.xml
    qpid/jms/trunk/src/main/java/org/apache/qpid/jms/engine/AmqpConnection.java
    qpid/jms/trunk/src/test/java/org/apache/qpid/jms/JmsTest.java

Modified: qpid/jms/trunk/pom.xml
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/pom.xml?rev=1511290&r1=1511289&r2=1511290&view=diff
==============================================================================
--- qpid/jms/trunk/pom.xml (original)
+++ qpid/jms/trunk/pom.xml Wed Aug  7 12:48:19 2013
@@ -6,16 +6,17 @@
   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.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <parent>
     <groupId>org.apache</groupId>
     <artifactId>apache</artifactId>
@@ -39,17 +40,17 @@
       <artifactId>proton-api</artifactId>
       <version>${proton-version}</version>
     </dependency>
-    <!-- TODO remove compile-time dependency once proton-c/j agree on what Delivery.isSettled() represents -->
-	<dependency>
+    <!-- TODO once proton-c/j agree on what Delivery.isSettled() represents we can make this a test-scope dependency -->
+    <dependency>
       <groupId>org.apache.qpid</groupId>
       <artifactId>proton-j-impl</artifactId>
       <version>${proton-version}</version>
     </dependency>
     <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>${junit-version}</version>
-      <scope>test</scope>
+      <groupId>org.apache.qpid</groupId>
+      <artifactId>proton-j-impl</artifactId>
+      <version>${proton-version}</version>
+      <type>test-jar</type>
     </dependency>
     <dependency>
       <groupId>org.hamcrest</groupId>
@@ -57,6 +58,12 @@
       <version>1.3</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>${junit-version}</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>
@@ -72,19 +79,34 @@
           <showWarnings>true</showWarnings>
         </configuration>
       </plugin>
-      
+
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
           <systemPropertyVariables>
-            <java.util.logging.config.file>${project.build.testOutputDirectory}/logging.properties</java.util.logging.config.file>
+            <java.util.logging.config.file>${project.build.testOutputDirectory}/logging.properties
+            </java.util.logging.config.file>
           </systemPropertyVariables>
         </configuration>
       </plugin>
     </plugins>
   </build>
 
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>findbugs-maven-plugin</artifactId>
+        <version>2.5.2</version>
+        <configuration>
+          <includeFilterFile>${project.basedir}/src/site/findbugs.xml</includeFilterFile>
+          <threshold>Low</threshold>
+          <effort>Max</effort>
+        </configuration>
+      </plugin>
+    </plugins>
+  </reporting>
 
   <scm>
     <url>http://svn.apache.org/viewvc/qpid/jms/</url>

Modified: qpid/jms/trunk/src/main/java/org/apache/qpid/jms/engine/AmqpConnection.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/main/java/org/apache/qpid/jms/engine/AmqpConnection.java?rev=1511290&r1=1511289&r2=1511290&view=diff
==============================================================================
--- qpid/jms/trunk/src/main/java/org/apache/qpid/jms/engine/AmqpConnection.java (original)
+++ qpid/jms/trunk/src/main/java/org/apache/qpid/jms/engine/AmqpConnection.java Wed Aug  7 12:48:19 2013
@@ -40,11 +40,12 @@ import org.apache.qpid.proton.engine.Sen
 import org.apache.qpid.proton.engine.Session;
 import org.apache.qpid.proton.message.MessageFactory;
 
+// TODO tightly define the thread-safety of this class, e.g. should setSasl etc be synchronized?
 @SuppressWarnings("rawtypes")
 public class AmqpConnection
 {
     /** default timeout in milliseconds */
-    public static final long TIMEOUT = 10000L;
+    public static final long TIMEOUT = 10_000L;
 
     private static Logger _logger = Logger.getLogger("qpid.jms-client.connection");
 

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/ConnectionIntegrationTest.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/ConnectionIntegrationTest.java?rev=1511290&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/ConnectionIntegrationTest.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/ConnectionIntegrationTest.java Wed Aug  7 12:48:19 2013
@@ -0,0 +1,51 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.jms;
+
+import static org.junit.Assert.assertNull;
+
+import org.apache.qpid.jms.impl.ConnectionImpl;
+import org.apache.qpid.jms.test.testpeer.TestAmqpPeer;
+import org.junit.Test;
+
+// TODO find a way to make the test abort immediately if the TestAmqpPeer throws an exception
+// TODO add tests such as testBrokerDoesNotRespond and testBrokerSendsWrongFrame
+public class ConnectionIntegrationTest
+{
+    private static final int PORT = 25672;
+
+    @Test
+    public void testCreateConnection() throws Exception
+    {
+        try(TestAmqpPeer testPeer = new TestAmqpPeer(PORT);)
+        {
+            testPeer.expectPlainConnect("guest", "guest", true);
+            testPeer.expectClose();
+
+            ConnectionImpl connection =  new ConnectionImpl("clientName", "localhost", PORT, "guest", "guest");
+            connection.connect();
+
+            assertNull(testPeer.getException());
+
+            connection.close();
+        }
+    }
+}

Modified: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/JmsTest.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/JmsTest.java?rev=1511290&r1=1511289&r2=1511290&view=diff
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/JmsTest.java (original)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/JmsTest.java Wed Aug  7 12:48:19 2013
@@ -32,6 +32,7 @@ import org.apache.qpid.proton.ProtonFact
 import org.apache.qpid.proton.amqp.messaging.AmqpValue;
 import org.apache.qpid.proton.message.Message;
 import org.apache.qpid.proton.message.MessageFactory;
+import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -49,6 +50,7 @@ public class JmsTest
     private final MessageFactory _messageFactory = new ProtonFactoryLoader<MessageFactory>(MessageFactory.class).loadFactory();
 
     @Test
+    @Ignore("PHTODO reinstate me")
     public void test() throws Exception
     {
         try

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/AmqpDataFramer.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/AmqpDataFramer.java?rev=1511290&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/AmqpDataFramer.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/AmqpDataFramer.java Wed Aug  7 12:48:19 2013
@@ -0,0 +1,61 @@
+/*
+ * 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;
+
+import java.nio.ByteBuffer;
+
+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.codec.Data;
+
+/**
+ * Generates frames as per section 2.3.1 of the AMQP spec
+ */
+public class AmqpDataFramer
+{
+    private static final int CAPACITY = 1024;
+    private static final byte FRAME_PREAMBLE_SIZE_IN_FOUR_BYTE_WORDS = 2;
+
+    public static byte[] encodeFrame(FrameType type, int channel, DescribedType describedType, Binary payload)
+    {
+        ByteBuffer buffer = ByteBuffer.allocate(CAPACITY);  //TODO: set a proper size
+
+        buffer.position(8); // leave hole for frame header
+
+        Data frameBody = Proton.data(CAPACITY);
+        frameBody.putDescribedType(describedType);
+        frameBody.encode(buffer);
+        //TODO: cope with payload
+
+        int frameSize = buffer.position();
+        buffer.rewind();
+        buffer.putInt(frameSize);
+        buffer.put(FRAME_PREAMBLE_SIZE_IN_FOUR_BYTE_WORDS);
+        buffer.put((byte)type.ordinal());
+        buffer.putShort((short)channel);
+
+        byte[] target = new byte[frameSize];
+
+        buffer.rewind();
+        buffer.get(target, 0, frameSize);
+        return target;
+    }
+}

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/AmqpPeerRunnable.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/AmqpPeerRunnable.java?rev=1511290&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/AmqpPeerRunnable.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/AmqpPeerRunnable.java Wed Aug  7 12:48:19 2013
@@ -0,0 +1,25 @@
+/*
+ *
+ * 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;
+
+public interface AmqpPeerRunnable extends Runnable
+{
+}

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/Frame.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/Frame.java?rev=1511290&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/Frame.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/Frame.java Wed Aug  7 12:48:19 2013
@@ -0,0 +1,46 @@
+/*
+ * 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;
+
+import java.util.Arrays;
+
+import org.apache.qpid.proton.amqp.DescribedType;
+import org.apache.qpid.proton.amqp.Symbol;
+
+// TODO rename to performative
+public abstract class Frame implements DescribedType
+{
+    private final Object[] _fields;
+
+    public Frame(int numberOfFields)
+    {
+        _fields = new Object[numberOfFields];
+    }
+
+    @Override
+    public Object getDescribed()
+    {
+        return Arrays.asList(_fields);
+    }
+
+    protected Object[] getFields()
+    {
+        return _fields;
+    }
+}
\ No newline at end of file

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameHandler.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameHandler.java?rev=1511290&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameHandler.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameHandler.java Wed Aug  7 12:48:19 2013
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+import org.apache.qpid.proton.amqp.Binary;
+import org.apache.qpid.proton.amqp.DescribedType;
+
+interface FrameHandler extends Handler
+{
+    void frame(int type, int channel, DescribedType describedType, Binary payload, TestAmqpPeer peer);
+}
\ No newline at end of file

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameMatchingHandler.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameMatchingHandler.java?rev=1511290&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameMatchingHandler.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameMatchingHandler.java Wed Aug  7 12:48:19 2013
@@ -0,0 +1,96 @@
+/*
+ * 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;
+
+import java.util.List;
+
+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;
+
+abstract class FrameMatchingHandler implements FrameHandler
+{
+    public static int ANY_CHANNEL = -1;
+
+    private final UnsignedLong _numericDescriptor;
+    private final Symbol _symbolicDescriptor;
+    private final FrameType _frameType;
+    private int _channel;
+    private Runnable _onSuccessAction;
+
+    protected FrameMatchingHandler(FrameType frameType,
+                                   int channel,
+                                   UnsignedLong numericDescriptor,
+                                   Symbol symbolicDescriptor, Runnable onSuccessAction)
+    {
+        _frameType = frameType;
+        _numericDescriptor = numericDescriptor;
+        _symbolicDescriptor = symbolicDescriptor;
+        _channel = channel;
+        _onSuccessAction = onSuccessAction;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public void frame(int type, int ch, DescribedType dt, Binary payload, TestAmqpPeer peer)
+    {
+        if(type == _frameType.ordinal()
+           && (_channel == -1 || _channel == ch)
+           && (_numericDescriptor.equals(dt.getDescriptor()) || _symbolicDescriptor.equals(dt.getDescriptor()))
+           && (dt.getDescribed() instanceof List))
+        {
+            frame((List<Object>)dt.getDescribed(),payload);
+        }
+        else
+        {
+            throw new IllegalArgumentException(String.format(
+                    "Frame was not as expected. Expected: " +
+                    "type=%s, channel=%s, descriptor=%s/%s but got: " +
+                    "type=%s, channel=%s, descriptor=%s",
+                    _frameType.ordinal(), _channel, _symbolicDescriptor, _numericDescriptor,
+                    type, ch, dt.getDescriptor()));
+        }
+    }
+
+    protected void succeeded()
+    {
+        _onSuccessAction.run();
+    }
+
+    public Runnable getOnSuccessAction()
+    {
+        return _onSuccessAction;
+    }
+
+    public FrameMatchingHandler onSuccess(Runnable onSuccessAction)
+    {
+        _onSuccessAction = onSuccessAction;
+        return this;
+    }
+
+
+    public FrameMatchingHandler onChannel(int channel)
+    {
+        _channel = channel;
+        return this;
+    }
+
+    protected abstract void frame(List<Object> described, Binary payload);
+}
\ No newline at end of file

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameSender.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameSender.java?rev=1511290&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameSender.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameSender.java Wed Aug  7 12:48:19 2013
@@ -0,0 +1,45 @@
+/*
+ * 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;
+
+import org.apache.qpid.proton.amqp.Binary;
+
+class FrameSender implements AmqpPeerRunnable
+{
+    private final TestAmqpPeer _testAmqpPeer;
+    private final FrameType _type;
+    private final int _channel;
+    private final Frame _frame;
+    private final Binary _payload;
+
+    FrameSender(TestAmqpPeer testAmqpPeer, FrameType type, int channel, Frame frame, Binary payload)
+    {
+        _testAmqpPeer = testAmqpPeer;
+        _type = type;
+        _channel = channel;
+        _frame = frame;
+        _payload = payload;
+    }
+
+    @Override
+    public void run()
+    {
+        _testAmqpPeer.sendFrame(_type, _channel, _frame, _payload);
+    }
+}
\ No newline at end of file

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameType.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameType.java?rev=1511290&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameType.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameType.java Wed Aug  7 12:48:19 2013
@@ -0,0 +1,22 @@
+/*
+ * 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;
+
+/** The frame type used in frame headers. The ordinal numbers are used to get the numeric value */
+public enum FrameType { AMQP, SASL }
\ No newline at end of file

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameWithNoPayloadMatchingHandler.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameWithNoPayloadMatchingHandler.java?rev=1511290&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameWithNoPayloadMatchingHandler.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/FrameWithNoPayloadMatchingHandler.java Wed Aug  7 12:48:19 2013
@@ -0,0 +1,91 @@
+/*
+ * 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;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.qpid.proton.amqp.Binary;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedLong;
+import org.hamcrest.Matcher;
+
+public class FrameWithNoPayloadMatchingHandler extends FrameMatchingHandler
+{
+    private final Map<Integer, Matcher<?>> _matchers;
+    private boolean _isComplete;
+
+    protected FrameWithNoPayloadMatchingHandler(FrameType frameType,
+                                                int channel,
+                                                UnsignedLong numericDescriptor,
+                                                Symbol symbolicDescriptor,
+                                                Map<Integer, Matcher<?>> matchers,
+                                                Runnable onSuccess)
+    {
+        super(frameType, channel, numericDescriptor, symbolicDescriptor, onSuccess);
+        _matchers = matchers;
+    }
+
+    @Override
+    protected void frame(List<Object> described, Binary payload)
+    {
+        if(payload == null || payload.getLength() == 0)
+        {
+            int i = 0;
+            HashMap<Integer, Object> valueMap = new HashMap<>();
+            for(Object value : described)
+            {
+                valueMap.put(i++, value);
+            }
+            frame(valueMap);
+        }
+        else
+        {
+            throw new IllegalArgumentException("Expected no payload but received payload of length: " + payload.getLength());
+        }
+    }
+
+    protected void frame(Map<Integer, Object> valueMap)
+    {
+        for(Map.Entry<Integer, Matcher<?>> entry : _matchers.entrySet())
+        {
+            @SuppressWarnings("unchecked")
+            Matcher<Object> matcher = (Matcher<Object>) entry.getValue();
+            Integer field = entry.getKey();
+
+            assertThat("Field value should match", valueMap.get(field), matcher);
+        }
+        succeeded();
+        _isComplete = true;
+    }
+
+    @Override
+    public boolean isComplete()
+    {
+        return _isComplete;
+    }
+
+    protected Map<Integer, Matcher<?>> getMatchers()
+    {
+        return _matchers;
+    }
+}
\ No newline at end of file

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/Handler.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/Handler.java?rev=1511290&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/Handler.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/Handler.java Wed Aug  7 12:48:19 2013
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+/**
+ * Handles incoming AMQP data, usually asserting that it matches expectations
+ * and potentially generating a response.
+ */
+interface Handler
+{
+    boolean isComplete();
+}
\ No newline at end of file

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/HeaderHandler.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/HeaderHandler.java?rev=1511290&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/HeaderHandler.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/HeaderHandler.java Wed Aug  7 12:48:19 2013
@@ -0,0 +1,24 @@
+/*
+ * 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;
+
+interface HeaderHandler extends Handler
+{
+    void header(byte[] header, TestAmqpPeer peer);
+}
\ No newline at end of file

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/HeaderHandlerImpl.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/HeaderHandlerImpl.java?rev=1511290&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/HeaderHandlerImpl.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/HeaderHandlerImpl.java Wed Aug  7 12:48:19 2013
@@ -0,0 +1,60 @@
+/*
+ * 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;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+
+class HeaderHandlerImpl implements HeaderHandler
+{
+    private final byte[] _expectedHeader;
+    private final byte[] _response;
+    private final Runnable _onSuccess;
+    private boolean _isComplete;
+
+    HeaderHandlerImpl(byte[] expectedHeader, byte[] response)
+    {
+       this(expectedHeader, response, null);
+    }
+
+    public HeaderHandlerImpl(byte[] header, byte[] response, Runnable onSuccess)
+    {
+        _expectedHeader = header;
+        _response = response;
+        _onSuccess = onSuccess;
+    }
+
+    @Override
+    public boolean isComplete()
+    {
+        return _isComplete;
+    }
+
+    @Override
+    public void header(byte[] header, TestAmqpPeer peer)
+    {
+        assertThat("Header should match", header, equalTo(_expectedHeader));
+        peer.sendHeader(_response);
+        if(_onSuccess !=null)
+        {
+            _onSuccess.run();
+        }
+        _isComplete = true;
+    }
+}
\ No newline at end of file

Added: 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=1511290&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java Wed Aug  7 12:48:19 2013
@@ -0,0 +1,178 @@
+/*
+ * 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;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.notNullValue;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.qpid.jms.test.testpeer.frames.CloseFrame;
+import org.apache.qpid.jms.test.testpeer.frames.OpenFrame;
+import org.apache.qpid.jms.test.testpeer.frames.SaslMechanismsFrame;
+import org.apache.qpid.jms.test.testpeer.frames.SaslOutcomeFrame;
+import org.apache.qpid.jms.test.testpeer.matchers.CloseMatcher;
+import org.apache.qpid.jms.test.testpeer.matchers.OpenMatcher;
+import org.apache.qpid.jms.test.testpeer.matchers.SaslInitMatcher;
+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.UnsignedByte;
+import org.apache.qpid.proton.engine.impl.AmqpHeader;
+import org.hamcrest.Matchers;
+
+
+public class TestAmqpPeer implements AutoCloseable
+{
+    private final TestAmqpPeerRunner _driverRunnable;
+    private final Thread _driverThread;
+    private final List<Handler> _handlers = new ArrayList<>();
+
+    public TestAmqpPeer(int port) throws IOException
+    {
+        _driverRunnable = new TestAmqpPeerRunner(port, this);
+        _driverThread = new Thread(_driverRunnable, "MockAmqpPeerThread");
+        _driverThread.start();
+    }
+
+    @Override
+    public void close() throws IOException
+    {
+        _driverRunnable.stop();
+
+        try
+        {
+            _driverThread.join(30000);
+        }
+        catch (InterruptedException e)
+        {
+            Thread.currentThread().interrupt();
+        }
+    }
+
+    public Exception getException()
+    {
+        return _driverRunnable.getException();
+    }
+
+    public void receiveHeader(byte[] header)
+    {
+        Handler handler = getFirstHandler();
+        if(handler instanceof HeaderHandler)
+        {
+            ((HeaderHandler)handler).header(header,this);
+            if(handler.isComplete())
+            {
+                _handlers.remove(0);
+            }
+        }
+        else
+        {
+            throw new IllegalStateException("Received header but the next handler is a " + handler);
+        }
+    }
+
+    public void receiveFrame(int type, int channel, DescribedType describedType, Binary payload)
+    {
+        Handler handler = getFirstHandler();
+        if(handler instanceof FrameHandler)
+        {
+            ((FrameHandler)handler).frame(type, channel, describedType, payload, this);
+            if(handler.isComplete())
+            {
+                _handlers.remove(0);
+            }
+        }
+        else
+        {
+            throw new IllegalStateException("Received frame but the next handler is a " + handler);
+        }
+    }
+
+    private Handler getFirstHandler()
+    {
+        if(_handlers.isEmpty())
+        {
+            throw new IllegalStateException("No handlers");
+        }
+        return _handlers.get(0);
+    }
+
+    void sendHeader(byte[] header)
+    {
+        _driverRunnable.sendBytes(header);
+    }
+
+    public void sendFrame(FrameType type, int channel, DescribedType describedType, Binary payload)
+    {
+        byte[] output = AmqpDataFramer.encodeFrame(type, channel, describedType, payload);
+        _driverRunnable.sendBytes(output);
+    }
+
+    public void expectPlainConnect(String username, String password, boolean authorize)
+    {
+        SaslMechanismsFrame saslMechanismsFrame = new SaslMechanismsFrame().setSaslServerMechanisms(Symbol.valueOf("PLAIN"));
+        _handlers.add(new HeaderHandlerImpl(AmqpHeader.SASL_HEADER, AmqpHeader.SASL_HEADER,
+                                            new FrameSender(
+                                                    this, FrameType.SASL, 0,
+                                                    saslMechanismsFrame, null)));
+
+        byte[] usernameBytes = username.getBytes();
+        byte[] passwordBytes = password.getBytes();
+        byte[] data = new byte[usernameBytes.length+passwordBytes.length+2];
+        System.arraycopy(usernameBytes, 0, data, 1, usernameBytes.length);
+        System.arraycopy(passwordBytes, 0, data, 2 + usernameBytes.length, passwordBytes.length);
+
+        _handlers.add(new SaslInitMatcher()
+            .withMechanism(equalTo(Symbol.valueOf("PLAIN")))
+            .withInitialResponse(equalTo(new Binary(data)))
+            .onSuccess(new AmqpPeerRunnable()
+            {
+                @Override
+                public void run()
+                {
+                    TestAmqpPeer.this.sendFrame(
+                            FrameType.SASL, 0,
+                            new SaslOutcomeFrame().setCode(UnsignedByte.valueOf((byte)0)),
+                            null);
+                    _driverRunnable.expectHeader();
+                }
+            }));
+
+        _handlers.add(new HeaderHandlerImpl(AmqpHeader.HEADER, AmqpHeader.HEADER));
+
+        _handlers.add(new OpenMatcher()
+            .withContainerId(notNullValue(String.class))
+            .onSuccess(new FrameSender(
+                    this, FrameType.AMQP, 0,
+                    new OpenFrame().setContainerId("test-amqp-peer-container-id"),
+                    null)));
+    }
+
+    public void expectClose()
+    {
+        _handlers.add(new CloseMatcher()
+            .withError(Matchers.nullValue())
+            .onSuccess(new FrameSender(this, FrameType.AMQP, 0,
+                    new CloseFrame(),
+                    null)));
+    }
+}

Added: 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=1511290&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeerRunner.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeerRunner.java Wed Aug  7 12:48:19 2013
@@ -0,0 +1,130 @@
+/*
+ * 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;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.nio.ByteBuffer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.apache.qpid.proton.amqp.Binary;
+
+class TestAmqpPeerRunner implements Runnable
+{
+    private static final Logger _logger = Logger.getLogger(TestAmqpPeerRunner.class.getName());
+
+    private final ServerSocket _serverSocket;
+
+    /** TODO handle multiple connections */
+    private Socket _clientSocket;
+    private OutputStream _networkOutputStream;
+
+    private final TestFrameParser _testFrameParser;
+
+    private volatile Exception _exception;
+
+    public TestAmqpPeerRunner(int port, TestAmqpPeer peer) throws IOException
+    {
+        _serverSocket = new ServerSocket(port);
+        _testFrameParser = new TestFrameParser(peer);
+    }
+
+    @Override
+    public void run()
+    {
+        try
+        (
+            Socket clientSocket = _serverSocket.accept();
+            InputStream networkInputStream = clientSocket.getInputStream();
+            OutputStream networkOutputStream = clientSocket.getOutputStream();
+        )
+        {
+            _clientSocket = clientSocket;
+            _networkOutputStream = networkOutputStream;
+
+            int bytesRead;
+            byte[] networkInputBytes = new byte[1024];
+            while((bytesRead = networkInputStream.read(networkInputBytes)) != -1)
+            {
+                ByteBuffer networkInputByteBuffer = ByteBuffer.wrap(networkInputBytes, 0, bytesRead);
+
+                _logger.info("Read: " + new Binary(networkInputBytes, 0, bytesRead));
+
+                _testFrameParser.input(networkInputByteBuffer);
+            }
+        }
+        catch (Exception e)
+        {
+            _logger.log(Level.SEVERE, "Problem in peer", e);
+            e.printStackTrace(); // TODO make this a logger call
+            _exception = e;
+        }
+        finally
+        {
+            try
+            {
+                _serverSocket.close();
+            }
+            catch (IOException e)
+            {
+                _logger.log(Level.SEVERE, "Unable to close server socket", e);
+            }
+        }
+    }
+
+    public void stop() throws IOException
+    {
+        try
+        {
+            _serverSocket.close();
+        }
+        finally
+        {
+            _clientSocket.close();
+        }
+    }
+
+    public void expectHeader()
+    {
+        _testFrameParser.expectHeader();
+    }
+
+    public void sendBytes(byte[] bytes)
+    {
+        //TODO remove
+        _logger.info("Sending: " + new Binary(bytes));
+        try
+        {
+            _networkOutputStream.write(bytes);
+            _networkOutputStream.flush();
+        }
+        catch (IOException e)
+        {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public Exception getException()
+    {
+        return _exception;
+    }
+}

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/TestFrameParser.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/TestFrameParser.java?rev=1511290&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/TestFrameParser.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/TestFrameParser.java Wed Aug  7 12:48:19 2013
@@ -0,0 +1,383 @@
+/*
+ * 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;
+
+import static org.apache.qpid.proton.engine.TransportResultFactory.error;
+
+import java.nio.ByteBuffer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.qpid.proton.ProtonFactoryLoader;
+import org.apache.qpid.proton.amqp.Binary;
+import org.apache.qpid.proton.amqp.DescribedType;
+import org.apache.qpid.proton.codec.Data;
+import org.apache.qpid.proton.codec.DataFactory;
+import org.apache.qpid.proton.codec.DecodeException;
+import org.apache.qpid.proton.engine.TransportResult;
+import org.apache.qpid.proton.engine.TransportResultFactory;
+
+class TestFrameParser
+{
+    // PHTODO replace logger
+    private static final Logger TRACE_LOGGER = Logger.getLogger("proton.trace");
+
+    private enum State
+    {
+        HEADER0,
+        HEADER1,
+        HEADER2,
+        HEADER3,
+        HEADER4,
+        HEADER5,
+        HEADER6,
+        HEADER7,
+        SIZE_0,
+        SIZE_1,
+        SIZE_2,
+        SIZE_3,
+        PRE_PARSE,
+        BUFFERING,
+        PARSING,
+        ERROR
+    }
+
+
+    private State _state = State.HEADER0;
+
+    /** the stated size of the current frame */
+    private int _size;
+
+    /** holds the current frame that is being parsed */
+    private ByteBuffer _frameBuffer;
+
+    private final DataFactory _dataFactory = new ProtonFactoryLoader<DataFactory>(DataFactory.class).loadFactory();
+
+    private TestAmqpPeer _peer;
+
+    /** PHTOD remove args? */
+    public TestFrameParser(TestAmqpPeer peer)
+    {
+        _peer = peer;
+    }
+
+    public void expectHeader()
+    {
+        _state = State.HEADER0;
+    }
+
+    public void input(final ByteBuffer input)
+    {
+        TransportResult frameParsingError = null;
+        int size = _size;
+        ByteBuffer nextFramesInput = null;
+        byte[] header = new byte[8];
+
+        boolean transportAccepting = true;
+
+        ByteBuffer currentInput = input;
+        while(currentInput.hasRemaining() && _state != State.ERROR && transportAccepting)
+        {
+            switch(_state)
+            {
+                case HEADER0:
+                    if(currentInput.hasRemaining())
+                    {
+                        byte c = currentInput.get();
+                        header[0] = c;
+                        _state = State.HEADER1;
+                    }
+                    else
+                    {
+                        break;
+                    }
+                case HEADER1:
+                    if(currentInput.hasRemaining())
+                    {
+                        byte c = currentInput.get();
+                        header[1] = c;
+                        _state = State.HEADER2;
+                    }
+                    else
+                    {
+                        break;
+                    }
+                case HEADER2:
+                    if(currentInput.hasRemaining())
+                    {
+                        byte c = currentInput.get();
+                        header[2] = c;
+                        _state = State.HEADER3;
+                    }
+                    else
+                    {
+                        break;
+                    }
+                case HEADER3:
+                    if(currentInput.hasRemaining())
+                    {
+                        byte c = currentInput.get();
+                        header[3] = c;
+                        _state = State.HEADER4;
+                    }
+                    else
+                    {
+                        break;
+                    }
+                case HEADER4:
+                    if(currentInput.hasRemaining())
+                    {
+                        byte c = currentInput.get();
+                        header[4] = c;
+                        _state = State.HEADER5;
+                    }
+                    else
+                    {
+                        break;
+                    }
+                case HEADER5:
+                    if(currentInput.hasRemaining())
+                    {
+                        byte c = currentInput.get();
+                        header[5] = c;
+                        _state = State.HEADER6;
+                    }
+                    else
+                    {
+                        break;
+                    }
+                case HEADER6:
+                    if(currentInput.hasRemaining())
+                    {
+                        byte c = currentInput.get();
+                        header[6] = c;
+                        _state = State.HEADER7;
+                    }
+                    else
+                    {
+                        break;
+                    }
+                case HEADER7:
+                    if(currentInput.hasRemaining())
+                    {
+                        byte c = currentInput.get();
+                        header[7] = c;
+                        _peer.receiveHeader(header);
+                        _state = State.SIZE_0;
+                    }
+                    else
+                    {
+                        break;
+                    }
+                case SIZE_0:
+                    if(!currentInput.hasRemaining())
+                    {
+                        break;
+                    }
+                    if(currentInput.remaining() >= 4)
+                    {
+                        size = currentInput.getInt();
+                        _state = State.PRE_PARSE;
+                        break;
+                    }
+                    else
+                    {
+                        size = (currentInput.get() << 24) & 0xFF000000;
+                        if(!currentInput.hasRemaining())
+                        {
+                            _state = State.SIZE_1;
+                            break;
+                        }
+                    }
+                case SIZE_1:
+                    size |= (currentInput.get() << 16) & 0xFF0000;
+                    if(!currentInput.hasRemaining())
+                    {
+                        _state = State.SIZE_2;
+                        break;
+                    }
+                case SIZE_2:
+                    size |= (currentInput.get() << 8) & 0xFF00;
+                    if(!currentInput.hasRemaining())
+                    {
+                        _state = State.SIZE_3;
+                        break;
+                    }
+                case SIZE_3:
+                    size |= currentInput.get() & 0xFF;
+                    _state = State.PRE_PARSE;
+
+                case PRE_PARSE:
+                    ;
+                    if(size < 8)
+                    {
+                        frameParsingError = error("specified frame size %d smaller than minimum frame header "
+                                                         + "size %d",
+                                                         _size, 8);
+                        _state = State.ERROR;
+                        break;
+                    }
+
+                    if(currentInput.remaining() < size-4)
+                    {
+                        _frameBuffer = ByteBuffer.allocate(size-4);
+                        _frameBuffer.put(currentInput);
+                        _state = State.BUFFERING;
+                        break;
+                    }
+                case BUFFERING:
+                    if(_frameBuffer != null)
+                    {
+                        if(currentInput.remaining() < _frameBuffer.remaining())
+                        {
+                            // in does not contain enough bytes to complete the frame
+                            _frameBuffer.put(currentInput);
+                            break;
+                        }
+                        else
+                        {
+                            ByteBuffer dup = currentInput.duplicate();
+                            dup.limit(dup.position()+_frameBuffer.remaining());
+                            currentInput.position(currentInput.position()+_frameBuffer.remaining());
+                            _frameBuffer.put(dup);
+                            nextFramesInput = currentInput;
+                            _frameBuffer.flip();
+                            currentInput = _frameBuffer;
+                            _state = State.PARSING;
+                        }
+                    }
+
+                case PARSING:
+
+                    int dataOffset = (currentInput.get() << 2) & 0x3FF;
+
+                    if(dataOffset < 8)
+                    {
+                        frameParsingError = error("specified frame data offset %d smaller than minimum frame header size %d", dataOffset, 8);
+                        _state = State.ERROR;
+                        break;
+                    }
+                    else if(dataOffset > size)
+                    {
+                        frameParsingError = error("specified frame data offset %d larger than the frame size %d", dataOffset, _size);
+                        _state = State.ERROR;
+                        break;
+                    }
+
+                    // type
+
+                    int type = currentInput.get() & 0xFF;
+                    int channel = currentInput.getShort() & 0xFF;
+
+                    // note that this skips over the extended header if it's present
+                    if(dataOffset!=8)
+                    {
+                        currentInput.position(currentInput.position()+dataOffset-8);
+                    }
+
+                    // oldIn null iff not working on duplicated buffer
+                    final int frameBodySize = size - dataOffset;
+                    if(nextFramesInput == null)
+                    {
+                        nextFramesInput = currentInput;
+                        currentInput = currentInput.duplicate();
+                        final int endPos = currentInput.position() + frameBodySize;
+                        currentInput.limit(endPos);
+                        nextFramesInput.position(endPos);
+
+                    }
+
+                    // in's remaining bytes are now exactly those of one complete frame body
+                    // oldIn's remaining bytes are those beyond the end of currentIn's frame
+
+                    try
+                    {
+                        if (frameBodySize > 0)
+                        {
+
+                            Data data = _dataFactory.createData(frameBodySize);
+                            data.decode(currentInput);
+                            Data.DataType dataType = data.type();
+                            if(dataType != Data.DataType.DESCRIBED)
+                            {
+                                throw new IllegalArgumentException("Frame body type expected to be " + Data.DataType.DESCRIBED + " but was: " + dataType);
+                            }
+
+                            DescribedType describedType = data.getDescribedType();
+                            TRACE_LOGGER.info("Received described type: " + describedType);
+
+                            Binary payload;
+
+                            if(currentInput.hasRemaining())
+                            {
+                                byte[] payloadBytes = new byte[currentInput.remaining()];
+                                currentInput.get(payloadBytes);
+                                payload = new Binary(payloadBytes);
+                            }
+                            else
+                            {
+                                payload = null;
+                            }
+
+                            _peer.receiveFrame(type, channel, describedType, payload);
+                        }
+                        else
+                        {
+                            if(TRACE_LOGGER.isLoggable(Level.FINEST))
+                            {
+                                TRACE_LOGGER.finest("Ignored empty frame");
+                            }
+                        }
+                        _size = 0;
+                        currentInput = nextFramesInput;
+                        nextFramesInput = null;
+                        _frameBuffer = null;
+                        if(_state != State.HEADER0)
+                        {
+                            _state = State.SIZE_0;
+                        }
+                    }
+                    catch (DecodeException ex)
+                    {
+                        _state = State.ERROR;
+                        frameParsingError = error(ex);
+                    }
+                    break;
+                case ERROR:
+                    // do nothing
+            }
+
+        }
+
+        _size = size;
+
+        if(_state == State.ERROR)
+        {
+            // PHTODO throw non-proton exception
+            if(frameParsingError != null)
+            {
+                frameParsingError.checkIsOk();
+            }
+            else
+            {
+                TransportResultFactory.error("Unable to parse, probably because of a previous error").checkIsOk();
+            }
+        }
+    }
+}

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/AttachFrame.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/AttachFrame.java?rev=1511290&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/AttachFrame.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/AttachFrame.java Wed Aug  7 12:48:19 2013
@@ -0,0 +1,149 @@
+/*
+ * 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.frames;
+
+import org.apache.qpid.jms.test.testpeer.Frame;
+import org.apache.qpid.proton.amqp.Symbol;
+
+/**
+ * Generated by generate-frames.xsl, which resides in this package.
+ */
+public class AttachFrame extends Frame
+{
+    private static final Symbol DESCRIPTOR = Symbol.valueOf("amqp:attach:list");
+
+    private static final int FIELD_NAME = 0;
+    private static final int FIELD_HANDLE = 1;
+    private static final int FIELD_ROLE = 2;
+    private static final int FIELD_SND_SETTLE_MODE = 3;
+    private static final int FIELD_RCV_SETTLE_MODE = 4;
+    private static final int FIELD_SOURCE = 5;
+    private static final int FIELD_TARGET = 6;
+    private static final int FIELD_UNSETTLED = 7;
+    private static final int FIELD_INCOMPLETE_UNSETTLED = 8;
+    private static final int FIELD_INITIAL_DELIVERY_COUNT = 9;
+    private static final int FIELD_MAX_MESSAGE_SIZE = 10;
+    private static final int FIELD_OFFERED_CAPABILITIES = 11;
+    private static final int FIELD_DESIRED_CAPABILITIES = 12;
+    private static final int FIELD_PROPERTIES = 13;
+
+    public AttachFrame(Object... fields)
+    {
+        super(14);
+        int i = 0;
+        for(Object field : fields)
+        {
+            getFields()[i++] = field;
+        }
+    }
+
+    @Override
+    public Symbol getDescriptor()
+    {
+        return DESCRIPTOR;
+    }
+
+    public AttachFrame setName(Object o)
+    {
+        getFields()[FIELD_NAME] = o;
+        return this;
+    }
+
+    public AttachFrame setHandle(Object o)
+    {
+        getFields()[FIELD_HANDLE] = o;
+        return this;
+    }
+
+    public AttachFrame setRole(Object o)
+    {
+        getFields()[FIELD_ROLE] = o;
+        return this;
+    }
+
+    public AttachFrame setSndSettleMode(Object o)
+    {
+        getFields()[FIELD_SND_SETTLE_MODE] = o;
+        return this;
+    }
+
+    public AttachFrame setRcvSettleMode(Object o)
+    {
+        getFields()[FIELD_RCV_SETTLE_MODE] = o;
+        return this;
+    }
+
+    public AttachFrame setSource(Object o)
+    {
+        getFields()[FIELD_SOURCE] = o;
+        return this;
+    }
+
+    public AttachFrame setTarget(Object o)
+    {
+        getFields()[FIELD_TARGET] = o;
+        return this;
+    }
+
+    public AttachFrame setUnsettled(Object o)
+    {
+        getFields()[FIELD_UNSETTLED] = o;
+        return this;
+    }
+
+    public AttachFrame setIncompleteUnsettled(Object o)
+    {
+        getFields()[FIELD_INCOMPLETE_UNSETTLED] = o;
+        return this;
+    }
+
+    public AttachFrame setInitialDeliveryCount(Object o)
+    {
+        getFields()[FIELD_INITIAL_DELIVERY_COUNT] = o;
+        return this;
+    }
+
+    public AttachFrame setMaxMessageSize(Object o)
+    {
+        getFields()[FIELD_MAX_MESSAGE_SIZE] = o;
+        return this;
+    }
+
+    public AttachFrame setOfferedCapabilities(Object o)
+    {
+        getFields()[FIELD_OFFERED_CAPABILITIES] = o;
+        return this;
+    }
+
+    public AttachFrame setDesiredCapabilities(Object o)
+    {
+        getFields()[FIELD_DESIRED_CAPABILITIES] = o;
+        return this;
+    }
+
+    public AttachFrame setProperties(Object o)
+    {
+        getFields()[FIELD_PROPERTIES] = o;
+        return this;
+    }
+
+}
+

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/BeginFrame.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/BeginFrame.java?rev=1511290&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/BeginFrame.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/BeginFrame.java Wed Aug  7 12:48:19 2013
@@ -0,0 +1,107 @@
+/*
+ * 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.frames;
+
+import org.apache.qpid.jms.test.testpeer.Frame;
+import org.apache.qpid.proton.amqp.Symbol;
+
+/**
+ * Generated by generate-frames.xsl, which resides in this package.
+ */
+public class BeginFrame extends Frame
+{
+    private static final Symbol DESCRIPTOR = Symbol.valueOf("amqp:begin:list");
+
+    private static final int FIELD_REMOTE_CHANNEL = 0;
+    private static final int FIELD_NEXT_OUTGOING_ID = 1;
+    private static final int FIELD_INCOMING_WINDOW = 2;
+    private static final int FIELD_OUTGOING_WINDOW = 3;
+    private static final int FIELD_HANDLE_MAX = 4;
+    private static final int FIELD_OFFERED_CAPABILITIES = 5;
+    private static final int FIELD_DESIRED_CAPABILITIES = 6;
+    private static final int FIELD_PROPERTIES = 7;
+
+    public BeginFrame(Object... fields)
+    {
+        super(8);
+        int i = 0;
+        for(Object field : fields)
+        {
+            getFields()[i++] = field;
+        }
+    }
+
+    @Override
+    public Symbol getDescriptor()
+    {
+        return DESCRIPTOR;
+    }
+
+    public BeginFrame setRemoteChannel(Object o)
+    {
+        getFields()[FIELD_REMOTE_CHANNEL] = o;
+        return this;
+    }
+
+    public BeginFrame setNextOutgoingId(Object o)
+    {
+        getFields()[FIELD_NEXT_OUTGOING_ID] = o;
+        return this;
+    }
+
+    public BeginFrame setIncomingWindow(Object o)
+    {
+        getFields()[FIELD_INCOMING_WINDOW] = o;
+        return this;
+    }
+
+    public BeginFrame setOutgoingWindow(Object o)
+    {
+        getFields()[FIELD_OUTGOING_WINDOW] = o;
+        return this;
+    }
+
+    public BeginFrame setHandleMax(Object o)
+    {
+        getFields()[FIELD_HANDLE_MAX] = o;
+        return this;
+    }
+
+    public BeginFrame setOfferedCapabilities(Object o)
+    {
+        getFields()[FIELD_OFFERED_CAPABILITIES] = o;
+        return this;
+    }
+
+    public BeginFrame setDesiredCapabilities(Object o)
+    {
+        getFields()[FIELD_DESIRED_CAPABILITIES] = o;
+        return this;
+    }
+
+    public BeginFrame setProperties(Object o)
+    {
+        getFields()[FIELD_PROPERTIES] = o;
+        return this;
+    }
+
+}
+

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/CloseFrame.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/CloseFrame.java?rev=1511290&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/CloseFrame.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/CloseFrame.java Wed Aug  7 12:48:19 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.frames;
+
+import org.apache.qpid.jms.test.testpeer.Frame;
+import org.apache.qpid.proton.amqp.Symbol;
+
+/**
+ * Generated by generate-frames.xsl, which resides in this package.
+ */
+public class CloseFrame extends Frame
+{
+    private static final Symbol DESCRIPTOR = Symbol.valueOf("amqp:close:list");
+
+    private static final int FIELD_ERROR = 0;
+
+    public CloseFrame(Object... fields)
+    {
+        super(1);
+        int i = 0;
+        for(Object field : fields)
+        {
+            getFields()[i++] = field;
+        }
+    }
+
+    @Override
+    public Symbol getDescriptor()
+    {
+        return DESCRIPTOR;
+    }
+
+    public CloseFrame setError(Object o)
+    {
+        getFields()[FIELD_ERROR] = o;
+        return this;
+    }
+
+}
+

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/DetachFrame.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/DetachFrame.java?rev=1511290&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/DetachFrame.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/DetachFrame.java Wed Aug  7 12:48:19 2013
@@ -0,0 +1,72 @@
+/*
+ * 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.frames;
+
+import org.apache.qpid.jms.test.testpeer.Frame;
+import org.apache.qpid.proton.amqp.Symbol;
+
+/**
+ * Generated by generate-frames.xsl, which resides in this package.
+ */
+public class DetachFrame extends Frame
+{
+    private static final Symbol DESCRIPTOR = Symbol.valueOf("amqp:detach:list");
+
+    private static final int FIELD_HANDLE = 0;
+    private static final int FIELD_CLOSED = 1;
+    private static final int FIELD_ERROR = 2;
+
+    public DetachFrame(Object... fields)
+    {
+        super(3);
+        int i = 0;
+        for(Object field : fields)
+        {
+            getFields()[i++] = field;
+        }
+    }
+
+    @Override
+    public Symbol getDescriptor()
+    {
+        return DESCRIPTOR;
+    }
+
+    public DetachFrame setHandle(Object o)
+    {
+        getFields()[FIELD_HANDLE] = o;
+        return this;
+    }
+
+    public DetachFrame setClosed(Object o)
+    {
+        getFields()[FIELD_CLOSED] = o;
+        return this;
+    }
+
+    public DetachFrame setError(Object o)
+    {
+        getFields()[FIELD_ERROR] = o;
+        return this;
+    }
+
+}
+

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/DispositionFrame.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/DispositionFrame.java?rev=1511290&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/DispositionFrame.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/DispositionFrame.java Wed Aug  7 12:48:19 2013
@@ -0,0 +1,93 @@
+/*
+ * 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.frames;
+
+import org.apache.qpid.jms.test.testpeer.Frame;
+import org.apache.qpid.proton.amqp.Symbol;
+
+/**
+ * Generated by generate-frames.xsl, which resides in this package.
+ */
+public class DispositionFrame extends Frame
+{
+    private static final Symbol DESCRIPTOR = Symbol.valueOf("amqp:disposition:list");
+
+    private static final int FIELD_ROLE = 0;
+    private static final int FIELD_FIRST = 1;
+    private static final int FIELD_LAST = 2;
+    private static final int FIELD_SETTLED = 3;
+    private static final int FIELD_STATE = 4;
+    private static final int FIELD_BATCHABLE = 5;
+
+    public DispositionFrame(Object... fields)
+    {
+        super(6);
+        int i = 0;
+        for(Object field : fields)
+        {
+            getFields()[i++] = field;
+        }
+    }
+
+    @Override
+    public Symbol getDescriptor()
+    {
+        return DESCRIPTOR;
+    }
+
+    public DispositionFrame setRole(Object o)
+    {
+        getFields()[FIELD_ROLE] = o;
+        return this;
+    }
+
+    public DispositionFrame setFirst(Object o)
+    {
+        getFields()[FIELD_FIRST] = o;
+        return this;
+    }
+
+    public DispositionFrame setLast(Object o)
+    {
+        getFields()[FIELD_LAST] = o;
+        return this;
+    }
+
+    public DispositionFrame setSettled(Object o)
+    {
+        getFields()[FIELD_SETTLED] = o;
+        return this;
+    }
+
+    public DispositionFrame setState(Object o)
+    {
+        getFields()[FIELD_STATE] = o;
+        return this;
+    }
+
+    public DispositionFrame setBatchable(Object o)
+    {
+        getFields()[FIELD_BATCHABLE] = o;
+        return this;
+    }
+
+}
+

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/EndFrame.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/EndFrame.java?rev=1511290&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/EndFrame.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/EndFrame.java Wed Aug  7 12:48:19 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.frames;
+
+import org.apache.qpid.jms.test.testpeer.Frame;
+import org.apache.qpid.proton.amqp.Symbol;
+
+/**
+ * Generated by generate-frames.xsl, which resides in this package.
+ */
+public class EndFrame extends Frame
+{
+    private static final Symbol DESCRIPTOR = Symbol.valueOf("amqp:end:list");
+
+    private static final int FIELD_ERROR = 0;
+
+    public EndFrame(Object... fields)
+    {
+        super(1);
+        int i = 0;
+        for(Object field : fields)
+        {
+            getFields()[i++] = field;
+        }
+    }
+
+    @Override
+    public Symbol getDescriptor()
+    {
+        return DESCRIPTOR;
+    }
+
+    public EndFrame setError(Object o)
+    {
+        getFields()[FIELD_ERROR] = o;
+        return this;
+    }
+
+}
+

Added: qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/FlowFrame.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/FlowFrame.java?rev=1511290&view=auto
==============================================================================
--- qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/FlowFrame.java (added)
+++ qpid/jms/trunk/src/test/java/org/apache/qpid/jms/test/testpeer/frames/FlowFrame.java Wed Aug  7 12:48:19 2013
@@ -0,0 +1,128 @@
+/*
+ * 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.frames;
+
+import org.apache.qpid.jms.test.testpeer.Frame;
+import org.apache.qpid.proton.amqp.Symbol;
+
+/**
+ * Generated by generate-frames.xsl, which resides in this package.
+ */
+public class FlowFrame extends Frame
+{
+    private static final Symbol DESCRIPTOR = Symbol.valueOf("amqp:flow:list");
+
+    private static final int FIELD_NEXT_INCOMING_ID = 0;
+    private static final int FIELD_INCOMING_WINDOW = 1;
+    private static final int FIELD_NEXT_OUTGOING_ID = 2;
+    private static final int FIELD_OUTGOING_WINDOW = 3;
+    private static final int FIELD_HANDLE = 4;
+    private static final int FIELD_DELIVERY_COUNT = 5;
+    private static final int FIELD_LINK_CREDIT = 6;
+    private static final int FIELD_AVAILABLE = 7;
+    private static final int FIELD_DRAIN = 8;
+    private static final int FIELD_ECHO = 9;
+    private static final int FIELD_PROPERTIES = 10;
+
+    public FlowFrame(Object... fields)
+    {
+        super(11);
+        int i = 0;
+        for(Object field : fields)
+        {
+            getFields()[i++] = field;
+        }
+    }
+
+    @Override
+    public Symbol getDescriptor()
+    {
+        return DESCRIPTOR;
+    }
+
+    public FlowFrame setNextIncomingId(Object o)
+    {
+        getFields()[FIELD_NEXT_INCOMING_ID] = o;
+        return this;
+    }
+
+    public FlowFrame setIncomingWindow(Object o)
+    {
+        getFields()[FIELD_INCOMING_WINDOW] = o;
+        return this;
+    }
+
+    public FlowFrame setNextOutgoingId(Object o)
+    {
+        getFields()[FIELD_NEXT_OUTGOING_ID] = o;
+        return this;
+    }
+
+    public FlowFrame setOutgoingWindow(Object o)
+    {
+        getFields()[FIELD_OUTGOING_WINDOW] = o;
+        return this;
+    }
+
+    public FlowFrame setHandle(Object o)
+    {
+        getFields()[FIELD_HANDLE] = o;
+        return this;
+    }
+
+    public FlowFrame setDeliveryCount(Object o)
+    {
+        getFields()[FIELD_DELIVERY_COUNT] = o;
+        return this;
+    }
+
+    public FlowFrame setLinkCredit(Object o)
+    {
+        getFields()[FIELD_LINK_CREDIT] = o;
+        return this;
+    }
+
+    public FlowFrame setAvailable(Object o)
+    {
+        getFields()[FIELD_AVAILABLE] = o;
+        return this;
+    }
+
+    public FlowFrame setDrain(Object o)
+    {
+        getFields()[FIELD_DRAIN] = o;
+        return this;
+    }
+
+    public FlowFrame setEcho(Object o)
+    {
+        getFields()[FIELD_ECHO] = o;
+        return this;
+    }
+
+    public FlowFrame setProperties(Object o)
+    {
+        getFields()[FIELD_PROPERTIES] = o;
+        return this;
+    }
+
+}
+



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


Mime
View raw message