From ca589f316bad37638742d64d34e40c7aef587cfc Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Thu, 24 May 2018 12:47:42 -0400 Subject: [PATCH] ARTEMIS-1887 and ARTEMIS-1885 Adding tests on maxConsumer This is a test for PRs #2106 and #2107 --- tests/smoke-tests/pom.xml | 20 +- .../resources/servers/maxConsumers/broker.xml | 206 ++++++++++++++++++ .../smoke/maxConsumers/MaxConsumersTest.java | 66 ++++++ 3 files changed, 289 insertions(+), 3 deletions(-) create mode 100644 tests/smoke-tests/src/main/resources/servers/maxConsumers/broker.xml create mode 100644 tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/maxConsumers/MaxConsumersTest.java diff --git a/tests/smoke-tests/pom.xml b/tests/smoke-tests/pom.xml index 41c756957d..2c3e008bb7 100644 --- a/tests/smoke-tests/pom.xml +++ b/tests/smoke-tests/pom.xml @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> - + 4.0.0 org.apache.activemq.tests @@ -185,14 +186,27 @@ create - - ${basedir}/target/classes/servers/mqtt true admin admin ${basedir}/target/standard + + test-compile + create-maxConsumers + + create + + + + ${basedir}/target/classes/servers/maxConsumers + true + admin + admin + ${basedir}/target/maxConsumers + + diff --git a/tests/smoke-tests/src/main/resources/servers/maxConsumers/broker.xml b/tests/smoke-tests/src/main/resources/servers/maxConsumers/broker.xml new file mode 100644 index 0000000000..ffb043a971 --- /dev/null +++ b/tests/smoke-tests/src/main/resources/servers/maxConsumers/broker.xml @@ -0,0 +1,206 @@ + + + + + + + + 0.0.0.0 + + true + + + NIO + + ./data/paging + + ./data/bindings + + ./data/journal + + ./data/large-messages + + true + + 2 + + -1 + + 1000 + + + + + + + + + + + + + + + + + + + + + + 5000 + + + 90 + + + + + + + + + + + + tcp://0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;useKQueue;amqpCredits=1000;amqpLowCredits=300 + + + tcp://0.0.0.0:5672?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=AMQP;useEpoll=true;useKQueue=true;amqpCredits=1000;amqpLowCredits=300 + + + tcp://0.0.0.0:61613?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=STOMP;useEpoll=true;useKQueue=true + + + tcp://0.0.0.0:5445?protocols=HORNETQ,STOMP;useEpoll=true;useKQueue=true + + + tcp://0.0.0.0:1883?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=MQTT;useEpoll=true;useKQueue=true + + + + + + + + + + + + + + + + + + + + + + + + DLQ + ExpiryQueue + 0 + + -1 + 10 + PAGE + true + true + true + true + + + + DLQ + ExpiryQueue + 0 + + -1 + 10 + PAGE + true + true + true + true + + + DLQ + ExpiryQueue + 0 + + -1 + 1 + 10 + PAGE + true + true + true + true + + + + +
+ + + +
+
+ + + +
+
+ + + + + +
+ +
+ +
+
diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/maxConsumers/MaxConsumersTest.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/maxConsumers/MaxConsumersTest.java new file mode 100644 index 0000000000..05a5f1fcde --- /dev/null +++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/maxConsumers/MaxConsumersTest.java @@ -0,0 +1,66 @@ +/** + * 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.activemq.artemis.tests.smoke.maxConsumers; + +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.JMSException; +import javax.jms.MessageConsumer; +import javax.jms.Queue; +import javax.jms.Session; + +import org.apache.activemq.artemis.tests.smoke.common.SmokeTestBase; +import org.apache.qpid.jms.JmsConnectionFactory; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class MaxConsumersTest extends SmokeTestBase { + + public static final String SERVER_NAME_0 = "maxConsumers"; + + @Before + public void before() throws Exception { + cleanupData(SERVER_NAME_0); + disableCheckThread(); + startServer(SERVER_NAME_0, 0, 30000); + } + + @Test + public void testMax() throws Exception { + for (int i = 0; i < 5; i++) { + ConnectionFactory factory = new JmsConnectionFactory("amqp://localhost:61616"); + Connection connection = factory.createConnection(); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + Queue queue = session.createQueue("myQueue"); + + MessageConsumer consumer = session.createConsumer(queue); + try { + MessageConsumer consumer2 = session.createConsumer(queue); + Assert.fail("Exception was expected here"); + } catch (JMSException expectedMax) { + } + + consumer.close(); + connection.close(); + } + + } + +}