Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 08DFC19BCE for ; Fri, 4 Mar 2016 22:42:49 +0000 (UTC) Received: (qmail 28940 invoked by uid 500); 4 Mar 2016 22:42:47 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 28892 invoked by uid 500); 4 Mar 2016 22:42:47 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 26926 invoked by uid 99); 4 Mar 2016 22:42:46 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Mar 2016 22:42:46 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 89C2FE7944; Fri, 4 Mar 2016 22:42:46 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: clebertsuconic@apache.org To: commits@activemq.apache.org Date: Fri, 04 Mar 2016 22:43:24 -0000 Message-Id: <6a53b8f1bac04e1e83858d03fbb5c42e@git.apache.org> In-Reply-To: <64a7ec3b1ddf4b2f8d97fa76fd178cb9@git.apache.org> References: <64a7ec3b1ddf4b2f8d97fa76fd178cb9@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [40/58] [abbrv] activemq-artemis git commit: investigation tests investigation tests don't merge this commit on master, this is to be removed... just something that Clebert is using to debug openwire packets Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/54eb9c90 Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/54eb9c90 Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/54eb9c90 Branch: refs/heads/refactor-openwire Commit: 54eb9c90f2d3f44b30d272a361c2535ad664de16 Parents: 79292b2 Author: Clebert Suconic Authored: Tue Feb 23 21:51:05 2016 -0500 Committer: Clebert Suconic Committed: Fri Mar 4 15:41:48 2016 -0500 ---------------------------------------------------------------------- .../integration/openwire/BasicOpenWireTest.java | 4 + .../InvestigationOpenwireTest.java | 184 +++++++++++++++++++ 2 files changed, 188 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54eb9c90/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/BasicOpenWireTest.java ---------------------------------------------------------------------- diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/BasicOpenWireTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/BasicOpenWireTest.java index d2e3215..09fd9b7 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/BasicOpenWireTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/BasicOpenWireTest.java @@ -31,6 +31,7 @@ import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException; import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.ActiveMQXAConnectionFactory; import org.apache.activemq.command.ActiveMQDestination; import org.junit.After; import org.junit.Before; @@ -44,6 +45,9 @@ public class BasicOpenWireTest extends OpenWireTestBase { protected static final String urlString = "tcp://" + OWHOST + ":" + OWPORT + "?wireFormat.cacheEnabled=true"; protected ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(urlString); + protected ActiveMQXAConnectionFactory xaFactory = new ActiveMQXAConnectionFactory(urlString); + + protected ActiveMQConnection connection; protected String topicName = "amqTestTopic1"; protected String queueName = "amqTestQueue1"; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54eb9c90/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/investigations/InvestigationOpenwireTest.java ---------------------------------------------------------------------- diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/investigations/InvestigationOpenwireTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/investigations/InvestigationOpenwireTest.java new file mode 100644 index 0000000..3614b9a --- /dev/null +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/investigations/InvestigationOpenwireTest.java @@ -0,0 +1,184 @@ +/** + * 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.integration.openwire.investigations; + +import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; +import org.junit.Assert; +import org.junit.Test; + +import javax.jms.*; +import javax.transaction.xa.XAResource; +import java.util.Collection; +import java.util.LinkedList; + +public class InvestigationOpenwireTest extends BasicOpenWireTest { + + @Test + public void testSimple() throws Exception { + try { + + Connection connection = factory.createConnection(); + // Thread.sleep(5000); + + Collection sessions = new LinkedList<>(); + + for (int i = 0; i < 10; i++) { + Session session = connection.createSession(true, Session.SESSION_TRANSACTED); + sessions.add(session); + } + + connection.close(); + + System.err.println("Done!!!"); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + @Test + public void testAutoAck() throws Exception { + try { + + Connection connection = factory.createConnection(); + // Thread.sleep(5000); + + Collection sessions = new LinkedList<>(); + + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + Queue queue = session.createQueue(queueName); + System.out.println("Queue:" + queue); + MessageProducer producer = session.createProducer(queue); + MessageConsumer consumer = session.createConsumer(queue); + producer.send(session.createTextMessage("test")); + + Assert.assertNull(consumer.receive(100)); + connection.start(); + + TextMessage message = (TextMessage)consumer.receive(5000); + + Assert.assertNotNull(message); + + + connection.close(); + + System.err.println("Done!!!"); + } + catch (Throwable e) { + e.printStackTrace(); + } + } + + + + @Test + public void testRollback() throws Exception { + try { + + Connection connection = factory.createConnection(); + // Thread.sleep(5000); + + Collection sessions = new LinkedList<>(); + + Session session = connection.createSession(true, Session.SESSION_TRANSACTED); + Queue queue = session.createQueue(queueName); + System.out.println("Queue:" + queue); + MessageProducer producer = session.createProducer(queue); + MessageConsumer consumer = session.createConsumer(queue); + producer.send(session.createTextMessage("test")); + connection.start(); + Assert.assertNull(consumer.receive(1000)); + session.rollback(); + producer.send(session.createTextMessage("test2")); + Assert.assertNull(consumer.receive(1000)); + session.commit(); + TextMessage msg = (TextMessage)consumer.receive(1000); + + + Assert.assertNotNull(msg); + Assert.assertEquals("test2", msg.getText()); + + connection.close(); + + System.err.println("Done!!!"); + } + catch (Throwable e) { + e.printStackTrace(); + } + } + + + @Test + public void testClientACK() throws Exception { + try { + + Connection connection = factory.createConnection(); + // Thread.sleep(5000); + + Collection sessions = new LinkedList<>(); + + Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); + Queue queue = session.createQueue(queueName); + System.out.println("Queue:" + queue); + MessageProducer producer = session.createProducer(queue); + MessageConsumer consumer = session.createConsumer(queue); + producer.send(session.createTextMessage("test")); + + Assert.assertNull(consumer.receive(100)); + connection.start(); + + TextMessage message = (TextMessage)consumer.receive(5000); + + Assert.assertNotNull(message); + + message.acknowledge(); + + + connection.close(); + + System.err.println("Done!!!"); + } + catch (Throwable e) { + e.printStackTrace(); + } + } + + @Test + public void testXASimple() throws Exception { + try { + + XAConnection connection = xaFactory.createXAConnection(); + // Thread.sleep(5000); + + Collection sessions = new LinkedList<>(); + + for (int i = 0; i < 10; i++) { + XASession session = connection.createXASession(); + session.getXAResource().start(newXID(), XAResource.TMNOFLAGS); + sessions.add(session); + } + + connection.close(); + + System.err.println("Done!!!"); + } + catch (Exception e) { + e.printStackTrace(); + } + } +}