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 2017/12/21 17:27:46 UTC
[3/7] qpid-broker-j git commit: QPID-6933: [System Tests] Move
simplified LargeMessageTest to new suite
QPID-6933: [System Tests] Move simplified LargeMessageTest to new suite
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/9b0a837a
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/9b0a837a
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/9b0a837a
Branch: refs/heads/master
Commit: 9b0a837a9f5e38c5ea00639ece6e2e511f92882b
Parents: e30acdd
Author: Keith Wall <kw...@apache.org>
Authored: Thu Dec 21 10:34:54 2017 +0000
Committer: Keith Wall <kw...@apache.org>
Committed: Thu Dec 21 11:28:56 2017 +0000
----------------------------------------------------------------------
.../jms_1_1/message/LargeMessageTest.java | 98 ++++++++++++
.../qpid/test/unit/basic/LargeMessageTest.java | 159 -------------------
2 files changed, 98 insertions(+), 159 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/9b0a837a/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/message/LargeMessageTest.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/message/LargeMessageTest.java b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/message/LargeMessageTest.java
new file mode 100644
index 0000000..08b9fa9
--- /dev/null
+++ b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/message/LargeMessageTest.java
@@ -0,0 +1,98 @@
+/*
+ *
+ * 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.systests.jms_1_1.message;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.stream.IntStream;
+
+import javax.jms.Connection;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.junit.Test;
+
+import org.apache.qpid.systests.JmsTestBase;
+
+public class LargeMessageTest extends JmsTestBase
+{
+
+ @Test
+ public void message256k() throws Exception
+ {
+ checkLargeMessage(256 * 1024);
+ }
+
+ @Test
+ public void message512k() throws Exception
+ {
+ checkLargeMessage(512 * 1024);
+ }
+
+ @Test
+ public void message1024k() throws Exception
+ {
+ checkLargeMessage(1024 * 1024);
+ }
+
+ public void checkLargeMessage(final int messageSize) throws Exception
+ {
+ Queue queue = createQueue(getTestName());
+ Connection connection = getConnection();
+ try
+ {
+ final String messageText = buildLargeMessage(messageSize);
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer producer = session.createProducer(queue);
+
+ TextMessage message = session.createTextMessage(messageText);
+
+ producer.send(message);
+
+ MessageConsumer consumer = session.createConsumer(queue);
+ connection.start();
+ Message receivedMessage = consumer.receive(getReceiveTimeout());
+
+ assertTrue("TextMessage should be received", receivedMessage instanceof TextMessage);
+ String receivedMessageText = ((TextMessage) receivedMessage).getText();
+ assertEquals(String.format("Unexpected large message content for size : %d", messageSize),
+ receivedMessageText, messageText);
+ }
+ finally
+ {
+ connection.close();
+ }
+ }
+
+ private String buildLargeMessage(int size)
+ {
+ return IntStream.range(0, size)
+ .map(operand -> (char)(operand % 26) + 'A')
+ .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append).toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/9b0a837a/systests/src/test/java/org/apache/qpid/test/unit/basic/LargeMessageTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/test/unit/basic/LargeMessageTest.java b/systests/src/test/java/org/apache/qpid/test/unit/basic/LargeMessageTest.java
deleted file mode 100644
index acfeb4f..0000000
--- a/systests/src/test/java/org/apache/qpid/test/unit/basic/LargeMessageTest.java
+++ /dev/null
@@ -1,159 +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.test.unit.basic;
-
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
-public class LargeMessageTest extends QpidBrokerTestCase
-{
- private static final Logger LOGGER = LoggerFactory.getLogger(LargeMessageTest.class);
-
- private Destination _destination;
- private Session _session;
- private Connection _connection;
-
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
- _connection = getConnection();
- _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- _destination = createTestQueue(_session);
-
- _connection.start();
- }
-
- @Override
- public void tearDown() throws Exception
- {
- _connection.close();
- super.tearDown();
- }
-
- public void test64kminus9() throws JMSException
- {
- checkLargeMessage((64 * 1024) - 9);
- }
-
- public void test64kminus8() throws JMSException
- {
- checkLargeMessage((64 * 1024)-8);
- }
-
- public void test64kminus7() throws JMSException
- {
- checkLargeMessage((64 * 1024)-7);
- }
-
-
- public void test64kplus1() throws JMSException
- {
- checkLargeMessage((64 * 1024) + 1);
- }
-
- public void test128kminus1() throws JMSException
- {
- checkLargeMessage((128 * 1024) - 1);
- }
-
- public void test128k() throws JMSException
- {
- checkLargeMessage(128 * 1024);
- }
-
- public void test128kplus1() throws JMSException
- {
- checkLargeMessage((128 * 1024) + 1);
- }
-
- // Testing larger messages
-
- public void test256k() throws JMSException
- {
- checkLargeMessage(256 * 1024);
- }
-
- public void test512k() throws JMSException
- {
- checkLargeMessage(512 * 1024);
- }
-
- public void test1024k() throws JMSException
- {
- checkLargeMessage(1024 * 1024);
- }
-
- protected void checkLargeMessage(int messageSize) throws JMSException
- {
- MessageConsumer consumer = _session.createConsumer(_destination);
- MessageProducer producer = _session.createProducer(_destination);
- LOGGER.info("Testing message of size:" + messageSize);
-
- String _messageText = buildLargeMessage(messageSize);
-
- LOGGER.debug("Message built");
-
- producer.send(_session.createTextMessage(_messageText));
-
- TextMessage result = (TextMessage) consumer.receive(10000);
-
- assertNotNull("Null message received", result);
- assertEquals("Message Size", _messageText.length(), result.getText().length());
- assertEquals("Message content differs", _messageText, result.getText());
-
- }
-
- private String buildLargeMessage(int size)
- {
- StringBuilder builder = new StringBuilder(size);
-
- char ch = 'a';
-
- for (int i = 1; i <= size; i++)
- {
- builder.append(ch);
-
- if ((i % 1000) == 0)
- {
- ch++;
- if (ch == ('z' + 1))
- {
- ch = 'a';
- }
- }
- }
-
- return builder.toString();
- }
-
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org