activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [57/58] [abbrv] activemq-artemis git commit: investigation tests
Date Wed, 09 Mar 2016 19:43:20 GMT
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/2630ddec
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/2630ddec
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/2630ddec

Branch: refs/heads/refactor-openwire
Commit: 2630ddeca995f8046efea15b0178ba0d3165f744
Parents: 83dc2e1
Author: Clebert Suconic <clebertsuconic@apache.org>
Authored: Tue Feb 23 21:51:05 2016 -0500
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Wed Mar 9 14:41:41 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/2630ddec/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/2630ddec/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<Session> 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<Session> 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<Session> 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<Session> 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<Session> 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();
+      }
+   }
+}


Mime
View raw message