You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2017/12/28 21:48:34 UTC
[2/3] qpid-broker-j git commit: QPID-6933: [System Tests] Refactor
nondestructive consumer tests as JMS 1.1 system test
QPID-6933: [System Tests] Refactor nondestructive consumer tests as JMS 1.1 system test
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/b4e6fcf5
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/b4e6fcf5
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/b4e6fcf5
Branch: refs/heads/master
Commit: b4e6fcf55854076fce74360dadbd1f366e5a2b4f
Parents: e3f8e59
Author: Alex Rudyy <or...@apache.org>
Authored: Thu Dec 28 20:22:46 2017 +0000
Committer: Alex Rudyy <or...@apache.org>
Committed: Thu Dec 28 21:48:24 2017 +0000
----------------------------------------------------------------------
.../EnsureNondestructiveConsumersTest.java | 102 +++++++++++++++
.../EnsureNondestructiveConsumersTest.java | 128 -------------------
test-profiles/CPPExcludes | 1 -
3 files changed, 102 insertions(+), 129 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/b4e6fcf5/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/nondestructiveconsumer/EnsureNondestructiveConsumersTest.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/nondestructiveconsumer/EnsureNondestructiveConsumersTest.java b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/nondestructiveconsumer/EnsureNondestructiveConsumersTest.java
new file mode 100644
index 0000000..db02103
--- /dev/null
+++ b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/nondestructiveconsumer/EnsureNondestructiveConsumersTest.java
@@ -0,0 +1,102 @@
+/*
+ *
+ * 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.extensions.nondestructiveconsumer;
+
+import static org.apache.qpid.systests.Utils.INDEX;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.Collections;
+
+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 org.junit.Test;
+
+import org.apache.qpid.systests.JmsTestBase;
+import org.apache.qpid.systests.Utils;
+
+public class EnsureNondestructiveConsumersTest extends JmsTestBase
+{
+
+ @Test
+ public void testEnsureNondestructiveConsumers() throws Exception
+ {
+ String queueName = getTestName();
+ createEntityUsingAmqpManagement(queueName, "org.apache.qpid.Queue",
+ Collections.singletonMap("ensureNondestructiveConsumers", true));
+ Queue queue = createQueue(queueName);
+ int numberOfMessages = 5;
+ Connection connection = getConnectionBuilder().setSyncPublish(true).build();
+ try
+ {
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ connection.start();
+
+ Utils.sendMessages(session, queue, numberOfMessages);
+
+ MessageConsumer consumer1 = session.createConsumer(queue);
+
+ for (int i = 0; i < numberOfMessages; i++)
+ {
+ Message receivedMsg = consumer1.receive(getReceiveTimeout());
+ assertNotNull("Message " + i + " not received", receivedMsg);
+ assertEquals("Unexpected message", i, receivedMsg.getIntProperty(INDEX));
+ }
+
+ assertNull("Unexpected message arrived", consumer1.receive(getShortReceiveTimeout()));
+
+ MessageConsumer consumer2 = session.createConsumer(queue);
+
+ for (int i = 0; i < numberOfMessages; i++)
+ {
+ Message receivedMsg = consumer2.receive(getReceiveTimeout());
+ assertNotNull("Message " + i + " not received", receivedMsg);
+ assertEquals("Unexpected message", i, receivedMsg.getIntProperty(INDEX));
+ }
+
+ assertNull("Unexpected message arrived", consumer2.receive(getShortReceiveTimeout()));
+
+ MessageProducer producer = session.createProducer(queue);
+ producer.send(Utils.createNextMessage(session, 6));
+
+ assertNotNull("Message not received on first consumer", consumer1.receive(getReceiveTimeout()));
+ assertNotNull("Message not received on second consumer", consumer2.receive(getReceiveTimeout()));
+
+ assertNull("Unexpected message arrived", consumer1.receive(getShortReceiveTimeout()));
+ assertNull("Unexpected message arrived", consumer2.receive(getShortReceiveTimeout()));
+ }
+ finally
+ {
+ connection.close();
+ }
+ }
+
+ private long getShortReceiveTimeout()
+ {
+ return getReceiveTimeout() / 4;
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/b4e6fcf5/systests/src/test/java/org/apache/qpid/server/queue/EnsureNondestructiveConsumersTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/server/queue/EnsureNondestructiveConsumersTest.java b/systests/src/test/java/org/apache/qpid/server/queue/EnsureNondestructiveConsumersTest.java
deleted file mode 100644
index 1a85dc4..0000000
--- a/systests/src/test/java/org/apache/qpid/server/queue/EnsureNondestructiveConsumersTest.java
+++ /dev/null
@@ -1,128 +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.server.queue;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-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.apache.qpid.QpidException;
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
-public class EnsureNondestructiveConsumersTest extends QpidBrokerTestCase
-{
-
- private String _queueName;
- private Connection _connection;
- private Session _session;
- private Queue _queue;
-
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
-
- _queueName = getTestQueueName();
- _connection = getConnectionWithSyncPublishing();
- _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- _connection.start();
- }
-
- private void createQueueEnsureNondestructiveConsumerOption(boolean ensureNonDestructiveConsumer)
- throws QpidException, JMSException
- {
- final Map<String,Object> arguments = new HashMap<>();
- if(isBroker10())
- {
- if(ensureNonDestructiveConsumer)
- {
- arguments.put("ensureNondestructiveConsumers", true);
- }
- createEntityUsingAmqpManagement(_queueName, _session, "org.apache.qpid.Queue", arguments);
- _queue = _session.createQueue(_queueName);
- }
- else
- {
- arguments.put("qpid.ensure_nondestructive_consumers", String.valueOf(ensureNonDestructiveConsumer));
- ((AMQSession<?, ?>) _session).createQueue(_queueName, false, true, false, arguments);
- _queue = new org.apache.qpid.client.AMQQueue("amq.direct", _queueName);
- ((AMQSession<?, ?>) _session).declareAndBind((AMQDestination) _queue);
- }
- }
-
- public void testEnsureNondestructiveConsumers() throws QpidException, JMSException
- {
- createQueueEnsureNondestructiveConsumerOption(true);
- final MessageProducer prod = _session.createProducer(_queue);
- TextMessage textMessage;
-
- for(int i = 0; i < 5; i++)
- {
- textMessage = _session.createTextMessage("hello");
- textMessage.setIntProperty("msgID", i);
- prod.send(textMessage);
- }
-
- MessageConsumer cons1 = _session.createConsumer(_queue);
-
- for(int i = 0; i < 5 ; i++)
- {
- Message receivedMsg = cons1.receive(500);
- assertNotNull("Message "+i+" not received", receivedMsg);
- assertEquals("Unexpected message", i, receivedMsg.getIntProperty("msgID"));
- }
-
- assertNull("Unexpected message arrived", cons1.receive(500));
-
- MessageConsumer cons2 = _session.createConsumer(_queue);
-
- for(int i = 0; i < 5 ; i++)
- {
- Message receivedMsg = cons2.receive(500);
- assertNotNull("Message "+i+" not received", receivedMsg);
- assertEquals("Unexpected message", i, receivedMsg.getIntProperty("msgID"));
- }
-
- assertNull("Unexpected message arrived", cons2.receive(500));
-
- textMessage = _session.createTextMessage("hello");
- textMessage.setIntProperty("msgID", 6);
- prod.send(textMessage);
-
- assertNotNull("Message not received on first consumer", cons1.receive(500));
- assertNotNull("Message not received on second consumer", cons2.receive(500));
-
- assertNull("Unexpected message arrived", cons1.receive(500));
- assertNull("Unexpected message arrived", cons2.receive(500));
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/b4e6fcf5/test-profiles/CPPExcludes
----------------------------------------------------------------------
diff --git a/test-profiles/CPPExcludes b/test-profiles/CPPExcludes
index 966aebd..054e5c9 100755
--- a/test-profiles/CPPExcludes
+++ b/test-profiles/CPPExcludes
@@ -161,7 +161,6 @@ org.apache.qpid.systest.MessageCompressionTest#*
org.apache.qpid.test.unit.client.AMQSessionTest#testQueueDepthForQueueThatDoesNotExistLegacyBehaviour_08_091
-org.apache.qpid.server.queue.EnsureNondestructiveConsumersTest#*
org.apache.qpid.server.protocol.v0_8.*
//Qpid Broker-J BDB System Tests
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org