Author: chirino
Date: Fri Jan 27 05:46:58 2012
New Revision: 1236538
URL: http://svn.apache.org/viewvc?rev=1236538&view=rev
Log:
Make the itests module pure java. Simplify the base test class.
Added:
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/AutoFailTestSupport.java
- copied, changed from r1236537,
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/AutoFailTestSupport.java
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/BrokerAdmin.java
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/CombinationTestSupport.java
- copied, changed from r1236537,
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/CombinationTestSupport.java
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JMSMessageTest.java
- copied, changed from r1236537,
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/JMSMessageTest.java
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JmsQueueTransactionTest.java
- copied, changed from r1236537,
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/JmsQueueTransactionTest.java
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JmsTestBase.java
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JmsTopicTransactionTest.java
- copied, changed from r1236537,
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/JmsTopicTransactionTest.java
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JmsTransactionTestSupport.java
- copied, changed from r1236537,
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/JmsTransactionTestSupport.java
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/OpenwireBrokerAdmin.java
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/StompBrokerAdmin.java
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/test/
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/test/JmsResourceProvider.java
- copied, changed from r1236537,
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/test/JmsResourceProvider.java
activemq/activemq-apollo/trunk/apollo-itests/src/test/resources/apollo.xml
- copied, changed from r1236537,
activemq/activemq-apollo/trunk/apollo-itests/src/test/resources/apollo-stomp.xml
Removed:
activemq/activemq-apollo/trunk/apollo-itests/src/test/resources/apollo-openwire.xml
activemq/activemq-apollo/trunk/apollo-itests/src/test/resources/apollo-stomp.xml
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/AutoFailTestSupport.java
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/BrokerService.scala
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/CombinationTestSupport.java
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/JMSMessageTest.java
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/JmsQueueTransactionTest.java
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/JmsTestSupport.java
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/JmsTopicTransactionTest.java
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/JmsTransactionTestSupport.java
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/TestSupport.java
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/test/JmsResourceProvider.java
Modified:
activemq/activemq-apollo/trunk/apollo-itests/pom.xml
activemq/activemq-apollo/trunk/apollo-itests/src/test/resources/log4j.properties
Modified: activemq/activemq-apollo/trunk/apollo-itests/pom.xml
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-itests/pom.xml?rev=1236538&r1=1236537&r2=1236538&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-itests/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-itests/pom.xml Fri Jan 27 05:46:58
2012
@@ -21,9 +21,8 @@
<parent>
<groupId>org.apache.activemq</groupId>
- <artifactId>apollo-scala</artifactId>
+ <artifactId>apollo-project</artifactId>
<version>1.1-SNAPSHOT</version>
- <relativePath>../apollo-scala</relativePath>
</parent>
<groupId>org.apache.activemq</groupId>
@@ -35,71 +34,61 @@
<properties>
<maven-compiler-plugin-version>2.3.2</maven-compiler-plugin-version>
- <stompjms-client-version>1.5-SNAPSHOT</stompjms-client-version>
+ <stompjms-client-version>1.7</stompjms-client-version>
</properties>
<dependencies>
- <!-- Scala Support -->
- <dependency>
- <groupId>org.scala-lang</groupId>
- <artifactId>scala-library</artifactId>
- <scope>compile</scope>
- <version>${scala-version}</version>
- </dependency>
-
-
+ <!-- The JMS Client Jars -->
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_1.1_spec</artifactId>
<version>1.1.1</version>
</dependency>
-
<dependency>
<groupId>org.fusesource.stompjms</groupId>
<artifactId>stompjms-client</artifactId>
<version>${stompjms-client-version}</version>
<scope>test</scope>
</dependency>
-
- <!-- Testing Dependencies -->
<dependency>
<groupId>org.apache.activemq</groupId>
- <artifactId>apollo-broker</artifactId>
- <version>1.1-SNAPSHOT</version>
- <type>test-jar</type>
+ <artifactId>activemq-core</artifactId>
+ <version>5.5.1</version>
<scope>test</scope>
</dependency>
+ <!-- So we can boot up a broker -->
<dependency>
<groupId>org.apache.activemq</groupId>
- <artifactId>apollo-util</artifactId>
+ <artifactId>apollo-stomp</artifactId>
<version>1.1-SNAPSHOT</version>
- <type>test-jar</type>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.apache.activemq</groupId>
- <artifactId>apollo-stomp</artifactId>
+ <artifactId>apollo-openwire</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>apollo-bdb</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
-
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>apollo-leveldb</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.eclipse.jetty.aggregate</groupId>
<artifactId>jetty-all-server</artifactId>
<version>${jetty-version}</version>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>apollo-web</artifactId>
@@ -107,20 +96,27 @@
<scope>test</scope>
</dependency>
+ <!-- Test framework support files -->
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>apollo-broker</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ <type>test-jar</type>
<scope>test</scope>
- <version>${junit-version}</version>
</dependency>
-
<dependency>
- <groupId>org.scalatest</groupId>
- <artifactId>scalatest_2.9.1</artifactId>
- <version>${scalatest-version}</version>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>apollo-util</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
-
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ <version>${junit-version}</version>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
@@ -136,18 +132,6 @@
<id>unstable</id>
<dependencies>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-core</artifactId>
- <version>5.5.1</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>apollo-openwire</artifactId>
- <version>1.1-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
</dependencies>
</profile>
@@ -155,98 +139,8 @@
</profiles>
<build>
-
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.scala-tools</groupId>
- <artifactId>maven-scala-plugin</artifactId>
- <version>${maven-scala-plugin-version}</version>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>${maven-compiler-plugin-version}</version>
- </plugin>
- </plugins>
- </pluginManagement>
-
<plugins>
<plugin>
- <groupId>org.scala-tools</groupId>
- <artifactId>maven-scala-plugin</artifactId>
- <version>${maven-scala-plugin-version}</version>
- <executions>
- <execution>
- <id>scala-compile-first</id>
- <phase>process-resources</phase>
- <goals>
- <goal>add-source</goal>
- <goal>compile</goal>
- </goals>
- </execution>
- <execution>
- <id>scala-test-compile</id>
- <phase>process-test-resources</phase>
- <goals>
- <goal>testCompile</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <testSourceDir>src/test/scala</testSourceDir>
- <args>
- <arg>-deprecation</arg>
- <arg>-P:continuations:enable</arg>
- </args>
- <compilerPlugins>
- <compilerPlugin>
- <groupId>org.scala-lang.plugins</groupId>
- <artifactId>continuations</artifactId>
- <version>${scala-version}</version>
- </compilerPlugin>
- <compilerPlugin>
- <groupId>org.fusesource.jvmassert</groupId>
- <artifactId>jvmassert</artifactId>
- <version>1.2</version>
- </compilerPlugin>
- </compilerPlugins>
- <jvmArgs>
- <jvmArg>-Xmx1024m</jvmArg>
- <jvmArg>-Xss8m</jvmArg>
- </jvmArgs>
- <scalaVersion>${scala-version}</scalaVersion>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>${maven-compiler-plugin-version}</version>
- <executions>
- <execution>
- <phase>compile</phase>
- <goals>
- <goal>compile</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <!-- Generate a test jar for the test cases in this package -->
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin-version}</version>
@@ -255,21 +149,20 @@
<!-- we must turn off the use of system class loader so our tests
can find stuff - otherwise ScalaSupport compiler can't find stuff -->
<useSystemClassLoader>false</useSystemClassLoader>
<!--forkMode>pertest</forkMode-->
- <childDelegation>false</childDelegation>
- <useFile>true</useFile>
- <redirectTestOutputToFile>true</redirectTestOutputToFile>
- <failIfNoTests>false</failIfNoTests>
-
- <excludes>
- <!-- hangs -->
- <!--
- <exclude>**/JmsTopicTransactionTest.*</exclude>
- -->
- </excludes>
- </configuration>
- </plugin>
+ <childDelegation>false</childDelegation>
+ <useFile>true</useFile>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <failIfNoTests>false</failIfNoTests>
+
+ <excludes>
+ <!--
+ <exclude>**/JmsTopicTransactionTest.*</exclude>
+ -->
+ </excludes>
+ </configuration>
+ </plugin>
- </plugins>
-</build>
+ </plugins>
+ </build>
</project>
Copied:
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/AutoFailTestSupport.java
(from r1236537,
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/AutoFailTestSupport.java)
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/AutoFailTestSupport.java?p2=activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/AutoFailTestSupport.java&p1=activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/AutoFailTestSupport.java&r1=1236537&r2=1236538&rev=1236538&view=diff
==============================================================================
(empty)
Added:
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/BrokerAdmin.java
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/BrokerAdmin.java?rev=1236538&view=auto
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/BrokerAdmin.java
(added)
+++
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/BrokerAdmin.java
Fri Jan 27 05:46:58 2012
@@ -0,0 +1,56 @@
+/**
+ * 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.apollo;
+
+import org.apache.activemq.apollo.broker.Broker;
+import org.apache.activemq.apollo.broker.BrokerFactory;
+import org.apache.activemq.apollo.util.ServiceControl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jms.ConnectionFactory;
+import java.net.InetSocketAddress;
+
+/**
+ * <p>
+ * </p>
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+abstract public class BrokerAdmin {
+ protected static final Logger LOG =
LoggerFactory.getLogger(BrokerAdmin.class);
+
+ public Object create(String config) {
+ LOG.info("Loading broker configuration from the classpath with URI: "
+ config);
+ return BrokerFactory.createBroker(config);
+ }
+ public void start(Object broker) {
+ ServiceControl.start((Broker)broker, "Starting "+broker);
+ }
+ public void stop(Object broker) {
+ ServiceControl.stop((Broker)broker, "Stopping "+broker);
+ }
+
+ public int port(Object broker) {
+ Broker b = (Broker) broker;
+ InetSocketAddress address = (InetSocketAddress) b.get_socket_address();
+ return address.getPort();
+ }
+
+ abstract ConnectionFactory getConnectionFactory(Object broker);
+
+}
Copied:
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/CombinationTestSupport.java
(from r1236537,
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/CombinationTestSupport.java)
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/CombinationTestSupport.java?p2=activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/CombinationTestSupport.java&p1=activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/CombinationTestSupport.java&r1=1236537&r2=1236538&rev=1236538&view=diff
==============================================================================
(empty)
Copied:
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JMSMessageTest.java
(from r1236537,
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/JMSMessageTest.java)
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JMSMessageTest.java?p2=activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JMSMessageTest.java&p1=activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/JMSMessageTest.java&r1=1236537&r2=1236538&rev=1236538&view=diff
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/JMSMessageTest.java
(original)
+++
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JMSMessageTest.java
Fri Jan 27 05:46:58 2012
@@ -20,7 +20,6 @@ import junit.framework.Test;
import org.fusesource.stomp.jms.StompJmsSession;
import javax.jms.*;
-import java.net.URISyntaxException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Vector;
@@ -30,7 +29,7 @@ import java.util.Vector;
*
*
*/
-public class JMSMessageTest extends JmsTestSupport {
+public class JMSMessageTest extends JmsTestBase {
public Destination destination;
public int deliveryMode = DeliveryMode.NON_PERSISTENT;
Copied:
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JmsQueueTransactionTest.java
(from r1236537,
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/JmsQueueTransactionTest.java)
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JmsQueueTransactionTest.java?p2=activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JmsQueueTransactionTest.java&p1=activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/JmsQueueTransactionTest.java&r1=1236537&r2=1236538&rev=1236538&view=diff
==============================================================================
(empty)
Added:
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JmsTestBase.java
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JmsTestBase.java?rev=1236538&view=auto
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JmsTestBase.java
(added)
+++
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JmsTestBase.java
Fri Jan 27 05:46:58 2012
@@ -0,0 +1,267 @@
+/**
+ * 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.apollo;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jms.*;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * Test cases used to test the JMS message consumer.
+ *
+ *
+ */
+public class JmsTestBase extends CombinationTestSupport {
+ protected static final Logger LOG =
LoggerFactory.getLogger(BrokerAdmin.class);
+ public BrokerAdmin brokerAdmin;
+
+ public void initCombos() {
+ ArrayList<Object> brokerAdmins = new ArrayList<Object>();
+ brokerAdmins.add(new StompBrokerAdmin());
+ try {
+
Class.forName("org.apache.activemq.apollo.openwire.OpenwireProtocolHandler",
false, JmsTestBase.class.getClassLoader());
+ brokerAdmins.add(new OpenwireBrokerAdmin());
+ } catch (ClassNotFoundException e) {
+ }
+ addCombinationValues("brokerAdmin", brokerAdmins.toArray());
+ }
+
+ public String brokerConfig = "xml:classpath:apollo.xml";
+
+ protected Object broker;
+ protected ConnectionFactory factory;
+ protected Connection connection;
+ protected List<Connection> connections = Collections.synchronizedList(new
ArrayList<Connection>());
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ if (System.getProperty("basedir") == null) {
+ File file = new File(".");
+ System.setProperty("basedir", file.getAbsolutePath());
+ }
+ broker = brokerAdmin.create(brokerConfig);
+ brokerAdmin.start(broker);
+ factory = brokerAdmin.getConnectionFactory(broker);
+
+ connection = factory.createConnection(userName, password);
+ connections.add(connection);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ for (Iterator iter = connections.iterator(); iter.hasNext();) {
+ Connection conn = (Connection)iter.next();
+ try {
+ conn.close();
+ } catch (Throwable e) {
+ }
+ iter.remove();
+ }
+
+ connection = null;
+ if(broker!=null) {
+ brokerAdmin.stop(broker);
+ broker = null;
+ }
+ super.tearDown();
+ }
+
+ public ConnectionFactory getConnectionFactory() throws Exception {
+ return factory;
+ }
+
+ /**
+ * Factory method to create a new connection
+ */
+ public Connection createConnection() throws Exception {
+ return getConnectionFactory().createConnection();
+ }
+
+ /**
+ * @param messsage
+ * @param firstSet
+ * @param secondSet
+ */
+ protected void assertTextMessagesEqual(String messsage, Message[]
firstSet, Message[] secondSet)
+ throws JMSException {
+ assertEquals("Message count does not match: " + messsage,
firstSet.length, secondSet.length);
+ for (int i = 0; i < secondSet.length; i++) {
+ TextMessage m1 = (TextMessage)firstSet[i];
+ TextMessage m2 = (TextMessage)secondSet[i];
+ if (m1 != null) {
+ m1.getText();
+ }
+ if (m2 != null) {
+ m2.getText();
+ }
+ assertFalse("Message " + (i + 1) + " did not match : " + messsage
+ ": expected {" + m1
+ + "}, but was {" + m2 + "}", m1 == null ^ m2 == null);
+ assertEquals("Message " + (i + 1) + " did not match: " + messsage
+ ": expected {" + m1
+ + "}, but was {" + m2 + "}", m1.getText(),
m2.getText());
+ }
+ }
+
+
+ protected String getConsumerDestinationName() {
+ return getDestinationName();
+ }
+ protected String getProducerDestinationName() {
+ return getDestinationName();
+ }
+ protected String getDestinationName() {
+ return getName().replaceAll("[{}= @\\.]+", "_");
+ }
+
+ protected boolean topic = true;
+
+ protected Destination createDestination(String subject) {
+ return null;
+ }
+ protected Destination createDestination() {
+ return createDestination(getDestinationString());
+ }
+
+ /**
+ * Returns the name of the destination used in this test case
+ */
+ protected String getDestinationString() {
+ return getClass().getName() + "." + getName(true);
+ }
+
+
+ public static void recursiveDelete(File f) {
+ if (f.isDirectory()) {
+ File[] files = f.listFiles();
+ for (int i = 0; i < files.length; i++) {
+ recursiveDelete(files[i]);
+ }
+ }
+ f.delete();
+ }
+
+
+ static final private AtomicLong TEST_COUNTER = new AtomicLong();
+ public String userName;
+ public String password;
+ public String messageTextPrefix = "";
+
+
+ enum DestinationType {
+ QUEUE_TYPE,
+ TOPIC_TYPE,
+ TEMP_QUEUE_TYPE,
+ TEMP_TOPIC_TYPE
+ }
+
+ // /////////////////////////////////////////////////////////////////
+ //
+ // Test support methods.
+ //
+ // /////////////////////////////////////////////////////////////////
+ protected Destination createDestination(Session session, DestinationType
type) throws JMSException {
+ String testMethod = getName();
+ if( testMethod.indexOf(" ")>0 ) {
+ testMethod = testMethod.substring(0, testMethod.indexOf(" "));
+ }
+ String name = "TEST." + getClass().getName() + "."
+testMethod+"."+TEST_COUNTER.getAndIncrement();
+ switch (type) {
+ case QUEUE_TYPE:
+ return session.createQueue(name);
+ case TOPIC_TYPE:
+ return session.createTopic(name);
+ case TEMP_QUEUE_TYPE:
+ return session.createTemporaryQueue();
+ case TEMP_TOPIC_TYPE:
+ return session.createTemporaryTopic();
+ default:
+ throw new IllegalArgumentException("type: " + type);
+ }
+ }
+
+ protected void sendMessages(Destination destination, int count) throws
Exception {
+ Connection connection = getConnectionFactory().createConnection();
+ connection.start();
+ sendMessages(connection, destination, count);
+ connection.close();
+ }
+
+ protected void sendMessages(Connection connection, Destination
destination, int count) throws JMSException {
+ Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
+ sendMessages(session, destination, count);
+ session.close();
+ }
+
+ protected void sendMessages(Session session, Destination destination, int
count) throws JMSException {
+ MessageProducer producer = session.createProducer(destination);
+ for (int i = 0; i < count; i++) {
+ producer.send(session.createTextMessage(messageTextPrefix + i));
+ }
+ producer.close();
+ }
+
+
+ protected void safeClose(Connection c) {
+ try {
+ c.close();
+ } catch (Throwable e) {
+ }
+ }
+
+ protected void safeClose(Session s) {
+ try {
+ s.close();
+ } catch (Throwable e) {
+ }
+ }
+
+ protected void safeClose(MessageConsumer c) {
+ try {
+ c.close();
+ } catch (Throwable e) {
+ }
+ }
+
+ protected void safeClose(MessageProducer p) {
+ try {
+ p.close();
+ } catch (Throwable e) {
+ }
+ }
+
+ protected void profilerPause(String prompt) throws IOException {
+ if (System.getProperty("profiler") != null) {
+ pause(prompt);
+ }
+ }
+
+ protected void pause(String prompt) throws IOException {
+ System.out.println();
+ System.out.println(prompt + "> Press enter to continue: ");
+ while (System.in.read() != '\n') {
+ }
+ }
+
+}
Copied:
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JmsTopicTransactionTest.java
(from r1236537,
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/JmsTopicTransactionTest.java)
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JmsTopicTransactionTest.java?p2=activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JmsTopicTransactionTest.java&p1=activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/JmsTopicTransactionTest.java&r1=1236537&r2=1236538&rev=1236538&view=diff
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/JmsTopicTransactionTest.java
(original)
+++
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JmsTopicTransactionTest.java
Fri Jan 27 05:46:58 2012
@@ -42,7 +42,7 @@ public class JmsTopicTransactionTest ext
@Override
public void runBare() throws Throwable {
- if (broker instanceof StompBroker) {
+ if (brokerAdmin instanceof StompBrokerAdmin) {
// TODO - seem to have a broker hang on some of these tests when
STOMP is used
return;
}
Copied:
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JmsTransactionTestSupport.java
(from r1236537,
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/JmsTransactionTestSupport.java)
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JmsTransactionTestSupport.java?p2=activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JmsTransactionTestSupport.java&p1=activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/JmsTransactionTestSupport.java&r1=1236537&r2=1236538&rev=1236538&view=diff
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/JmsTransactionTestSupport.java
(original)
+++
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/JmsTransactionTestSupport.java
Fri Jan 27 05:46:58 2012
@@ -22,15 +22,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.jms.*;
-import java.net.URI;
-import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
-public abstract class JmsTransactionTestSupport extends JmsTestSupport
implements MessageListener {
+public abstract class JmsTransactionTestSupport extends JmsTestBase implements
MessageListener {
private static final Logger LOG =
LoggerFactory.getLogger(JmsTransactionTestSupport.class);
private static final int MESSAGE_COUNT = 5;
@@ -49,34 +47,12 @@ public abstract class JmsTransactionTest
private List<Message> ackMessages = new ArrayList<Message>(MESSAGE_COUNT);
private boolean resendPhase;
- public JmsTransactionTestSupport() {
- super();
- }
-
- public void initCombos() {
- super.initCombos();
- }
-
- /*
- public JmsTransactionTestSupport(String name) {
- super(name);
- }
- */
-
- /*
- * (non-Javadoc)
- *
- * @see junit.framework.TestCase#setUp()
- */
protected void setUp() throws Exception {
- broker.start();
- //broker.waitUntilStarted();
-
+ super.setUp();
resourceProvider = getJmsResourceProvider();
topic = resourceProvider.isTopic();
// We will be using transacted sessions.
setSessionTransacted();
- connectionFactory = newConnectionFactory();
reconnect();
}
@@ -100,25 +76,6 @@ public abstract class JmsTransactionTest
session.rollback();
}
- /*
- * (non-Javadoc)
- *
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- LOG.info("Closing down connection");
-
- session.close();
- session = null;
- connection.stop();
- connection = null;
-
- broker.stop();
- broker = null;
-
- LOG.info("Connection closed.");
- }
-
protected abstract JmsResourceProvider getJmsResourceProvider();
protected Connection connection() throws Exception {
@@ -621,13 +578,12 @@ public abstract class JmsTransactionTest
* @throws javax.jms.JMSException
*/
protected void reconnect() throws Exception {
-
if (connection != null) {
// Close the prev connection.
connection.close();
}
session = null;
- connection = resourceProvider.createConnection(connectionFactory);
+ connection = resourceProvider.createConnection(getConnectionFactory());
reconnectSession();
connection.start();
}
@@ -643,7 +599,7 @@ public abstract class JmsTransactionTest
}
session = resourceProvider.createSession(connection);
- destination = resourceProvider.createDestination(session,
getSubject());
+ destination = resourceProvider.createDestination(session,
getDestinationName());
producer = resourceProvider.createProducer(session, destination);
consumer = resourceProvider.createConsumer(session, destination);
}
Added:
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/OpenwireBrokerAdmin.java
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/OpenwireBrokerAdmin.java?rev=1236538&view=auto
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/OpenwireBrokerAdmin.java
(added)
+++
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/OpenwireBrokerAdmin.java
Fri Jan 27 05:46:58 2012
@@ -0,0 +1,40 @@
+/**
+ * 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.apollo;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.apollo.broker.Broker;
+import static java.lang.String.*;
+
+import javax.jms.ConnectionFactory;
+
+/**
+ * <p>
+ * </p>
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+public class OpenwireBrokerAdmin extends BrokerAdmin {
+
+ @Override
+ ConnectionFactory getConnectionFactory(Object broker) {
+ ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
+ factory.setBrokerURL(format("tcp://localhost:%s", port(broker)));
+ return factory;
+ }
+
+}
Added:
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/StompBrokerAdmin.java
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/StompBrokerAdmin.java?rev=1236538&view=auto
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/StompBrokerAdmin.java
(added)
+++
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/StompBrokerAdmin.java
Fri Jan 27 05:46:58 2012
@@ -0,0 +1,46 @@
+/**
+ * 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.apollo;
+
+import org.fusesource.stomp.jms.StompJmsConnectionFactory;
+
+import javax.jms.ConnectionFactory;
+
+import static java.lang.String.format;
+
+/**
+ * <p>
+ * </p>
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+public class StompBrokerAdmin extends BrokerAdmin {
+
+ @Override
+ ConnectionFactory getConnectionFactory(Object broker) {
+ StompJmsConnectionFactory factory = new StompJmsConnectionFactory();
+ factory.setBrokerURI(format("tcp://localhost:%s", port(broker)));
+ return factory;
+ }
+
+// def broker_config_uri = "xml:classpath:apollo-stomp.xml"
+//
+// protected def getInitialContextFactoryClass =
"org.fusesource.stompjms.jndi.StompJmsInitialContextFactory"
+//
+// def getConnectionUri = "tcp://localhost:%s".format(port);
+
+}
Copied:
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/test/JmsResourceProvider.java
(from r1236537,
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/test/JmsResourceProvider.java)
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/test/JmsResourceProvider.java?p2=activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/test/JmsResourceProvider.java&p1=activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/test/JmsResourceProvider.java&r1=1236537&r2=1236538&rev=1236538&view=diff
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-itests/src/test/scala/org/apache/activemq/apollo/test/JmsResourceProvider.java
(original)
+++
activemq/activemq-apollo/trunk/apollo-itests/src/test/java/org/apache/activemq/apollo/test/JmsResourceProvider.java
Fri Jan 27 05:46:58 2012
@@ -16,10 +16,9 @@
*/
package org.apache.activemq.apollo.test;
-import org.apache.activemq.apollo.TestSupport;
+import org.apache.activemq.apollo.JmsTestBase;
import javax.jms.*;
-import java.util.regex.Pattern;
/**
*
@@ -32,9 +31,9 @@ public class JmsResourceProvider {
private int deliveryMode = DeliveryMode.PERSISTENT;
private String durableName = "DummyName";
private String clientID = getClass().getName();
- private TestSupport support;
+ private JmsTestBase support;
- public JmsResourceProvider(TestSupport support) {
+ public JmsResourceProvider(JmsTestBase support) {
this.support = support;
}
@@ -44,7 +43,7 @@ public class JmsResourceProvider {
* @see
org.apache.activemq.apollo.test.JmsResourceProvider#createConnectionFactory()
*/
public ConnectionFactory createConnectionFactory() throws Exception {
- return support.createConnectionFactory();
+ return support.getConnectionFactory();
}
/**
Copied:
activemq/activemq-apollo/trunk/apollo-itests/src/test/resources/apollo.xml
(from r1236537,
activemq/activemq-apollo/trunk/apollo-itests/src/test/resources/apollo-stomp.xml)
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-itests/src/test/resources/apollo.xml?p2=activemq/activemq-apollo/trunk/apollo-itests/src/test/resources/apollo.xml&p1=activemq/activemq-apollo/trunk/apollo-itests/src/test/resources/apollo-stomp.xml&r1=1236537&r2=1236538&rev=1236538&view=diff
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-itests/src/test/resources/apollo-stomp.xml
(original)
+++ activemq/activemq-apollo/trunk/apollo-itests/src/test/resources/apollo.xml
Fri Jan 27 05:46:58 2012
@@ -20,11 +20,9 @@
<virtual_host id="default" purge_on_startup="true" auto_create_queues="true">
<host_name>localhost</host_name>
-
<queue name="mirrored.**" mirrored="true"/>
-
</virtual_host>
- <connector id="tcp" protocol="stomp" bind="tcp://0.0.0.0:0"/>
+ <connector id="tcp" bind="tcp://0.0.0.0:0"/>
</broker>
\ No newline at end of file
Modified:
activemq/activemq-apollo/trunk/apollo-itests/src/test/resources/log4j.properties
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-itests/src/test/resources/log4j.properties?rev=1236538&r1=1236537&r2=1236538&view=diff
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-itests/src/test/resources/log4j.properties
(original)
+++
activemq/activemq-apollo/trunk/apollo-itests/src/test/resources/log4j.properties
Fri Jan 27 05:46:58 2012
@@ -19,14 +19,22 @@
# The logging properties used during tests..
#
log4j.rootLogger=WARN, console, file
-log4j.logger.org.apache.activemq=TRACE
-log4j.logger.org.fusesource=TRACE
+
+#
+# Comment/Uncomment to enabled debugging in different areas.
+log4j.logger.org.apache.activemq.apollo=TRACE
+#log4j.logger.org.apache.activemq.apollo.broker=TRACE
+#log4j.logger.org.apache.activemq.apollo.broker.store=TRACE
+#log4j.logger.org.apache.activemq.apollo.openwire=TRACE
+#log4j.logger.org.apache.activemq.apollo.stomp=TRACE
+#log4j.logger.org.apache.activemq.apollo.web=TRACE
+#log4j.logger.org.apache.activemq.apollo.cli=TRACE
# Console will only display warnnings
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-5p | %t | %m%n
-log4j.appender.console.threshold=WARN
+log4j.appender.console.threshold=TRACE
# File appender will contain all info messages
log4j.appender.file=org.apache.log4j.FileAppender