You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2016/03/31 04:31:23 UTC
[41/69] [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/33edfff9
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/33edfff9
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/33edfff9
Branch: refs/heads/refactor-openwire
Commit: 33edfff9403ea3413079e7ba72beb18f255ea269
Parents: 9e95d8e
Author: Clebert Suconic <cl...@apache.org>
Authored: Tue Feb 23 21:51:05 2016 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Wed Mar 30 22:29:44 2016 -0400
----------------------------------------------------------------------
.../integration/openwire/BasicOpenWireTest.java | 4 +
.../InvestigationOpenwireTest.java | 184 +++++++++++++++++++
2 files changed, 188 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/33edfff9/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/33edfff9/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();
+ }
+ }
+}