activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject [3/7] activemq git commit: https://issues.apache.org/jira/browse/AMQ-5617
Date Thu, 26 Feb 2015 21:20:38 GMT
https://issues.apache.org/jira/browse/AMQ-5617

Absorbe these into the general JMSClientTest that covers all four
transport types.

Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/4fa420bb
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/4fa420bb
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/4fa420bb

Branch: refs/heads/master
Commit: 4fa420bbd198167281cacf96313fa5a04da055ae
Parents: 12202c9
Author: Timothy Bish <tabish121@gmail.com>
Authored: Thu Feb 26 14:48:57 2015 -0500
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Thu Feb 26 14:48:57 2015 -0500

----------------------------------------------------------------------
 .../activemq/transport/amqp/AMQ4696Test.java    |  68 ---------
 .../activemq/transport/amqp/JMSClientTest.java  |  38 +++++
 .../transport/amqp/bugs/AMQ4914Test.java        | 109 --------------
 .../transport/amqp/bugs/AMQ5256Test.java        | 149 -------------------
 4 files changed, 38 insertions(+), 326 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/4fa420bb/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AMQ4696Test.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AMQ4696Test.java
b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AMQ4696Test.java
deleted file mode 100644
index 677374e..0000000
--- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/AMQ4696Test.java
+++ /dev/null
@@ -1,68 +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.activemq.transport.amqp;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.jms.TopicConnection;
-import javax.jms.TopicSession;
-import javax.jms.TopicSubscriber;
-
-import org.apache.activemq.broker.jmx.BrokerView;
-import org.junit.Test;
-
-public class AMQ4696Test extends AmqpTestSupport {
-
-    @Test(timeout=30*1000)
-    public void simpleDurableTopicTest() throws Exception {
-        String TOPIC_NAME = "AMQ4696Test" + System.currentTimeMillis();
-        String durableClientId = "AMQPDurableTopicTestClient";
-        String durableSubscriberName = "durableSubscriberName";
-
-        BrokerView adminView = this.brokerService.getAdminView();
-        int durableSubscribersAtStart = adminView.getDurableTopicSubscribers().length;
-        int inactiveSubscribersAtStart = adminView.getInactiveDurableTopicSubscribers().length;
-        LOG.debug(">>>> At Start, durable Subscribers {} inactiveDurableSubscribers
{}", durableSubscribersAtStart, inactiveSubscribersAtStart);
-
-        TopicConnection subscriberConnection =
-            JmsClientContext.INSTANCE.createTopicConnection(amqpURI, "admin", "password");
-        subscriberConnection.setClientID(durableClientId);
-        TopicSession subscriberSession = subscriberConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
-        Topic topic = subscriberSession.createTopic(TOPIC_NAME);
-        TopicSubscriber messageConsumer = subscriberSession.createDurableSubscriber(topic,
durableSubscriberName);
-
-        assertNotNull(messageConsumer);
-
-        int durableSubscribers = adminView.getDurableTopicSubscribers().length;
-        int inactiveSubscribers = adminView.getInactiveDurableTopicSubscribers().length;
-        LOG.debug(">>>> durable Subscribers after creation {} inactiveDurableSubscribers
{}", durableSubscribers, inactiveSubscribers);
-        assertEquals("Wrong number of durable subscribers after first subscription", 1, (durableSubscribers
- durableSubscribersAtStart));
-        assertEquals("Wrong number of inactive durable subscribers after first subscription",
0, (inactiveSubscribers - inactiveSubscribersAtStart));
-
-        subscriberConnection.close();
-        subscriberConnection = null;
-
-        durableSubscribers = adminView.getDurableTopicSubscribers().length;
-        inactiveSubscribers = adminView.getInactiveDurableTopicSubscribers().length;
-        LOG.debug(">>>> durable Subscribers after close {} inactiveDurableSubscribers
{}", durableSubscribers, inactiveSubscribers);
-        assertEquals("Wrong number of durable subscribers after close", 0, (durableSubscribersAtStart));
-        assertEquals("Wrong number of inactive durable subscribers after close", 1, (inactiveSubscribers
- inactiveSubscribersAtStart));
-    }
-}

http://git-wip-us.apache.org/repos/asf/activemq/blob/4fa420bb/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTest.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTest.java
b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTest.java
index 34f20ba..250053a 100644
--- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTest.java
+++ b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/JMSClientTest.java
@@ -45,7 +45,11 @@ import javax.jms.QueueBrowser;
 import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.jms.Topic;
+import javax.jms.TopicConnection;
+import javax.jms.TopicSession;
+import javax.jms.TopicSubscriber;
 
+import org.apache.activemq.broker.jmx.BrokerView;
 import org.apache.activemq.broker.jmx.BrokerViewMBean;
 import org.apache.activemq.broker.jmx.ConnectorViewMBean;
 import org.apache.activemq.broker.jmx.QueueViewMBean;
@@ -881,6 +885,40 @@ public class JMSClientTest extends JMSClientTestSupport {
         assertEquals(messageText, textMessage.getText());
     }
 
+    @Test(timeout=30*1000)
+    public void simpleDurableTopicTest() throws Exception {
+        String durableClientId = getDestinationName() + "-ClientId";
+        String durableSubscriberName = getDestinationName() + "-SubscriptionName";
+
+        BrokerView adminView = this.brokerService.getAdminView();
+        int durableSubscribersAtStart = adminView.getDurableTopicSubscribers().length;
+        int inactiveSubscribersAtStart = adminView.getInactiveDurableTopicSubscribers().length;
+        LOG.debug(">>>> At Start, durable Subscribers {} inactiveDurableSubscribers
{}", durableSubscribersAtStart, inactiveSubscribersAtStart);
+
+        TopicConnection subscriberConnection =
+            JmsClientContext.INSTANCE.createTopicConnection(amqpURI, "admin", "password");
+        subscriberConnection.setClientID(durableClientId);
+        TopicSession subscriberSession = subscriberConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+        Topic topic = subscriberSession.createTopic(getDestinationName());
+        TopicSubscriber messageConsumer = subscriberSession.createDurableSubscriber(topic,
durableSubscriberName);
+
+        assertNotNull(messageConsumer);
+
+        int durableSubscribers = adminView.getDurableTopicSubscribers().length;
+        int inactiveSubscribers = adminView.getInactiveDurableTopicSubscribers().length;
+        LOG.debug(">>>> durable Subscribers after creation {} inactiveDurableSubscribers
{}", durableSubscribers, inactiveSubscribers);
+        assertEquals("Wrong number of durable subscribers after first subscription", 1, (durableSubscribers
- durableSubscribersAtStart));
+        assertEquals("Wrong number of inactive durable subscribers after first subscription",
0, (inactiveSubscribers - inactiveSubscribersAtStart));
+
+        subscriberConnection.close();
+
+        durableSubscribers = adminView.getDurableTopicSubscribers().length;
+        inactiveSubscribers = adminView.getInactiveDurableTopicSubscribers().length;
+        LOG.debug(">>>> durable Subscribers after close {} inactiveDurableSubscribers
{}", durableSubscribers, inactiveSubscribers);
+        assertEquals("Wrong number of durable subscribers after close", 0, (durableSubscribersAtStart));
+        assertEquals("Wrong number of inactive durable subscribers after close", 1, (inactiveSubscribers
- inactiveSubscribersAtStart));
+    }
+
     @Test(timeout=30000)
     public void testDurableConsumerUnsubscribe() throws Exception {
         ActiveMQAdmin.enableJMSFrameTracing();

http://git-wip-us.apache.org/repos/asf/activemq/blob/4fa420bb/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/bugs/AMQ4914Test.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/bugs/AMQ4914Test.java
b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/bugs/AMQ4914Test.java
deleted file mode 100644
index d171ea9..0000000
--- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/bugs/AMQ4914Test.java
+++ /dev/null
@@ -1,109 +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.activemq.transport.amqp.bugs;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-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.activemq.transport.amqp.AmqpTestSupport;
-import org.apache.activemq.transport.amqp.JmsClientContext;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ4914Test extends AmqpTestSupport {
-
-    @Rule
-    public TestName testName = new TestName();
-
-    protected static final Logger LOG = LoggerFactory.getLogger(AMQ4914Test.class);
-
-    private String createLargeString(int sizeInBytes) {
-        byte[] base = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
-        StringBuilder builder = new StringBuilder();
-        for (int i = 0; i < sizeInBytes; i++) {
-            builder.append(base[i % base.length]);
-        }
-
-        LOG.debug("Created string with size : " + builder.toString().getBytes().length +
" bytes");
-        return builder.toString();
-    }
-
-    @Test(timeout = 60 * 1000)
-    public void testSendSmallerMessages() throws JMSException {
-        for (int i = 512; i <= (8 * 1024); i += 512) {
-            doTestSendLargeMessage(i);
-        }
-    }
-
-    @Test(timeout = 60 * 1000)
-    public void testSendFixedSizedMessages() throws JMSException {
-        doTestSendLargeMessage(65536);
-        doTestSendLargeMessage(65536 * 2);
-        doTestSendLargeMessage(65536 * 4);
-    }
-
-    @Test(timeout = 60 * 1000)
-    public void testSendHugeMessage() throws JMSException {
-        doTestSendLargeMessage(1024 * 1024 * 10);
-    }
-
-    public void doTestSendLargeMessage(int expectedSize) throws JMSException{
-        LOG.info("doTestSendLargeMessage called with expectedSize " + expectedSize);
-        String payload = createLargeString(expectedSize);
-        assertEquals(expectedSize, payload.getBytes().length);
-
-        Connection connection = JmsClientContext.INSTANCE.createConnection(amqpURI);
-        long startTime = System.currentTimeMillis();
-        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-        Queue queue = session.createQueue(testName.getMethodName());
-        MessageProducer producer = session.createProducer(queue);
-        TextMessage message = session.createTextMessage();
-        message.setText(payload);
-        producer.send(message);
-        long endTime = System.currentTimeMillis();
-        LOG.info("Returned from send after {} ms", endTime - startTime);
-
-        startTime = System.currentTimeMillis();
-        MessageConsumer consumer = session.createConsumer(queue);
-        connection.start();
-        LOG.info("Calling receive");
-        Message receivedMessage = consumer.receive();
-        assertNotNull(receivedMessage);
-        assertTrue(receivedMessage instanceof TextMessage);
-        TextMessage receivedTextMessage = (TextMessage) receivedMessage;
-        assertNotNull(receivedMessage);
-        endTime = System.currentTimeMillis();
-        LOG.info("Returned from receive after {} ms", endTime - startTime);
-        String receivedText = receivedTextMessage.getText();
-        assertEquals(expectedSize, receivedText.getBytes().length);
-        assertEquals(payload, receivedText);
-        connection.close();
-    }
-}

http://git-wip-us.apache.org/repos/asf/activemq/blob/4fa420bb/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/bugs/AMQ5256Test.java
----------------------------------------------------------------------
diff --git a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/bugs/AMQ5256Test.java
b/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/bugs/AMQ5256Test.java
deleted file mode 100644
index 989e501..0000000
--- a/activemq-amqp/src/test/java/org/apache/activemq/transport/amqp/bugs/AMQ5256Test.java
+++ /dev/null
@@ -1,149 +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.activemq.transport.amqp.bugs;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-
-import org.apache.activemq.transport.amqp.AmqpTestSupport;
-import org.apache.activemq.transport.amqp.JmsClientContext;
-import org.junit.Test;
-
-public class AMQ5256Test extends AmqpTestSupport {
-
-    @Override
-    protected boolean isUseTcpConnector() {
-        return true;
-    }
-
-    @Override
-    protected boolean isUseSslConnector() {
-        return true;
-    }
-
-    @Override
-    protected boolean isUseNioConnector() {
-        return true;
-    }
-
-    @Override
-    protected boolean isUseNioPlusSslConnector() {
-        return true;
-    }
-
-    @Test(timeout = 60000)
-    public void testParallelConnectPlain() throws Exception {
-        final int numThreads = 40;
-        ExecutorService executorService = Executors.newFixedThreadPool(numThreads);
-        for (int i = 0; i < numThreads; i++) {
-            executorService.execute(new Runnable() {
-                @Override
-                public void run() {
-
-                    try {
-                        Connection connection = JmsClientContext.INSTANCE.createConnection(amqpURI,
"admin", "password");
-                        connection.start();
-                        connection.close();
-                    } catch (JMSException e) {
-                        e.printStackTrace();
-                    }
-                }
-            });
-        }
-
-        executorService.shutdown();
-        assertTrue("executor done on time", executorService.awaitTermination(30, TimeUnit.SECONDS));
-    }
-
-    @Test(timeout = 60000)
-    public void testParallelConnectNio() throws Exception {
-        final int numThreads = 40;
-        ExecutorService executorService = Executors.newFixedThreadPool(numThreads);
-        for (int i = 0; i < numThreads; i++) {
-            executorService.execute(new Runnable() {
-                @Override
-                public void run() {
-
-                    try {
-                        Connection connection = JmsClientContext.INSTANCE.createConnection(amqpNioURI,
"admin", "password");
-                        connection.start();
-                        connection.close();
-                    } catch (JMSException e) {
-                        e.printStackTrace();
-                    }
-                }
-            });
-        }
-
-        executorService.shutdown();
-        assertTrue("executor done on time", executorService.awaitTermination(30, TimeUnit.SECONDS));
-    }
-
-    @Test(timeout = 60000)
-    public void testParallelConnectSsl() throws Exception {
-        final int numThreads = 40;
-        ExecutorService executorService = Executors.newFixedThreadPool(numThreads);
-        for (int i = 0; i < numThreads; i++) {
-            executorService.execute(new Runnable() {
-                @Override
-                public void run() {
-
-                    try {
-                        Connection connection = JmsClientContext.INSTANCE.createConnection(amqpSslURI,
"admin", "password");
-                        connection.start();
-                        connection.close();
-                    } catch (JMSException e) {
-                        e.printStackTrace();
-                    }
-                }
-            });
-        }
-
-        executorService.shutdown();
-        assertTrue("executor done on time", executorService.awaitTermination(30, TimeUnit.SECONDS));
-    }
-
-    @Test(timeout = 60000)
-    public void testParallelConnectNioPlusSsl() throws Exception {
-        final int numThreads = 40;
-        ExecutorService executorService = Executors.newFixedThreadPool(numThreads);
-        for (int i = 0; i < numThreads; i++) {
-            executorService.execute(new Runnable() {
-                @Override
-                public void run() {
-
-                    try {
-                        Connection connection = JmsClientContext.INSTANCE.createConnection(amqpNioPlusSslURI,
"admin", "password");
-                        connection.start();
-                        connection.close();
-                    } catch (JMSException e) {
-                        e.printStackTrace();
-                    }
-                }
-            });
-        }
-
-        executorService.shutdown();
-        assertTrue("executor done on time", executorService.awaitTermination(30, TimeUnit.SECONDS));
-    }
-}


Mime
View raw message