You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by lq...@apache.org on 2017/04/07 16:38:57 UTC
svn commit: r1790583 [2/2] - in /qpid/java/trunk: ./
broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/
broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/
broker-plugins/amqp-1-0...
Added: qpid/java/trunk/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/link/AttachTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/link/AttachTest.java?rev=1790583&view=auto
==============================================================================
--- qpid/java/trunk/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/link/AttachTest.java (added)
+++ qpid/java/trunk/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/link/AttachTest.java Fri Apr 7 16:38:56 2017
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2017 by Lorenz Quack
+ *
+ * This file is part of qpid-java-build.
+ *
+ * qpid-java-build is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * qpid-java-build is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with qpid-java-build. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.apache.qpid.tests.protocol.v1_0.transport.link;
+
+import static org.hamcrest.CoreMatchers.both;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.lessThan;
+import static org.hamcrest.Matchers.notNullValue;
+
+import java.net.InetSocketAddress;
+
+import org.junit.Test;
+
+import org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger;
+import org.apache.qpid.server.protocol.v1_0.type.messaging.Source;
+import org.apache.qpid.server.protocol.v1_0.type.messaging.Target;
+import org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError;
+import org.apache.qpid.server.protocol.v1_0.type.transport.Attach;
+import org.apache.qpid.server.protocol.v1_0.type.transport.Close;
+import org.apache.qpid.server.protocol.v1_0.type.transport.Role;
+import org.apache.qpid.tests.protocol.v1_0.BrokerAdmin;
+import org.apache.qpid.tests.protocol.v1_0.FrameTransport;
+import org.apache.qpid.tests.protocol.v1_0.PerformativeResponse;
+import org.apache.qpid.tests.protocol.v1_0.ProtocolTestBase;
+
+public class AttachTest extends ProtocolTestBase
+{
+ @Test
+ public void emptyAttach() throws Exception
+ {
+ final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
+ try (FrameTransport transport = new FrameTransport(addr))
+ {
+ transport.doBeginSession();
+ Attach attach = new Attach();
+
+ transport.sendPerformative(attach);
+ PerformativeResponse response = (PerformativeResponse) transport.getNextResponse();
+
+ assertThat(response, is(notNullValue()));
+ assertThat(response.getFrameBody(), is(instanceOf(Close.class)));
+ Close responseClose = (Close) response.getFrameBody();
+ assertThat(responseClose.getError(), is(notNullValue()));
+ assertThat(responseClose.getError().getCondition(), equalTo(AmqpError.DECODE_ERROR));
+ }
+ }
+
+ @Test
+ public void successfulAttachAsSender() throws Exception
+ {
+ final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
+ try (FrameTransport transport = new FrameTransport(addr))
+ {
+ Role localRole = Role.SENDER;
+ transport.doBeginSession();
+ Attach attach = new Attach();
+ attach.setName("testLink");
+ attach.setHandle(new UnsignedInteger(0));
+ attach.setRole(localRole);
+ attach.setInitialDeliveryCount(UnsignedInteger.ZERO);
+ Source source = new Source();
+ attach.setSource(source);
+ Target target = new Target();
+ attach.setTarget(target);
+
+ transport.sendPerformative(attach);
+ PerformativeResponse response = (PerformativeResponse) transport.getNextResponse();
+
+ assertThat(response, is(notNullValue()));
+ assertThat(response.getFrameBody(), is(instanceOf(Attach.class)));
+ Attach responseAttach = (Attach) response.getFrameBody();
+ assertThat(responseAttach.getName(), is(notNullValue()));
+ assertThat(responseAttach.getHandle().longValue(), is(both(greaterThanOrEqualTo(0L)).and(lessThan(UnsignedInteger.MAX_VALUE.longValue()))));
+ assertThat(responseAttach.getRole(), is(Role.RECEIVER));
+ assertThat(responseAttach.getTarget(), is(notNullValue()));
+ assertThat(responseAttach.getSource(), is(notNullValue()));
+ }
+ }
+
+ @Test
+ public void successfulAttachAsReceiver() throws Exception
+ {
+ String queueName = "testQueue";
+ getBrokerAdmin().createQueue(queueName);
+ final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
+ try (FrameTransport transport = new FrameTransport(addr))
+ {
+ Role localRole = Role.RECEIVER;
+ transport.doBeginSession();
+ Attach attach = new Attach();
+ attach.setName("testLink");
+ attach.setHandle(new UnsignedInteger(0));
+ attach.setRole(localRole);
+ Source source = new Source();
+ source.setAddress(queueName);
+ attach.setSource(source);
+ Target target = new Target();
+ attach.setTarget(target);
+
+ transport.sendPerformative(attach);
+ PerformativeResponse response = (PerformativeResponse) transport.getNextResponse();
+
+ assertThat(response, is(notNullValue()));
+ assertThat(response.getFrameBody(), is(instanceOf(Attach.class)));
+ Attach responseAttach = (Attach) response.getFrameBody();
+ assertThat(responseAttach.getName(), is(notNullValue()));
+ assertThat(responseAttach.getHandle().longValue(), is(both(greaterThanOrEqualTo(0L)).and(lessThan(UnsignedInteger.MAX_VALUE.longValue()))));
+ assertThat(responseAttach.getRole(), is(Role.SENDER));
+ assertThat(responseAttach.getSource(), is(notNullValue()));
+ }
+ }
+}
Added: qpid/java/trunk/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/session/BeginTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/session/BeginTest.java?rev=1790583&view=auto
==============================================================================
--- qpid/java/trunk/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/session/BeginTest.java (added)
+++ qpid/java/trunk/systests/protocol-tests-amqp-1-0/src/test/java/org/apache/qpid/tests/protocol/v1_0/transport/session/BeginTest.java Fri Apr 7 16:38:56 2017
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2017 by Lorenz Quack
+ *
+ * This file is part of qpid-java-build.
+ *
+ * qpid-java-build is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * qpid-java-build is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with qpid-java-build. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.apache.qpid.tests.protocol.v1_0.transport.session;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+import java.net.InetSocketAddress;
+
+import org.junit.Test;
+
+import org.apache.qpid.server.protocol.v1_0.framing.TransportFrame;
+import org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger;
+import org.apache.qpid.server.protocol.v1_0.type.UnsignedShort;
+import org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError;
+import org.apache.qpid.server.protocol.v1_0.type.transport.Begin;
+import org.apache.qpid.server.protocol.v1_0.type.transport.Close;
+import org.apache.qpid.tests.protocol.v1_0.BrokerAdmin;
+import org.apache.qpid.tests.protocol.v1_0.FrameTransport;
+import org.apache.qpid.tests.protocol.v1_0.PerformativeResponse;
+import org.apache.qpid.tests.protocol.v1_0.ProtocolTestBase;
+
+public class BeginTest extends ProtocolTestBase
+{
+ @Test
+ public void emptyBegin() throws Exception
+ {
+ final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
+ try(FrameTransport transport = new FrameTransport(addr))
+ {
+ transport.doOpenConnection();
+ Begin begin = new Begin();
+ short channel = (short) 37;
+ TransportFrame transportFrame = new TransportFrame(channel, begin);
+ transport.sendPerformative(transportFrame);
+ PerformativeResponse response = (PerformativeResponse) transport.getNextResponse();
+
+ assertThat(response, is(notNullValue()));
+ assertThat(response.getFrameBody(), is(instanceOf(Close.class)));
+ Close responseClose = (Close) response.getFrameBody();
+ assertThat(responseClose.getError(), is(notNullValue()));
+ assertThat(responseClose.getError().getCondition(), equalTo(AmqpError.DECODE_ERROR));
+ }
+ }
+
+ @Test
+ public void successfulBegin() throws Exception
+ {
+ final InetSocketAddress addr = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
+ try (FrameTransport transport = new FrameTransport(addr))
+ {
+ transport.doOpenConnection();
+ Begin begin = new Begin();
+ begin.setNextOutgoingId(UnsignedInteger.ZERO);
+ begin.setIncomingWindow(UnsignedInteger.ZERO);
+ begin.setOutgoingWindow(UnsignedInteger.ZERO);
+
+ UnsignedShort channel = UnsignedShort.valueOf((short) 37);
+ TransportFrame transportFrame = new TransportFrame(channel.shortValue(), begin);
+ transport.sendPerformative(transportFrame);
+ PerformativeResponse response = (PerformativeResponse) transport.getNextResponse();
+
+ assertThat(response, is(notNullValue()));
+ assertThat(response.getFrameBody(), is(instanceOf(Begin.class)));
+ Begin responseBegin = (Begin) response.getFrameBody();
+ assertThat(responseBegin.getRemoteChannel(), equalTo(channel));
+ assertThat(responseBegin.getIncomingWindow(), is(instanceOf(UnsignedInteger.class)));
+ assertThat(responseBegin.getOutgoingWindow(), is(instanceOf(UnsignedInteger.class)));
+ assertThat(responseBegin.getNextOutgoingId(), is(instanceOf(UnsignedInteger.class)));
+ transport.assertNoMoreResponses();
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org