-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QPID-8203: [Broker-J][AMQP 0-9] Fix maximum message size check
- Loading branch information
1 parent
560d4a3
commit 025b48f
Showing
2 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
...c/test/java/org/apache/qpid/tests/protocol/v0_8/extension/maxsize/MaximumMessageSize.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* | ||
* 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))); | ||
} | ||
} | ||
} |