You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2018/06/06 21:57:08 UTC
qpid-broker-j git commit: QPID-8203: [Broker-J] Improve protocol tests
Repository: qpid-broker-j
Updated Branches:
refs/heads/master 11c33ac9b -> fc3555cb8
QPID-8203: [Broker-J] Improve protocol tests
Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/fc3555cb
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/fc3555cb
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/fc3555cb
Branch: refs/heads/master
Commit: fc3555cb8da0024b0a9a7b59c1ffbcac8bf0a391
Parents: 11c33ac
Author: Keith Wall <kw...@apache.org>
Authored: Wed Jun 6 22:55:07 2018 +0100
Committer: Keith Wall <kw...@apache.org>
Committed: Wed Jun 6 22:55:20 2018 +0100
----------------------------------------------------------------------
.../maxsize/MaximumMessageSizeTest.java | 91 ++++++++++++++++++++
.../extension/maxsize/MaximumMessageSize.java | 83 ------------------
.../maxsize/MaximumMessageSizeTest.java | 88 +++++++++++++++++++
3 files changed, 179 insertions(+), 83 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/fc3555cb/systests/protocol-tests-amqp-0-10/src/test/java/org/apache/qpid/tests/protocol/v0_10/extensions/maxsize/MaximumMessageSizeTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-0-10/src/test/java/org/apache/qpid/tests/protocol/v0_10/extensions/maxsize/MaximumMessageSizeTest.java b/systests/protocol-tests-amqp-0-10/src/test/java/org/apache/qpid/tests/protocol/v0_10/extensions/maxsize/MaximumMessageSizeTest.java
new file mode 100644
index 0000000..546c40e
--- /dev/null
+++ b/systests/protocol-tests-amqp-0-10/src/test/java/org/apache/qpid/tests/protocol/v0_10/extensions/maxsize/MaximumMessageSizeTest.java
@@ -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.tests.protocol.v0_10.extensions.maxsize;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.qpid.tests.utils.BrokerAdmin.KIND_BROKER_J;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.net.InetSocketAddress;
+import java.util.stream.IntStream;
+
+import org.hamcrest.core.IsEqual;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.qpid.server.protocol.v0_10.transport.ExecutionErrorCode;
+import org.apache.qpid.server.protocol.v0_10.transport.ExecutionException;
+import org.apache.qpid.server.protocol.v0_10.transport.MessageProperties;
+import org.apache.qpid.server.protocol.v0_10.transport.SessionCommandPoint;
+import org.apache.qpid.tests.protocol.v0_10.FrameTransport;
+import org.apache.qpid.tests.protocol.v0_10.Interaction;
+import org.apache.qpid.tests.utils.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
+import org.apache.qpid.tests.utils.BrokerSpecific;
+import org.apache.qpid.tests.utils.ConfigItem;
+
+@BrokerSpecific(kind = KIND_BROKER_J)
+@ConfigItem(name = "qpid.max_message_size", value = "1000")
+public class MaximumMessageSizeTest extends BrokerAdminUsingTestBase
+{
+ private InetSocketAddress _brokerAddress;
+
+ @Before
+ public void setUp()
+ {
+ _brokerAddress = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
+ getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
+ }
+
+ @Test
+ public void limitExceeded() throws Exception
+ {
+ try (FrameTransport transport = new FrameTransport(_brokerAddress).connect())
+ {
+ final Interaction interaction = transport.newInteraction();
+ byte[] sessionName = "test".getBytes(UTF_8);
+
+ final byte[] messageContent = new byte[1001];
+ IntStream.range(0, messageContent.length).forEach(i -> {messageContent[i] = (byte) (i & 0xFF);});
+
+ MessageProperties messageProperties = new MessageProperties();
+ messageProperties.setContentLength(messageContent.length);
+
+ ExecutionException executionException = interaction.openAnonymousConnection()
+ .channelId(1)
+ .attachSession(sessionName)
+ .message()
+ .transferDestination(BrokerAdmin.TEST_QUEUE_NAME)
+ .transferId(0)
+ .transferBody(messageContent)
+ .transferHeader(null, messageProperties)
+ .transfer()
+ .session()
+ .flushCompleted()
+ .flush()
+ .consumeResponse(SessionCommandPoint.class)
+ .consumeResponse()
+ .getLatestResponse(ExecutionException.class);
+
+ assertThat(executionException.getErrorCode(), IsEqual.equalTo(ExecutionErrorCode.RESOURCE_LIMIT_EXCEEDED));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/fc3555cb/systests/protocol-tests-amqp-0-8/src/test/java/org/apache/qpid/tests/protocol/v0_8/extension/maxsize/MaximumMessageSize.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-0-8/src/test/java/org/apache/qpid/tests/protocol/v0_8/extension/maxsize/MaximumMessageSize.java b/systests/protocol-tests-amqp-0-8/src/test/java/org/apache/qpid/tests/protocol/v0_8/extension/maxsize/MaximumMessageSize.java
deleted file mode 100644
index 837b6e5..0000000
--- a/systests/protocol-tests-amqp-0-8/src/test/java/org/apache/qpid/tests/protocol/v0_8/extension/maxsize/MaximumMessageSize.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.tests.protocol.v0_8.extension.maxsize;
-
-import static org.apache.qpid.tests.utils.BrokerAdmin.KIND_BROKER_J;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-import java.net.InetSocketAddress;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import org.apache.qpid.server.protocol.v0_8.transport.ChannelCloseBody;
-import org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody;
-import org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseOkBody;
-import org.apache.qpid.tests.protocol.ChannelClosedResponse;
-import org.apache.qpid.tests.protocol.v0_8.FrameTransport;
-import org.apache.qpid.tests.protocol.v0_8.Interaction;
-import org.apache.qpid.tests.utils.BrokerAdmin;
-import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
-import org.apache.qpid.tests.utils.BrokerSpecific;
-import org.apache.qpid.tests.utils.ConfigItem;
-
-@BrokerSpecific(kind = KIND_BROKER_J)
-@ConfigItem(name = "qpid.max_message_size", value = "1000")
-public class MaximumMessageSize extends BrokerAdminUsingTestBase
-{
- private InetSocketAddress _brokerAddress;
-
- @Before
- public void setUp()
- {
- _brokerAddress = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
- getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
- }
-
- @Test
- public void limitExceeded() throws Exception
- {
- String content = Stream.generate(() -> String.valueOf('.')).limit(1001).collect(Collectors.joining());
- try(FrameTransport transport = new FrameTransport(_brokerAddress).connect())
- {
- final Interaction interaction = transport.newInteraction();
- interaction.openAnonymousConnection()
- .channel().open().consumeResponse(ChannelOpenOkBody.class)
- .basic().contentHeaderPropertiesContentType("text/plain")
- .contentHeaderPropertiesDeliveryMode((byte)1)
- .contentHeaderPropertiesPriority((byte)1)
- .publishExchange("")
- .publishRoutingKey(BrokerAdmin.TEST_QUEUE_NAME)
- .content(content)
- .publishMessage()
- .consumeResponse(ChannelCloseBody.class)
- .channel().closeOk()
- .connection().close()
- .consumeResponse(ConnectionCloseOkBody.class, ChannelClosedResponse.class);
-
- assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/fc3555cb/systests/protocol-tests-amqp-0-8/src/test/java/org/apache/qpid/tests/protocol/v0_8/extension/maxsize/MaximumMessageSizeTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-0-8/src/test/java/org/apache/qpid/tests/protocol/v0_8/extension/maxsize/MaximumMessageSizeTest.java b/systests/protocol-tests-amqp-0-8/src/test/java/org/apache/qpid/tests/protocol/v0_8/extension/maxsize/MaximumMessageSizeTest.java
new file mode 100644
index 0000000..16721be
--- /dev/null
+++ b/systests/protocol-tests-amqp-0-8/src/test/java/org/apache/qpid/tests/protocol/v0_8/extension/maxsize/MaximumMessageSizeTest.java
@@ -0,0 +1,88 @@
+/*
+ *
+ * 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.tests.protocol.v0_8.extension.maxsize;
+
+import static org.apache.qpid.tests.utils.BrokerAdmin.KIND_BROKER_J;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.net.InetSocketAddress;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.qpid.server.protocol.ErrorCodes;
+import org.apache.qpid.server.protocol.v0_8.transport.ChannelCloseBody;
+import org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody;
+import org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseOkBody;
+import org.apache.qpid.tests.protocol.ChannelClosedResponse;
+import org.apache.qpid.tests.protocol.v0_8.FrameTransport;
+import org.apache.qpid.tests.protocol.v0_8.Interaction;
+import org.apache.qpid.tests.utils.BrokerAdmin;
+import org.apache.qpid.tests.utils.BrokerAdminUsingTestBase;
+import org.apache.qpid.tests.utils.BrokerSpecific;
+import org.apache.qpid.tests.utils.ConfigItem;
+
+@BrokerSpecific(kind = KIND_BROKER_J)
+@ConfigItem(name = "qpid.max_message_size", value = "1000")
+public class MaximumMessageSizeTest extends BrokerAdminUsingTestBase
+{
+ private InetSocketAddress _brokerAddress;
+
+ @Before
+ public void setUp()
+ {
+ _brokerAddress = getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.ANONYMOUS_AMQP);
+ getBrokerAdmin().createQueue(BrokerAdmin.TEST_QUEUE_NAME);
+ }
+
+ @Test
+ public void limitExceeded() throws Exception
+ {
+ String content = Stream.generate(() -> String.valueOf('.')).limit(1001).collect(Collectors.joining());
+ try(FrameTransport transport = new FrameTransport(_brokerAddress).connect())
+ {
+ final Interaction interaction = transport.newInteraction();
+ interaction.openAnonymousConnection()
+ .channel().open().consumeResponse(ChannelOpenOkBody.class)
+ .basic().contentHeaderPropertiesContentType("text/plain")
+ .contentHeaderPropertiesDeliveryMode((byte) 1)
+ .contentHeaderPropertiesPriority((byte) 1)
+ .publishExchange("")
+ .publishRoutingKey(BrokerAdmin.TEST_QUEUE_NAME)
+ .content(content)
+ .publishMessage();
+
+ ChannelCloseBody channelClose = interaction.consumeResponse()
+ .getLatestResponse(ChannelCloseBody.class);
+ assertThat(channelClose.getReplyCode(), is(equalTo(ErrorCodes.MESSAGE_TOO_LARGE)));
+
+ interaction.channel().closeOk()
+ .connection().close()
+ .consumeResponse(ConnectionCloseOkBody.class, ChannelClosedResponse.class);
+
+ assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org