diff --git a/README.md b/README.md index 3c7ec50f3b..e42b119d42 100644 --- a/README.md +++ b/README.md @@ -1,107 +1,27 @@ # ActiveMQ Artemis -This file describes some minimum 'stuff one needs to know' to get -started coding in this project. +This file describes some minimum 'stuff one needs to know' to get started coding in this project. ## Source -The project's source code is hosted at: - -https://git-wip-us.apache.org/repos/asf/activemq-artemis.git - -### Git usage: - -Pull requests should be merged without fast forwards '--no-ff'. An easy way to achieve that is to use - -```% git config branch.master.mergeoptions --no-ff``` - -## Maven - -The minimum required Maven version is 3.0.0. - -Do note that there are some compatibility issues with Maven 3.X still -unsolved [1]. This is specially true for the 'site' plugin [2]. - -[1]: -[2]: - - -## building the distribution - -If you want to build the full release with documentation, Javadocs and the full web site then run the following: - -```% mvn -Prelease package``` - -If you want to install it to your local maven repo then run - -```% mvn -Prelease install``` - -The full release uses gitbook to build a static website from the documentation, if you don't have gitbook installed then - install gitbook using npm - -```npm install -g gitbook gitbook-cli``` - -### Installing NPM - -If you don't have npm installed then you would need to install it first. - -#### On Fedora - -```yum install npm``` - -#### On Mac-OS - -The easiest way would be through brew [brew] - -You first install brew using the instructions on the [brew] website. - -After you installed brew you can install npm by: - -```brew install npm``` - -[brew]: - -#### Build without docs - - -It is possible to build a distribution with out the manuals and javadocs if you dont have or want gitbook installed, -simply run - -```% mvn package``` - -## Tests - -To run the unit tests: - -```% mvn -Ptests test``` - -Generating reports from unit tests: - -```% mvn install site``` - - -Running tests individually - -```% mvn -Ptests -DfailIfNoTests=false -Dtest= test ``` - -where <test-name> is the name of the Test class without its package name - +For details about the modifying the code, building the project, running tests, IDE integration, etc. see +our [Hacking Guide](./docs/hacking-guide/en/README.md). ## Examples To run an example firstly make sure you have run -```% mvn -Prelease install``` + $ mvn -Prelease install If the project version has already been released then this is unnecessary. then you will need to set the following maven options, on Linux by -```export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=512m"``` + $ export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=512m" and the finally run the examples by -```% mvn verify``` + $ mvn verify You can also run individual examples by running the same command from the directory of which ever example you want to run. NB for this make sure you have installed examples/common. @@ -110,241 +30,5 @@ NB for this make sure you have installed examples/common. If you are trying to copy the examples somewhere else and modifying them. Consider asking Maven to explicitly list all the dependencies: -``` -# if trying to modify the 'topic' example: -cd examples/jms/topic && mvn dependency:list -``` - -## Eclipse - -We recommend using Eclipse Kepler (4.3), due to the built-in support -for Maven and Git. Note that there are still some Maven plugins used -by sub-projects (e.g. documentation) which are not supported even in -Eclipse Kepler (4.3). - -Eclipse [m2e] is already included in "Eclipse IDE for Java Developers", or it -can be installed from [Eclipse Kepler release repository]. - -[m2e]: http://eclipse.org/m2e/ -[Eclipse Kepler release repository]: http://download.eclipse.org/releases/kepler - -## IntelliJ IDEA - -### Importing the Project - -The following steps show how to import ActiveMQ Artemis source into IntelliJ IDEA and setup the correct maven profile to allow -running of JUnit tests from within the IDE. (Steps are based on version: 13.1.4) - -* File --> Import Project --> Select the root directory of the ActiveMQ Artemis source folder. --> Click OK - -This should open the import project wizard. From here: - -* Select "Import from existing model" toggle box, then select Maven from the list box below. Click Next. -* Leave the defaults set on this page and click next. -* On the "Select profiles page", select the checkbox next to "tests" and click next. -* From here the default settings should suffice. Continue through the wizard, clicking next until the wizard is complete. - -Once the project has been imported and IDEA has caught up importing all the relevant dependencies, you should be able to -run JUnit tests from with the IDE. Select any test class in the tests -> integration tests folder. Right click on the -class in the project tab and click "Run ". If the "Run " option is present then you're all set to go. - - -### Style Templates for Idea - -We have shared the style templates that are good for this project. If you want to apply them use these steps: - -* File->Import Settings -* Select the file under ./artemis-cloned-folder/etc/IDEA-style.jar -* Select both Code Style Templates and File templates (it's the default option) -* Select OK and restart Idea - -### Issue: My JUnit tests are not runnable with in the IDE. - -If the "Run " or "Run all tests" option is not present. It is likely that the default profile has not been -imported properly. To (re)import the "tests" Maven profile in an existing project. - -* Open the Maven Projects Tool Window: View -> Tool Windows -> Maven Projects -* Select the "profiles" drop down -* Unselect then reselect the checkbox next to "tests". -* Click on the "Reimport all maven projects" button in the top left hand corner of the window. (It looks like a ciruclar -blue arrow. -* Wait for IDEA to reload and try running a JUnit test again. The option to run should now be present. - -### Annotation Pre-Processing - -ActiveMQ Artemis uses [JBoss Logging] and that requires source code generation from Java -annotations. In order for it to 'just work' in Eclipse you need to install the -_Maven Integration for Eclipse JDT Annotation Processor Toolkit_ [m2e-apt]. See -this [JBoss blog post] for details. - -[JBoss Logging]: -[m2e-apt]: https://github.com/jbosstools/m2e-apt -[JBoss blog post]: https://community.jboss.org/en/tools/blog/2012/05/20/annotation-processing-support-in-m2e-or-m2e-apt-100-is-out - -### M2E Connector for Javacc-Maven-Plugin - -Eclipse Indigo (3.7) has out-of-the-box support for it. - -As of this writing, Eclipse Kepler (4.3) still lacks support for -Maven's javacc plugin. The available [m2e connector for -javacc-maven-plugin] requires a downgrade of Maven components to be -installed. manual installation instructions (as of this writing you -need to use the development update site). See [this post] for how to -do this with Eclipse Juno (4.2). - -The current recommended solution for Eclipse Kepler is to mark -`javacc-maven-plugin` as ignored by Eclipse, run Maven from the -command line and then modify the project `activemq-core-client` adding -the folder `target/generated-sources/javacc` to its build path. - -[m2e connector for javacc-maven-plugin]: https://github.com/objectledge/maven-extensions -[this post]: -http://dev.eclipse.org/mhonarc/lists/m2e-users/msg02725.html - -### Use _Project Working Sets_ - -Importing all ActiveMQ Artemis subprojects will create _too many_ projects in Eclipse, -cluttering your _Package Explorer_ and _Project Explorer_ views. One way to address -that is to use [Eclipse's Working Sets] feature. A good introduction to it can be -found at a [Dzone article on Eclipse Working Sets]. - -[Eclipse's Working Sets]: http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Fconcepts%2Fcworkset.htm -[Dzone article on Eclipse Working Sets]: http://eclipse.dzone.com/articles/categorise-projects-package - -### Code Formatting - -Eclipse code formatting and (basic) project configuration files can be found at -the ```etc/``` folder. You should manually copy them _after importing all your -projects_: - -``` -for settings_dir in `find . -type d -name .settings`; do - \cp -v etc/org.eclipse.jdt.* $settings_dir -done -``` - -Do not use the [maven-eclipse-plugin] to copy the files as it conflicts with [m2e]. - -[maven-eclipse-plugin]: https://maven.apache.org/plugins/maven-eclipse-plugin/ -[m2e]: http://eclipse.org/m2e/ - -## Committing Changes - -### Repositories - -The code repository for ActiveMQ Artemis is hosted by Apache org and lives here: https://git-wip-us.apache.org/repos/asf/activemq-artemis.git. - -We also host a mirror of the ActiveMQ Artemis repository on GitHub: https://github.com/apache/activemq-artemis. We use this mirror for all code submissions and reviews. To submit code to ActiveMQ Artemis please open a Pull Request as outlined as part of the GitHub workflow described here: https://guides.github.com/introduction/flow/index.html. Once a pull request is opened it will be reviewed and commented on. Any further changes as a result of comments / review process should be addressed and reflected in the original pull request as outlined in the GitHub workflow. When the pull request has went through the review process and ready to merge, the reviewer should comment with "Ack, Ready to Push". Once an Ack message is received one of the ActiveMQ Artemis core team members will push the changes to upstream Apache ActiveMQ Artemis repository and close the pull request. - -### Commit Messages - -We follow the 50/72 git commit message format. An ActiveMQ Artemis commit message should be formatted in the following manner: - -* Add the ACTIVEMQ6 JIRA or Bugzilla reference (if one exists) followed by a brief description of the change in the first line. -* Insert a single blank line after the first line. -* Provide a detailed description of the change in the following lines, breaking paragraphs where needed. -* The first line should be limited to 50 characters -* Subsequent lines should be wrapped at 72 characters. - -An example correctly formatted commit message: - -``` -ACTIVEMQ6-123 Add new commit msg format to README - -Adds a description of the new commit message format as well as examples -of well formatted commit messages to the README.md. This is required -to enable developers to quickly identify what the commit is intended to -do and why the commit was added. -``` -### Adding New Dependencies - -Due to incompatibilities between some open source licenses and the Apache v2.0 license (that this project is licensed under) -care must be taken when adding new dependencies to the project. The Apache Software Foundation 3rd party - licensing policy has more information here: http://www.apache.org/legal/3party.html - -To keep track of all licenses in ActiveMQ Artemis, new dependencies must be added in either the top level pom.xml or in test/pom.xml -(depending on whether this is a test only dependency or if it is used in the main code base). The dependency should be -added under the dependency management section with version and labelled with a comment highlighting the license for the -dependency version. See existing dependencies in the main pom.xml for examples. The dependency can then be added to -individual ActiveMQ Artemis modules *without* the version specified (the version is implied from the dependency management -section of the top level pom). This allows ActiveMQ Artemis developers to keep track of all dependencies and licenses. - -### Core Contributers - -Core ActiveMQ Artemis members have write access to the Apache ActiveMQ Artemis repositories and will be responsible for Ack'ing and pushing commits contributed via pull requests on GitHub. The follow steps can be used as an example for how to set up relevant ActiveMQ Artemis repositories for reviewing and pushing changes. - -To setup repositories for reviewing and pushing: - -```bash - # Clone the GitHub Mirror of ActiveMQ Artemis Repo: - git clone git@github.com:apache/activemq-artemis.git - - # Add the following section to your /.git/config statement to fetch all pull requests sent to the GitHub mirror. Note that the remote name for git@github.com:apache/activemq-artemis.git may be different. Be sure to edit all references to the remote name. In this case "activemq". - - [remote "origin"] - url = git@github.com:apache/activemq-artemis.git - fetch = +refs/heads/*:refs/remotes/origin/* - fetch = +refs/pull/*/head:refs/remotes/origin/pr/* - - - # Add the Apache repository as a remote - git remote add upstream https://git-wip-us.apache.org/repos/asf/activemq-artemis.git - - # Fetch - git fetch --all -``` - -To push commits from a pull request to the apache repository: - -```bash - cd - - # Download all the remote branches etc... including all the pull requests. - git fetch --all - - # Checkout the pull request you wish to review - git checkout pr/2 - - # Review is done... READY TO MERGE. - - # Check out the master branch. - git checkout master - - # Ensure you are up to date - git pull - - # Create a new merge commit from the - git merge --no-ff pr/2 - - # IMPORTANT: In this commit message be sure to write something along the lines of: "Merge Pull Request #2" Where 2 is the Pull Request ID. "#2" shows up as a link in the GitHub UI for navigating to the PR from the commit message. - - # Pushes to the upstream repo. - git push upstream master -``` - -#### Notes: - -The GitHub mirror repository is cloning the Apache ActiveMQ Artemis repository (The root repository). There maybe a slight delay between when a commit is pushed to the Apache repo and when that commit is reflected in the GitHub mirror. This may cause some difficulty when trying to push a PR to upstream (Apache) that has been merged on an out of date GitHub (mirror) master. You can wait for the mirror to update before performing the steps above. A solution to this is to change local master branch to track the upstream (Apache) master, rather than GitHub (mirror) master by editing your config to look like this: - -```bash - [branch "master"] - remote = upstream - merge = refs/heads/master -``` - -Where upstream points to the Apache Repo. - -If you'd like master to always track GitHub master, then another way to acheive this is to add another branch that tracks upstream master and push from that branch to upstream master e.g. - -```bash - # .git/config entry - [branch "umaster"] - remote = upstream - merge = refs/heads/master - - git checkout umaster - git pull - git merge --no-ff pr/2 - git push upstream umaster:master # Push local branch umaster to upstream branch master. -``` - + # if trying to modify the 'topic' example: + cd examples/jms/topic && mvn dependency:list diff --git a/artemis-core-client/src/test/java/org/apache/activemq/artemis/tests/CoreUnitTestCase.java b/artemis-core-client/src/test/java/org/apache/activemq/artemis/tests/CoreUnitTestCase.java deleted file mode 100644 index 3bdc561f2e..0000000000 --- a/artemis-core-client/src/test/java/org/apache/activemq/artemis/tests/CoreUnitTestCase.java +++ /dev/null @@ -1,89 +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.artemis.tests; - - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.apache.activemq.artemis.core.client.ActiveMQClientLogger; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.rules.TestRule; -import org.junit.rules.TestWatcher; -import org.junit.runner.Description; - -public abstract class CoreUnitTestCase extends Assert -{ - public static void assertEqualsByteArrays(final byte[] expected, final byte[] actual) - { - for (int i = 0; i < expected.length; i++) - { - Assert.assertEquals("byte at index " + i, expected[i], actual[i]); - } - } - - private static final ActiveMQClientLogger log = ActiveMQClientLogger.LOGGER; - - @Rule - public TestRule watcher = new TestWatcher() - { - @Override - protected void starting(Description description) - { - log.info(String.format("#*#*# Starting test: %s()...", description.getMethodName())); - } - - @Override - protected void finished(Description description) - { - log.info(String.format("#*#*# Finished test: %s()...", description.getMethodName())); - } - }; - - /** - * Asserts that latch completes within a (rather large interval). - *

- * Use this instead of just calling {@code latch.await()}. Otherwise your test may hang the whole - * test run if it fails to count-down the latch. - * - * @param latch - * @throws InterruptedException - */ - public static void waitForLatch(CountDownLatch latch) throws InterruptedException - { - assertTrue("Latch has got to return within a minute", latch.await(1, TimeUnit.MINUTES)); - } - - public static int countOccurrencesOf(String str, String sub) - { - if (str == null || sub == null || str.length() == 0 || sub.length() == 0) - { - return 0; - } - int count = 0; - int pos = 0; - int idx; - while ((idx = str.indexOf(sub, pos)) != -1) - { - ++count; - pos = idx + sub.length(); - } - return count; - } - -} diff --git a/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/TimeAndCounterIDGeneratorTest.java b/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/TimeAndCounterIDGeneratorTest.java index d97fafc81f..995b65bb38 100644 --- a/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/TimeAndCounterIDGeneratorTest.java +++ b/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/TimeAndCounterIDGeneratorTest.java @@ -16,16 +16,13 @@ */ package org.apache.activemq.artemis.util; +import org.apache.activemq.artemis.utils.ConcurrentHashSet; +import org.apache.activemq.artemis.utils.TimeAndCounterIDGenerator; +import org.junit.Assert; import org.junit.Test; import java.util.concurrent.CountDownLatch; - -import org.junit.Assert; - - -import org.apache.activemq.artemis.tests.CoreUnitTestCase; -import org.apache.activemq.artemis.utils.ConcurrentHashSet; -import org.apache.activemq.artemis.utils.TimeAndCounterIDGenerator; +import java.util.concurrent.TimeUnit; public class TimeAndCounterIDGeneratorTest extends Assert { @@ -105,7 +102,7 @@ public class TimeAndCounterIDGeneratorTest extends Assert try { latchAlign.countDown(); - CoreUnitTestCase.waitForLatch(latchStart); + assertTrue("Latch has got to return within a minute", latchStart.await(1, TimeUnit.MINUTES)); long lastValue = 0L; for (int i = 0; i < NUMBER_OF_IDS; i++) @@ -136,7 +133,7 @@ public class TimeAndCounterIDGeneratorTest extends Assert arrays[i].start(); } - CoreUnitTestCase.waitForLatch(latchAlign); + assertTrue("Latch has got to return within a minute", latchAlign.await(1, TimeUnit.MINUTES)); latchStart.countDown(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java index e4396c2b90..51fcb0194a 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java @@ -359,4 +359,7 @@ public interface ActiveMQMessageBundle @Message(id = 119111, value = "Too many queues created by user ''{0}''. Queues allowed: {1}.", format = Message.Format.MESSAGE_FORMAT) ActiveMQSessionCreationException queueLimitReached(String username, int limit); + + @Message(id = 119112, value = "Cannot set MBeanServer during startup or while started") + IllegalStateException cannotSetMBeanserver(); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java index 18a3ce1bba..7790812d7c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java @@ -48,6 +48,8 @@ import org.apache.activemq.artemis.spi.core.protocol.SessionCallback; import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager; import org.apache.activemq.artemis.utils.ExecutorFactory; +import javax.management.MBeanServer; + /** * This interface defines the internal interface of the ActiveMQ Artemis Server exposed to other components * of the server. @@ -278,4 +280,6 @@ public interface ActiveMQServer extends ActiveMQComponent HAPolicy getHAPolicy(); void setHAPolicy(HAPolicy haPolicy); + + void setMBeanServer(MBeanServer mBeanServer); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java index adfa348279..6d17703c0e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java @@ -183,7 +183,7 @@ public class ActiveMQServerImpl implements ActiveMQServer private final Configuration configuration; - private final MBeanServer mbeanServer; + private MBeanServer mbeanServer; private volatile SecurityStore securityStore; @@ -519,6 +519,16 @@ public class ActiveMQServerImpl implements ActiveMQServer this.haPolicy = haPolicy; } + @Override + public void setMBeanServer(MBeanServer mbeanServer) + { + if (state == SERVER_STATE.STARTING || state == SERVER_STATE.STARTED) + { + throw ActiveMQMessageBundle.BUNDLE.cannotSetMBeanserver(); + } + this.mbeanServer = mbeanServer; + } + public ExecutorService getThreadPool() { return threadPool; @@ -2226,7 +2236,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { File journalDir = new File(configuration.getJournalDirectory()); - if (!journalDir.exists()) + if (!journalDir.exists() && configuration.isPersistenceEnabled()) { if (configuration.isCreateJournalDir()) { diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java index de509150bb..9bfc3a3b85 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java @@ -15,10 +15,17 @@ * limitations under the License. */ package org.apache.activemq.artemis.core.config.impl; -import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; -import org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration; -import org.junit.Before; +import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration; +import org.apache.activemq.artemis.core.journal.impl.JournalConstants; +import org.apache.activemq.artemis.core.server.JournalType; +import org.apache.activemq.artemis.tests.util.RandomUtil; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; +import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import java.io.ByteArrayInputStream; @@ -26,16 +33,7 @@ import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import org.junit.Assert; - -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.core.config.Configuration; -import org.apache.activemq.artemis.core.journal.impl.JournalConstants; -import org.apache.activemq.artemis.core.server.JournalType; -import org.apache.activemq.artemis.tests.util.RandomUtil; -import org.apache.activemq.artemis.tests.util.UnitTestCase; - -public class ConfigurationImplTest extends UnitTestCase +public class ConfigurationImplTest extends ServiceTestBase { protected Configuration conf; diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationParserTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationParserTest.java index 1c94a45468..6ee3fa40d5 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationParserTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationParserTest.java @@ -16,20 +16,20 @@ */ package org.apache.activemq.artemis.core.config.impl; +import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; +import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.core.config.FileDeploymentManager; +import org.apache.activemq.artemis.core.deployers.impl.FileConfigurationParser; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; +import org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec; +import org.junit.Test; + import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; -import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; -import org.apache.activemq.artemis.core.config.Configuration; -import org.apache.activemq.artemis.core.config.FileDeploymentManager; -import org.apache.activemq.artemis.core.deployers.impl.FileConfigurationParser; -import org.apache.activemq.artemis.tests.util.UnitTestCase; -import org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec; -import org.junit.Test; - -public class FileConfigurationParserTest extends UnitTestCase +public class FileConfigurationParserTest extends ServiceTestBase { /** * These "InvalidConfigurationTest*.xml" files are modified copies of {@value diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/HAPolicyConfigurationTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/HAPolicyConfigurationTest.java index 57a7b286e8..8da767c2df 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/HAPolicyConfigurationTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/HAPolicyConfigurationTest.java @@ -16,6 +16,7 @@ */ package org.apache.activemq.artemis.core.config.impl; +import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.FileDeploymentManager; import org.apache.activemq.artemis.core.server.cluster.ha.ColocatedPolicy; import org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy; @@ -25,21 +26,20 @@ import org.apache.activemq.artemis.core.server.cluster.ha.ReplicatedPolicy; import org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy; import org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreMasterPolicy; import org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreSlavePolicy; +import org.apache.activemq.artemis.core.server.impl.Activation; +import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl; import org.apache.activemq.artemis.core.server.impl.ColocatedActivation; import org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation; import org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation; import org.apache.activemq.artemis.core.server.impl.SharedNothingLiveActivation; -import org.apache.activemq.artemis.core.config.Configuration; -import org.apache.activemq.artemis.core.server.impl.Activation; -import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl; import org.apache.activemq.artemis.core.server.impl.SharedStoreBackupActivation; import org.apache.activemq.artemis.core.server.impl.SharedStoreLiveActivation; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Test; import java.util.List; -public class HAPolicyConfigurationTest extends UnitTestCase +public class HAPolicyConfigurationTest extends ServiceTestBase { @Test public void liveOnlyTest() throws Exception diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/WrongRoleFileConfigurationParserTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/WrongRoleFileConfigurationParserTest.java index 9ec1bc39aa..d24b5e6059 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/WrongRoleFileConfigurationParserTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/WrongRoleFileConfigurationParserTest.java @@ -16,21 +16,21 @@ */ package org.apache.activemq.artemis.core.config.impl; -import java.io.ByteArrayInputStream; -import java.nio.charset.StandardCharsets; - import org.apache.activemq.artemis.core.deployers.impl.FileConfigurationParser; import org.apache.activemq.artemis.logs.AssertionLoggerHandler; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; +import java.io.ByteArrayInputStream; +import java.nio.charset.StandardCharsets; + /** * When running this test from an IDE add this to the test command line so that the AssertionLoggerHandler works properly: * -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Dlogging.configuration=file:/tests/config/logging.properties */ -public class WrongRoleFileConfigurationParserTest extends UnitTestCase +public class WrongRoleFileConfigurationParserTest extends ServiceTestBase { @BeforeClass public static void prepareLogger() diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/group/impl/ClusteredResetMockTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/group/impl/ClusteredResetMockTest.java index 745306489b..2959eb8e5a 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/group/impl/ClusteredResetMockTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/group/impl/ClusteredResetMockTest.java @@ -17,12 +17,6 @@ package org.apache.activemq.artemis.core.server.group.impl; -import javax.management.ObjectName; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; @@ -39,8 +33,8 @@ import org.apache.activemq.artemis.core.persistence.StorageManager; import org.apache.activemq.artemis.core.postoffice.PostOffice; import org.apache.activemq.artemis.core.remoting.server.RemotingService; import org.apache.activemq.artemis.core.security.Role; -import org.apache.activemq.artemis.core.server.Divert; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.core.server.Divert; import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.server.QueueFactory; import org.apache.activemq.artemis.core.server.ServerMessage; @@ -54,18 +48,24 @@ import org.apache.activemq.artemis.core.settings.HierarchicalRepository; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.core.transaction.ResourceManager; import org.apache.activemq.artemis.spi.core.remoting.Acceptor; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.utils.ConcurrentHashSet; import org.apache.activemq.artemis.utils.ReusableLatch; import org.junit.Assert; import org.junit.Test; +import javax.management.ObjectName; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + /** * this is testing the case for resending notifications from RemotingGroupHandler * There is a small window where you could receive notifications wrongly * this test will make sure the component would play well with that notification */ -public class ClusteredResetMockTest extends UnitTestCase +public class ClusteredResetMockTest extends ServiceTestBase { public static final SimpleString ANYCLUSTER = SimpleString.toSimpleString("anycluster"); diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/settings/AddressSettingsTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/settings/AddressSettingsTest.java index 676aa20493..563022c407 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/settings/AddressSettingsTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/settings/AddressSettingsTest.java @@ -19,11 +19,11 @@ package org.apache.activemq.artemis.core.settings; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Assert; import org.junit.Test; -public class AddressSettingsTest extends UnitTestCase +public class AddressSettingsTest extends ServiceTestBase { @Test public void testDefaults() diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/settings/RepositoryTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/settings/RepositoryTest.java index 277b26e864..97c65443b5 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/settings/RepositoryTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/settings/RepositoryTest.java @@ -16,18 +16,18 @@ */ package org.apache.activemq.artemis.core.settings; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.concurrent.atomic.AtomicInteger; - import org.apache.activemq.artemis.core.security.Role; import org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -public class RepositoryTest extends UnitTestCase +import java.util.ArrayList; +import java.util.HashSet; +import java.util.concurrent.atomic.AtomicInteger; + +public class RepositoryTest extends ServiceTestBase { HierarchicalRepository> securityRepository; diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/RemoveFolder.java b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/RemoveFolder.java index e068467f2d..66a41c6f15 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/RemoveFolder.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/RemoveFolder.java @@ -38,6 +38,6 @@ public class RemoveFolder extends ExternalResource */ protected void after() { - UnitTestCase.deleteDirectory(new File(folderName)); + ServiceTestBase.deleteDirectory(new File(folderName)); } } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ServiceTestBase.java b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ServiceTestBase.java index 3299edbaec..baeae3ceb9 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ServiceTestBase.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ServiceTestBase.java @@ -16,32 +16,29 @@ */ package org.apache.activemq.artemis.tests.util; -import javax.management.MBeanServer; -import java.io.File; -import java.lang.management.ManagementFactory; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - +import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQException; +import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; +import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.Pair; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; +import org.apache.activemq.artemis.core.asyncio.impl.AsynchronousFileImpl; +import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl; import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal; +import org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl; import org.apache.activemq.artemis.core.client.impl.Topology; import org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl; +import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration; import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; import org.apache.activemq.artemis.core.journal.RecordInfo; import org.apache.activemq.artemis.core.journal.SequentialFileFactory; @@ -50,64 +47,1144 @@ import org.apache.activemq.artemis.core.journal.impl.JournalImpl; import org.apache.activemq.artemis.core.journal.impl.JournalReaderCallback; import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory; import org.apache.activemq.artemis.core.paging.PagingStore; +import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl; import org.apache.activemq.artemis.core.postoffice.Binding; import org.apache.activemq.artemis.core.postoffice.Bindings; import org.apache.activemq.artemis.core.postoffice.PostOffice; import org.apache.activemq.artemis.core.postoffice.QueueBinding; import org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding; +import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory; +import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; import org.apache.activemq.artemis.core.remoting.impl.invm.InVMRegistry; import org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants; +import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory; +import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnector; +import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; import org.apache.activemq.artemis.core.server.ActiveMQComponent; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; import org.apache.activemq.artemis.core.server.ActiveMQServers; +import org.apache.activemq.artemis.core.server.JournalType; +import org.apache.activemq.artemis.core.server.MessageReference; import org.apache.activemq.artemis.core.server.NodeManager; import org.apache.activemq.artemis.core.server.Queue; +import org.apache.activemq.artemis.core.server.ServerMessage; import org.apache.activemq.artemis.core.server.cluster.ClusterConnection; +import org.apache.activemq.artemis.core.server.cluster.ClusterManager; import org.apache.activemq.artemis.core.server.cluster.RemoteQueueBinding; import org.apache.activemq.artemis.core.server.impl.Activation; import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl; +import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl; import org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation; import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.core.transaction.impl.XidImpl; import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager; import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManagerImpl; +import org.apache.activemq.artemis.utils.OrderedExecutorFactory; import org.apache.activemq.artemis.utils.UUIDGenerator; import org.junit.After; import org.junit.Assert; import org.junit.Before; +import org.junit.Rule; +import org.junit.rules.TemporaryFolder; +import org.junit.rules.TestName; +import org.junit.rules.TestRule; +import org.junit.rules.TestWatcher; +import org.junit.runner.Description; + +import javax.naming.Context; +import javax.transaction.xa.XAException; +import javax.transaction.xa.Xid; +import java.beans.BeanInfo; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.management.ManagementFactory; +import java.lang.ref.Reference; +import java.lang.ref.WeakReference; +import java.net.ServerSocket; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; /** * Base class with basic utilities on starting up a basic server */ -public abstract class ServiceTestBase extends UnitTestCase +public abstract class ServiceTestBase extends Assert { + public static final String TARGET_TMP = "./target/tmp"; + public static final String INVM_ACCEPTOR_FACTORY = InVMAcceptorFactory.class.getCanonicalName(); + public static final String INVM_CONNECTOR_FACTORY = InVMConnectorFactory.class.getCanonicalName(); + public static final String NETTY_ACCEPTOR_FACTORY = NettyAcceptorFactory.class.getCanonicalName(); + public static final String NETTY_CONNECTOR_FACTORY = NettyConnectorFactory.class.getCanonicalName(); + public static final String CLUSTER_PASSWORD = "UnitTestsClusterPassword"; /** * Add a "sendCallNumber" property to messages sent using helper classes. Meant to help in * debugging. */ private static final String SEND_CALL_NUMBER = "sendCallNumber"; - protected static final long WAIT_TIMEOUT = 20000; - private int sendMsgCount = 0; + private static final String OS_TYPE = System.getProperty("os.name").toLowerCase(); + private static final int DEFAULT_UDP_PORT; + private static final ActiveMQServerLogger log = ActiveMQServerLogger.LOGGER; + + protected static final long WAIT_TIMEOUT = 20000; + + // There is a verification about thread leakages. We only fail a single thread when this happens + private static Set alreadyFailedThread = new HashSet(); + + private final Collection servers = new ArrayList(); + private final Collection locators = new ArrayList(); + private final Collection sessionFactories = new ArrayList(); + private final Collection clientSessions = new HashSet(); + private final Collection clientConsumers = new HashSet(); + private final Collection clientProducers = new HashSet(); + private final Collection otherComponents = new HashSet(); + private final Set executorSet = new HashSet(); + + private boolean checkThread = true; + private String testDir; + private int sendMsgCount = 0; + private Map previousThreads; + + @Rule + public TestName name = new TestName(); + + @Rule + public TemporaryFolder temporaryFolder; + + @Rule + // This Custom rule will remove any files under ./target/tmp + // including anything created previously by TemporaryFolder + public RemoveFolder folder = new RemoveFolder(TARGET_TMP); + + @Rule + public TestRule watcher = new TestWatcher() + { + @Override + protected void starting(Description description) + { + log.info(String.format("#*#*# Starting test: %s()...", description.getMethodName())); + } + + @Override + protected void finished(Description description) + { + log.info(String.format("#*#*# Finished test: %s()...", description.getMethodName())); + } + }; + + static + { + Random random = new Random(); + DEFAULT_UDP_PORT = 6000 + random.nextInt(1000); + } + + public ServiceTestBase() + { + File parent = new File(TARGET_TMP); + parent.mkdirs(); + temporaryFolder = new TemporaryFolder(parent); + } - @Override @After public void tearDown() throws Exception { - super.tearDown(); + for (ExecutorService s : executorSet) + { + s.shutdown(); + } + closeAllSessionFactories(); + closeAllServerLocatorsFactories(); + + try + { + assertAllExecutorsFinished(); + assertAllClientConsumersAreClosed(); + assertAllClientProducersAreClosed(); + assertAllClientSessionsAreClosed(); + } + finally + { + synchronized (servers) + { + for (ActiveMQServer server : servers) + { + if (server == null) + { + continue; + } + try + { + final ClusterManager clusterManager = server.getClusterManager(); + if (clusterManager != null) + { + for (ClusterConnection cc : clusterManager.getClusterConnections()) + { + stopComponent(cc); + } + } + } + catch (Exception e) + { + // no-op + } + stopComponentOutputExceptions(server); + } + servers.clear(); + } + + closeAllOtherComponents(); + + ArrayList exceptions; + try + { + exceptions = checkCsfStopped(); + } + finally + { + cleanupPools(); + } + //clean up pools before failing + if (!exceptions.isEmpty()) + { + for (Exception exception : exceptions) + { + exception.printStackTrace(); + } + fail("Client Session Factories still trying to reconnect, see above to see where created"); + } + Map threadMap = Thread.getAllStackTraces(); + for (Thread thread : threadMap.keySet()) + { + StackTraceElement[] stack = threadMap.get(thread); + for (StackTraceElement stackTraceElement : stack) + { + if (stackTraceElement.getMethodName().contains("getConnectionWithRetry") && !alreadyFailedThread.contains(thread)) + { + alreadyFailedThread.add(thread); + System.out.println(threadDump(this.getName() + " has left threads running. Look at thread " + + thread.getName() + + " id = " + + thread.getId() + + " has running locators on test " + + this.getName() + + " on this following dump")); + fail("test '" + getName() + "' left serverlocator running, this could effect other tests"); + } + else if (stackTraceElement.getMethodName().contains("BroadcastGroupImpl.run") && !alreadyFailedThread.contains(thread)) + { + alreadyFailedThread.add(thread); + System.out.println(threadDump(this.getName() + " has left threads running. Look at thread " + + thread.getName() + + " id = " + + thread.getId() + + " is still broadcasting " + + this.getName() + + " on this following dump")); + fail("test left broadcastgroupimpl running, this could effect other tests"); + } + } + } + + if (checkThread) + { + StringBuffer buffer = null; + + boolean failed = true; + + + long timeout = System.currentTimeMillis() + 60000; + while (failed && timeout > System.currentTimeMillis()) + { + buffer = new StringBuffer(); + + failed = checkThread(buffer); + + if (failed) + { + forceGC(); + Thread.sleep(500); + log.info("There are still threads running, trying again"); + System.out.println(buffer); + } + } + + if (failed) + { + logAndSystemOut("Thread leaked on test " + this.getClass().getName() + "::" + this.getName() + "\n" + + buffer); + logAndSystemOut("Thread leakage"); + + fail("Thread leaked"); + } + + } + else + { + checkThread = true; + } + + if (Thread.currentThread().getContextClassLoader() == null) + { + Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); + fail("Thread Context ClassLoader was set to null at some point before this test. We will set to this.getClass().getClassLoader(), but you are supposed to fix your tests"); + } + + checkFilesUsage(); + } + if (InVMRegistry.instance.size() > 0) { fail("InVMREgistry size > 0"); } } - @Override @Before public void setUp() throws Exception { sendMsgCount = 0; - super.setUp(); + testDir = temporaryFolder.getRoot().getAbsolutePath(); + clearDataRecreateServerDirs(); + OperationContextImpl.clearContext(); + + InVMRegistry.instance.clear(); + + // checkFreePort(TransportConstants.DEFAULT_PORT); + + previousThreads = Thread.getAllStackTraces(); + + logAndSystemOut("#test " + getName()); + } + + public static void assertEqualsByteArrays(final byte[] expected, final byte[] actual) + { + for (int i = 0; i < expected.length; i++) + { + Assert.assertEquals("byte at index " + i, expected[i], actual[i]); + } + } + + public static int countOccurrencesOf(String str, String sub) + { + if (str == null || sub == null || str.length() == 0 || sub.length() == 0) + { + return 0; + } + int count = 0; + int pos = 0; + int idx; + while ((idx = str.indexOf(sub, pos)) != -1) + { + ++count; + pos = idx + sub.length(); + } + return count; + } + + protected void disableCheckThread() + { + checkThread = false; + } + + protected String getName() + { + return name.getMethodName(); + } + + protected boolean isWindows() + { + return (OS_TYPE.indexOf("win") >= 0); + } + + protected Configuration createDefaultConfig() throws Exception + { + return createDefaultConfig(false); + } + + protected Configuration createDefaultConfig(final boolean netty) throws Exception + { + ConfigurationImpl configuration = createBasicConfig(-1) + .setJMXManagementEnabled(false) + .clearAcceptorConfigurations() + .addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY)); + + if (netty) + { + configuration.addAcceptorConfiguration(new TransportConfiguration(NETTY_ACCEPTOR_FACTORY)); + } + + return configuration; + } + + protected Configuration createDefaultConfig(final int index, + final Map params, + final String... acceptors) + { + Configuration configuration = createBasicConfig(index).clearAcceptorConfigurations(); + + for (String acceptor : acceptors) + { + TransportConfiguration transportConfig = new TransportConfiguration(acceptor, params); + configuration.getAcceptorConfigurations().add(transportConfig); + } + + return configuration; + } + + protected static final ClusterConnectionConfiguration basicClusterConnectionConfig(String connectorName, String... connectors) + { + ArrayList connectors0 = new ArrayList<>(); + for (String c : connectors) + { + connectors0.add(c); + } + ClusterConnectionConfiguration clusterConnectionConfiguration = new ClusterConnectionConfiguration() + .setName("cluster1") + .setAddress("jms") + .setConnectorName(connectorName) + .setRetryInterval(1000) + .setDuplicateDetection(false) + .setForwardWhenNoConsumers(true) + .setMaxHops(1) + .setConfirmationWindowSize(1) + .setStaticConnectors(connectors0); + + return clusterConnectionConfiguration; + } + + protected final OrderedExecutorFactory getOrderedExecutor() + { + final ExecutorService executor = Executors.newCachedThreadPool(); + executorSet.add(executor); + return new OrderedExecutorFactory(executor); + } + + protected ConfigurationImpl createBasicConfig() throws Exception + { + return createBasicConfig(0); + } + + /** + * @param serverID + * @return + * @throws Exception + */ + protected ConfigurationImpl createBasicConfig(final int serverID) + { + ConfigurationImpl configuration = new ConfigurationImpl() + .setSecurityEnabled(false) + .setJournalMinFiles(2) + .setJournalFileSize(100 * 1024) + .setJournalType(getDefaultJournalType()) + .setJournalDirectory(getJournalDir(serverID, false)) + .setBindingsDirectory(getBindingsDir(serverID, false)) + .setPagingDirectory(getPageDir(serverID, false)) + .setLargeMessagesDirectory(getLargeMessagesDir(serverID, false)) + .setJournalCompactMinFiles(0) + .setJournalCompactPercentage(0) + .setClusterPassword(CLUSTER_PASSWORD); + + return configuration; + } + + public static final ConfigurationImpl createBasicConfigNoDataFolder() + { + ConfigurationImpl configuration = new ConfigurationImpl() + .setSecurityEnabled(false) + .setJournalType(getDefaultJournalType()) + .setPersistenceEnabled(false) + .setJournalCompactMinFiles(0) + .setJournalCompactPercentage(0) + .setClusterPassword(CLUSTER_PASSWORD); + + return configuration; + } + + protected static String getUDPDiscoveryAddress() + { + return System.getProperty("TEST-UDP-ADDRESS", "230.1.2.3"); + } + + protected static String getUDPDiscoveryAddress(final int variant) + { + String value = getUDPDiscoveryAddress(); + + int posPoint = value.lastIndexOf('.'); + + int last = Integer.valueOf(value.substring(posPoint + 1)); + + return value.substring(0, posPoint + 1) + (last + variant); + } + + public static int getUDPDiscoveryPort() + { + String port = System.getProperty("TEST-UDP-PORT"); + if (port != null) + { + return Integer.parseInt(port); + } + return DEFAULT_UDP_PORT; + } + + public static int getUDPDiscoveryPort(final int variant) + { + return getUDPDiscoveryPort() + variant; + } + + public static JournalType getDefaultJournalType() + { + if (AsynchronousFileImpl.isLoaded()) + { + return JournalType.ASYNCIO; + } + else + { + return JournalType.NIO; + } + } + + public static void forceGC() + { + log.info("#test forceGC"); + WeakReference dumbReference = new WeakReference(new Object()); + // A loop that will wait GC, using the minimal time as possible + while (dumbReference.get() != null) + { + System.gc(); + try + { + Thread.sleep(100); + } + catch (InterruptedException e) + { + } + } + log.info("#test forceGC Done"); + } + + public static void forceGC(final Reference ref, final long timeout) + { + long waitUntil = System.currentTimeMillis() + timeout; + // A loop that will wait GC, using the minimal time as possible + while (ref.get() != null && System.currentTimeMillis() < waitUntil) + { + ArrayList list = new ArrayList(); + for (int i = 0; i < 1000; i++) + { + list.add("Some string with garbage with concatenation " + i); + } + list.clear(); + list = null; + System.gc(); + try + { + Thread.sleep(500); + } + catch (InterruptedException e) + { + } + } + } + + /** + * Verifies whether weak references are released after a few GCs. + * + * @param references + * @throws InterruptedException + */ + public static void checkWeakReferences(final WeakReference... references) + { + int i = 0; + boolean hasValue = false; + + do + { + hasValue = false; + + if (i > 0) + { + forceGC(); + } + + for (WeakReference ref : references) + { + if (ref.get() != null) + { + hasValue = true; + break; + } + } + } + while (i++ <= 30 && hasValue); + + for (WeakReference ref : references) + { + Assert.assertNull(ref.get()); + } + } + + public static String threadDump(final String msg) + { + StringWriter str = new StringWriter(); + PrintWriter out = new PrintWriter(str); + + Map stackTrace = Thread.getAllStackTraces(); + + out.println("*******************************************************************************"); + out.println("Complete Thread dump " + msg); + + for (Map.Entry el : stackTrace.entrySet()) + { + out.println("==============================================================================="); + out.println("Thread " + el.getKey() + + " name = " + + el.getKey().getName() + + " id = " + + el.getKey().getId() + + " group = " + + el.getKey().getThreadGroup()); + out.println(); + for (StackTraceElement traceEl : el.getValue()) + { + out.println(traceEl); + } + } + + out.println("==============================================================================="); + out.println("End Thread dump " + msg); + out.println("*******************************************************************************"); + + return str.toString(); + } + + /** + * Sends the message to both logger and System.out (for unit report) + */ + public void logAndSystemOut(String message, Exception e) + { + ActiveMQServerLogger log0 = ActiveMQServerLogger.LOGGER; + log0.info(message, e); + System.out.println(message); + e.printStackTrace(System.out); + } + + /** + * Sends the message to both logger and System.out (for unit report) + */ + public void logAndSystemOut(String message) + { + ActiveMQServerLogger log0 = ActiveMQServerLogger.LOGGER; + log0.info(message); + System.out.println(this.getClass().getName() + "::" + message); + } + + public static String dumpBytes(final byte[] bytes) + { + StringBuffer buff = new StringBuffer(); + + buff.append(System.identityHashCode(bytes) + ", size: " + bytes.length + " ["); + + for (int i = 0; i < bytes.length; i++) + { + buff.append(bytes[i]); + + if (i != bytes.length - 1) + { + buff.append(", "); + } + } + + buff.append("]"); + + return buff.toString(); + } + + public static String dumbBytesHex(final byte[] buffer, final int bytesPerLine) + { + + StringBuffer buff = new StringBuffer(); + + buff.append("["); + + for (int i = 0; i < buffer.length; i++) + { + buff.append(String.format("%1$2X", buffer[i])); + if (i + 1 < buffer.length) + { + buff.append(", "); + } + if ((i + 1) % bytesPerLine == 0) + { + buff.append("\n "); + } + } + buff.append("]"); + + return buff.toString(); + } + + public static void assertEqualsTransportConfigurations(final TransportConfiguration[] expected, + final TransportConfiguration[] actual) + { + assertEquals(expected.length, actual.length); + for (int i = 0; i < expected.length; i++) + { + Assert.assertEquals("TransportConfiguration at index " + i, expected[i], actual[i]); + } + } + + public static void assertEqualsBuffers(final int size, final ActiveMQBuffer expected, final ActiveMQBuffer actual) + { + // assertEquals(expected.length, actual.length); + expected.readerIndex(0); + actual.readerIndex(0); + + for (int i = 0; i < size; i++) + { + byte b1 = expected.readByte(); + byte b2 = actual.readByte(); + Assert.assertEquals("byte at index " + i, b1, b2); + } + expected.resetReaderIndex(); + actual.resetReaderIndex(); + } + + public static void assertEqualsByteArrays(final int length, final byte[] expected, final byte[] actual) + { + // we check only for the given length (the arrays might be + // larger) + Assert.assertTrue(expected.length >= length); + Assert.assertTrue(actual.length >= length); + for (int i = 0; i < length; i++) + { + Assert.assertEquals("byte at index " + i, expected[i], actual[i]); + } + } + + public static void assertSameXids(final List expected, final List actual) + { + Assert.assertNotNull(expected); + Assert.assertNotNull(actual); + Assert.assertEquals(expected.size(), actual.size()); + + for (int i = 0; i < expected.size(); i++) + { + Xid expectedXid = expected.get(i); + Xid actualXid = actual.get(i); + assertEqualsByteArrays(expectedXid.getBranchQualifier(), actualXid.getBranchQualifier()); + Assert.assertEquals(expectedXid.getFormatId(), actualXid.getFormatId()); + assertEqualsByteArrays(expectedXid.getGlobalTransactionId(), actualXid.getGlobalTransactionId()); + } + } + + protected static void checkNoBinding(final Context context, final String binding) + { + try + { + context.lookup(binding); + Assert.fail("there must be no resource to look up for " + binding); + } + catch (Exception e) + { + } + } + + protected static Object checkBinding(final Context context, final String binding) throws Exception + { + Object o = context.lookup(binding); + Assert.assertNotNull(o); + return o; + } + + /** + * @param connectorConfigs + * @return + */ + protected ArrayList registerConnectors(final ActiveMQServer server, + final List connectorConfigs) + { + // The connectors need to be pre-configured at main config object but this method is taking + // TransportConfigurations directly + // So this will first register them at the config and then generate a list of objects + ArrayList connectors = new ArrayList(); + for (TransportConfiguration tnsp : connectorConfigs) + { + String name1 = RandomUtil.randomString(); + + server.getConfiguration().getConnectorConfigurations().put(name1, tnsp); + + connectors.add(name1); + } + return connectors; + } + + protected static final void checkFreePort(final int... ports) + { + for (int port : ports) + { + ServerSocket ssocket = null; + try + { + ssocket = new ServerSocket(port); + } + catch (Exception e) + { + throw new IllegalStateException("port " + port + " is bound", e); + } + finally + { + if (ssocket != null) + { + try + { + ssocket.close(); + } + catch (IOException e) + { + } + } + } + } + } + + /** + * @return the testDir + */ + protected final String getTestDir() + { + return testDir; + } + + protected final void setTestDir(String testDir) + { + this.testDir = testDir; + } + + protected final void clearDataRecreateServerDirs() + { + clearDataRecreateServerDirs(getTestDir()); + } + + protected void clearDataRecreateServerDirs(final String testDir1) + { + // Need to delete the root + + File file = new File(testDir1); + deleteDirectory(file); + file.mkdirs(); + + recreateDirectory(getJournalDir(testDir1)); + recreateDirectory(getBindingsDir(testDir1)); + recreateDirectory(getPageDir(testDir1)); + recreateDirectory(getLargeMessagesDir(testDir1)); + recreateDirectory(getClientLargeMessagesDir(testDir1)); + recreateDirectory(getTemporaryDir(testDir1)); + } + + /** + * @return the journalDir + */ + public String getJournalDir() + { + return getJournalDir(getTestDir()); + } + + protected static String getJournalDir(final String testDir1) + { + return testDir1 + "/journal"; + } + + protected String getJournalDir(final int index, final boolean backup) + { + return getJournalDir(getTestDir(), index, backup); + } + + public static String getJournalDir(final String testDir, final int index, final boolean backup) + { + return getJournalDir(testDir) + directoryNameSuffix(index, backup); + } + + /** + * @return the bindingsDir + */ + protected String getBindingsDir() + { + return getBindingsDir(getTestDir()); + } + + /** + * @return the bindingsDir + */ + protected static String getBindingsDir(final String testDir1) + { + return testDir1 + "/bindings"; + } + + /** + * @return the bindingsDir + */ + protected String getBindingsDir(final int index, final boolean backup) + { + return getBindingsDir(getTestDir(), index, backup); + } + + public static String getBindingsDir(final String testDir, final int index, final boolean backup) + { + return getBindingsDir(testDir) + directoryNameSuffix(index, backup); + } + + /** + * @return the pageDir + */ + protected String getPageDir() + { + return getPageDir(getTestDir()); + } + + /** + * @return the pageDir + */ + protected static String getPageDir(final String testDir1) + { + return testDir1 + "/page"; + } + + protected String getPageDir(final int index, final boolean backup) + { + return getPageDir(getTestDir(), index, backup); + } + + public static String getPageDir(final String testDir, final int index, final boolean backup) + { + return getPageDir(testDir) + directoryNameSuffix(index, backup); + } + + /** + * @return the largeMessagesDir + */ + protected String getLargeMessagesDir() + { + return getLargeMessagesDir(getTestDir()); + } + + /** + * @return the largeMessagesDir + */ + protected static String getLargeMessagesDir(final String testDir1) + { + return testDir1 + "/large-msg"; + } + + protected String getLargeMessagesDir(final int index, final boolean backup) + { + return getLargeMessagesDir(getTestDir(), index, backup); + } + + public static String getLargeMessagesDir(final String testDir, final int index, final boolean backup) + { + return getLargeMessagesDir(testDir) + directoryNameSuffix(index, backup); + } + + private static String directoryNameSuffix(int index, boolean backup) + { + if (index == -1) + return ""; + return index + "-" + (backup ? "B" : "L"); + } + + /** + * @return the clientLargeMessagesDir + */ + protected String getClientLargeMessagesDir() + { + return getClientLargeMessagesDir(getTestDir()); + } + + /** + * @return the clientLargeMessagesDir + */ + protected String getClientLargeMessagesDir(final String testDir1) + { + return testDir1 + "/client-large-msg"; + } + + /** + * @return the temporaryDir + */ + protected final String getTemporaryDir() + { + return getTemporaryDir(getTestDir()); + } + + /** + * @return the temporaryDir + */ + protected String getTemporaryDir(final String testDir1) + { + return testDir1 + "/temp"; + } + + protected static void expectActiveMQException(final String message, final ActiveMQExceptionType errorCode, final ActiveMQAction action) + { + try + { + action.run(); + Assert.fail(message); + } + catch (Exception e) + { + Assert.assertTrue(e instanceof ActiveMQException); + Assert.assertEquals(errorCode, ((ActiveMQException) e).getType()); + } + } + + protected static void expectActiveMQException(final ActiveMQExceptionType errorCode, final ActiveMQAction action) + { + expectActiveMQException("must throw a ActiveMQException with the expected errorCode: " + errorCode, + errorCode, + action); + } + + protected static void expectXAException(final int errorCode, final ActiveMQAction action) + { + try + { + action.run(); + Assert.fail("must throw a XAException with the expected errorCode: " + errorCode); + } + catch (Exception e) + { + Assert.assertTrue(e instanceof XAException); + Assert.assertEquals(errorCode, ((XAException) e).errorCode); + } + } + + public static byte getSamplebyte(final long position) + { + return (byte) ('a' + position % ('z' - 'a' + 1)); + } + + // Creates a Fake LargeStream without using a real file + public static InputStream createFakeLargeStream(final long size) throws Exception + { + return new InputStream() + { + private long count; + + private boolean closed = false; + + @Override + public void close() throws IOException + { + super.close(); + closed = true; + } + + @Override + public int read() throws IOException + { + if (closed) + { + throw new IOException("Stream was closed"); + } + if (count++ < size) + { + return getSamplebyte(count - 1); + } + else + { + return -1; + } + } + }; + + } + + /** + * It validates a Bean (POJO) using simple setters and getters with random values. + * You can pass a list of properties to be ignored, as some properties will have a pre-defined domain (not being possible to use random-values on them) + */ + protected void validateGettersAndSetters(final Object pojo, final String... ignoredProperties) throws Exception + { + HashSet ignoreSet = new HashSet(); + + for (String ignore : ignoredProperties) + { + ignoreSet.add(ignore); + } + + BeanInfo info = Introspector.getBeanInfo(pojo.getClass()); + + PropertyDescriptor[] properties = info.getPropertyDescriptors(); + + for (PropertyDescriptor prop : properties) + { + Object value; + + if (prop.getPropertyType() == String.class) + { + value = RandomUtil.randomString(); + } + else if (prop.getPropertyType() == Integer.class || prop.getPropertyType() == Integer.TYPE) + { + value = RandomUtil.randomInt(); + } + else if (prop.getPropertyType() == Long.class || prop.getPropertyType() == Long.TYPE) + { + value = RandomUtil.randomLong(); + } + else if (prop.getPropertyType() == Boolean.class || prop.getPropertyType() == Boolean.TYPE) + { + value = RandomUtil.randomBoolean(); + } + else if (prop.getPropertyType() == Double.class || prop.getPropertyType() == Double.TYPE) + { + value = RandomUtil.randomDouble(); + } + else + { + System.out.println("Can't validate property of type " + prop.getPropertyType() + " on " + prop.getName()); + value = null; + } + + if (value != null && prop.getWriteMethod() != null && prop.getReadMethod() == null) + { + System.out.println("WriteOnly property " + prop.getName() + " on " + pojo.getClass()); + } + else if (value != null & prop.getWriteMethod() != null && + prop.getReadMethod() != null && + !ignoreSet.contains(prop.getName())) + { + System.out.println("Validating " + prop.getName() + " type = " + prop.getPropertyType()); + prop.getWriteMethod().invoke(pojo, value); + + Assert.assertEquals("Property " + prop.getName(), value, prop.getReadMethod().invoke(pojo)); + } + } } /** @@ -322,7 +1399,6 @@ public abstract class ServiceTestBase extends UnitTestCase return new TransportConfiguration(className, params); } - private final ActiveMQServerLogger log = ActiveMQServerLogger.LOGGER; protected void waitForServer(ActiveMQServer server) throws InterruptedException { @@ -464,61 +1540,13 @@ public abstract class ServiceTestBase extends UnitTestCase } } - protected final ActiveMQServer - createServer(final boolean realFiles, - final Configuration configuration, - final int pageSize, - final int maxAddressSize, - final Map settings, - final MBeanServer mbeanServer) - { - ActiveMQServer server; - - if (realFiles) - { - server = ActiveMQServers.newActiveMQServer(configuration, mbeanServer, true); - } - else - { - server = ActiveMQServers.newActiveMQServer(configuration, mbeanServer, false); - } - try - { - for (Map.Entry setting : settings.entrySet()) - { - server.getAddressSettingsRepository().addMatch(setting.getKey(), setting.getValue()); - } - - AddressSettings defaultSetting = new AddressSettings(); - defaultSetting.setPageSizeBytes(pageSize); - defaultSetting.setMaxSizeBytes(maxAddressSize); - - server.getAddressSettingsRepository().addMatch("#", defaultSetting); - - return server; - } - finally - { - addServer(server); - } - } - protected final ActiveMQServer createServer(final boolean realFiles, final Configuration configuration, - final int pageSize, - final int maxAddressSize, + final long pageSize, + final long maxAddressSize, final Map settings) { - return createServer(realFiles, configuration, pageSize, maxAddressSize, AddressFullMessagePolicy.PAGE, settings); - } - protected final ActiveMQServer createServer(final boolean realFiles, - final Configuration configuration, - final int pageSize, - final int maxAddressSize, - final AddressFullMessagePolicy fullPolicy, - final Map settings) - { ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(configuration, realFiles)); if (settings != null) { @@ -531,56 +1559,13 @@ public abstract class ServiceTestBase extends UnitTestCase AddressSettings defaultSetting = new AddressSettings(); defaultSetting.setPageSizeBytes(pageSize); defaultSetting.setMaxSizeBytes(maxAddressSize); - defaultSetting.setAddressFullMessagePolicy(fullPolicy); + defaultSetting.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE); server.getAddressSettingsRepository().addMatch("#", defaultSetting); return server; } - - protected final ActiveMQServer createServer(final boolean realFiles, - Configuration conf, - MBeanServer mbeanServer) - { - return createServer(realFiles, conf, mbeanServer, new HashMap()); - } - - protected final ActiveMQServer - createServer(final boolean realFiles, - final Configuration configuration, - final MBeanServer mbeanServer, - final Map settings) - { - ActiveMQServer server; - - if (realFiles) - { - server = ActiveMQServers.newActiveMQServer(configuration, mbeanServer); - } - else - { - server = ActiveMQServers.newActiveMQServer(configuration, mbeanServer, false); - } - try - { - for (Map.Entry setting : settings.entrySet()) - { - server.getAddressSettingsRepository().addMatch(setting.getKey(), setting.getValue()); - } - - AddressSettings defaultSetting = new AddressSettings(); - server.getAddressSettingsRepository().addMatch("#", defaultSetting); - - - return server; - } - finally - { - addServer(server); - } - } - protected final ActiveMQServer createServer(final boolean realFiles) throws Exception { return createServer(realFiles, false); @@ -588,18 +1573,17 @@ public abstract class ServiceTestBase extends UnitTestCase protected final ActiveMQServer createServer(final boolean realFiles, final boolean netty) throws Exception { - return createServer(realFiles, createDefaultConfig(netty), -1, -1, new HashMap()); + return createServer(realFiles, createDefaultConfig(netty), AddressSettings.DEFAULT_PAGE_SIZE, AddressSettings.DEFAULT_MAX_SIZE_BYTES, new HashMap()); } protected ActiveMQServer createServer(final boolean realFiles, final Configuration configuration) { - return createServer(realFiles, configuration, -1, -1, new HashMap()); + return createServer(realFiles, configuration, AddressSettings.DEFAULT_PAGE_SIZE, AddressSettings.DEFAULT_MAX_SIZE_BYTES, new HashMap()); } protected final ActiveMQServer createServer(final Configuration configuration) { - return createServer(configuration.isPersistenceEnabled(), configuration, -1, -1, - new HashMap()); + return createServer(configuration.isPersistenceEnabled(), configuration, AddressSettings.DEFAULT_PAGE_SIZE, AddressSettings.DEFAULT_MAX_SIZE_BYTES, new HashMap()); } protected ActiveMQServer createInVMFailoverServer(final boolean realFiles, @@ -712,46 +1696,6 @@ public abstract class ServiceTestBase extends UnitTestCase } } - protected ActiveMQServer createServer(final boolean realFiles, - final Configuration configuration, - final ActiveMQSecurityManager securityManager) - { - ActiveMQServer server; - - if (realFiles) - { - server = ActiveMQServers.newActiveMQServer(configuration, - ManagementFactory.getPlatformMBeanServer(), - securityManager); - } - else - { - server = ActiveMQServers.newActiveMQServer(configuration, - ManagementFactory.getPlatformMBeanServer(), - securityManager, - false); - } - try - { - Map settings = new HashMap(); - - for (Map.Entry setting : settings.entrySet()) - { - server.getAddressSettingsRepository().addMatch(setting.getKey(), setting.getValue()); - } - - AddressSettings defaultSetting = new AddressSettings(); - - server.getAddressSettingsRepository().addMatch("#", defaultSetting); - - return server; - } - finally - { - addServer(server); - } - } - protected ActiveMQServer createClusteredServerWithParams(final boolean isNetty, final int index, final boolean realFiles, @@ -872,8 +1816,7 @@ public abstract class ServiceTestBase extends UnitTestCase * @param numMessages * @throws Exception */ - public final void - sendMessages(ClientSession session, ClientProducer producer, int numMessages) throws ActiveMQException + public final void sendMessages(ClientSession session, ClientProducer producer, int numMessages) throws ActiveMQException { for (int i = 0; i < numMessages; i++) { @@ -881,8 +1824,7 @@ public abstract class ServiceTestBase extends UnitTestCase } } - protected final ClientMessage - createMessage(ClientSession session, int counter, boolean durable) throws ActiveMQException + protected final ClientMessage createMessage(ClientSession session, int counter, boolean durable) throws ActiveMQException { ClientMessage message = session.createMessage(durable); setBody(counter, message); @@ -891,8 +1833,7 @@ public abstract class ServiceTestBase extends UnitTestCase return message; } - protected final void - receiveMessages(ClientConsumer consumer, final int start, final int msgCount, final boolean ack) throws ActiveMQException + protected final void receiveMessages(ClientConsumer consumer, final int start, final int msgCount, final boolean ack) throws ActiveMQException { for (int i = start; i < msgCount; i++) { @@ -1260,4 +2201,800 @@ public abstract class ServiceTestBase extends UnitTestCase } } + + private void assertAllExecutorsFinished() throws InterruptedException + { + for (ExecutorService s : executorSet) + { + Assert.assertTrue(s.awaitTermination(5, TimeUnit.SECONDS)); + } + } + + private ArrayList checkCsfStopped() + { + long time = System.currentTimeMillis(); + long waitUntil = time + 5000; + while (!ClientSessionFactoryImpl.CLOSE_RUNNABLES.isEmpty() && time < waitUntil) + { + try + { + Thread.sleep(50); + } + catch (InterruptedException e) + { + //ignore + } + time = System.currentTimeMillis(); + } + List closeRunnables = new ArrayList<>(ClientSessionFactoryImpl.CLOSE_RUNNABLES); + ArrayList exceptions = new ArrayList<>(); + + if (!closeRunnables.isEmpty()) + { + for (ClientSessionFactoryImpl.CloseRunnable closeRunnable : closeRunnables) + { + if (closeRunnable != null) + { + exceptions.add(closeRunnable.stop().createTrace); + } + } + } + + return exceptions; + } + + private void assertAllClientProducersAreClosed() + { + synchronized (clientProducers) + { + for (ClientProducer p : clientProducers) + { + assertTrue(p + " should be closed", p.isClosed()); + } + clientProducers.clear(); + } + } + + /** + * + */ + private void closeAllOtherComponents() + { + synchronized (otherComponents) + { + for (ActiveMQComponent c : otherComponents) + { + stopComponent(c); + } + otherComponents.clear(); + } + } + + /** + * @param buffer + * @return + */ + private boolean checkThread(StringBuffer buffer) + { + boolean failedThread = false; + + Map postThreads = Thread.getAllStackTraces(); + + if (postThreads != null && previousThreads != null && postThreads.size() > previousThreads.size()) + { + + buffer.append("*********************************************************************************\n"); + buffer.append("LEAKING THREADS\n"); + + for (Thread aliveThread : postThreads.keySet()) + { + if (!isExpectedThread(aliveThread) && !previousThreads.containsKey(aliveThread)) + { + failedThread = true; + buffer.append("=============================================================================\n"); + buffer.append("Thread " + aliveThread + " is still alive with the following stackTrace:\n"); + StackTraceElement[] elements = postThreads.get(aliveThread); + for (StackTraceElement el : elements) + { + buffer.append(el + "\n"); + } + } + + } + buffer.append("*********************************************************************************\n"); + + } + return failedThread; + } + + /** + * if it's an expected thread... we will just move along ignoring it + * + * @param thread + * @return + */ + private boolean isExpectedThread(Thread thread) + { + final String threadName = thread.getName(); + final ThreadGroup group = thread.getThreadGroup(); + final boolean isSystemThread = group != null && "system".equals(group.getName()); + final String javaVendor = System.getProperty("java.vendor"); + + if (threadName.contains("SunPKCS11")) + { + return true; + } + else if (threadName.contains("Attach Listener")) + { + return true; + } + else if ((javaVendor.contains("IBM") || isSystemThread) && threadName.equals("process reaper")) + { + return true; + } + else if (javaVendor.contains("IBM") && threadName.equals("MemoryPoolMXBean notification dispatcher")) + { + return true; + } + else if (threadName.contains("globalEventExecutor")) + { + return true; + } + else if (threadName.contains("threadDeathWatcher")) + { + return true; + } + else if (threadName.contains("netty-threads")) + { + // This is ok as we use EventLoopGroup.shutdownGracefully() which will shutdown things with a bit of delay + // if the EventLoop's are still busy. + return true; + } + else if (threadName.contains("threadDeathWatcher")) + { + //another netty thread + return true; + } + else + { + for (StackTraceElement element : thread.getStackTrace()) + { + if (element.getClassName().contains("org.jboss.byteman.agent.TransformListener")) + { + return true; + } + } + return false; + } + } + + private void checkFilesUsage() + { + long timeout = System.currentTimeMillis() + 15000; + + while (AsynchronousFileImpl.getTotalMaxIO() != 0 && System.currentTimeMillis() > timeout) + { + try + { + Thread.sleep(100); + } + catch (Exception ignored) + { + } + } + + int invmSize = InVMRegistry.instance.size(); + if (invmSize > 0) + { + InVMRegistry.instance.clear(); + log.info(threadDump("Thread dump")); + fail("invm registry still had acceptors registered"); + } + + final int totalMaxIO = AsynchronousFileImpl.getTotalMaxIO(); + if (totalMaxIO != 0) + { + AsynchronousFileImpl.resetMaxAIO(); + Assert.fail("test did not close all its files " + totalMaxIO); + } + } + + private void cleanupPools() + { + OperationContextImpl.clearContext(); + + // We shutdown the global pools to give a better isolation between tests + try + { + ServerLocatorImpl.clearThreadPools(); + } + catch (Throwable e) + { + log.info(threadDump(e.getMessage())); + System.err.println(threadDump(e.getMessage())); + } + + try + { + NettyConnector.clearThreadPools(); + } + catch (Exception e) + { + log.info(threadDump(e.getMessage())); + System.err.println(threadDump(e.getMessage())); + } + } + + protected static final void recreateDirectory(final String directory) + { + File file = new File(directory); + deleteDirectory(file); + file.mkdirs(); + } + + protected static final boolean deleteDirectory(final File directory) + { + if (directory.isDirectory()) + { + String[] files = directory.list(); + int num = 5; + int attempts = 0; + while (files == null && (attempts < num)) + { + try + { + Thread.sleep(100); + } + catch (InterruptedException e) + { + } + files = directory.list(); + attempts++; + } + + for (String file : files) + { + File f = new File(directory, file); + if (!deleteDirectory(f)) + { + log.warn("Failed to clean up file: " + f.getAbsolutePath()); + } + } + } + + return directory.delete(); + } + + protected static final void copyRecursive(final File from, final File to) throws Exception + { + if (from.isDirectory()) + { + if (!to.exists()) + { + to.mkdir(); + } + + String[] subs = from.list(); + + for (String sub : subs) + { + copyRecursive(new File(from, sub), new File(to, sub)); + } + } + else + { + InputStream in = null; + + OutputStream out = null; + + try + { + in = new BufferedInputStream(new FileInputStream(from)); + + out = new BufferedOutputStream(new FileOutputStream(to)); + + int b; + + while ((b = in.read()) != -1) + { + out.write(b); + } + } + finally + { + if (in != null) + { + in.close(); + } + + if (out != null) + { + out.close(); + } + } + } + } + + protected void assertRefListsIdenticalRefs(final List l1, final List l2) + { + if (l1.size() != l2.size()) + { + Assert.fail("Lists different sizes: " + l1.size() + ", " + l2.size()); + } + + Iterator iter1 = l1.iterator(); + Iterator iter2 = l2.iterator(); + + while (iter1.hasNext()) + { + MessageReference o1 = iter1.next(); + MessageReference o2 = iter2.next(); + + Assert.assertTrue("expected " + o1 + " but was " + o2, o1 == o2); + } + } + + protected ServerMessage generateMessage(final long id) + { + ServerMessage message = new ServerMessageImpl(id, 1000); + + message.setMessageID(id); + + message.getBodyBuffer().writeString(UUID.randomUUID().toString()); + + message.setAddress(new SimpleString("foo")); + + return message; + } + + protected MessageReference generateReference(final Queue queue, final long id) + { + ServerMessage message = generateMessage(id); + + return message.createReference(queue); + } + + protected int calculateRecordSize(final int size, final int alignment) + { + return (size / alignment + (size % alignment != 0 ? 1 : 0)) * alignment; + } + + protected ClientMessage createTextMessage(final ClientSession session, final String s) + { + return createTextMessage(session, s, true); + } + + + protected ClientMessage createTextMessage(final ClientSession session, final String s, final boolean durable) + { + ClientMessage message = session.createMessage(Message.TEXT_TYPE, + durable, + 0, + System.currentTimeMillis(), + (byte) 4); + message.getBodyBuffer().writeString(s); + return message; + } + + protected XidImpl newXID() + { + return new XidImpl("xa1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes()); + } + + protected int getMessageCount(final ActiveMQServer service, final String address) throws Exception + { + return getMessageCount(service.getPostOffice(), address); + } + + /** + * @param address + * @param postOffice + * @return + * @throws Exception + */ + protected int getMessageCount(final PostOffice postOffice, final String address) throws Exception + { + int messageCount = 0; + + List bindings = getLocalQueueBindings(postOffice, address); + + for (QueueBinding qBinding : bindings) + { + qBinding.getQueue().flushExecutor(); + messageCount += getMessageCount(qBinding.getQueue()); + } + + return messageCount; + } + + protected int getMessageCount(final Queue queue) + { + queue.flushExecutor(); + return (int)queue.getMessageCount(); + } + + protected int getMessagesAdded(final Queue queue) + { + queue.flushExecutor(); + return (int)queue.getMessagesAdded(); + } + + private List getLocalQueueBindings(final PostOffice postOffice, final String address) throws Exception + { + ArrayList bindingsFound = new ArrayList(); + + Bindings bindings = postOffice.getBindingsForAddress(new SimpleString(address)); + + for (Binding binding : bindings.getBindings()) + { + if (binding instanceof LocalQueueBinding) + { + bindingsFound.add((QueueBinding) binding); + } + } + return bindingsFound; + } + + protected final ServerLocator createInVMNonHALocator() + { + return createNonHALocator(false); + } + + protected final ServerLocator createNettyNonHALocator() + { + return createNonHALocator(true); + } + + protected final ServerLocator createNonHALocator(final boolean isNetty) + { + ServerLocator locatorWithoutHA = internalCreateNonHALocator(isNetty); + return addServerLocator(locatorWithoutHA); + } + + /** + * Creates the Locator without adding it to the list where the tearDown will take place + * This is because we don't want it closed in certain tests where we are issuing failures + * @param isNetty + * @return + */ + public ServerLocator internalCreateNonHALocator(boolean isNetty) + { + return isNetty + ? ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(NETTY_CONNECTOR_FACTORY)) + : ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(INVM_CONNECTOR_FACTORY)); + } + + protected static final void stopComponent(ActiveMQComponent component) + { + if (component == null) + return; + try + { + component.stop(); + } + catch (Exception e) + { + // no-op + } + } + + protected static final void stopComponentOutputExceptions(ActiveMQComponent component) + { + if (component == null) + return; + try + { + component.stop(); + } + catch (Exception e) + { + System.err.println("Exception closing " + component); + e.printStackTrace(); + } + } + + protected final ClientSessionFactory createSessionFactory(ServerLocator locator) throws Exception + { + ClientSessionFactory sf = locator.createSessionFactory(); + addSessionFactory(sf); + return sf; + } + + protected final ActiveMQServer addServer(final ActiveMQServer server) + { + if (server != null) + { + synchronized (servers) + { + servers.add(server); + } + } + return server; + } + + protected final ServerLocator addServerLocator(final ServerLocator locator) + { + if (locator != null) + { + synchronized (locators) + { + locators.add(locator); + } + } + return locator; + } + + protected final ClientSession addClientSession(final ClientSession session) + { + if (session != null) + { + synchronized (clientSessions) + { + clientSessions.add(session); + } + } + return session; + } + + protected final ClientConsumer addClientConsumer(final ClientConsumer consumer) + { + if (consumer != null) + { + synchronized (clientConsumers) + { + clientConsumers.add(consumer); + } + } + return consumer; + } + + protected final ClientProducer addClientProducer(final ClientProducer producer) + { + if (producer != null) + { + synchronized (clientProducers) + { + clientProducers.add(producer); + } + } + return producer; + } + + protected final void addActiveMQComponent(final ActiveMQComponent component) + { + if (component != null) + { + synchronized (otherComponents) + { + otherComponents.add(component); + } + } + } + + protected final ClientSessionFactory addSessionFactory(final ClientSessionFactory sf) + { + if (sf != null) + { + synchronized (sessionFactories) + { + sessionFactories.add(sf); + } + } + return sf; + } + + private void assertAllClientConsumersAreClosed() + { + synchronized (clientConsumers) + { + for (ClientConsumer cc : clientConsumers) + { + if (cc == null) + continue; + assertTrue(cc.isClosed()); + } + clientConsumers.clear(); + } + } + + private void assertAllClientSessionsAreClosed() + { + synchronized (clientSessions) + { + for (final ClientSession cs : clientSessions) + { + if (cs == null) + continue; + assertTrue(cs.isClosed()); + } + clientSessions.clear(); + } + } + + protected void closeAllSessionFactories() + { + synchronized (sessionFactories) + { + for (ClientSessionFactory sf : sessionFactories) + { + closeSessionFactory(sf); + assert sf.isClosed(); + } + sessionFactories.clear(); + } + } + + protected void closeAllServerLocatorsFactories() + { + synchronized (locators) + { + for (ServerLocator locator : locators) + { + closeServerLocator(locator); + } + locators.clear(); + } + } + + public static final void closeServerLocator(ServerLocator locator) + { + if (locator == null) + return; + try + { + locator.close(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public static final void closeSessionFactory(final ClientSessionFactory sf) + { + if (sf == null) + return; + try + { + sf.close(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public static void crashAndWaitForFailure(ActiveMQServer server, ClientSession... sessions) throws Exception + { + CountDownLatch latch = new CountDownLatch(sessions.length); + for (ClientSession session : sessions) + { + CountDownSessionFailureListener listener = new CountDownSessionFailureListener(latch, session); + session.addFailureListener(listener); + } + + ClusterManager clusterManager = server.getClusterManager(); + clusterManager.flushExecutor(); + clusterManager.clear(); + Assert.assertTrue("server should be running!", server.isStarted()); + server.stop(true); + + if (sessions.length > 0) + { + // Wait to be informed of failure + boolean ok = latch.await(10000, TimeUnit.MILLISECONDS); + Assert.assertTrue("Failed to stop the server! Latch count is " + latch.getCount() + " out of " + + sessions.length, ok); + } + } + + public static void crashAndWaitForFailure(ActiveMQServer server, ServerLocator locator) throws Exception + { + ClientSessionFactory sf = locator.createSessionFactory(); + ClientSession session = sf.createSession(); + try + { + crashAndWaitForFailure(server, session); + } + finally + { + try + { + session.close(); + sf.close(); + } + catch (Exception ignored) + { + } + } + } + + public interface RunnerWithEX + { + void run() throws Throwable; + } + + // This can be used to interrupt a thread if it takes more than timeoutMilliseconds + public boolean runWithTimeout(final RunnerWithEX runner, final long timeoutMilliseconds) throws Throwable + { + + class ThreadRunner extends Thread + { + + Throwable t; + + final RunnerWithEX run; + + ThreadRunner(RunnerWithEX run) + { + this.run = run; + } + + public void run() + { + try + { + runner.run(); + } + catch (Throwable t) + { + this.t = t; + } + } + } + + ThreadRunner runnerThread = new ThreadRunner(runner); + + runnerThread.start(); + + boolean hadToInterrupt = false; + while (runnerThread.isAlive()) + { + runnerThread.join(timeoutMilliseconds); + if (runnerThread.isAlive()) + { + System.err.println("Thread still running, interrupting it now:"); + for (Object t : runnerThread.getStackTrace()) + { + System.err.println(t); + } + hadToInterrupt = true; + runnerThread.interrupt(); + } + } + + if (runnerThread.t != null) + { + runnerThread.t.printStackTrace(); + throw runnerThread.t; + } + + // we are returning true if it ran ok. + // had to Interrupt is exactly the opposite of what we are returning + return !hadToInterrupt; + } + + + // Private ------------------------------------------------------- + + // Inner classes ------------------------------------------------- + + protected interface ActiveMQAction + { + void run() throws Exception; + } + + /** + * Asserts that latch completes within a (rather large interval). + *

+ * Use this instead of just calling {@code latch.await()}. Otherwise your test may hang the whole + * test run if it fails to count-down the latch. + * + * @param latch + * @throws InterruptedException + */ + public static void waitForLatch(CountDownLatch latch) throws InterruptedException + { + assertTrue("Latch has got to return within a minute", latch.await(1, TimeUnit.MINUTES)); + } } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/SimpleStringTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/SimpleStringTest.java index 2f92aa82bf..cc45e64b52 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/SimpleStringTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/SimpleStringTest.java @@ -437,7 +437,7 @@ public class SimpleStringTest extends Assert x[i].start(); } - UnitTestCase.waitForLatch(latch); + ServiceTestBase.waitForLatch(latch); start.countDown(); for (T t : x) diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/SingleServerTestBase.java b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/SingleServerTestBase.java index 8751f2bdbd..017c5aa6ce 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/SingleServerTestBase.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/SingleServerTestBase.java @@ -59,7 +59,7 @@ public abstract class SingleServerTestBase extends ServiceTestBase protected ServerLocator createLocator() { - ServerLocator retlocator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator retlocator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(INVM_CONNECTOR_FACTORY)); addServerLocator(retlocator); return retlocator; } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/UnitTestCase.java b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/UnitTestCase.java deleted file mode 100644 index 0134d8e2ab..0000000000 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/UnitTestCase.java +++ /dev/null @@ -1,2137 +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.artemis.tests.util; - -import javax.naming.Context; -import javax.transaction.xa.XAException; -import javax.transaction.xa.Xid; -import java.beans.BeanInfo; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.lang.ref.Reference; -import java.lang.ref.WeakReference; -import java.net.ServerSocket; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.activemq.artemis.api.core.ActiveMQBuffer; -import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; -import org.apache.activemq.artemis.api.core.Message; -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.api.core.client.ClientConsumer; -import org.apache.activemq.artemis.api.core.client.ClientMessage; -import org.apache.activemq.artemis.api.core.client.ClientProducer; -import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; -import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.core.asyncio.impl.AsynchronousFileImpl; -import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl; -import org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl; -import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration; -import org.apache.activemq.artemis.core.config.Configuration; -import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; -import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; -import org.apache.activemq.artemis.core.journal.RecordInfo; -import org.apache.activemq.artemis.core.journal.SequentialFileFactory; -import org.apache.activemq.artemis.core.journal.impl.JournalImpl; -import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory; -import org.apache.activemq.artemis.core.persistence.impl.journal.DescribeJournal; -import org.apache.activemq.artemis.core.persistence.impl.journal.DescribeJournal.ReferenceDescribe; -import org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds; -import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl; -import org.apache.activemq.artemis.core.postoffice.Binding; -import org.apache.activemq.artemis.core.postoffice.Bindings; -import org.apache.activemq.artemis.core.postoffice.PostOffice; -import org.apache.activemq.artemis.core.postoffice.QueueBinding; -import org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding; -import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory; -import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; -import org.apache.activemq.artemis.core.remoting.impl.invm.InVMRegistry; -import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory; -import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnector; -import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; -import org.apache.activemq.artemis.core.server.ActiveMQComponent; -import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle; -import org.apache.activemq.artemis.core.server.ActiveMQServer; -import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; -import org.apache.activemq.artemis.core.server.JournalType; -import org.apache.activemq.artemis.core.server.MessageReference; -import org.apache.activemq.artemis.core.server.Queue; -import org.apache.activemq.artemis.core.server.ServerMessage; -import org.apache.activemq.artemis.core.server.cluster.ClusterConnection; -import org.apache.activemq.artemis.core.server.cluster.ClusterManager; -import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl; -import org.apache.activemq.artemis.core.transaction.impl.XidImpl; -import org.apache.activemq.artemis.tests.CoreUnitTestCase; -import org.apache.activemq.artemis.utils.OrderedExecutorFactory; -import org.apache.activemq.artemis.utils.UUIDGenerator; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.rules.TemporaryFolder; -import org.junit.rules.TestName; - -/** - * Helper base class for our unit tests. - *

- * See {@code org.apache.activemq.tests.util.ServiceTestBase} for a test case with server set-up. - * - * @see ServiceTestBase - */ -public abstract class UnitTestCase extends CoreUnitTestCase -{ - public static final String TARGET_TMP = "./target/tmp"; - // Constants ----------------------------------------------------- - - @Rule - public TestName name = new TestName(); - - @Rule - public TemporaryFolder temporaryFolder; - - @Rule - // This Custom rule will remove any files under ./target/tmp - // including anything created previously by TemporaryFolder - public RemoveFolder folder = new RemoveFolder(TARGET_TMP); - - - private String testDir; - - private static final ActiveMQServerLogger log = ActiveMQServerLogger.LOGGER; - - public static final String INVM_ACCEPTOR_FACTORY = InVMAcceptorFactory.class.getCanonicalName(); - - public static final String INVM_CONNECTOR_FACTORY = InVMConnectorFactory.class.getCanonicalName(); - - public static final String NETTY_ACCEPTOR_FACTORY = NettyAcceptorFactory.class.getCanonicalName(); - - public static final String NETTY_CONNECTOR_FACTORY = NettyConnectorFactory.class.getCanonicalName(); - - protected static final String CLUSTER_PASSWORD = "UnitTestsClusterPassword"; - - private static final String OS_TYPE = System.getProperty("os.name").toLowerCase(); - private static final int DEFAULT_UDP_PORT; - - - public UnitTestCase() - { - File parent = new File(TARGET_TMP); - parent.mkdirs(); - temporaryFolder = new TemporaryFolder(parent); - } - - static - { - Random random = new Random(); - DEFAULT_UDP_PORT = 6000 + random.nextInt(1000); - } - - // Attributes ---------------------------------------------------- - - // There is a verification about thread leakages. We only fail a single thread when this happens - private static Set alreadyFailedThread = new HashSet(); - - private final Collection servers = new ArrayList(); - private final Collection locators = new ArrayList(); - private final Collection sessionFactories = new ArrayList(); - private final Collection clientSessions = new HashSet(); - private final Collection clientConsumers = new HashSet(); - private final Collection clientProducers = new HashSet(); - private final Collection otherComponents = new HashSet(); - private final Set executorSet = new HashSet(); - - private boolean checkThread = true; - - protected void disableCheckThread() - { - checkThread = false; - } - - protected String getName() - { - return name.getMethodName(); - } - - protected boolean isWindows() - { - return (OS_TYPE.indexOf("win") >= 0); - } - - // Static -------------------------------------------------------- - - protected Configuration createDefaultConfig() throws Exception - { - return createDefaultConfig(false); - } - - protected Configuration createDefaultConfig(int serverId) throws Exception - { - return createDefaultConfig(false, serverId); - } - - protected Configuration createDefaultConfig(final boolean netty) throws Exception - { - if (netty) - { - return createDefaultConfig(new HashMap(), INVM_ACCEPTOR_FACTORY, NETTY_ACCEPTOR_FACTORY); - } - else - { - return createDefaultConfig(new HashMap(), INVM_ACCEPTOR_FACTORY); - } - } - - protected Configuration createDefaultConfig(final boolean netty, int serverId) throws Exception - { - if (netty) - { - return createDefaultConfig(serverId, new HashMap(), INVM_ACCEPTOR_FACTORY, NETTY_ACCEPTOR_FACTORY); - } - else - { - return createDefaultConfig(serverId, new HashMap(), INVM_ACCEPTOR_FACTORY); - } - } - - protected static final ClusterConnectionConfiguration basicClusterConnectionConfig(String connectorName, - String... connectors) - { - ArrayList connectors0 = new ArrayList(); - for (String c : connectors) - { - connectors0.add(c); - } - return basicClusterConnectionConfig(connectorName, connectors0); - } - - protected static final ClusterConnectionConfiguration basicClusterConnectionConfig(String connectorName, - List connectors) - { - ClusterConnectionConfiguration ccc = new ClusterConnectionConfiguration() - .setName("cluster1") - .setAddress("jms") - .setConnectorName(connectorName) - .setRetryInterval(1000) - .setDuplicateDetection(false) - .setForwardWhenNoConsumers(true) - .setMaxHops(1) - .setConfirmationWindowSize(1) - .setStaticConnectors(connectors); - - return ccc; - } - - protected Configuration createDefaultConfig(final int index, - final Map params, - final String... acceptors) - { - Configuration configuration = createBasicConfig(index); - - configuration.getAcceptorConfigurations().clear(); - - for (String acceptor : acceptors) - { - TransportConfiguration transportConfig = new TransportConfiguration(acceptor, params); - configuration.getAcceptorConfigurations().add(transportConfig); - } - - return configuration; - } - - protected final OrderedExecutorFactory getOrderedExecutor() - { - final ExecutorService executor = Executors.newCachedThreadPool(); - executorSet.add(executor); - return new OrderedExecutorFactory(executor); - } - - protected ConfigurationImpl createBasicConfig() throws Exception - { - return createBasicConfig(0); - } - - /** - * @param serverID - * @return - * @throws Exception - */ - protected ConfigurationImpl createBasicConfig(final int serverID) - { - ConfigurationImpl configuration = new ConfigurationImpl() - .setSecurityEnabled(false) - .setJournalMinFiles(2) - .setJournalFileSize(100 * 1024) - .setJournalType(getDefaultJournalType()) - .setJournalDirectory(getJournalDir(serverID, false)) - .setBindingsDirectory(getBindingsDir(serverID, false)) - .setPagingDirectory(getPageDir(serverID, false)) - .setLargeMessagesDirectory(getLargeMessagesDir(serverID, false)) - .setJournalCompactMinFiles(0) - .setJournalCompactPercentage(0) - .setClusterPassword(CLUSTER_PASSWORD); - - return configuration; - } - - public static final ConfigurationImpl createBasicConfig(final String testDir, final int serverID) - { - ConfigurationImpl configuration = new ConfigurationImpl() - .setSecurityEnabled(false) - .setJournalMinFiles(2) - .setJournalFileSize(100 * 1024) - .setJournalType(getDefaultJournalType()) - .setJournalDirectory(getJournalDir(testDir, serverID, false)) - .setBindingsDirectory(getBindingsDir(testDir, serverID, false)) - .setPagingDirectory(getPageDir(testDir, serverID, false)) - .setLargeMessagesDirectory(getLargeMessagesDir(testDir, serverID, false)) - .setJournalCompactMinFiles(0) - .setJournalCompactPercentage(0) - .setClusterPassword(CLUSTER_PASSWORD); - - return configuration; - } - - public static final ConfigurationImpl createBasicConfigNoDataFolder() - { - ConfigurationImpl configuration = new ConfigurationImpl() - .setSecurityEnabled(false) - .setJournalType(getDefaultJournalType()) - .setJournalCompactMinFiles(0) - .setJournalCompactPercentage(0) - .setClusterPassword(CLUSTER_PASSWORD); - - return configuration; - } - - protected Configuration createDefaultConfig(final Map params, final String... acceptors) throws Exception - { - ConfigurationImpl configuration = createBasicConfig(-1) - .setJMXManagementEnabled(false) - .clearAcceptorConfigurations(); - - for (String acceptor : acceptors) - { - TransportConfiguration transportConfig = new TransportConfiguration(acceptor, params); - configuration.addAcceptorConfiguration(transportConfig); - } - - return configuration; - } - - protected static String getUDPDiscoveryAddress() - { - return System.getProperty("TEST-UDP-ADDRESS", "230.1.2.3"); - } - - protected static String getUDPDiscoveryAddress(final int variant) - { - String value = getUDPDiscoveryAddress(); - - int posPoint = value.lastIndexOf('.'); - - int last = Integer.valueOf(value.substring(posPoint + 1)); - - return value.substring(0, posPoint + 1) + (last + variant); - } - - public static int getUDPDiscoveryPort() - { - String port = System.getProperty("TEST-UDP-PORT"); - if (port != null) - { - return Integer.parseInt(port); - } - return DEFAULT_UDP_PORT; - } - - public static int getUDPDiscoveryPort(final int variant) - { - return getUDPDiscoveryPort() + variant; - } - - protected static JournalType getDefaultJournalType() - { - if (AsynchronousFileImpl.isLoaded()) - { - return JournalType.ASYNCIO; - } - else - { - return JournalType.NIO; - } - } - - public static void forceGC() - { - log.info("#test forceGC"); - WeakReference dumbReference = new WeakReference(new Object()); - // A loop that will wait GC, using the minimal time as possible - while (dumbReference.get() != null) - { - System.gc(); - try - { - Thread.sleep(100); - } - catch (InterruptedException e) - { - } - } - log.info("#test forceGC Done"); - } - - public static void forceGC(final Reference ref, final long timeout) - { - long waitUntil = System.currentTimeMillis() + timeout; - // A loop that will wait GC, using the minimal time as possible - while (ref.get() != null && System.currentTimeMillis() < waitUntil) - { - ArrayList list = new ArrayList(); - for (int i = 0; i < 1000; i++) - { - list.add("Some string with garbage with concatenation " + i); - } - list.clear(); - list = null; - System.gc(); - try - { - Thread.sleep(500); - } - catch (InterruptedException e) - { - } - } - } - - /** - * Verifies whether weak references are released after a few GCs. - * - * @param references - * @throws InterruptedException - */ - public static void checkWeakReferences(final WeakReference... references) - { - int i = 0; - boolean hasValue = false; - - do - { - hasValue = false; - - if (i > 0) - { - UnitTestCase.forceGC(); - } - - for (WeakReference ref : references) - { - if (ref.get() != null) - { - hasValue = true; - break; - } - } - } - while (i++ <= 30 && hasValue); - - for (WeakReference ref : references) - { - Assert.assertNull(ref.get()); - } - } - - public static String threadDump(final String msg) - { - StringWriter str = new StringWriter(); - PrintWriter out = new PrintWriter(str); - - Map stackTrace = Thread.getAllStackTraces(); - - out.println("*******************************************************************************"); - out.println("Complete Thread dump " + msg); - - for (Map.Entry el : stackTrace.entrySet()) - { - out.println("==============================================================================="); - out.println("Thread " + el.getKey() + - " name = " + - el.getKey().getName() + - " id = " + - el.getKey().getId() + - " group = " + - el.getKey().getThreadGroup()); - out.println(); - for (StackTraceElement traceEl : el.getValue()) - { - out.println(traceEl); - } - } - - out.println("==============================================================================="); - out.println("End Thread dump " + msg); - out.println("*******************************************************************************"); - - return str.toString(); - } - - /** - * Sends the message to both logger and System.out (for unit report) - */ - public void logAndSystemOut(String message, Exception e) - { - ActiveMQServerLogger log0 = ActiveMQServerLogger.LOGGER; - log0.info(message, e); - System.out.println(message); - e.printStackTrace(System.out); - } - - /** - * Sends the message to both logger and System.out (for unit report) - */ - public void logAndSystemOut(String message) - { - ActiveMQServerLogger log0 = ActiveMQServerLogger.LOGGER; - log0.info(message); - System.out.println(this.getClass().getName() + "::" + message); - } - - public static String dumpBytes(final byte[] bytes) - { - StringBuffer buff = new StringBuffer(); - - buff.append(System.identityHashCode(bytes) + ", size: " + bytes.length + " ["); - - for (int i = 0; i < bytes.length; i++) - { - buff.append(bytes[i]); - - if (i != bytes.length - 1) - { - buff.append(", "); - } - } - - buff.append("]"); - - return buff.toString(); - } - - public static String dumbBytesHex(final byte[] buffer, final int bytesPerLine) - { - - StringBuffer buff = new StringBuffer(); - - buff.append("["); - - for (int i = 0; i < buffer.length; i++) - { - buff.append(String.format("%1$2X", buffer[i])); - if (i + 1 < buffer.length) - { - buff.append(", "); - } - if ((i + 1) % bytesPerLine == 0) - { - buff.append("\n "); - } - } - buff.append("]"); - - return buff.toString(); - } - - public static void assertEqualsByteArrays(final byte[] expected, final byte[] actual) - { - // assertEquals(expected.length, actual.length); - for (int i = 0; i < expected.length; i++) - { - Assert.assertEquals("byte at index " + i, expected[i], actual[i]); - } - } - - public static void assertEqualsTransportConfigurations(final TransportConfiguration[] expected, - final TransportConfiguration[] actual) - { - assertEquals(expected.length, actual.length); - for (int i = 0; i < expected.length; i++) - { - Assert.assertEquals("TransportConfiguration at index " + i, expected[i], actual[i]); - } - } - - public static void assertEqualsBuffers(final int size, final ActiveMQBuffer expected, final ActiveMQBuffer actual) - { - // assertEquals(expected.length, actual.length); - expected.readerIndex(0); - actual.readerIndex(0); - - for (int i = 0; i < size; i++) - { - byte b1 = expected.readByte(); - byte b2 = actual.readByte(); - Assert.assertEquals("byte at index " + i, b1, b2); - } - expected.resetReaderIndex(); - actual.resetReaderIndex(); - } - - public static void assertEqualsByteArrays(final int length, final byte[] expected, final byte[] actual) - { - // we check only for the given length (the arrays might be - // larger) - Assert.assertTrue(expected.length >= length); - Assert.assertTrue(actual.length >= length); - for (int i = 0; i < length; i++) - { - Assert.assertEquals("byte at index " + i, expected[i], actual[i]); - } - } - - public static void assertSameXids(final List expected, final List actual) - { - Assert.assertNotNull(expected); - Assert.assertNotNull(actual); - Assert.assertEquals(expected.size(), actual.size()); - - for (int i = 0; i < expected.size(); i++) - { - Xid expectedXid = expected.get(i); - Xid actualXid = actual.get(i); - UnitTestCase.assertEqualsByteArrays(expectedXid.getBranchQualifier(), actualXid.getBranchQualifier()); - Assert.assertEquals(expectedXid.getFormatId(), actualXid.getFormatId()); - UnitTestCase.assertEqualsByteArrays(expectedXid.getGlobalTransactionId(), actualXid.getGlobalTransactionId()); - } - } - - protected static void checkNoBinding(final Context context, final String binding) - { - try - { - context.lookup(binding); - Assert.fail("there must be no resource to look up for " + binding); - } - catch (Exception e) - { - } - } - - protected static Object checkBinding(final Context context, final String binding) throws Exception - { - Object o = context.lookup(binding); - Assert.assertNotNull(o); - return o; - } - - /** - * @param connectorConfigs - * @return - */ - protected ArrayList registerConnectors(final ActiveMQServer server, - final List connectorConfigs) - { - // The connectors need to be pre-configured at main config object but this method is taking - // TransportConfigurations directly - // So this will first register them at the config and then generate a list of objects - ArrayList connectors = new ArrayList(); - for (TransportConfiguration tnsp : connectorConfigs) - { - String name1 = RandomUtil.randomString(); - - server.getConfiguration().getConnectorConfigurations().put(name1, tnsp); - - connectors.add(name1); - } - return connectors; - } - - protected static final void checkFreePort(final int... ports) - { - for (int port : ports) - { - ServerSocket ssocket = null; - try - { - ssocket = new ServerSocket(port); - } - catch (Exception e) - { - throw new IllegalStateException("port " + port + " is bound", e); - } - finally - { - if (ssocket != null) - { - try - { - ssocket.close(); - } - catch (IOException e) - { - } - } - } - } - } - - /** - * @return the testDir - */ - protected final String getTestDir() - { - return testDir; - } - - protected final void setTestDir(String testDir) - { - this.testDir = testDir; - } - - protected final void clearDataRecreateServerDirs() - { - clearDataRecreateServerDirs(getTestDir()); - } - - protected final void deleteTmpDir() - { - File file = new File(getTestDir()); - deleteDirectory(file); - } - - protected void clearDataRecreateServerDirs(final String testDir1) - { - // Need to delete the root - - File file = new File(testDir1); - deleteDirectory(file); - file.mkdirs(); - - recreateDirectory(getJournalDir(testDir1)); - recreateDirectory(getBindingsDir(testDir1)); - recreateDirectory(getPageDir(testDir1)); - recreateDirectory(getLargeMessagesDir(testDir1)); - recreateDirectory(getClientLargeMessagesDir(testDir1)); - recreateDirectory(getTemporaryDir(testDir1)); - } - - /** - * @return the journalDir - */ - public String getJournalDir() - { - return getJournalDir(getTestDir()); - } - - protected static String getJournalDir(final String testDir1) - { - return testDir1 + "/journal"; - } - - protected String getJournalDir(final int index, final boolean backup) - { - return getJournalDir(getTestDir(), index, backup); - } - - protected static String getJournalDir(final String testDir, final int index, final boolean backup) - { - return getJournalDir(testDir) + directoryNameSuffix(index, backup); - } - - /** - * @return the bindingsDir - */ - protected String getBindingsDir() - { - return getBindingsDir(getTestDir()); - } - - /** - * @return the bindingsDir - */ - protected static String getBindingsDir(final String testDir1) - { - return testDir1 + "/bindings"; - } - - /** - * @return the bindingsDir - */ - protected String getBindingsDir(final int index, final boolean backup) - { - return getBindingsDir(getTestDir(), index, backup); - } - - protected static String getBindingsDir(final String testDir, final int index, final boolean backup) - { - return getBindingsDir(testDir) + directoryNameSuffix(index, backup); - } - - /** - * @return the pageDir - */ - protected String getPageDir() - { - return getPageDir(getTestDir()); - } - - /** - * @return the pageDir - */ - protected static String getPageDir(final String testDir1) - { - return testDir1 + "/page"; - } - - protected String getPageDir(final int index, final boolean backup) - { - return getPageDir(getTestDir(), index, backup); - } - - protected static String getPageDir(final String testDir, final int index, final boolean backup) - { - return getPageDir(testDir) + directoryNameSuffix(index, backup); - } - - /** - * @return the largeMessagesDir - */ - protected String getLargeMessagesDir() - { - return getLargeMessagesDir(getTestDir()); - } - - /** - * @return the largeMessagesDir - */ - protected static String getLargeMessagesDir(final String testDir1) - { - return testDir1 + "/large-msg"; - } - - protected String getLargeMessagesDir(final int index, final boolean backup) - { - return getLargeMessagesDir(getTestDir(), index, backup); - } - - protected static String getLargeMessagesDir(final String testDir, final int index, final boolean backup) - { - return getLargeMessagesDir(testDir) + directoryNameSuffix(index, backup); - } - - private static String directoryNameSuffix(int index, boolean backup) - { - if (index == -1) - return ""; - return index + "-" + (backup ? "B" : "L"); - } - - /** - * @return the clientLargeMessagesDir - */ - protected String getClientLargeMessagesDir() - { - return getClientLargeMessagesDir(getTestDir()); - } - - /** - * @return the clientLargeMessagesDir - */ - protected String getClientLargeMessagesDir(final String testDir1) - { - return testDir1 + "/client-large-msg"; - } - - /** - * @return the temporaryDir - */ - protected final String getTemporaryDir() - { - return getTemporaryDir(getTestDir()); - } - - /** - * @return the temporaryDir - */ - protected String getTemporaryDir(final String testDir1) - { - return testDir1 + "/temp"; - } - - protected static void expectActiveMQException(final String message, final ActiveMQExceptionType errorCode, final ActiveMQAction action) - { - try - { - action.run(); - Assert.fail(message); - } - catch (Exception e) - { - Assert.assertTrue(e instanceof ActiveMQException); - Assert.assertEquals(errorCode, ((ActiveMQException) e).getType()); - } - } - - protected static void expectActiveMQException(final ActiveMQExceptionType errorCode, final ActiveMQAction action) - { - UnitTestCase.expectActiveMQException("must throw a ActiveMQException with the expected errorCode: " + errorCode, - errorCode, - action); - } - - protected static void expectXAException(final int errorCode, final ActiveMQAction action) - { - try - { - action.run(); - Assert.fail("must throw a XAException with the expected errorCode: " + errorCode); - } - catch (Exception e) - { - Assert.assertTrue(e instanceof XAException); - Assert.assertEquals(errorCode, ((XAException) e).errorCode); - } - } - - public static byte getSamplebyte(final long position) - { - return (byte) ('a' + position % ('z' - 'a' + 1)); - } - - // Creates a Fake LargeStream without using a real file - public static InputStream createFakeLargeStream(final long size) throws Exception - { - return new InputStream() - { - private long count; - - private boolean closed = false; - - @Override - public void close() throws IOException - { - super.close(); - closed = true; - } - - @Override - public int read() throws IOException - { - if (closed) - { - throw new IOException("Stream was closed"); - } - if (count++ < size) - { - return UnitTestCase.getSamplebyte(count - 1); - } - else - { - return -1; - } - } - }; - - } - - /** - * It validates a Bean (POJO) using simple setters and getters with random values. - * You can pass a list of properties to be ignored, as some properties will have a pre-defined domain (not being possible to use random-values on them) - */ - protected void validateGettersAndSetters(final Object pojo, final String... ignoredProperties) throws Exception - { - HashSet ignoreSet = new HashSet(); - - for (String ignore : ignoredProperties) - { - ignoreSet.add(ignore); - } - - BeanInfo info = Introspector.getBeanInfo(pojo.getClass()); - - PropertyDescriptor[] properties = info.getPropertyDescriptors(); - - for (PropertyDescriptor prop : properties) - { - Object value; - - if (prop.getPropertyType() == String.class) - { - value = RandomUtil.randomString(); - } - else if (prop.getPropertyType() == Integer.class || prop.getPropertyType() == Integer.TYPE) - { - value = RandomUtil.randomInt(); - } - else if (prop.getPropertyType() == Long.class || prop.getPropertyType() == Long.TYPE) - { - value = RandomUtil.randomLong(); - } - else if (prop.getPropertyType() == Boolean.class || prop.getPropertyType() == Boolean.TYPE) - { - value = RandomUtil.randomBoolean(); - } - else if (prop.getPropertyType() == Double.class || prop.getPropertyType() == Double.TYPE) - { - value = RandomUtil.randomDouble(); - } - else - { - System.out.println("Can't validate property of type " + prop.getPropertyType() + " on " + prop.getName()); - value = null; - } - - if (value != null && prop.getWriteMethod() != null && prop.getReadMethod() == null) - { - System.out.println("WriteOnly property " + prop.getName() + " on " + pojo.getClass()); - } - else if (value != null & prop.getWriteMethod() != null && - prop.getReadMethod() != null && - !ignoreSet.contains(prop.getName())) - { - System.out.println("Validating " + prop.getName() + " type = " + prop.getPropertyType()); - prop.getWriteMethod().invoke(pojo, value); - - Assert.assertEquals("Property " + prop.getName(), value, prop.getReadMethod().invoke(pojo)); - } - } - } - - // Package protected --------------------------------------------- - - // Protected ----------------------------------------------------- - - Map previousThreads; - - @Before - public void setUp() throws Exception - { - testDir = temporaryFolder.getRoot().getAbsolutePath(); - clearDataRecreateServerDirs(); - OperationContextImpl.clearContext(); - - InVMRegistry.instance.clear(); - - // checkFreePort(TransportConstants.DEFAULT_PORT); - - previousThreads = Thread.getAllStackTraces(); - - logAndSystemOut("#test " + getName()); - } - - @After - public void tearDown() throws Exception - { - for (ExecutorService s : executorSet) - { - s.shutdown(); - } - closeAllSessionFactories(); - closeAllServerLocatorsFactories(); - - try - { - assertAllExecutorsFinished(); - assertAllClientConsumersAreClosed(); - assertAllClientProducersAreClosed(); - assertAllClientSessionsAreClosed(); - } - finally - { - synchronized (servers) - { - for (ActiveMQServer server : servers) - { - if (server == null) - continue; - try - { - final ClusterManager clusterManager = server.getClusterManager(); - if (clusterManager != null) - { - for (ClusterConnection cc : clusterManager.getClusterConnections()) - { - stopComponent(cc); - } - } - } - catch (Exception e) - { - // no-op - } - stopComponentOutputExceptions(server); - } - servers.clear(); - } - - closeAllOtherComponents(); - - ArrayList exceptions; - try - { - exceptions = checkCsfStopped(); - } - finally - { - cleanupPools(); - } - //clean up pools before failing - if (!exceptions.isEmpty()) - { - for (Exception exception : exceptions) - { - exception.printStackTrace(); - } - fail("Client Session Factories still trying to reconnect, see above to see where created"); - } - Map threadMap = Thread.getAllStackTraces(); - for (Thread thread : threadMap.keySet()) - { - StackTraceElement[] stack = threadMap.get(thread); - for (StackTraceElement stackTraceElement : stack) - { - if (stackTraceElement.getMethodName().contains("getConnectionWithRetry") && !alreadyFailedThread.contains(thread)) - { - alreadyFailedThread.add(thread); - System.out.println(threadDump(this.getName() + " has left threads running. Look at thread " + - thread.getName() + - " id = " + - thread.getId() + - " has running locators on test " + - this.getName() + - " on this following dump")); - fail("test '" + getName() + "' left serverlocator running, this could effect other tests"); - } - else if (stackTraceElement.getMethodName().contains("BroadcastGroupImpl.run") && !alreadyFailedThread.contains(thread)) - { - alreadyFailedThread.add(thread); - System.out.println(threadDump(this.getName() + " has left threads running. Look at thread " + - thread.getName() + - " id = " + - thread.getId() + - " is still broadcasting " + - this.getName() + - " on this following dump")); - fail("test left broadcastgroupimpl running, this could effect other tests"); - } - } - } - - if (checkThread) - { - StringBuffer buffer = null; - - boolean failed = true; - - - long timeout = System.currentTimeMillis() + 60000; - while (failed && timeout > System.currentTimeMillis()) - { - buffer = new StringBuffer(); - - failed = checkThread(buffer); - - if (failed) - { - forceGC(); - Thread.sleep(500); - log.info("There are still threads running, trying again"); - System.out.println(buffer); - } - } - - if (failed) - { - logAndSystemOut("Thread leaked on test " + this.getClass().getName() + "::" + this.getName() + "\n" + - buffer); - logAndSystemOut("Thread leakage"); - - fail("Thread leaked"); - } - - } - else - { - checkThread = true; - } - - if (Thread.currentThread().getContextClassLoader() == null) - { - Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); - fail("Thread Context ClassLoader was set to null at some point before this test. We will set to this.getClass().getClassLoader(), but you are supposed to fix your tests"); - } - - checkFilesUsage(); - } - } - - private void assertAllExecutorsFinished() throws InterruptedException - { - for (ExecutorService s : executorSet) - { - Assert.assertTrue(s.awaitTermination(5, TimeUnit.SECONDS)); - } - } - - private ArrayList checkCsfStopped() - { - long time = System.currentTimeMillis(); - long waitUntil = time + 5000; - while (!ClientSessionFactoryImpl.CLOSE_RUNNABLES.isEmpty() && time < waitUntil) - { - try - { - Thread.sleep(50); - } - catch (InterruptedException e) - { - //ignore - } - time = System.currentTimeMillis(); - } - List closeRunnables = - new ArrayList(ClientSessionFactoryImpl.CLOSE_RUNNABLES); - ArrayList exceptions = new ArrayList(); - - if (!closeRunnables.isEmpty()) - { - for (ClientSessionFactoryImpl.CloseRunnable closeRunnable : closeRunnables) - { - if (closeRunnable != null) - { - exceptions.add(closeRunnable.stop().createTrace); - } - } - } - - return exceptions; - } - - private void assertAllClientProducersAreClosed() - { - synchronized (clientProducers) - { - for (ClientProducer p : clientProducers) - { - assertTrue(p + " should be closed", p.isClosed()); - } - clientProducers.clear(); - } - } - - /** - * - */ - private void closeAllOtherComponents() - { - synchronized (otherComponents) - { - for (ActiveMQComponent c : otherComponents) - { - stopComponent(c); - } - otherComponents.clear(); - } - } - - /** - * @param buffer - * @return - */ - private boolean checkThread(StringBuffer buffer) - { - boolean failedThread = false; - - Map postThreads = Thread.getAllStackTraces(); - - if (postThreads != null && previousThreads != null && postThreads.size() > previousThreads.size()) - { - - buffer.append("*********************************************************************************\n"); - buffer.append("LEAKING THREADS\n"); - - for (Thread aliveThread : postThreads.keySet()) - { - if (!isExpectedThread(aliveThread) && !previousThreads.containsKey(aliveThread)) - { - failedThread = true; - buffer.append("=============================================================================\n"); - buffer.append("Thread " + aliveThread + " is still alive with the following stackTrace:\n"); - StackTraceElement[] elements = postThreads.get(aliveThread); - for (StackTraceElement el : elements) - { - buffer.append(el + "\n"); - } - } - - } - buffer.append("*********************************************************************************\n"); - - } - return failedThread; - } - - /** - * if it's an expected thread... we will just move along ignoring it - * - * @param thread - * @return - */ - private boolean isExpectedThread(Thread thread) - { - final String threadName = thread.getName(); - final ThreadGroup group = thread.getThreadGroup(); - final boolean isSystemThread = group != null && "system".equals(group.getName()); - final String javaVendor = System.getProperty("java.vendor"); - - if (threadName.contains("SunPKCS11")) - { - return true; - } - else if (threadName.contains("Attach Listener")) - { - return true; - } - else if ((javaVendor.contains("IBM") || isSystemThread) && threadName.equals("process reaper")) - { - return true; - } - else if (javaVendor.contains("IBM") && threadName.equals("MemoryPoolMXBean notification dispatcher")) - { - return true; - } - else if (threadName.contains("globalEventExecutor")) - { - return true; - } - else if (threadName.contains("threadDeathWatcher")) - { - return true; - } - else if (threadName.contains("netty-threads")) - { - // This is ok as we use EventLoopGroup.shutdownGracefully() which will shutdown things with a bit of delay - // if the EventLoop's are still busy. - return true; - } - else if (threadName.contains("threadDeathWatcher")) - { - //another netty thread - return true; - } - else - { - for (StackTraceElement element : thread.getStackTrace()) - { - if (element.getClassName().contains("org.jboss.byteman.agent.TransformListener")) - { - return true; - } - } - return false; - } - } - - - private void checkFilesUsage() - { - long timeout = System.currentTimeMillis() + 15000; - - while (AsynchronousFileImpl.getTotalMaxIO() != 0 && System.currentTimeMillis() > timeout) - { - try - { - Thread.sleep(100); - } - catch (Exception ignored) - { - } - } - - int invmSize = InVMRegistry.instance.size(); - if (invmSize > 0) - { - InVMRegistry.instance.clear(); - log.info(threadDump("Thread dump")); - fail("invm registry still had acceptors registered"); - } - - final int totalMaxIO = AsynchronousFileImpl.getTotalMaxIO(); - if (totalMaxIO != 0) - { - AsynchronousFileImpl.resetMaxAIO(); - Assert.fail("test did not close all its files " + totalMaxIO); - } - } - - private void cleanupPools() - { - OperationContextImpl.clearContext(); - - // We shutdown the global pools to give a better isolation between tests - try - { - ServerLocatorImpl.clearThreadPools(); - } - catch (Throwable e) - { - log.info(threadDump(e.getMessage())); - System.err.println(threadDump(e.getMessage())); - } - - try - { - NettyConnector.clearThreadPools(); - } - catch (Exception e) - { - log.info(threadDump(e.getMessage())); - System.err.println(threadDump(e.getMessage())); - } - } - - protected static final byte[] autoEncode(final Object... args) - { - - int size = 0; - - for (Object arg : args) - { - if (arg instanceof Byte) - { - size++; - } - else if (arg instanceof Boolean) - { - size++; - } - else if (arg instanceof Integer) - { - size += 4; - } - else if (arg instanceof Long) - { - size += 8; - } - else if (arg instanceof Float) - { - size += 4; - } - else if (arg instanceof Double) - { - size += 8; - } - else - { - throw ActiveMQMessageBundle.BUNDLE.autoConvertError(arg.getClass()); - } - } - - ByteBuffer buffer = ByteBuffer.allocate(size); - - for (Object arg : args) - { - if (arg instanceof Byte) - { - buffer.put(((Byte) arg).byteValue()); - } - else if (arg instanceof Boolean) - { - Boolean b = (Boolean) arg; - buffer.put((byte) (b.booleanValue() ? 1 : 0)); - } - else if (arg instanceof Integer) - { - buffer.putInt(((Integer) arg).intValue()); - } - else if (arg instanceof Long) - { - buffer.putLong(((Long) arg).longValue()); - } - else if (arg instanceof Float) - { - buffer.putFloat(((Float) arg).floatValue()); - } - else if (arg instanceof Double) - { - buffer.putDouble(((Double) arg).doubleValue()); - } - else - { - throw ActiveMQMessageBundle.BUNDLE.autoConvertError(arg.getClass()); - } - } - - return buffer.array(); - } - - protected static final void recreateDirectory(final String directory) - { - File file = new File(directory); - deleteDirectory(file); - file.mkdirs(); - } - - protected static final boolean deleteDirectory(final File directory) - { - if (directory.isDirectory()) - { - String[] files = directory.list(); - int num = 5; - int attempts = 0; - while (files == null && (attempts < num)) - { - try - { - Thread.sleep(100); - } - catch (InterruptedException e) - { - } - files = directory.list(); - attempts++; - } - - for (String file : files) - { - File f = new File(directory, file); - if (!deleteDirectory(f)) - { - log.warn("Failed to clean up file: " + f.getAbsolutePath()); - } - } - } - - return directory.delete(); - } - - protected static final void copyRecursive(final File from, final File to) throws Exception - { - if (from.isDirectory()) - { - if (!to.exists()) - { - to.mkdir(); - } - - String[] subs = from.list(); - - for (String sub : subs) - { - copyRecursive(new File(from, sub), new File(to, sub)); - } - } - else - { - InputStream in = null; - - OutputStream out = null; - - try - { - in = new BufferedInputStream(new FileInputStream(from)); - - out = new BufferedOutputStream(new FileOutputStream(to)); - - int b; - - while ((b = in.read()) != -1) - { - out.write(b); - } - } - finally - { - if (in != null) - { - in.close(); - } - - if (out != null) - { - out.close(); - } - } - } - } - - protected void assertRefListsIdenticalRefs(final List l1, final List l2) - { - if (l1.size() != l2.size()) - { - Assert.fail("Lists different sizes: " + l1.size() + ", " + l2.size()); - } - - Iterator iter1 = l1.iterator(); - Iterator iter2 = l2.iterator(); - - while (iter1.hasNext()) - { - MessageReference o1 = iter1.next(); - MessageReference o2 = iter2.next(); - - Assert.assertTrue("expected " + o1 + " but was " + o2, o1 == o2); - } - } - - protected ServerMessage generateMessage(final long id) - { - ServerMessage message = new ServerMessageImpl(id, 1000); - - message.setMessageID(id); - - message.getBodyBuffer().writeString(UUID.randomUUID().toString()); - - message.setAddress(new SimpleString("foo")); - - return message; - } - - protected MessageReference generateReference(final Queue queue, final long id) - { - ServerMessage message = generateMessage(id); - - return message.createReference(queue); - } - - protected int calculateRecordSize(final int size, final int alignment) - { - return (size / alignment + (size % alignment != 0 ? 1 : 0)) * alignment; - } - - protected ClientMessage createTextMessage(final ClientSession session, final String s) - { - return createTextMessage(session, s, true); - } - - - protected ClientMessage createTextMessage(final ClientSession session, final String s, final boolean durable) - { - ClientMessage message = session.createMessage(Message.TEXT_TYPE, - durable, - 0, - System.currentTimeMillis(), - (byte) 4); - message.getBodyBuffer().writeString(s); - return message; - } - - protected XidImpl newXID() - { - return new XidImpl("xa1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes()); - } - - protected int getMessageCount(final ActiveMQServer service, final String address) throws Exception - { - return getMessageCount(service.getPostOffice(), address); - } - - /** - * @param address - * @param postOffice - * @return - * @throws Exception - */ - protected int getMessageCount(final PostOffice postOffice, final String address) throws Exception - { - int messageCount = 0; - - List bindings = getLocalQueueBindings(postOffice, address); - - for (QueueBinding qBinding : bindings) - { - qBinding.getQueue().flushExecutor(); - messageCount += getMessageCount(qBinding.getQueue()); - } - - return messageCount; - } - - protected int getMessageCount(final Queue queue) - { - queue.flushExecutor(); - return (int)queue.getMessageCount(); - } - - protected int getMessagesAdded(final Queue queue) - { - queue.flushExecutor(); - return (int)queue.getMessagesAdded(); - } - - protected List getLocalQueueBindings(final PostOffice postOffice, final String address) throws Exception - { - ArrayList bindingsFound = new ArrayList(); - - Bindings bindings = postOffice.getBindingsForAddress(new SimpleString(address)); - - for (Binding binding : bindings.getBindings()) - { - if (binding instanceof LocalQueueBinding) - { - bindingsFound.add((QueueBinding) binding); - } - } - return bindingsFound; - } - - /** - * It will inspect the journal directly and determine if there are queues on this journal, - * - * @param serverToInvestigate - * @return a Map containing the reference counts per queue - * @throws Exception - */ - protected Map loadQueues(ActiveMQServer serverToInvestigate) throws Exception - { - SequentialFileFactory messagesFF = new NIOSequentialFileFactory(serverToInvestigate.getConfiguration() - .getJournalDirectory()); - - JournalImpl messagesJournal = new JournalImpl(serverToInvestigate.getConfiguration().getJournalFileSize(), - serverToInvestigate.getConfiguration().getJournalMinFiles(), - 0, - 0, - messagesFF, - "activemq-data", - "amq", - 1); - List records = new LinkedList(); - - List preparedTransactions = new LinkedList(); - - messagesJournal.start(); - messagesJournal.load(records, preparedTransactions, null); - - // These are more immutable integers - Map messageRefCounts = new HashMap(); - - for (RecordInfo info : records) - { - Object o = DescribeJournal.newObjectEncoding(info); - if (info.getUserRecordType() == JournalRecordIds.ADD_REF) - { - ReferenceDescribe ref = (ReferenceDescribe) o; - AtomicInteger count = messageRefCounts.get(ref.refEncoding.queueID); - if (count == null) - { - count = new AtomicInteger(1); - messageRefCounts.put(ref.refEncoding.queueID, count); - } - else - { - count.incrementAndGet(); - } - } - } - - messagesJournal.stop(); - - return messageRefCounts; - - } - - protected final ServerLocator createInVMNonHALocator() - { - return createNonHALocator(false); - } - - protected final ServerLocator createNettyNonHALocator() - { - return createNonHALocator(true); - } - - protected final ServerLocator createNonHALocator(final boolean isNetty) - { - ServerLocator locatorWithoutHA = internalCreateNonHALocator(isNetty); - return addServerLocator(locatorWithoutHA); - } - - /** - * Creates the Locator without adding it to the list where the tearDown will take place - * This is because we don't want it closed in certain tests where we are issuing failures - * @param isNetty - * @return - */ - protected ServerLocator internalCreateNonHALocator(boolean isNetty) - { - return isNetty - ? ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(NETTY_CONNECTOR_FACTORY)) - : ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(INVM_CONNECTOR_FACTORY)); - } - - protected static final void stopComponent(ActiveMQComponent component) - { - if (component == null) - return; - try - { - component.stop(); - } - catch (Exception e) - { - // no-op - } - } - - protected static final void stopComponentOutputExceptions(ActiveMQComponent component) - { - if (component == null) - return; - try - { - component.stop(); - } - catch (Exception e) - { - System.err.println("Exception closing " + component); - e.printStackTrace(); - } - } - - protected final ClientSessionFactory createSessionFactory(ServerLocator locator) throws Exception - { - ClientSessionFactory sf = locator.createSessionFactory(); - addSessionFactory(sf); - return sf; - } - - protected final ActiveMQServer addServer(final ActiveMQServer server) - { - if (server != null) - { - synchronized (servers) - { - servers.add(server); - } - } - return server; - } - - protected final ServerLocator addServerLocator(final ServerLocator locator) - { - if (locator != null) - { - synchronized (locators) - { - locators.add(locator); - } - } - return locator; - } - - protected final ClientSession addClientSession(final ClientSession session) - { - if (session != null) - { - synchronized (clientSessions) - { - clientSessions.add(session); - } - } - return session; - } - - protected final ClientConsumer addClientConsumer(final ClientConsumer consumer) - { - if (consumer != null) - { - synchronized (clientConsumers) - { - clientConsumers.add(consumer); - } - } - return consumer; - } - - protected final ClientProducer addClientProducer(final ClientProducer producer) - { - if (producer != null) - { - synchronized (clientProducers) - { - clientProducers.add(producer); - } - } - return producer; - } - - protected final void addActiveMQComponent(final ActiveMQComponent component) - { - if (component != null) - { - synchronized (otherComponents) - { - otherComponents.add(component); - } - } - } - - protected final ClientSessionFactory addSessionFactory(final ClientSessionFactory sf) - { - if (sf != null) - { - synchronized (sessionFactories) - { - sessionFactories.add(sf); - } - } - return sf; - } - - private void assertAllClientConsumersAreClosed() - { - synchronized (clientConsumers) - { - for (ClientConsumer cc : clientConsumers) - { - if (cc == null) - continue; - assertTrue(cc.isClosed()); - } - clientConsumers.clear(); - } - } - - private void assertAllClientSessionsAreClosed() - { - synchronized (clientSessions) - { - for (final ClientSession cs : clientSessions) - { - if (cs == null) - continue; - assertTrue(cs.isClosed()); - } - clientSessions.clear(); - } - } - - protected void closeAllSessionFactories() - { - synchronized (sessionFactories) - { - for (ClientSessionFactory sf : sessionFactories) - { - closeSessionFactory(sf); - assert sf.isClosed(); - } - sessionFactories.clear(); - } - } - - protected void closeAllServerLocatorsFactories() - { - synchronized (locators) - { - for (ServerLocator locator : locators) - { - closeServerLocator(locator); - } - locators.clear(); - } - } - - public static final void closeServerLocator(ServerLocator locator) - { - if (locator == null) - return; - try - { - locator.close(); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - public static final void closeSessionFactory(final ClientSessionFactory sf) - { - if (sf == null) - return; - try - { - sf.close(); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - public static void crashAndWaitForFailure(ActiveMQServer server, ClientSession... sessions) throws Exception - { - CountDownLatch latch = new CountDownLatch(sessions.length); - for (ClientSession session : sessions) - { - CountDownSessionFailureListener listener = new CountDownSessionFailureListener(latch, session); - session.addFailureListener(listener); - } - - ClusterManager clusterManager = server.getClusterManager(); - clusterManager.flushExecutor(); - clusterManager.clear(); - Assert.assertTrue("server should be running!", server.isStarted()); - server.stop(true); - - if (sessions.length > 0) - { - // Wait to be informed of failure - boolean ok = latch.await(10000, TimeUnit.MILLISECONDS); - Assert.assertTrue("Failed to stop the server! Latch count is " + latch.getCount() + " out of " + - sessions.length, ok); - } - } - - public static void crashAndWaitForFailure(ActiveMQServer server, ServerLocator locator) throws Exception - { - ClientSessionFactory sf = locator.createSessionFactory(); - ClientSession session = sf.createSession(); - try - { - crashAndWaitForFailure(server, session); - } - finally - { - try - { - session.close(); - sf.close(); - } - catch (Exception ignored) - { - } - } - } - - public interface RunnerWithEX - { - void run() throws Throwable; - } - - // This can be used to interrupt a thread if it takes more than timeoutMilliseconds - public boolean runWithTimeout(final RunnerWithEX runner, final long timeoutMilliseconds) throws Throwable - { - - class ThreadRunner extends Thread - { - - Throwable t; - - final RunnerWithEX run; - - ThreadRunner(RunnerWithEX run) - { - this.run = run; - } - - public void run() - { - try - { - runner.run(); - } - catch (Throwable t) - { - this.t = t; - } - } - } - - ThreadRunner runnerThread = new ThreadRunner(runner); - - runnerThread.start(); - - boolean hadToInterrupt = false; - while (runnerThread.isAlive()) - { - runnerThread.join(timeoutMilliseconds); - if (runnerThread.isAlive()) - { - System.err.println("Thread still running, interrupting it now:"); - for (Object t : runnerThread.getStackTrace()) - { - System.err.println(t); - } - hadToInterrupt = true; - runnerThread.interrupt(); - } - } - - if (runnerThread.t != null) - { - runnerThread.t.printStackTrace(); - throw runnerThread.t; - } - - // we are returning true if it ran ok. - // had to Interrupt is exactly the opposite of what we are returning - return !hadToInterrupt; - } - - - // Private ------------------------------------------------------- - - // Inner classes ------------------------------------------------- - - protected interface ActiveMQAction - { - void run() throws Exception; - } - - /** - * Asserts that latch completes within a (rather large interval). - *

- * Use this instead of just calling {@code latch.await()}. Otherwise your test may hang the whole - * test run if it fails to count-down the latch. - * - * @param latch - * @throws InterruptedException - */ - public static void waitForLatch(CountDownLatch latch) throws InterruptedException - { - assertTrue("Latch has got to return within a minute", latch.await(1, TimeUnit.MINUTES)); - } -} diff --git a/artemis-website/pom.xml b/artemis-website/pom.xml index 1db47fd15e..db3fbd8c9c 100644 --- a/artemis-website/pom.xml +++ b/artemis-website/pom.xml @@ -27,43 +27,44 @@ jar ActiveMQ Artemis Web - - - org.apache.activemq - artemis-core-client - ${project.version} - - - org.apache.activemq - artemis-jms-client - ${project.version} - - - org.apache.activemq - artemis-server - ${project.version} - - - org.apache.activemq - artemis-jms-server - ${project.version} - - - org.apache.activemq - artemis-journal - ${project.version} - - - org.apache.activemq - artemis-selector - ${project.version} - - + + + org.apache.activemq + artemis-core-client + ${project.version} + + + org.apache.activemq + artemis-jms-client + ${project.version} + + + org.apache.activemq + artemis-server + ${project.version} + + + org.apache.activemq + artemis-jms-server + ${project.version} + + + org.apache.activemq + artemis-journal + ${project.version} + + + org.apache.activemq + artemis-selector + ${project.version} + + - ${project.basedir}/.. - ${project.artifactId}-${project.version} - ${basedir}/target/classes/user-manual + ${project.basedir}/.. + ${project.artifactId}-${project.version} + ${basedir}/target/classes/user-manual + ${basedir}/target/classes/hacking-guide @@ -109,35 +110,42 @@ release - - + + maven-antrun-plugin 1.6 - - generate-sources - - - - - - - - executing ${gitbook.cmd} - - - - - - - - - run - - + + generate-sources + + + + + + + + executing ${gitbook.cmd} + + + + + + + executing ${gitbook.cmd} + + + + + + + + + run + + - - + + diff --git a/artemis-website/src/main/resources/hacking-guide/index.html b/artemis-website/src/main/resources/hacking-guide/index.html new file mode 100644 index 0000000000..ef75a15157 --- /dev/null +++ b/artemis-website/src/main/resources/hacking-guide/index.html @@ -0,0 +1,24 @@ + + +

User Manual

+ +

If you are seeing this message, it is because the Hacking Guide was not built during the Apache ActiveMQ Artemis build. To +build Apache ActiveMQ Artemis with the Hacking Guide you must use the maven release profile: +mvn clean install -Prelease.

\ No newline at end of file diff --git a/artemis-website/src/main/resources/index.html b/artemis-website/src/main/resources/index.html index a805c32c7d..dceecd37f7 100644 --- a/artemis-website/src/main/resources/index.html +++ b/artemis-website/src/main/resources/index.html @@ -52,6 +52,7 @@ diff --git a/artemis-website/src/main/resources/user-manual/index.html b/artemis-website/src/main/resources/user-manual/index.html index 64903181c0..a36e404c94 100644 --- a/artemis-website/src/main/resources/user-manual/index.html +++ b/artemis-website/src/main/resources/user-manual/index.html @@ -21,6 +21,4 @@ under the License.

If you are seeing this message, it is because the User Manual was not built during the Apache ActiveMQ Artemis build. To build Apache ActiveMQ Artemis with the User Manual you must use the maven release profile: -mvn clean install -Prelease.

- -

Please see the README in the source distribution for more information.

+mvn clean install -Prelease.

\ No newline at end of file diff --git a/docs/hacking-guide/en/README.md b/docs/hacking-guide/en/README.md new file mode 100644 index 0000000000..43de4dbfcf --- /dev/null +++ b/docs/hacking-guide/en/README.md @@ -0,0 +1,7 @@ +![ActiveMQ Artemis logo](images/artemis-logo.jpg) + +Apache ActiveMQ Artemis Hacking Guide +===================================== + +This hacking guide outlines how developers can get involved in contributing to the Apache ActiveMQ Artemis project. + diff --git a/docs/hacking-guide/en/SUMMARY.md b/docs/hacking-guide/en/SUMMARY.md new file mode 100644 index 0000000000..d9c7a05499 --- /dev/null +++ b/docs/hacking-guide/en/SUMMARY.md @@ -0,0 +1,10 @@ +# Summary + +* [Legal Notice](notice.md) +* [Working with the Code](code.md) +* [IDE Integration](ide.md) +* [Building](building.md) +* [Tests](tests.md) +* [Code Formatting](formatting.md) +* [Notes for Maintainers](maintainers.md) + diff --git a/docs/hacking-guide/en/book.json b/docs/hacking-guide/en/book.json new file mode 100644 index 0000000000..0d6ce8b0a4 --- /dev/null +++ b/docs/hacking-guide/en/book.json @@ -0,0 +1,11 @@ +{ + "title": "ActiveMQ Artemis Documentation", + "description": "ActiveMQ Artemis Hacking Guide", + "github": "apache/activemq-artemis", + "githubHost": "https://github.com/", + "links": { + "home": "http://activemq.apache.org/", + "issues": "http://activemq.apache.org/", + "contribute": "http://activemq.apache.org/contributing.html" + } +} \ No newline at end of file diff --git a/docs/hacking-guide/en/building.md b/docs/hacking-guide/en/building.md new file mode 100644 index 0000000000..2651745a62 --- /dev/null +++ b/docs/hacking-guide/en/building.md @@ -0,0 +1,48 @@ +# Building + +We use Apache Maven to build the code, docs, distribution, etc. and to manage dependencies. + +The minimum required Maven version is 3.0.0. + +Note that there are some [compatibility issues with Maven 3.X](https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Compatibility+Notes) +still unsolved. This is specially true for the ['site' plugin](https://maven.apache.org/plugins-archives/maven-site-plugin-3.3/maven-3.html). + +## Full Release + +The full release uses `gitbook` to build a static website from the documentation, if you don't have `gitbook` installed +then you can build the distribution without docs (see below) or install `gitbook` using `npm`: + + $ npm install -g gitbook gitbook-cli + +If you don't have `npm` installed then you would need to install it first. + +#### Install npm On Fedora + + $ yum install npm + +#### Install npm On Mac-OS + +The easiest way would be through brew [brew] + +You first install brew using the instructions on the [brew] website. + +After you installed brew you can install npm by: + + brew install npm + +[brew]: + +To build the full release with documentation, Javadocs, and the full web site: + + $ mvn -Prelease package + +To install it to your local maven repo: + + $ mvn -Prelease install + +## Build the distribution without docs + +It is possible to build a distribution with out the manuals and Javadocs if you don't have or want `gitbook` installed, +simply run + + $ mvn package \ No newline at end of file diff --git a/docs/hacking-guide/en/code.md b/docs/hacking-guide/en/code.md new file mode 100644 index 0000000000..c25fe4c664 --- /dev/null +++ b/docs/hacking-guide/en/code.md @@ -0,0 +1,164 @@ +# Working with the Code + +While the canonical Apache ActiveMQ Artemis git repository is hosted on Apache hardware at https://git-wip-us.apache.org/repos/asf?p=activemq-artemis.git +the developers use a mirror on GitHub for collaboration and pull-request review functionality. + +## Initial Steps + +1. Create a github account if you don't have one already + + http://github.com + +1. Fork the apache-artemis repository into your account + + https://github.com/apache/activemq-artemis + +1. Clone your newly forked copy onto your local workspace: + + $ git clone git@github.com:/activemq-artemis.git + Cloning into 'activemq-artemis'... + remote: Counting objects: 63800, done. + remote: Compressing objects: 100% (722/722), done. + remote: Total 63800 (delta 149), reused 0 (delta 0), pack-reused 62748 + Receiving objects: 100% (63800/63800), 18.28 MiB | 3.16 MiB/s, done. + Resolving deltas: 100% (28800/28800), done. + Checking connectivity... done. + + $ cd activemq-artemis + +1. Add a remote reference to `upstream` for pulling future updates + + $ git remote add upstream https://github.com/apache/activemq-artemis + +1. Build with Maven + + Typically developers will want to build using the `dev` profile which disables license and code style checks. For + example: + + $ mvn -Pdev install + ... + [INFO] ------------------------------------------------------------------------ + [INFO] Reactor Summary: + [INFO] + [INFO] ActiveMQ Artemis Parent ........................... SUCCESS [2.298s] + [INFO] ActiveMQ Artemis Commons .......................... SUCCESS [1.821s] + [INFO] ActiveMQ Artemis Selector Implementation .......... SUCCESS [0.767s] + [INFO] ActiveMQ Artemis Native POM ....................... SUCCESS [0.189s] + [INFO] ActiveMQ Artemis Journal .......................... SUCCESS [0.646s] + [INFO] ActiveMQ Artemis Core Client ...................... SUCCESS [5.969s] + [INFO] ActiveMQ Artemis JMS Client ....................... SUCCESS [2.110s] + [INFO] ActiveMQ Artemis Server ........................... SUCCESS [11.540s] + ... + [INFO] ActiveMQ Artemis stress Tests ..................... SUCCESS [0.332s] + [INFO] ActiveMQ Artemis performance Tests ................ SUCCESS [0.174s] + [INFO] ------------------------------------------------------------------------ + [INFO] BUILD SUCCESS + [INFO] ------------------------------------------------------------------------ + +## Typical development cycle + +1. Identify a task (e.g. a bug to fix or feature to implement) + + https://issues.apache.org/jira/browse/ACTIVEMQ6 + +1. Create a topic branch in your local git repo to do your work + + $ git checkout -b my_cool_feature + +1. Make the changes and commit one or more times + + $ git commit + + When you commit your changes you will need to supply a commit message. We follow the + 50/72 git commit message format. An ActiveMQ Artemis commit message should be formatted in the following manner: + + 1. Add the ACTIVEMQ6 JIRA (if one exists) followed by a brief description of the change in the first line. This line + should be limited to 50 characters. + 1. Insert a single blank line after the first line. + 1. Provide a detailed description of the change in the following lines, breaking paragraphs where needed. These lines + should be wrapped at 72 characters. + + An example correctly formatted commit message: + + ACTIVEMQ6-123 Add new commit msg format to README + + Adds a description of the new commit message format as well as examples + of well formatted commit messages to the README.md. This is required + to enable developers to quickly identify what the commit is intended to + do and why the commit was added. + +1. Occasionally you'll want to push your commit(s) to GitHub for safe-keeping and/or sharing with others. + + git push origin my_cool_feature + + Note that git push references the branch you are pushing and defaults to `master`, not your working branch. + +1. Discuss your planned changes (if you want feedback) + + On mailing list - http://activemq.apache.org/mailing-lists.html + On IRC - irc://irc.freenode.org/apache-activemq or https://webchat.freenode.net/?channels=apache-activemq + +1. Once you're finished coding your feature/fix then rebase your branch against the latest master (applies your patches + on top of master) + + git fetch upstream + git rebase -i upstream/master + # if you have conflicts fix them and rerun rebase + # The -f, forces the push, alters history, see note below + git push -f origin my_cool_feature + + The `rebase -i` triggers an interactive update which also allows you to combine commits, alter commit messages etc. + It's a good idea to make the commit log very nice for external consumption (e.g. by squashing all related commits + into a single commit. Note that rebasing and/or using `push -f` can alter history. While this is great for making a + clean patch, it is unfriendly to anyone who has forked your branch. Therefore you'll want to make sure that you + either work in a branch that you don't share, or if you do share it, tell them you are about to revise the branch + history (and thus, they will then need to rebase on top of your branch once you push it out). + +1. Get your changes merged into upstream + + 1. Send a github pull request, by clicking the pull request link while in your repo's fork. + 1. An email will automatically be sent to the ActiveMQ developer list. + 1. As part of the review you may see an automated test run comment on your request. + 1. After review a maintainer will merge your PR into the canonical git repository at which point those changes will + be synced with the GitHub mirror repository (i.e. your `master`) and your PR will be closed by the `asfgit` bot. + +## Other common tasks + +1. Pulling updates from upstream + + $ git pull --rebase upstream master + + (`--rebase` will automatically move your local commits, if any, on top of the latest branch you pull from; you can leave + it off if you do not have any local commits). + + One last option, which some prefer, is to avoid using pull altogether, and just use fetch + rebase (this is of course + more typing). For example: + + $ git fetch upstream + $ git pull + +1. Pushing pulled updates (or local commits if you aren't using topic branches) to your private github repo (origin) + + $ git push + Counting objects: 192, done. + Delta compression using up to 4 threads. + Compressing objects: 100% (44/44), done. + Writing objects: 100% (100/100), 10.67 KiB, done. + Total 100 (delta 47), reused 100 (delta 47) + To git@github.com:/apache-artemis.git + 3382570..1fa25df master -> master + + You might need to say -f to force the changes. + +## Adding New Dependencies + +Due to incompatibilities between some open source licenses and the Apache v2.0 license (that this project is licensed under) +care must be taken when adding new dependencies to the project. The Apache Software Foundation 3rd party licensing +policy has more information here: http://www.apache.org/legal/3party.html + +To keep track of all licenses in ActiveMQ Artemis, new dependencies must be added in either the top level pom.xml or in test/pom.xml +(depending on whether this is a test only dependency or if it is used in the main code base). The dependency should be +added under the dependency management section with version and labelled with a comment highlighting the license for the +dependency version. See existing dependencies in the main pom.xml for examples. The dependency can then be added to +individual ActiveMQ Artemis modules *without* the version specified (the version is implied from the dependency management +section of the top level pom). This allows ActiveMQ Artemis developers to keep track of all dependencies and licenses. \ No newline at end of file diff --git a/docs/hacking-guide/en/formatting.md b/docs/hacking-guide/en/formatting.md new file mode 100644 index 0000000000..40ee5857d3 --- /dev/null +++ b/docs/hacking-guide/en/formatting.md @@ -0,0 +1,11 @@ +# Code Formatting + +Eclipse code formatting and (basic) project configuration files can be found at the `etc/` folder. You should manually +copy them _after importing all your projects_: + + for settings_dir in `find . -type d -name .settings`; do + \cp -v etc/org.eclipse.jdt.* $settings_dir + done + +Do not use the [maven-eclipse-plugin](https://maven.apache.org/plugins/maven-eclipse-plugin/) to copy the files as it +conflicts with [m2e](http://eclipse.org/m2e/). \ No newline at end of file diff --git a/docs/hacking-guide/en/ide.md b/docs/hacking-guide/en/ide.md new file mode 100644 index 0000000000..a78287269b --- /dev/null +++ b/docs/hacking-guide/en/ide.md @@ -0,0 +1,79 @@ +# IDE Integration + +## IntelliJ IDEA + +### Importing the Project + +The following steps show how to import ActiveMQ Artemis source into IntelliJ IDEA and setup the correct maven profile to allow +running of JUnit tests from within the IDE. (Steps are based on version: 13.1.4) + +* File --> Import Project --> Select the root directory of the ActiveMQ Artemis source folder. --> Click OK + +This should open the import project wizard. From here: + +* Select "Import from existing model" toggle box, then select Maven from the list box below. Click Next. +* Leave the defaults set on this page and click next. +* On the "Select profiles page", select the checkbox next to "dev" and click next. +* From here the default settings should suffice. Continue through the wizard, clicking next until the wizard is complete. + +Once the project has been imported and IDEA has caught up importing all the relevant dependencies, you should be able to +run JUnit tests from with the IDE. Select any test class in the tests -> integration tests folder. Right click on the +class in the project tab and click "Run ". If the "Run " option is present then you're all set to go. + +### Style Templates for Idea + +We have shared the style templates that are good for this project. If you want to apply them use these steps: + +* File->Import Settings +* Select the file under ./artemis-cloned-folder/etc/IDEA-style.jar +* Select both Code Style Templates and File templates (it's the default option) +* Select OK and restart Idea + +### Issue: My JUnit tests are not runnable with in the IDE. + +If the "Run " or "Run all tests" option is not present. It is likely that the default profile has not been +imported properly. To (re)import the "tests" Maven profile in an existing project. + +* Open the Maven Projects Tool Window: View -> Tool Windows -> Maven Projects +* Select the "profiles" drop down +* Unselect then reselect the checkbox next to "tests". +* Click on the "Reimport all maven projects" button in the top left hand corner of the window. (It looks like a ciruclar +blue arrow. +* Wait for IDEA to reload and try running a JUnit test again. The option to run should now be present. + +## Eclipse + +We recommend using Eclipse Kepler (4.3), due to the built-in support for Maven and Git. Note that there are still some +Maven plugins used by sub-projects (e.g. documentation) which are not supported even in Eclipse Kepler (4.3). + +Eclipse [m2e](http://eclipse.org/m2e/) is already included in "Eclipse IDE for Java Developers", or it can be installed +from [Eclipse Kepler release repository](http://download.eclipse.org/releases/kepler). + +### Annotation Pre-Processing + +ActiveMQ Artemis uses [JBoss Logging](https://community.jboss.org/wiki/JBossLoggingTooling) and that requires source +code generation from Java annotations. In order for it to 'just work' in Eclipse you need to install the +_Maven Integration for Eclipse JDT Annotation Processor Toolkit_ [m2e-apt](https://github.com/jbosstools/m2e-apt). See +this [JBoss blog post](https://community.jboss.org/en/tools/blog/2012/05/20/annotation-processing-support-in-m2e-or-m2e-apt-100-is-out) + for details. + +### M2E Connector for Javacc-Maven-Plugin + +Eclipse Indigo (3.7) has out-of-the-box support for it. + +As of this writing, Eclipse Kepler (4.3) still lacks support for Maven's javacc plugin. The available [m2e connector for +javacc-maven-plugin](https://github.com/objectledge/maven-extensions) requires a downgrade of Maven components to be +installed. manual installation instructions (as of this writing you need to use the development update site). See +[this post](http://dev.eclipse.org/mhonarc/lists/m2e-users/msg02725.html) for how to do this with Eclipse Juno (4.2). + +The current recommended solution for Eclipse Kepler is to mark `javacc-maven-plugin` as ignored by Eclipse, run Maven +from the command line and then modify the project `activemq-core-client` adding the folder +`target/generated-sources/javacc` to its build path. + +### Use _Project Working Sets_ + +Importing all ActiveMQ Artemis subprojects will create _too many_ projects in Eclipse, cluttering your _Package Explorer_ +and _Project Explorer_ views. One way to address that is to use +[Eclipse's Working Sets](http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Fconcepts%2Fcworkset.htm) +feature. A good introduction to it can be found at a +[Dzone article on Eclipse Working Sets](http://eclipse.dzone.com/articles/categorise-projects-package). \ No newline at end of file diff --git a/docs/hacking-guide/en/images/artemis-logo.jpg b/docs/hacking-guide/en/images/artemis-logo.jpg new file mode 100644 index 0000000000..d2c2c6b239 Binary files /dev/null and b/docs/hacking-guide/en/images/artemis-logo.jpg differ diff --git a/docs/hacking-guide/en/maintainers.md b/docs/hacking-guide/en/maintainers.md new file mode 100644 index 0000000000..5d77af9fdf --- /dev/null +++ b/docs/hacking-guide/en/maintainers.md @@ -0,0 +1,90 @@ +# Notes for Maintainers + +Core ActiveMQ Artemis members have write access to the Apache ActiveMQ Artemis repositories and will be responsible for +acknowledging and pushing commits contributed via pull requests on GitHub. + +## Commit Messages + +Please ensure the commit messages follow the 50/72 format as described [here](code.md#commitMessageDetails). + +## Configuring git repositories + +Aside from the traditional `origin` and `upstream` repositories committers will need an additional reference for the +canonical Apache git repository where they will be merging and pushing pull-requests. For the purposes of this document, +let's assume these ref/repo associations already exist as described in the [Working with the Code](code.md) section: + +- `origin` : https://github.com/(your-user-name)/activemq-artemis.git +- `upstream` : https://github.com/apache/activemq-artemis + +1. Add the canonical Apache repository as a remote. Here we call it `apache`. + + $ git remote add apache https://git-wip-us.apache.org/repos/asf/activemq-artemis.git + +1. Add the following section to your /.git/config statement to fetch all pull requests sent to the GitHub + mirror. We are using `upstream` as the remote repo name (as noted above), but the remote repo name may be different + if you choose. Just be sure to edit all references to the remote repo name so it's consistent. + + [remote "upstream"] + url = git@github.com:apache/activemq-artemis.git + fetch = +refs/heads/*:refs/remotes/upstream/* + fetch = +refs/pull/*/head:refs/remotes/upstream/pr/* + +## Merging and pushing pull requests + +Here are the basic commands to retrieve pull requests, merge, and push them to the canonical Apache repository: + +1. Download all the remote branches etc... including all the pull requests. + + $ git fetch --all + Fetching origin + Fetching upstream + remote: Counting objects: 566, done. + remote: Compressing objects: 100% (188/188), done. + remote: Total 566 (delta 64), reused 17 (delta 17), pack-reused 351 + Receiving objects: 100% (566/566), 300.67 KiB | 0 bytes/s, done. + Resolving deltas: 100% (78/78), done. + From github.com:apache/activemq-artemis + * [new ref] refs/pull/105/head -> upstream/pr/105 + +1. Checkout the pull request you wish to review + + $ git checkout pr/105 + +1. Once you've reviewed the change and are ready to merge checkout `master`. + + $ git checkout master + +1. Ensure you are up to date + + $ git pull + +1. Create a new merge commit from the pull-request. IMPORTANT: The commit message here should be something like: "This + closes #105" where "105" is the pull request ID. The "#105" shows up as a link in the GitHub UI for navigating to + the PR from the commit message. + + $ git merge --no-ff pr/105 + +1. Push to the canonical Apache repo. + + $ git push apache master + +#### Notes: + +The GitHub mirror repository (i.e. `upstream`) is cloning the canonical Apache repository. Because of this there may be +a slight delay between when a commit is pushed to the Apache repo and when that commit is reflected in the GitHub mirror. +This may cause some difficulty when trying to push a PR to `apache` that has been merged on the out-of-date GitHub mirror. +You can wait for the mirror to update before performing the steps above or you can change your local master branch to +track the master branch on the canonical Apache repository rather than the master branch on the GitHub mirror: + + $ git branch master -u apache/master + +Where `apache` points to the canonical Apache repository. + +If you'd like your local master branch to always track `upstream/master` (i.e. the GitHub mirror) then another way to +achieve this is to add another branch that tracks `apache/master` and push from that branch e.g. + + $ git checkout master + $ git branch apache_master --track apache/master + $ git pull + $ git merge --no-ff pr/105 + $ git push diff --git a/docs/hacking-guide/en/notice.md b/docs/hacking-guide/en/notice.md new file mode 100644 index 0000000000..2b2cdc2438 --- /dev/null +++ b/docs/hacking-guide/en/notice.md @@ -0,0 +1,17 @@ +Legal Notice +============ + +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. diff --git a/docs/hacking-guide/en/tests.md b/docs/hacking-guide/en/tests.md new file mode 100644 index 0000000000..24bb520696 --- /dev/null +++ b/docs/hacking-guide/en/tests.md @@ -0,0 +1,27 @@ +# Tests + +## Running Tests + +To run the unit tests: + + $ mvn -Ptests test + +Generating reports from unit tests: + + $ mvn install site + +Running tests individually + + $ mvn -Ptests -DfailIfNoTests=false -Dtest= test + +where <test-name> is the name of the Test class without its package name + +## Writing Tests + +The broker is comprised of POJOs so it's simple to configure and run a broker instance and test particular functionality. +Even complex test-cases involving multiple clustered brokers are relatively easy to write. Almost every test in the +test-suite follows this pattern - configure broker, start broker, test functionality, stop broker. + +The test-suite uses JUnit to manage test execution and life-cycle. Most tests extend [org.apache.activemq.artemis.tests.util.ServiceTestBase](../../../artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ServiceTestBase.java) +which contains JUnit setup and tear-down methods as well as a wealth of utility functions to configure, start, manage, +and stop brokers as well as perform other common tasks. \ No newline at end of file diff --git a/pom.xml b/pom.xml index 8674572d35..61824fd69e 100644 --- a/pom.xml +++ b/pom.xml @@ -949,8 +949,8 @@ **/*.txt **/*.md etc/org.eclipse.* - docs/user-manual/en/*.json - docs/user-manual/en/_book/ + docs/**/*.json + docs/**/_book/ **/target/ **/META-INF/services/* **/*.iml diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ClosingConnectionTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ClosingConnectionTest.java index 4007b5b5ba..24f5af37df 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ClosingConnectionTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ClosingConnectionTest.java @@ -179,7 +179,8 @@ public class ClosingConnectionTest extends ServiceTestBase private ActiveMQServer newActiveMQServer() throws Exception { - ActiveMQServer server = createServer(true, createDefaultConfig(isNetty()), mBeanServer); + ActiveMQServer server = createServer(true, createDefaultConfig(isNetty())); + server.setMBeanServer(mBeanServer); AddressSettings defaultSetting = new AddressSettings(); defaultSetting.setPageSizeBytes(10 * 1024); diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/BridgeTestBase.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/BridgeTestBase.java index 668db2da93..1dc7d9ef09 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/BridgeTestBase.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/jms/bridge/BridgeTestBase.java @@ -60,12 +60,12 @@ import org.apache.activemq.artemis.jms.server.JMSServerManager; import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.After; import org.junit.Assert; import org.junit.Before; -public abstract class BridgeTestBase extends UnitTestCase +public abstract class BridgeTestBase extends ServiceTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; @@ -392,7 +392,7 @@ public abstract class BridgeTestBase extends UnitTestCase if (largeMessage) { BytesMessage msg = sess.createBytesMessage(); - ((ActiveMQMessage) msg).setInputStream(UnitTestCase.createFakeLargeStream(1024L * 1024L)); + ((ActiveMQMessage) msg).setInputStream(ServiceTestBase.createFakeLargeStream(1024L * 1024L)); msg.setStringProperty("msg", "message" + i); prod.send(msg); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/DuplicateDetectionTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/DuplicateDetectionTest.java index 1d7530fb4e..264e5971e2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/DuplicateDetectionTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/DuplicateDetectionTest.java @@ -16,34 +16,31 @@ */ package org.apache.activemq.artemis.tests.integration; -import javax.transaction.xa.XAException; -import javax.transaction.xa.XAResource; -import javax.transaction.xa.Xid; - import org.apache.activemq.artemis.api.core.ActiveMQDuplicateIdException; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.message.impl.MessageImpl; import org.apache.activemq.artemis.core.postoffice.impl.PostOfficeImpl; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.transaction.impl.XidImpl; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.utils.UUIDGenerator; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import javax.transaction.xa.XAException; +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; + public class DuplicateDetectionTest extends ServiceTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; @@ -57,7 +54,7 @@ public class DuplicateDetectionTest extends ServiceTestBase @Test public void testSimpleDuplicateDetecion() throws Exception { - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -165,7 +162,7 @@ public class DuplicateDetectionTest extends ServiceTestBase { final int TEST_SIZE = 100; - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); locator.setBlockOnNonDurableSend(true); @@ -242,7 +239,7 @@ public class DuplicateDetectionTest extends ServiceTestBase @Test public void testSimpleDuplicateDetectionWithString() throws Exception { - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -313,7 +310,7 @@ public class DuplicateDetectionTest extends ServiceTestBase @Test public void testCacheSize() throws Exception { - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -473,7 +470,7 @@ public class DuplicateDetectionTest extends ServiceTestBase @Test public void testTransactedDuplicateDetection1() throws Exception { - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -526,7 +523,7 @@ public class DuplicateDetectionTest extends ServiceTestBase @Test public void testTransactedDuplicateDetection2() throws Exception { - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -573,7 +570,7 @@ public class DuplicateDetectionTest extends ServiceTestBase @Test public void testTransactedDuplicateDetection3() throws Exception { - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -639,7 +636,7 @@ public class DuplicateDetectionTest extends ServiceTestBase @Test public void testRollbackThenSend() throws Exception { - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -688,7 +685,7 @@ public class DuplicateDetectionTest extends ServiceTestBase @Test public void testEntireTransactionRejected() throws Exception { - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -784,7 +781,7 @@ public class DuplicateDetectionTest extends ServiceTestBase @Test public void testXADuplicateDetection1() throws Exception { - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -864,7 +861,7 @@ public class DuplicateDetectionTest extends ServiceTestBase @Test public void testXADuplicateDetection2() throws Exception { - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -946,7 +943,7 @@ public class DuplicateDetectionTest extends ServiceTestBase @Test public void testXADuplicateDetection3() throws Exception { - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -1027,7 +1024,7 @@ public class DuplicateDetectionTest extends ServiceTestBase @Test public void testXADuplicateDetectionPrepareAndRollback() throws Exception { - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -1100,7 +1097,7 @@ public class DuplicateDetectionTest extends ServiceTestBase @Test public void testXADuplicateDetectionPrepareAndRollbackStopServer() throws Exception { - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -1187,7 +1184,7 @@ public class DuplicateDetectionTest extends ServiceTestBase @Test public void testXADuplicateDetection4() throws Exception { - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -1296,7 +1293,7 @@ public class DuplicateDetectionTest extends ServiceTestBase messagingService2.start(); - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -1383,7 +1380,7 @@ public class DuplicateDetectionTest extends ServiceTestBase messagingService2.start(); - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -1465,7 +1462,7 @@ public class DuplicateDetectionTest extends ServiceTestBase messagingService2.start(); - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -1558,7 +1555,7 @@ public class DuplicateDetectionTest extends ServiceTestBase messagingService2.start(); - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -1659,7 +1656,7 @@ public class DuplicateDetectionTest extends ServiceTestBase messagingService2.start(); - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -1745,7 +1742,7 @@ public class DuplicateDetectionTest extends ServiceTestBase messagingService2.start(); - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -1834,7 +1831,7 @@ public class DuplicateDetectionTest extends ServiceTestBase messagingService2.start(); - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -1954,7 +1951,7 @@ public class DuplicateDetectionTest extends ServiceTestBase messagingService2.start(); - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -2057,7 +2054,7 @@ public class DuplicateDetectionTest extends ServiceTestBase messagingService2.start(); - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); @@ -2158,7 +2155,7 @@ public class DuplicateDetectionTest extends ServiceTestBase messagingService2.start(); - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/String64KLimitTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/String64KLimitTest.java index 45847e7220..bffdc97cdc 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/String64KLimitTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/String64KLimitTest.java @@ -33,7 +33,7 @@ import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.tests.util.RandomUtil; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; /** * @@ -43,7 +43,7 @@ import org.apache.activemq.artemis.tests.util.UnitTestCase; * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4806007 * http://jira.jboss.com/jira/browse/JBAS-2641 */ -public class String64KLimitTest extends UnitTestCase +public class String64KLimitTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/aerogear/AeroGearBasicServerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/aerogear/AeroGearBasicServerTest.java index ab37bb873d..a755a6c899 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/aerogear/AeroGearBasicServerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/aerogear/AeroGearBasicServerTest.java @@ -17,32 +17,23 @@ package org.apache.activemq.artemis.tests.integration.aerogear; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.HashMap; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.SendAcknowledgementHandler; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration; import org.apache.activemq.artemis.core.config.CoreQueueConfiguration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.integration.aerogear.AeroGearConnectorServiceFactory; import org.apache.activemq.artemis.integration.aerogear.AeroGearConstants; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.utils.json.JSONArray; import org.apache.activemq.artemis.utils.json.JSONException; import org.apache.activemq.artemis.utils.json.JSONObject; @@ -54,6 +45,14 @@ import org.mortbay.jetty.Server; import org.mortbay.jetty.handler.AbstractHandler; import org.mortbay.jetty.nio.SelectChannelConnector; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + public class AeroGearBasicServerTest extends ServiceTestBase { @@ -128,7 +127,7 @@ public class AeroGearBasicServerTest extends ServiceTestBase CountDownLatch latch = new CountDownLatch(1); AeroGearHandler aeroGearHandler = new AeroGearHandler(latch); jetty.addHandler(aeroGearHandler); - TransportConfiguration tpconf = new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY); + TransportConfiguration tpconf = new TransportConfiguration(INVM_CONNECTOR_FACTORY); locator = ActiveMQClient.createServerLocatorWithoutHA(tpconf); ClientSessionFactory sf = createSessionFactory(locator); ClientSession session = sf.createSession(false, true, true); @@ -277,7 +276,7 @@ public class AeroGearBasicServerTest extends ServiceTestBase } }); - TransportConfiguration tpconf = new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY); + TransportConfiguration tpconf = new TransportConfiguration(INVM_CONNECTOR_FACTORY); locator = ActiveMQClient.createServerLocatorWithoutHA(tpconf); ClientSessionFactory sf = createSessionFactory(locator); ClientSession session = sf.createSession(false, true, true); @@ -331,7 +330,7 @@ public class AeroGearBasicServerTest extends ServiceTestBase } }); - TransportConfiguration tpconf = new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY); + TransportConfiguration tpconf = new TransportConfiguration(INVM_CONNECTOR_FACTORY); locator = ActiveMQClient.createServerLocatorWithoutHA(tpconf); ClientSessionFactory sf = createSessionFactory(locator); ClientSession session = sf.createSession(false, true, true); @@ -369,7 +368,7 @@ public class AeroGearBasicServerTest extends ServiceTestBase } }); - TransportConfiguration tpconf = new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY); + TransportConfiguration tpconf = new TransportConfiguration(INVM_CONNECTOR_FACTORY); locator = ActiveMQClient.createServerLocatorWithoutHA(tpconf); ClientSessionFactory sf = createSessionFactory(locator); ClientSession session = sf.createSession(false, true, true); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ActiveMQCrashTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ActiveMQCrashTest.java index e95b5e5bfc..018d694836 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ActiveMQCrashTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ActiveMQCrashTest.java @@ -15,13 +15,8 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.integration.client; + import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.junit.Before; - -import org.junit.Test; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.Interceptor; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.TransportConfiguration; @@ -29,7 +24,6 @@ import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.SendAcknowledgementHandler; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.config.Configuration; @@ -41,14 +35,16 @@ import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; /** * * From https://jira.jboss.org/jira/browse/HORNETQ-144 * */ -public class ActiveMQCrashTest extends UnitTestCase +public class ActiveMQCrashTest extends ServiceTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; @@ -156,7 +152,6 @@ public class ActiveMQCrashTest extends UnitTestCase public void setUp() throws Exception { super.setUp(); - locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(ServiceTestBase.INVM_CONNECTOR_FACTORY)); - addServerLocator(locator); + locator = createInVMNonHALocator(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConcurrentCreateDeleteProduceTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConcurrentCreateDeleteProduceTest.java index 3f2d947ded..59ea460b9e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConcurrentCreateDeleteProduceTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConcurrentCreateDeleteProduceTest.java @@ -62,7 +62,7 @@ public class ConcurrentCreateDeleteProduceTest extends ServiceTestBase { super.setUp(); - Configuration config = createDefaultConfig(false) + Configuration config = createDefaultConfig() .setJournalSyncNonTransactional(false) .setJournalSyncTransactional(false); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerCloseTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerCloseTest.java index 3fa49e7e9d..cba7278323 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerCloseTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerCloseTest.java @@ -16,9 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.client; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; import org.apache.activemq.artemis.api.core.SimpleString; @@ -28,10 +25,8 @@ import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory; @@ -44,6 +39,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + public class ConsumerCloseTest extends ServiceTestBase { @@ -72,7 +70,7 @@ public class ConsumerCloseTest extends ServiceTestBase Assert.assertTrue(consumer.isClosed()); - UnitTestCase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() + expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() { public void run() throws ActiveMQException { @@ -80,7 +78,7 @@ public class ConsumerCloseTest extends ServiceTestBase } }); - UnitTestCase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() + expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() { public void run() throws ActiveMQException { @@ -88,7 +86,7 @@ public class ConsumerCloseTest extends ServiceTestBase } }); - UnitTestCase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() + expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() { public void run() throws ActiveMQException { @@ -314,9 +312,7 @@ public class ConsumerCloseTest extends ServiceTestBase address = RandomUtil.randomSimpleString(); queue = RandomUtil.randomSimpleString(); - locator = - addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration( - ServiceTestBase.INVM_CONNECTOR_FACTORY))); + locator = createInVMNonHALocator(); sf = createSessionFactory(locator); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerStuckTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerStuckTest.java index 62be9c0ef7..0246b6be42 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerStuckTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerStuckTest.java @@ -17,19 +17,17 @@ package org.apache.activemq.artemis.tests.integration.client; import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl; import org.apache.activemq.artemis.core.protocol.core.impl.RemotingConnectionImpl; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnection; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Before; import org.junit.Test; @@ -59,7 +57,7 @@ public class ConsumerStuckTest extends ServiceTestBase public void testClientStuckTest() throws Exception { - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(NETTY_CONNECTOR_FACTORY)); + ServerLocator locator = createNettyNonHALocator(); locator.setConnectionTTL(1000); locator.setClientFailureCheckPeriod(100); locator.setConsumerWindowSize(10 * 1024 * 1024); @@ -170,7 +168,7 @@ public class ConsumerStuckTest extends ServiceTestBase public void testClientStuckTestWithDirectDelivery() throws Exception { - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(NETTY_CONNECTOR_FACTORY)); + ServerLocator locator = createNettyNonHALocator(); locator.setConnectionTTL(1000); locator.setClientFailureCheckPeriod(100); locator.setConsumerWindowSize(10 * 1024 * 1024); @@ -228,7 +226,7 @@ public class ConsumerStuckTest extends ServiceTestBase public void run() { try ( - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(NETTY_CONNECTOR_FACTORY)); + ServerLocator locator = createNettyNonHALocator(); ClientSessionFactory factory = locator.createSessionFactory(); ClientSession session = factory.createSession(false, true, true, true); ClientProducer producer = session.createProducer(QUEUE); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/DeadLetterAddressTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/DeadLetterAddressTest.java index 2098148f41..0a253e3da3 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/DeadLetterAddressTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/DeadLetterAddressTest.java @@ -15,27 +15,17 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.integration.client; + import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.junit.Before; - -import org.junit.Test; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.config.Configuration; @@ -46,7 +36,14 @@ import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.util.RandomUtil; import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; public class DeadLetterAddressTest extends ServiceTestBase { @@ -512,7 +509,7 @@ public class DeadLetterAddressTest extends ServiceTestBase public void setUp() throws Exception { super.setUp(); - TransportConfiguration transportConfig = new TransportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY); + TransportConfiguration transportConfig = new TransportConfiguration(ServiceTestBase.INVM_ACCEPTOR_FACTORY); Configuration configuration = createDefaultConfig() .setSecurityEnabled(false) @@ -523,7 +520,7 @@ public class DeadLetterAddressTest extends ServiceTestBase // then we create a client as normal locator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration( - UnitTestCase.INVM_CONNECTOR_FACTORY))); + INVM_CONNECTOR_FACTORY))); ClientSessionFactory sessionFactory = createSessionFactory(locator); clientSession = addClientSession(sessionFactory.createSession(false, true, false)); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ExpiryAddressTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ExpiryAddressTest.java index 62b5383154..409a6da463 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ExpiryAddressTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ExpiryAddressTest.java @@ -15,31 +15,28 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.integration.client; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; -import org.apache.activemq.artemis.core.message.impl.MessageImpl; -import org.junit.Before; - -import org.junit.Test; - -import org.junit.Assert; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.core.message.impl.MessageImpl; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.util.RandomUtil; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; public class ExpiryAddressTest extends ServiceTestBase { @@ -236,7 +233,7 @@ public class ExpiryAddressTest extends ServiceTestBase clientSession.createQueue(qName, qName, null, false); ServerLocator locator1 = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration( - UnitTestCase.INVM_CONNECTOR_FACTORY))); + INVM_CONNECTOR_FACTORY))); ClientSessionFactory sessionFactory = createSessionFactory(locator1); @@ -388,7 +385,7 @@ public class ExpiryAddressTest extends ServiceTestBase public void setUp() throws Exception { super.setUp(); - TransportConfiguration transportConfig = new TransportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY); + TransportConfiguration transportConfig = new TransportConfiguration(ServiceTestBase.INVM_ACCEPTOR_FACTORY); Configuration configuration = createDefaultConfig() .setSecurityEnabled(false) diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HangConsumerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HangConsumerTest.java index 0a47c3a48c..dbac19424c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HangConsumerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HangConsumerTest.java @@ -93,7 +93,7 @@ public class HangConsumerTest extends ServiceTestBase { super.setUp(); - Configuration config = createDefaultConfig(false) + Configuration config = createDefaultConfig() .setMessageExpiryScanPeriod(10); ActiveMQSecurityManager securityManager = new ActiveMQSecurityManagerImpl(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HeuristicXATest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HeuristicXATest.java index 30095d3b92..389bf8d694 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HeuristicXATest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HeuristicXATest.java @@ -15,21 +15,6 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.integration.client; -import org.apache.activemq.artemis.tests.integration.management.ManagementControlHelper; -import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.junit.Before; -import org.junit.After; - -import org.junit.Test; - -import java.util.HashMap; - -import javax.management.MBeanServer; -import javax.management.MBeanServerFactory; -import javax.transaction.xa.XAResource; -import javax.transaction.xa.Xid; - -import org.junit.Assert; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; @@ -42,8 +27,18 @@ import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.Queue; -import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.core.transaction.impl.XidImpl; +import org.apache.activemq.artemis.tests.integration.management.ManagementControlHelper; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; public class HeuristicXATest extends ServiceTestBase { @@ -70,7 +65,8 @@ public class HeuristicXATest extends ServiceTestBase Configuration configuration = createDefaultConfig() .setJMXManagementEnabled(true); - ActiveMQServer server = createServer(false, configuration, mbeanServer, new HashMap()); + ActiveMQServer server = createServer(false, configuration); + server.setMBeanServer(mbeanServer); server.start(); ActiveMQServerControl jmxServer = ManagementControlHelper.createActiveMQServerControl(mbeanServer); @@ -95,7 +91,8 @@ public class HeuristicXATest extends ServiceTestBase Configuration configuration = createDefaultConfig() .setJMXManagementEnabled(true); - ActiveMQServer server = createServer(false, configuration, mbeanServer, new HashMap()); + ActiveMQServer server = createServer(false, configuration); + server.setMBeanServer(mbeanServer); server.start(); Xid xid = newXID(); @@ -190,7 +187,8 @@ public class HeuristicXATest extends ServiceTestBase Configuration configuration = createDefaultConfig() .setJMXManagementEnabled(true); - ActiveMQServer server = createServer(true, configuration, mbeanServer, new HashMap()); + ActiveMQServer server = createServer(true, configuration); + server.setMBeanServer(mbeanServer); server.start(); Xid xid = newXID(); @@ -290,7 +288,8 @@ public class HeuristicXATest extends ServiceTestBase Configuration configuration = createDefaultConfig() .setJMXManagementEnabled(true); - ActiveMQServer server = createServer(true, configuration, mbeanServer, new HashMap()); + ActiveMQServer server = createServer(true, configuration); + server.setMBeanServer(mbeanServer); server.start(); Xid xid = newXID(); @@ -399,7 +398,8 @@ public class HeuristicXATest extends ServiceTestBase Configuration configuration = createDefaultConfig() .setJMXManagementEnabled(true); - ActiveMQServer server = createServer(true, configuration, mbeanServer, new HashMap()); + ActiveMQServer server = createServer(true, configuration); + server.setMBeanServer(mbeanServer); server.start(); Xid xid = newXID(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/IncompatibleVersionTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/IncompatibleVersionTest.java index a955ae7a18..3be17895df 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/IncompatibleVersionTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/IncompatibleVersionTest.java @@ -261,7 +261,7 @@ public class IncompatibleVersionTest extends ServiceTestBase } } - private static class ClientStarter + private class ClientStarter { public void perform() throws Exception { @@ -269,7 +269,7 @@ public class IncompatibleVersionTest extends ServiceTestBase ClientSessionFactory sf = null; try { - locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(NETTY_CONNECTOR_FACTORY)); + locator = createNettyNonHALocator(); sf = locator.createSessionFactory(); ClientSession session = sf.createSession(false, true, true); log.info("### client: connected. server incrementingVersion = " + session.getVersion()); @@ -284,6 +284,12 @@ public class IncompatibleVersionTest extends ServiceTestBase } public static void main(String[] args) throws Exception + { + IncompatibleVersionTest incompatibleVersionTest = new IncompatibleVersionTest(); + incompatibleVersionTest.execute(args); + } + + private void execute(String[] args) throws Exception { if (args[0].equals("server")) { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InterruptedLargeMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InterruptedLargeMessageTest.java index 22b30a4870..60592f9904 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InterruptedLargeMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InterruptedLargeMessageTest.java @@ -38,7 +38,7 @@ import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.integration.largemessage.LargeMessageTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.filter.Filter; import org.apache.activemq.artemis.core.paging.cursor.PageSubscription; import org.apache.activemq.artemis.core.persistence.StorageManager; @@ -128,7 +128,7 @@ public class InterruptedLargeMessageTest extends LargeMessageTestBase server.stop(false); - UnitTestCase.forceGC(); + ServiceTestBase.forceGC(); server.start(); @@ -261,7 +261,7 @@ public class InterruptedLargeMessageTest extends LargeMessageTestBase Assert.assertNotNull(clientMessage); for (int countByte = 0; countByte < LARGE_MESSAGE_SIZE; countByte++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(countByte), clientMessage.getBodyBuffer().readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(countByte), clientMessage.getBodyBuffer().readByte()); } clientMessage.acknowledge(); } @@ -340,7 +340,7 @@ public class InterruptedLargeMessageTest extends LargeMessageTestBase Assert.assertNotNull(clientMessage); for (int countByte = 0; countByte < LARGE_MESSAGE_SIZE; countByte++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(countByte), clientMessage.getBodyBuffer().readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(countByte), clientMessage.getBodyBuffer().readByte()); } clientMessage.acknowledge(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JmsNettyNioStressTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JmsNettyNioStressTest.java index ac20c5bdcc..484f65460b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JmsNettyNioStressTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JmsNettyNioStressTest.java @@ -16,6 +16,22 @@ */ package org.apache.activemq.artemis.tests.integration.client; +import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ClientSession; +import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; +import org.apache.activemq.artemis.api.core.client.ServerLocator; +import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; +import org.apache.activemq.artemis.api.jms.JMSFactoryType; +import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; +import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; +import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; +import org.apache.activemq.artemis.jms.client.ActiveMQDestination; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; +import org.junit.Assert; +import org.junit.Test; + import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.DeliveryMode; @@ -26,22 +42,6 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; -import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; -import org.apache.activemq.artemis.api.jms.JMSFactoryType; -import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.core.config.Configuration; -import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; -import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; -import org.apache.activemq.artemis.core.server.ActiveMQServer; -import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; -import org.apache.activemq.artemis.jms.client.ActiveMQDestination; -import org.junit.Assert; -import org.junit.Test; - /** * -- https://issues.jboss.org/browse/HORNETQ-746 * Stress test using netty with NIO and many JMS clients concurrently, to try @@ -92,7 +92,11 @@ public class JmsNettyNioStressTest extends ServiceTestBase // minimize threads to maximize possibility for deadlock params.put(TransportConstants.NIO_REMOTING_THREADS_PROPNAME, 1); params.put(TransportConstants.BATCH_DELAY, 50); - Configuration config = createDefaultConfig(params, ServiceTestBase.NETTY_ACCEPTOR_FACTORY); + TransportConfiguration transportConfig = new TransportConfiguration(ServiceTestBase.NETTY_ACCEPTOR_FACTORY, params); + Configuration config = createBasicConfig(-1) + .setJMXManagementEnabled(false) + .clearAcceptorConfigurations() + .addAcceptorConfiguration(transportConfig); ActiveMQServer server = createServer(true, config); server.getConfiguration().setThreadPoolMaxSize(2); server.start(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageAvoidLargeMessagesTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageAvoidLargeMessagesTest.java index bed8582749..e43ba04200 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageAvoidLargeMessagesTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageAvoidLargeMessagesTest.java @@ -25,7 +25,7 @@ import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.junit.Assert; @@ -350,7 +350,7 @@ public class LargeMessageAvoidLargeMessagesTest extends LargeMessageTest for (int i = 0; i < messageSize; i++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(i), msg1 + Assert.assertEquals(ServiceTestBase.getSamplebyte(i), msg1 .getBodyBuffer().readByte()); } @@ -375,7 +375,7 @@ public class LargeMessageAvoidLargeMessagesTest extends LargeMessageTest for (int i = 0; i < messageSize; i++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(i), msg1 + Assert.assertEquals(ServiceTestBase.getSamplebyte(i), msg1 .getBodyBuffer().readByte()); } @@ -394,7 +394,7 @@ public class LargeMessageAvoidLargeMessagesTest extends LargeMessageTest for (int i = 0; i < messageSize; i++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(i), msg1 + Assert.assertEquals(ServiceTestBase.getSamplebyte(i), msg1 .getBodyBuffer().readByte()); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageTest.java index 657de07e57..02fd2081bc 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LargeMessageTest.java @@ -49,7 +49,7 @@ import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.util.RandomUtil; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -489,7 +489,7 @@ public class LargeMessageTest extends LargeMessageTestBase for (int i = 0; i < messageSize; i++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(i), msg1.getBodyBuffer().readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(i), msg1.getBodyBuffer().readByte()); } session.close(); @@ -513,7 +513,7 @@ public class LargeMessageTest extends LargeMessageTestBase for (int i = 0; i < messageSize; i++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(i), msg1.getBodyBuffer().readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(i), msg1.getBodyBuffer().readByte()); } msg1.acknowledge(); @@ -530,7 +530,7 @@ public class LargeMessageTest extends LargeMessageTestBase for (int i = 0; i < messageSize; i++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(i), msg1.getBodyBuffer().readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(i), msg1.getBodyBuffer().readByte()); } msg1.acknowledge(); @@ -579,7 +579,7 @@ public class LargeMessageTest extends LargeMessageTestBase for (int i = 0; i < messageSize; i++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(i), msg.getBodyBuffer().readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(i), msg.getBodyBuffer().readByte()); } session.rollback(); @@ -594,7 +594,7 @@ public class LargeMessageTest extends LargeMessageTestBase msg.acknowledge(); for (int i = 0; i < messageSize; i++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(i), msg.getBodyBuffer().readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(i), msg.getBodyBuffer().readByte()); } Assert.assertEquals(2, msg.getDeliveryCount()); msg.acknowledge(); @@ -662,7 +662,7 @@ public class LargeMessageTest extends LargeMessageTestBase for (int j = 0; j < messageSize; j++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(j), msg1.getBodyBuffer().readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(j), msg1.getBodyBuffer().readByte()); } session.rollback(); @@ -680,7 +680,7 @@ public class LargeMessageTest extends LargeMessageTestBase for (int j = 0; j < messageSize; j++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(j), msg1.getBodyBuffer().readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(j), msg1.getBodyBuffer().readByte()); } session.rollback(); @@ -704,7 +704,7 @@ public class LargeMessageTest extends LargeMessageTestBase for (int i = 0; i < messageSize; i++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(i), msg1.getBodyBuffer().readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(i), msg1.getBodyBuffer().readByte()); } session.commit(); @@ -778,7 +778,7 @@ public class LargeMessageTest extends LargeMessageTestBase for (int j = 0; j < messageSize; j++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(j), msg1.getBodyBuffer().readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(j), msg1.getBodyBuffer().readByte()); } session.rollback(); @@ -795,7 +795,7 @@ public class LargeMessageTest extends LargeMessageTestBase for (int j = 0; j < messageSize; j++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(j), msg1.getBodyBuffer().readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(j), msg1.getBodyBuffer().readByte()); } session.rollback(); @@ -824,7 +824,7 @@ public class LargeMessageTest extends LargeMessageTestBase for (int i = 0; i < messageSize; i++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(i), msg1.getBodyBuffer().readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(i), msg1.getBodyBuffer().readByte()); } session.commit(); @@ -891,7 +891,7 @@ public class LargeMessageTest extends LargeMessageTestBase for (int i = 0; i < messageSize; i++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(i), msg1.getBodyBuffer().readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(i), msg1.getBodyBuffer().readByte()); } session.close(); @@ -915,7 +915,7 @@ public class LargeMessageTest extends LargeMessageTestBase for (int i = 0; i < messageSize; i++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(i), msg1.getBodyBuffer().readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(i), msg1.getBodyBuffer().readByte()); } msg1.acknowledge(); @@ -1195,7 +1195,7 @@ public class LargeMessageTest extends LargeMessageTestBase assertNotNull(msg); for (long i = 0; i < messageSize; i++) { - Assert.assertEquals("position " + i, UnitTestCase.getSamplebyte(i), msg.getBodyBuffer().readByte()); + Assert.assertEquals("position " + i, ServiceTestBase.getSamplebyte(i), msg.getBodyBuffer().readByte()); } } @@ -2447,7 +2447,7 @@ public class LargeMessageTest extends LargeMessageTestBase for (int i = 0; i < NUMBER_OF_MESSAGES; i++) { ClientMessage clientFile = session.createMessage(true); - clientFile.setBodyInputStream(UnitTestCase.createFakeLargeStream(SIZE)); + clientFile.setBodyInputStream(ServiceTestBase.createFakeLargeStream(SIZE)); producer.send(clientFile); } @@ -2480,7 +2480,7 @@ public class LargeMessageTest extends LargeMessageTestBase { for (int byteRead = 0; byteRead < SIZE; byteRead++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(byteRead), msg.getBodyBuffer().readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(byteRead), msg.getBodyBuffer().readByte()); } } @@ -2551,7 +2551,7 @@ public class LargeMessageTest extends LargeMessageTestBase for (int i = 0; i < NUMBER_OF_MESSAGES; i++) { ClientMessage clientFile = session.createMessage(true); - clientFile.setBodyInputStream(UnitTestCase.createFakeLargeStream(SIZE)); + clientFile.setBodyInputStream(ServiceTestBase.createFakeLargeStream(SIZE)); producer.send(clientFile); } @@ -2583,7 +2583,7 @@ public class LargeMessageTest extends LargeMessageTestBase { for (int byteRead = 0; byteRead < SIZE; byteRead++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(byteRead), msg.getBodyBuffer().readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(byteRead), msg.getBodyBuffer().readByte()); } } @@ -2910,7 +2910,7 @@ public class LargeMessageTest extends LargeMessageTestBase session.createQueue(ADDRESS, ADDRESS, null, true); ClientMessage clientFile = session.createMessage(true); - clientFile.setBodyInputStream(UnitTestCase.createFakeLargeStream(SIZE)); + clientFile.setBodyInputStream(ServiceTestBase.createFakeLargeStream(SIZE)); ClientProducer producer = session.createProducer(ADDRESS); @@ -2989,7 +2989,7 @@ public class LargeMessageTest extends LargeMessageTestBase for (int i = 0; i < NUMBER_OF_MESSAGES; i++) { ClientMessage msg = session.createMessage(true); - msg.setBodyInputStream(UnitTestCase.createFakeLargeStream(SIZE)); + msg.setBodyInputStream(ServiceTestBase.createFakeLargeStream(SIZE)); msg.putIntProperty(new SimpleString("key"), i); producer.send(msg); @@ -3047,7 +3047,7 @@ public class LargeMessageTest extends LargeMessageTestBase for (int i = 0; i < LARGE_MESSAGE_SIZE; i++) { - fileMessage.addBytes(new byte[]{UnitTestCase.getSamplebyte(i)}); + fileMessage.addBytes(new byte[]{ServiceTestBase.getSamplebyte(i)}); } // The server would be doing this @@ -3077,7 +3077,7 @@ public class LargeMessageTest extends LargeMessageTestBase for (int i = 0; i < LARGE_MESSAGE_SIZE; i++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(i), msg.getBodyBuffer().readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(i), msg.getBodyBuffer().readByte()); } msg.acknowledge(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LibaioDependencyCheckTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LibaioDependencyCheckTest.java index f5dcd1bd91..8a119738e4 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LibaioDependencyCheckTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/LibaioDependencyCheckTest.java @@ -19,7 +19,7 @@ package org.apache.activemq.artemis.tests.integration.client; import org.junit.Test; import org.apache.activemq.artemis.core.asyncio.impl.AsynchronousFileImpl; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; /** * This tests is placed in duplication here to validate that the libaio module is properly loaded on this @@ -27,7 +27,7 @@ import org.apache.activemq.artemis.tests.util.UnitTestCase; * * This test should be placed on each one of the tests modules to make sure the library is loaded correctly. */ -public class LibaioDependencyCheckTest extends UnitTestCase +public class LibaioDependencyCheckTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageDurabilityTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageDurabilityTest.java index 42bc4b86aa..5992390818 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageDurabilityTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageDurabilityTest.java @@ -25,7 +25,6 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.tests.util.RandomUtil; import org.apache.activemq.artemis.tests.util.ServiceTestBase; @@ -150,7 +149,7 @@ public class MessageDurabilityTest extends ServiceTestBase session.start(); - UnitTestCase.expectActiveMQException(ActiveMQExceptionType.QUEUE_DOES_NOT_EXIST, new ActiveMQAction() + ServiceTestBase.expectActiveMQException(ActiveMQExceptionType.QUEUE_DOES_NOT_EXIST, new ActiveMQAction() { public void run() throws ActiveMQException { @@ -178,7 +177,7 @@ public class MessageDurabilityTest extends ServiceTestBase restart(); session.start(); - UnitTestCase.expectActiveMQException(ActiveMQExceptionType.QUEUE_DOES_NOT_EXIST, new ActiveMQAction() + ServiceTestBase.expectActiveMQException(ActiveMQExceptionType.QUEUE_DOES_NOT_EXIST, new ActiveMQAction() { public void run() throws ActiveMQException { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageGroupingConnectionFactoryTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageGroupingConnectionFactoryTest.java index 23a28f8df3..dc96d1066f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageGroupingConnectionFactoryTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageGroupingConnectionFactoryTest.java @@ -15,34 +15,31 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.integration.client; + import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.tests.util.UnitTestCase; -import org.junit.Before; - -import org.junit.Test; - -import java.util.ArrayList; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.tests.util.ServiceTestBase; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; -public class MessageGroupingConnectionFactoryTest extends UnitTestCase +import java.util.ArrayList; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +public class MessageGroupingConnectionFactoryTest extends ServiceTestBase { private ActiveMQServer server; @@ -121,7 +118,7 @@ public class MessageGroupingConnectionFactoryTest extends UnitTestCase public void setUp() throws Exception { super.setUp(); - TransportConfiguration transportConfig = new TransportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY); + TransportConfiguration transportConfig = new TransportConfiguration(ServiceTestBase.INVM_ACCEPTOR_FACTORY); Configuration configuration = createDefaultConfig() .setSecurityEnabled(false) diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageGroupingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageGroupingTest.java index 2097ba8346..48c45902b4 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageGroupingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessageGroupingTest.java @@ -15,40 +15,37 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.integration.client; + import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.UnitTestCase; -import org.junit.Assume; -import org.junit.Before; - -import org.junit.Test; - -import java.util.ArrayList; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import javax.transaction.xa.XAResource; -import javax.transaction.xa.Xid; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.core.transaction.impl.XidImpl; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Before; +import org.junit.Test; -public class MessageGroupingTest extends UnitTestCase +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; +import java.util.ArrayList; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +public class MessageGroupingTest extends ServiceTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; @@ -282,7 +279,7 @@ public class MessageGroupingTest extends UnitTestCase private void doTestMultipleGroupingTXCommit() throws Exception { - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sessionFactory = createSessionFactory(locator); ClientSession clientSession = sessionFactory.createSession(false, false, false); ClientProducer clientProducer = this.clientSession.createProducer(qName); @@ -343,7 +340,7 @@ public class MessageGroupingTest extends UnitTestCase private void doTestMultipleGroupingTXRollback() throws Exception { log.info("*** starting test"); - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); locator.setBlockOnAcknowledge(true); ClientSessionFactory sessionFactory = createSessionFactory(locator); ClientSession clientSession = sessionFactory.createSession(false, false, false); @@ -419,7 +416,7 @@ public class MessageGroupingTest extends UnitTestCase private void dotestMultipleGroupingXACommit() throws Exception { - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sessionFactory = createSessionFactory(locator); ClientSession clientSession = sessionFactory.createSession(true, false, false); ClientProducer clientProducer = this.clientSession.createProducer(qName); @@ -479,7 +476,7 @@ public class MessageGroupingTest extends UnitTestCase private void doTestMultipleGroupingXARollback() throws Exception { - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); locator.setBlockOnAcknowledge(true); ClientSessionFactory sessionFactory = createSessionFactory(locator); ClientSession clientSession = sessionFactory.createSession(true, false, false); @@ -611,7 +608,7 @@ public class MessageGroupingTest extends UnitTestCase public void setUp() throws Exception { super.setUp(); - TransportConfiguration transportConfig = new TransportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY); + TransportConfiguration transportConfig = new TransportConfiguration(ServiceTestBase.INVM_ACCEPTOR_FACTORY); Configuration configuration = createDefaultConfig() .setSecurityEnabled(false) @@ -623,7 +620,7 @@ public class MessageGroupingTest extends UnitTestCase // then we create a client as normal locator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration( - UnitTestCase.INVM_CONNECTOR_FACTORY))); + INVM_CONNECTOR_FACTORY))); clientSessionFactory = createSessionFactory(locator); clientSession = addClientSession(clientSessionFactory.createSession(false, true, true)); clientSession.createQueue(qName, qName, null, false); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessagePriorityTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessagePriorityTest.java index e0f7d8cde4..e9b9da090c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessagePriorityTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MessagePriorityTest.java @@ -18,12 +18,12 @@ package org.apache.activemq.artemis.tests.integration.client; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory; @@ -32,12 +32,11 @@ import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.util.RandomUtil; import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -public class MessagePriorityTest extends UnitTestCase +public class MessagePriorityTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MultipleThreadFilterOneTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MultipleThreadFilterOneTest.java index 7a261a1e58..e6f854b3c3 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MultipleThreadFilterOneTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MultipleThreadFilterOneTest.java @@ -164,7 +164,7 @@ public class MultipleThreadFilterOneTest extends ServiceTestBase for (int i = 0; i < numberOfMessages; i++) { - ClientMessage msg = consumer.receive(5000); + ClientMessage msg = consumer.receive(15000); Assert.assertNotNull(msg); Assert.assertEquals(nr, msg.getIntProperty("prodNR").intValue()); msg.acknowledge(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/NIOvsOIOTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/NIOvsOIOTest.java index 7f9d9c16ee..ede5299757 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/NIOvsOIOTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/NIOvsOIOTest.java @@ -16,23 +16,12 @@ */ package org.apache.activemq.artemis.tests.integration.client; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.UnitTestCase; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CountDownLatch; - import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.config.Configuration; @@ -42,9 +31,18 @@ import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.core.settings.HierarchicalRepository; import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.utils.UUIDGenerator; +import org.junit.Test; -public class NIOvsOIOTest extends UnitTestCase +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CountDownLatch; + +public class NIOvsOIOTest extends ServiceTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; @@ -85,7 +83,7 @@ public class NIOvsOIOTest extends UnitTestCase List factories = new ArrayList(); - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); for (int i = 0; i < numReceivers; i++) { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/NewDeadLetterAddressTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/NewDeadLetterAddressTest.java index adfd621df9..9b9541ddbc 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/NewDeadLetterAddressTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/NewDeadLetterAddressTest.java @@ -16,7 +16,7 @@ */ package org.apache.activemq.artemis.tests.integration.client; import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Before; import org.junit.After; @@ -42,7 +42,7 @@ import org.apache.activemq.artemis.core.settings.impl.AddressSettings; * * A NewDeadLetterAddressTest */ -public class NewDeadLetterAddressTest extends UnitTestCase +public class NewDeadLetterAddressTest extends ServiceTestBase { private ActiveMQServer server; @@ -75,7 +75,7 @@ public class NewDeadLetterAddressTest extends UnitTestCase public void setUp() throws Exception { super.setUp(); - TransportConfiguration transportConfig = new TransportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY); + TransportConfiguration transportConfig = new TransportConfiguration(ServiceTestBase.INVM_ACCEPTOR_FACTORY); Configuration configuration = createDefaultConfig() .setSecurityEnabled(false) @@ -86,7 +86,7 @@ public class NewDeadLetterAddressTest extends UnitTestCase // then we create a client as normal locator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration( - UnitTestCase.INVM_CONNECTOR_FACTORY))); + INVM_CONNECTOR_FACTORY))); ClientSessionFactory sessionFactory = createSessionFactory(locator); clientSession = sessionFactory.createSession(false, true, false); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/PagingOrderTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/PagingOrderTest.java index 94a860bf42..b857030b30 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/PagingOrderTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/PagingOrderTest.java @@ -800,7 +800,8 @@ public class PagingOrderTest extends ServiceTestBase Configuration config = createDefaultConfig() .setJournalSyncNonTransactional(false); - ActiveMQServer server = createServer(true, config, -1, -1, AddressFullMessagePolicy.BLOCK, new HashMap()); + ActiveMQServer server = createServer(true, config, -1, -1, new HashMap()); + server.getAddressSettingsRepository().getMatch("#").setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK); JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server); InVMNamingContext context = new InVMNamingContext(); @@ -857,7 +858,8 @@ public class PagingOrderTest extends ServiceTestBase jmsServer.stop(); - server = createServer(true, config, -1, -1, AddressFullMessagePolicy.BLOCK, new HashMap()); + server = createServer(true, config, -1, -1, new HashMap()); + server.getAddressSettingsRepository().getMatch("#").setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK); jmsServer = new JMSServerManagerImpl(server); context = new InVMNamingContext(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/PagingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/PagingTest.java index d74a94ff9f..7abb2acd75 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/PagingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/PagingTest.java @@ -16,23 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.client; -import javax.transaction.xa.XAResource; -import javax.transaction.xa.Xid; -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; @@ -46,9 +29,6 @@ import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.core.client.impl.ClientConsumerInternal; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.DivertConfiguration; @@ -76,10 +56,29 @@ import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl; import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.logs.AssertionLoggerHandler; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + public class PagingTest extends ServiceTestBase { private ServerLocator locator; @@ -1236,12 +1235,8 @@ public class PagingTest extends ServiceTestBase Configuration config = createDefaultConfig() .setJournalSyncNonTransactional(false); - server = createServer(true, - config, - PagingTest.PAGE_SIZE, - PagingTest.PAGE_MAX, - AddressFullMessagePolicy.BLOCK, - new HashMap()); + server = createServer(true, config, PagingTest.PAGE_SIZE, PagingTest.PAGE_MAX, new HashMap()); + server.getAddressSettingsRepository().getMatch("#").setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK); server.start(); @@ -2342,8 +2337,8 @@ public class PagingTest extends ServiceTestBase } catch (AssertionError e) { - PagingTest.log.info("Expected buffer:" + UnitTestCase.dumbBytesHex(body, 40)); - PagingTest.log.info("Arriving buffer:" + UnitTestCase.dumbBytesHex(message2.getBodyBuffer() + PagingTest.log.info("Expected buffer:" + ServiceTestBase.dumbBytesHex(body, 40)); + PagingTest.log.info("Arriving buffer:" + ServiceTestBase.dumbBytesHex(message2.getBodyBuffer() .toByteBuffer() .array(), 40)); throw e; @@ -2541,8 +2536,8 @@ public class PagingTest extends ServiceTestBase } catch (AssertionError e) { - PagingTest.log.info("Expected buffer:" + UnitTestCase.dumbBytesHex(body, 40)); - PagingTest.log.info("Arriving buffer:" + UnitTestCase.dumbBytesHex(message2.getBodyBuffer() + PagingTest.log.info("Expected buffer:" + ServiceTestBase.dumbBytesHex(body, 40)); + PagingTest.log.info("Arriving buffer:" + ServiceTestBase.dumbBytesHex(message2.getBodyBuffer() .toByteBuffer() .array(), 40)); throw e; @@ -2694,8 +2689,8 @@ public class PagingTest extends ServiceTestBase } catch (AssertionError e) { - PagingTest.log.info("Expected buffer:" + UnitTestCase.dumbBytesHex(body, 40)); - PagingTest.log.info("Arriving buffer:" + UnitTestCase.dumbBytesHex(message2.getBodyBuffer() + PagingTest.log.info("Expected buffer:" + ServiceTestBase.dumbBytesHex(body, 40)); + PagingTest.log.info("Arriving buffer:" + ServiceTestBase.dumbBytesHex(message2.getBodyBuffer() .toByteBuffer() .array(), 40)); throw e; @@ -2713,7 +2708,7 @@ public class PagingTest extends ServiceTestBase buffer.readBytes(other); - UnitTestCase.assertEqualsByteArrays(body, other); + ServiceTestBase.assertEqualsByteArrays(body, other); } /** @@ -3360,7 +3355,7 @@ public class PagingTest extends ServiceTestBase for (int j = 0; j < numberOfBytes; j++) { - body[j] = UnitTestCase.getSamplebyte(j); + body[j] = ServiceTestBase.getSamplebyte(j); } long scheduledTime = System.currentTimeMillis() + 5000; @@ -3429,8 +3424,8 @@ public class PagingTest extends ServiceTestBase } catch (AssertionError e) { - PagingTest.log.info("Expected buffer:" + UnitTestCase.dumbBytesHex(body, 40)); - PagingTest.log.info("Arriving buffer:" + UnitTestCase.dumbBytesHex(message2.getBodyBuffer() + PagingTest.log.info("Expected buffer:" + ServiceTestBase.dumbBytesHex(body, 40)); + PagingTest.log.info("Arriving buffer:" + ServiceTestBase.dumbBytesHex(message2.getBodyBuffer() .toByteBuffer() .array(), 40)); throw e; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerCloseTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerCloseTest.java index 5a9f5f5961..fa4fb1c1fd 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerCloseTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerCloseTest.java @@ -15,16 +15,9 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.integration.client; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; -import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; -import org.junit.Before; - -import org.junit.Test; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; @@ -34,6 +27,10 @@ import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.tests.util.RandomUtil; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; public class ProducerCloseTest extends ServiceTestBase { @@ -54,7 +51,7 @@ public class ProducerCloseTest extends ServiceTestBase Assert.assertTrue(producer.isClosed()); - UnitTestCase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() + ServiceTestBase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() { public void run() throws ActiveMQException { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerFlowControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerFlowControlTest.java index 1f053c99b5..6707441341 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerFlowControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerFlowControlTest.java @@ -16,13 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.client; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - import org.apache.activemq.artemis.api.core.ActiveMQObjectClosedException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; @@ -32,7 +25,6 @@ import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.core.client.impl.ClientProducerCreditManagerImpl; import org.apache.activemq.artemis.core.client.impl.ClientProducerCredits; import org.apache.activemq.artemis.core.client.impl.ClientProducerInternal; @@ -48,6 +40,13 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; + public class ProducerFlowControlTest extends ServiceTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; @@ -274,7 +273,7 @@ public class ProducerFlowControlTest extends ServiceTestBase message.getBodyBuffer().readBytes(bytesRead); - UnitTestCase.assertEqualsByteArrays(bytes, bytesRead); + ServiceTestBase.assertEqualsByteArrays(bytes, bytesRead); message.acknowledge(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ReceiveImmediateTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ReceiveImmediateTest.java index 145f6bfca0..7bca4d22b3 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ReceiveImmediateTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ReceiveImmediateTest.java @@ -52,7 +52,7 @@ public class ReceiveImmediateTest extends ServiceTestBase { super.setUp(); - Configuration config = createDefaultConfig(false); + Configuration config = createDefaultConfig(); server = createServer(false, config); server.start(); locator = createInVMNonHALocator(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/RequestorTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/RequestorTest.java index 892b58547e..fea0f95377 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/RequestorTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/RequestorTest.java @@ -27,7 +27,6 @@ import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.core.client.impl.ClientMessageImpl; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; @@ -214,7 +213,7 @@ public class RequestorTest extends ServiceTestBase } }; - UnitTestCase.expectActiveMQException("ClientRequestor's session must not be closed", + ServiceTestBase.expectActiveMQException("ClientRequestor's session must not be closed", ActiveMQExceptionType.OBJECT_CLOSED, activeMQAction); } @@ -258,7 +257,7 @@ public class RequestorTest extends ServiceTestBase } }; - UnitTestCase.expectActiveMQException("can not send a request on a closed ClientRequestor", + ServiceTestBase.expectActiveMQException("can not send a request on a closed ClientRequestor", ActiveMQExceptionType.OBJECT_CLOSED, activeMQAction); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SelfExpandingBufferTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SelfExpandingBufferTest.java index 0ce600d807..23814fa837 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SelfExpandingBufferTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SelfExpandingBufferTest.java @@ -24,11 +24,10 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.util.RandomUtil; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Assert; import org.junit.Test; @@ -118,7 +117,7 @@ public class SelfExpandingBufferTest extends ServiceTestBase msg2.getBodyBuffer().readBytes(receivedBytes); - UnitTestCase.assertEqualsByteArrays(bytes, receivedBytes); + ServiceTestBase.assertEqualsByteArrays(bytes, receivedBytes); msg2 = cons.receive(3000); @@ -126,7 +125,7 @@ public class SelfExpandingBufferTest extends ServiceTestBase msg2.getBodyBuffer().readBytes(receivedBytes); - UnitTestCase.assertEqualsByteArrays(bytes, receivedBytes); + ServiceTestBase.assertEqualsByteArrays(bytes, receivedBytes); } finally { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCloseOnGCTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCloseOnGCTest.java index 372a8fd8fb..debde032d7 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCloseOnGCTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCloseOnGCTest.java @@ -16,19 +16,18 @@ */ package org.apache.activemq.artemis.tests.integration.client; -import java.lang.ref.WeakReference; - import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import java.lang.ref.WeakReference; + public class SessionCloseOnGCTest extends ServiceTestBase { private ActiveMQServer server; @@ -70,7 +69,7 @@ public class SessionCloseOnGCTest extends ServiceTestBase locator.close(); locator = null; - UnitTestCase.checkWeakReferences(wrs1, wrs2); + ServiceTestBase.checkWeakReferences(wrs1, wrs2); WeakReference fref = new WeakReference(factory); @@ -78,7 +77,7 @@ public class SessionCloseOnGCTest extends ServiceTestBase factory = null; - UnitTestCase.checkWeakReferences(fref, wrs1, wrs2); + ServiceTestBase.checkWeakReferences(fref, wrs1, wrs2); } @Test @@ -103,7 +102,7 @@ public class SessionCloseOnGCTest extends ServiceTestBase locator.close(); locator = null; - UnitTestCase.checkWeakReferences(wrs1, wrs2); + ServiceTestBase.checkWeakReferences(wrs1, wrs2); WeakReference fref = new WeakReference(factory); @@ -111,7 +110,7 @@ public class SessionCloseOnGCTest extends ServiceTestBase factory = null; - UnitTestCase.checkWeakReferences(fref, wrs1, wrs2); + ServiceTestBase.checkWeakReferences(fref, wrs1, wrs2); } @Test @@ -134,13 +133,13 @@ public class SessionCloseOnGCTest extends ServiceTestBase locator.close(); locator = null; - UnitTestCase.checkWeakReferences(wrs1, wrs2); + ServiceTestBase.checkWeakReferences(wrs1, wrs2); WeakReference fref = new WeakReference(factory); factory = null; - UnitTestCase.checkWeakReferences(fref, wrs1, wrs2); + ServiceTestBase.checkWeakReferences(fref, wrs1, wrs2); } @Test @@ -160,13 +159,13 @@ public class SessionCloseOnGCTest extends ServiceTestBase locator.close(); locator = null; - UnitTestCase.checkWeakReferences(wrs1, wrs2); + ServiceTestBase.checkWeakReferences(wrs1, wrs2); WeakReference fref = new WeakReference(factory); factory = null; - UnitTestCase.checkWeakReferences(fref, wrs1, wrs2); + ServiceTestBase.checkWeakReferences(fref, wrs1, wrs2); } @Test @@ -181,7 +180,7 @@ public class SessionCloseOnGCTest extends ServiceTestBase locator.close(); locator = null; - UnitTestCase.checkWeakReferences(fref); + ServiceTestBase.checkWeakReferences(fref); } @Test @@ -197,7 +196,7 @@ public class SessionCloseOnGCTest extends ServiceTestBase session = null; - UnitTestCase.checkWeakReferences(wses); + ServiceTestBase.checkWeakReferences(wses); Assert.assertEquals(0, sf.numSessions()); Assert.assertEquals(1, sf.numConnections()); @@ -223,7 +222,7 @@ public class SessionCloseOnGCTest extends ServiceTestBase session2 = null; session3 = null; - UnitTestCase.checkWeakReferences(ref1, ref2, ref3); + ServiceTestBase.checkWeakReferences(ref1, ref2, ref3); int count = 0; final int TOTAL_SLEEP_TIME = 400; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCloseTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCloseTest.java index 397556d48b..060d38b5b0 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCloseTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCloseTest.java @@ -15,34 +15,31 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.integration.client; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; -import org.apache.activemq.artemis.tests.util.UnitTestCase; -import org.junit.Before; -import org.junit.After; - -import org.junit.Test; - -import javax.transaction.xa.XAException; -import javax.transaction.xa.XAResource; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.tests.util.RandomUtil; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; -public class SessionCloseTest extends UnitTestCase +import javax.transaction.xa.XAException; +import javax.transaction.xa.XAResource; + +public class SessionCloseTest extends ServiceTestBase { // Constants ----------------------------------------------------- @@ -69,7 +66,7 @@ public class SessionCloseTest extends UnitTestCase Assert.assertTrue(session.isClosed()); - UnitTestCase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() + ServiceTestBase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() { public void run() throws ActiveMQException { @@ -77,7 +74,7 @@ public class SessionCloseTest extends UnitTestCase } }); - UnitTestCase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() + ServiceTestBase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() { public void run() throws ActiveMQException { @@ -85,7 +82,7 @@ public class SessionCloseTest extends UnitTestCase } }); - UnitTestCase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() + ServiceTestBase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() { public void run() throws ActiveMQException { @@ -95,7 +92,7 @@ public class SessionCloseTest extends UnitTestCase } }); - UnitTestCase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() + ServiceTestBase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() { public void run() throws ActiveMQException { @@ -103,7 +100,7 @@ public class SessionCloseTest extends UnitTestCase } }); - UnitTestCase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() + ServiceTestBase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() { public void run() throws ActiveMQException { @@ -111,7 +108,7 @@ public class SessionCloseTest extends UnitTestCase } }); - UnitTestCase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() + ServiceTestBase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() { public void run() throws ActiveMQException { @@ -119,7 +116,7 @@ public class SessionCloseTest extends UnitTestCase } }); - UnitTestCase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() + ServiceTestBase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() { public void run() throws ActiveMQException { @@ -127,7 +124,7 @@ public class SessionCloseTest extends UnitTestCase } }); - UnitTestCase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() + ServiceTestBase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() { public void run() throws ActiveMQException { @@ -135,7 +132,7 @@ public class SessionCloseTest extends UnitTestCase } }); - UnitTestCase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() + ServiceTestBase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() { public void run() throws ActiveMQException { @@ -143,7 +140,7 @@ public class SessionCloseTest extends UnitTestCase } }); - UnitTestCase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() + ServiceTestBase.expectActiveMQException(ActiveMQExceptionType.OBJECT_CLOSED, new ActiveMQAction() { public void run() throws ActiveMQException { @@ -164,7 +161,7 @@ public class SessionCloseTest extends UnitTestCase Assert.assertTrue(session.isXA()); Assert.assertTrue(session.isClosed()); - UnitTestCase.expectXAException(XAException.XA_RETRY, new ActiveMQAction() + ServiceTestBase.expectXAException(XAException.XA_RETRY, new ActiveMQAction() { public void run() throws XAException { @@ -172,7 +169,7 @@ public class SessionCloseTest extends UnitTestCase } }); - UnitTestCase.expectXAException(XAException.XAER_RMERR, new ActiveMQAction() + ServiceTestBase.expectXAException(XAException.XAER_RMERR, new ActiveMQAction() { public void run() throws XAException { @@ -180,7 +177,7 @@ public class SessionCloseTest extends UnitTestCase } }); - UnitTestCase.expectXAException(XAException.XAER_RMERR, new ActiveMQAction() + ServiceTestBase.expectXAException(XAException.XAER_RMERR, new ActiveMQAction() { public void run() throws XAException { @@ -188,7 +185,7 @@ public class SessionCloseTest extends UnitTestCase } }); - UnitTestCase.expectXAException(XAException.XAER_RMERR, new ActiveMQAction() + ServiceTestBase.expectXAException(XAException.XAER_RMERR, new ActiveMQAction() { public void run() throws XAException { @@ -196,7 +193,7 @@ public class SessionCloseTest extends UnitTestCase } }); - UnitTestCase.expectXAException(XAException.XAER_RMERR, new ActiveMQAction() + ServiceTestBase.expectXAException(XAException.XAER_RMERR, new ActiveMQAction() { public void run() throws XAException { @@ -204,7 +201,7 @@ public class SessionCloseTest extends UnitTestCase } }); - UnitTestCase.expectXAException(XAException.XAER_RMERR, new ActiveMQAction() + ServiceTestBase.expectXAException(XAException.XAER_RMERR, new ActiveMQAction() { public void run() throws XAException { @@ -212,7 +209,7 @@ public class SessionCloseTest extends UnitTestCase } }); - UnitTestCase.expectXAException(XAException.XAER_RMERR, new ActiveMQAction() + ServiceTestBase.expectXAException(XAException.XAER_RMERR, new ActiveMQAction() { public void run() throws XAException { @@ -260,7 +257,7 @@ public class SessionCloseTest extends UnitTestCase server.start(); - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); sf = createSessionFactory(locator); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/TemporaryQueueTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/TemporaryQueueTest.java index f1f75b6ed0..add2724911 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/TemporaryQueueTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/TemporaryQueueTest.java @@ -37,7 +37,7 @@ import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.tests.util.SingleServerTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.client.impl.ClientProducerImpl; import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal; import org.apache.activemq.artemis.core.protocol.core.Packet; @@ -574,7 +574,7 @@ public class TemporaryQueueTest extends SingleServerTestBase } }; - UnitTestCase.expectActiveMQException("temp queue must not exist after the server detected the client crash", + ServiceTestBase.expectActiveMQException("temp queue must not exist after the server detected the client crash", ActiveMQExceptionType.QUEUE_DOES_NOT_EXIST, activeMQAction); session.close(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/WildCardRoutingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/WildCardRoutingTest.java index 17383c0df4..3ada09d606 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/WildCardRoutingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/WildCardRoutingTest.java @@ -15,15 +15,8 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.integration.client; + import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.tests.util.UnitTestCase; -import org.junit.Before; -import org.junit.After; - -import org.junit.Test; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientConsumer; @@ -31,13 +24,17 @@ import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; -public class WildCardRoutingTest extends UnitTestCase +public class WildCardRoutingTest extends ServiceTestBase { private ActiveMQServer server; private ServerLocator locator; @@ -784,7 +781,7 @@ public class WildCardRoutingTest extends UnitTestCase public void setUp() throws Exception { super.setUp(); - TransportConfiguration transportConfig = new TransportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY); + TransportConfiguration transportConfig = new TransportConfiguration(ServiceTestBase.INVM_ACCEPTOR_FACTORY); Configuration configuration = createDefaultConfig() .setWildcardRoutingEnabled(true) @@ -797,7 +794,7 @@ public class WildCardRoutingTest extends UnitTestCase server.start(); server.getManagementService().enableNotifications(false); // then we create a client as normal - locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + locator = createInVMNonHALocator(); sessionFactory = createSessionFactory(locator); clientSession = sessionFactory.createSession(false, true, true); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/ClusterControllerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/ClusterControllerTest.java index 12d3f16206..23b73f4b38 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/ClusterControllerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/ClusterControllerTest.java @@ -17,13 +17,11 @@ package org.apache.activemq.artemis.tests.integration.cluster; import org.apache.activemq.artemis.api.core.ActiveMQClusterSecurityException; -import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal; import org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl; +import org.apache.activemq.artemis.core.server.cluster.ActiveMQServerSideProtocolManagerFactory; import org.apache.activemq.artemis.core.server.cluster.ClusterControl; import org.apache.activemq.artemis.core.server.cluster.ClusterController; -import org.apache.activemq.artemis.core.server.cluster.ActiveMQServerSideProtocolManagerFactory; import org.apache.activemq.artemis.tests.integration.cluster.distribution.ClusterTestBase; import org.junit.After; import org.junit.Before; @@ -70,7 +68,7 @@ public class ClusterControllerTest extends ClusterTestBase @Test public void controlWithDifferentConnector() throws Exception { - try (ServerLocatorImpl locator = (ServerLocatorImpl) ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(INVM_CONNECTOR_FACTORY))) + try (ServerLocatorImpl locator = (ServerLocatorImpl) createInVMNonHALocator()) { locator.setProtocolManagerFactory(ActiveMQServerSideProtocolManagerFactory.getInstance()); ClusterController controller = new ClusterController(getServer(0), getServer(0).getScheduledPool()); @@ -82,7 +80,7 @@ public class ClusterControllerTest extends ClusterTestBase @Test public void controlWithDifferentPassword() throws Exception { - try (ServerLocatorImpl locator = (ServerLocatorImpl) ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(INVM_CONNECTOR_FACTORY))) + try (ServerLocatorImpl locator = (ServerLocatorImpl) createInVMNonHALocator()) { locator.setProtocolManagerFactory(ActiveMQServerSideProtocolManagerFactory.getInstance()); ClusterController controller = new ClusterController(getServer(1), getServer(1).getScheduledPool()); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/RealNodeManagerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/RealNodeManagerTest.java index a6ccc059c2..d81abcdfcb 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/RealNodeManagerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/RealNodeManagerTest.java @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.List; import org.apache.activemq.artemis.tests.util.SpawnedVMSupport; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.server.NodeManager; import org.apache.activemq.artemis.core.server.impl.FileLockNodeManager; import org.apache.activemq.artemis.utils.UUID; @@ -37,7 +37,7 @@ public class RealNodeManagerTest extends NodeManagerTest UUID id1 = nodeManager.getUUID(); nodeManager.stop(); nodeManager.start(); - UnitTestCase.assertEqualsByteArrays(id1.asBytes(), nodeManager.getUUID().asBytes()); + ServiceTestBase.assertEqualsByteArrays(id1.asBytes(), nodeManager.getUUID().asBytes()); nodeManager.stop(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTest.java index 61e6f3bb5c..219429ad1a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTest.java @@ -16,33 +16,27 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.bridge; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.Semaphore; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.Interceptor; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.core.config.BridgeConfiguration; import org.apache.activemq.artemis.core.config.CoreQueueConfiguration; +import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; +import org.apache.activemq.artemis.core.journal.RecordInfo; +import org.apache.activemq.artemis.core.journal.SequentialFileFactory; +import org.apache.activemq.artemis.core.journal.impl.JournalImpl; +import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory; +import org.apache.activemq.artemis.core.persistence.impl.journal.DescribeJournal; +import org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds; import org.apache.activemq.artemis.core.postoffice.DuplicateIDCache; import org.apache.activemq.artemis.core.postoffice.impl.PostOfficeImpl; import org.apache.activemq.artemis.core.protocol.core.Packet; @@ -56,6 +50,7 @@ import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.server.cluster.impl.BridgeImpl; import org.apache.activemq.artemis.core.transaction.impl.TransactionImpl; import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.util.RandomUtil; import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.utils.LinkedListIterator; @@ -66,6 +61,18 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Semaphore; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + @RunWith(value = Parameterized.class) public class BridgeTest extends ServiceTestBase { @@ -226,7 +233,7 @@ public class BridgeTest extends ServiceTestBase if (largeMessage) { - message.setBodyInputStream(UnitTestCase.createFakeLargeStream(1024 * 1024)); + message.setBodyInputStream(ServiceTestBase.createFakeLargeStream(1024 * 1024)); } message.putIntProperty(propKey, i); @@ -403,7 +410,7 @@ public class BridgeTest extends ServiceTestBase if (largeMessage) { - message.setBodyInputStream(UnitTestCase.createFakeLargeStream(1024 * 1024)); + message.setBodyInputStream(ServiceTestBase.createFakeLargeStream(1024 * 1024)); } message.putIntProperty(propKey, i); @@ -588,7 +595,7 @@ public class BridgeTest extends ServiceTestBase if (largeMessage) { - message.setBodyInputStream(UnitTestCase.createFakeLargeStream(1024 * 1024)); + message.setBodyInputStream(ServiceTestBase.createFakeLargeStream(1024 * 1024)); } producer0.send(message); @@ -606,7 +613,7 @@ public class BridgeTest extends ServiceTestBase if (largeMessage) { - message.setBodyInputStream(UnitTestCase.createFakeLargeStream(1024 * 1024)); + message.setBodyInputStream(ServiceTestBase.createFakeLargeStream(1024 * 1024)); } producer0.send(message); @@ -1869,4 +1876,59 @@ public class BridgeTest extends ServiceTestBase } + + /** + * It will inspect the journal directly and determine if there are queues on this journal, + * + * @param serverToInvestigate + * @return a Map containing the reference counts per queue + * @throws Exception + */ + protected Map loadQueues(ActiveMQServer serverToInvestigate) throws Exception + { + SequentialFileFactory messagesFF = new NIOSequentialFileFactory(serverToInvestigate.getConfiguration() + .getJournalDirectory()); + + JournalImpl messagesJournal = new JournalImpl(serverToInvestigate.getConfiguration().getJournalFileSize(), + serverToInvestigate.getConfiguration().getJournalMinFiles(), + 0, + 0, + messagesFF, + "activemq-data", + "amq", + 1); + List records = new LinkedList(); + + List preparedTransactions = new LinkedList(); + + messagesJournal.start(); + messagesJournal.load(records, preparedTransactions, null); + + // These are more immutable integers + Map messageRefCounts = new HashMap(); + + for (RecordInfo info : records) + { + Object o = DescribeJournal.newObjectEncoding(info); + if (info.getUserRecordType() == JournalRecordIds.ADD_REF) + { + DescribeJournal.ReferenceDescribe ref = (DescribeJournal.ReferenceDescribe) o; + AtomicInteger count = messageRefCounts.get(ref.refEncoding.queueID); + if (count == null) + { + count = new AtomicInteger(1); + messageRefCounts.put(ref.refEncoding.queueID, count); + } + else + { + count.incrementAndGet(); + } + } + } + + messagesJournal.stop(); + + return messageRefCounts; + + } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTestBase.java index 8bbce917ee..dd542f5f35 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeTestBase.java @@ -20,7 +20,7 @@ import java.util.Map; import java.util.concurrent.TimeUnit; import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration; import org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration; @@ -31,7 +31,7 @@ import org.apache.activemq.artemis.core.server.NodeManager; import org.apache.activemq.artemis.tests.util.InVMNodeManagerServer; import org.junit.After; -public abstract class BridgeTestBase extends UnitTestCase +public abstract class BridgeTestBase extends ServiceTestBase { @Override diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterTestBase.java index 323d7b3d0c..16ce2bc45d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterTestBase.java @@ -16,21 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.distribution; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration; @@ -39,14 +24,13 @@ import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal; import org.apache.activemq.artemis.core.client.impl.Topology; import org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl; @@ -68,9 +52,9 @@ import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.core.server.NodeManager; +import org.apache.activemq.artemis.core.server.cluster.ActiveMQServerSideProtocolManagerFactory; import org.apache.activemq.artemis.core.server.cluster.ClusterConnection; import org.apache.activemq.artemis.core.server.cluster.ClusterManager; -import org.apache.activemq.artemis.core.server.cluster.ActiveMQServerSideProtocolManagerFactory; import org.apache.activemq.artemis.core.server.cluster.RemoteQueueBinding; import org.apache.activemq.artemis.core.server.cluster.impl.ClusterConnectionImpl; import org.apache.activemq.artemis.core.server.cluster.qourum.SharedNothingBackupQuorum; @@ -83,6 +67,21 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + public abstract class ClusterTestBase extends ServiceTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; @@ -138,7 +137,7 @@ public abstract class ClusterTestBase extends ServiceTestBase forceGC(); - UnitTestCase.checkFreePort(ClusterTestBase.PORTS); + ServiceTestBase.checkFreePort(ClusterTestBase.PORTS); consumers = new ConsumerHolder[ClusterTestBase.MAX_CONSUMERS]; @@ -187,7 +186,7 @@ public abstract class ClusterTestBase extends ServiceTestBase super.tearDown(); - UnitTestCase.checkFreePort(ClusterTestBase.PORTS); + ServiceTestBase.checkFreePort(ClusterTestBase.PORTS); } @@ -663,7 +662,7 @@ public abstract class ClusterTestBase extends ServiceTestBase { // Proxy the failure and print a dump into System.out, so it is captured by Jenkins reports e.printStackTrace(); - System.out.println(UnitTestCase.threadDump(" - fired by ClusterTestBase::addConsumer")); + System.out.println(ServiceTestBase.threadDump(" - fired by ClusterTestBase::addConsumer")); throw e; } @@ -1541,11 +1540,11 @@ public abstract class ClusterTestBase extends ServiceTestBase if (netty) { - serverTotc = new TransportConfiguration(UnitTestCase.NETTY_CONNECTOR_FACTORY, params); + serverTotc = new TransportConfiguration(ServiceTestBase.NETTY_CONNECTOR_FACTORY, params); } else { - serverTotc = new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY, params); + serverTotc = new TransportConfiguration(INVM_CONNECTOR_FACTORY, params); } if (ha) @@ -1582,11 +1581,11 @@ public abstract class ClusterTestBase extends ServiceTestBase if (netty) { - serverTotc = new TransportConfiguration(UnitTestCase.NETTY_CONNECTOR_FACTORY, params); + serverTotc = new TransportConfiguration(ServiceTestBase.NETTY_CONNECTOR_FACTORY, params); } else { - serverTotc = new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY, params); + serverTotc = new TransportConfiguration(INVM_CONNECTOR_FACTORY, params); } locators[node] = ActiveMQClient.createServerLocatorWithoutHA(serverTotc); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/MessageRedistributionWithDiscoveryTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/MessageRedistributionWithDiscoveryTest.java index 011036243f..f117f76dd0 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/MessageRedistributionWithDiscoveryTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/MessageRedistributionWithDiscoveryTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.integration.cluster.distribution; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Assert; import org.junit.Before; @@ -34,9 +34,9 @@ import org.apache.activemq.artemis.core.settings.impl.AddressSettings; public class MessageRedistributionWithDiscoveryTest extends ClusterTestBase { - protected final String groupAddress = UnitTestCase.getUDPDiscoveryAddress(); + protected final String groupAddress = ServiceTestBase.getUDPDiscoveryAddress(); - protected final int groupPort = UnitTestCase.getUDPDiscoveryPort(); + protected final int groupPort = ServiceTestBase.getUDPDiscoveryPort(); protected boolean isNetty() { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterTest.java index 1bd25cce09..71c83c0ba4 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterTest.java @@ -16,7 +16,7 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.distribution; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Before; import org.junit.After; @@ -153,7 +153,7 @@ public class SymmetricClusterTest extends ClusterTestBase } catch (Throwable e) { - System.out.println(UnitTestCase.threadDump("SymmetricClusterTest::testStopAllStartAll")); + System.out.println(ServiceTestBase.threadDump("SymmetricClusterTest::testStopAllStartAll")); throw e; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterWithBackupTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterWithBackupTest.java index 6d37234bf5..cd1d35cfa3 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterWithBackupTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterWithBackupTest.java @@ -18,7 +18,7 @@ package org.apache.activemq.artemis.tests.integration.cluster.distribution; import org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Test; public class SymmetricClusterWithBackupTest extends SymmetricClusterTest @@ -121,7 +121,7 @@ public class SymmetricClusterWithBackupTest extends SymmetricClusterTest } catch (Throwable e) { - System.out.println(UnitTestCase.threadDump("SymmetricClusterWithBackupTest::testStopAllStartAll")); + System.out.println(ServiceTestBase.threadDump("SymmetricClusterWithBackupTest::testStopAllStartAll")); throw e; } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterWithDiscoveryTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterWithDiscoveryTest.java index 752c8f9309..eee7afaf2a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterWithDiscoveryTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterWithDiscoveryTest.java @@ -18,15 +18,15 @@ package org.apache.activemq.artemis.tests.integration.cluster.distribution; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; public class SymmetricClusterWithDiscoveryTest extends SymmetricClusterTest { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; - protected final String groupAddress = UnitTestCase.getUDPDiscoveryAddress(); + protected final String groupAddress = ServiceTestBase.getUDPDiscoveryAddress(); - protected final int groupPort = UnitTestCase.getUDPDiscoveryPort(); + protected final int groupPort = ServiceTestBase.getUDPDiscoveryPort(); protected boolean isNetty() { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/AutomaticColocatedQuorumVoteTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/AutomaticColocatedQuorumVoteTest.java index 07f749ae51..d25195450a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/AutomaticColocatedQuorumVoteTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/AutomaticColocatedQuorumVoteTest.java @@ -330,7 +330,11 @@ public class AutomaticColocatedQuorumVoteTest extends ServiceTestBase transportConfigurationList.add(otherLiveNode.getName()); haPolicy.getExcludedConnectors().add(otherLiveNode.getName()); } - configuration.addClusterConfiguration(basicClusterConnectionConfig(liveConnector.getName(), transportConfigurationList)); + + String[] input = new String[transportConfigurationList.size()]; + transportConfigurationList.toArray(input); + + configuration.addClusterConfiguration(basicClusterConnectionConfig(liveConnector.getName(), input)); haPolicy.setBackupPortOffset(100); haPolicy.setBackupRequestRetries(-1); haPolicy.setBackupRequestRetryInterval(500); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupSyncLargeMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupSyncLargeMessageTest.java index 3e66bb9e4c..386c306e32 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupSyncLargeMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/BackupSyncLargeMessageTest.java @@ -18,7 +18,7 @@ package org.apache.activemq.artemis.tests.integration.cluster.failover; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Test; import java.io.File; @@ -130,7 +130,7 @@ public class BackupSyncLargeMessageTest extends BackupSyncJournalTest final ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS); final ClientMessage message = session.createMessage(true); final int largeMessageSize = 1000 * MIN_LARGE_MESSAGE; - message.setBodyInputStream(UnitTestCase.createFakeLargeStream(largeMessageSize)); + message.setBodyInputStream(ServiceTestBase.createFakeLargeStream(largeMessageSize)); final AtomicBoolean caughtException = new AtomicBoolean(false); final CountDownLatch latch = new CountDownLatch(1); @@ -162,7 +162,7 @@ public class BackupSyncLargeMessageTest extends BackupSyncJournalTest Executors.defaultThreadFactory().newThread(r).start(); waitForLatch(latch); startBackupFinishSyncing(); - UnitTestCase.waitForLatch(latch2); + ServiceTestBase.waitForLatch(latch2); crash(session); assertFalse("no exceptions while sending message", caughtException.get()); @@ -174,7 +174,7 @@ public class BackupSyncLargeMessageTest extends BackupSyncJournalTest for (int j = 0; j < largeMessageSize; j++) { Assert.assertTrue("large msg , expecting " + largeMessageSize + " bytes, got " + j, buffer.readable()); - Assert.assertEquals("equal at " + j, UnitTestCase.getSamplebyte(j), buffer.readByte()); + Assert.assertEquals("equal at " + j, ServiceTestBase.getSamplebyte(j), buffer.readByte()); } receiveMessages(consumer, 0, 20, true); assertNull("there should be no more messages!", consumer.receiveImmediate()); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverTestBase.java index a93a6f2dab..fbc6cd0e12 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverTestBase.java @@ -16,26 +16,15 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.failover; -import java.io.IOException; -import java.net.ServerSocket; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClusterTopologyListener; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.api.core.client.TopologyMember; -import org.apache.activemq.artemis.tests.integration.cluster.util.TestableServer; -import org.apache.activemq.artemis.tests.util.ReplicatedBackupUtils; -import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal; import org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal; import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration; @@ -50,10 +39,20 @@ import org.apache.activemq.artemis.core.server.cluster.ha.ReplicatedPolicy; import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl; import org.apache.activemq.artemis.core.server.impl.InVMNodeManager; import org.apache.activemq.artemis.tests.integration.cluster.util.SameProcessActiveMQServer; +import org.apache.activemq.artemis.tests.integration.cluster.util.TestableServer; +import org.apache.activemq.artemis.tests.util.ReplicatedBackupUtils; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.After; import org.junit.Assert; import org.junit.Before; +import java.io.IOException; +import java.net.ServerSocket; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + public abstract class FailoverTestBase extends ServiceTestBase { // Constants ----------------------------------------------------- @@ -143,7 +142,7 @@ public abstract class FailoverTestBase extends ServiceTestBase { try { - message.setBodyInputStream(UnitTestCase.createFakeLargeStream(LARGE_MESSAGE_SIZE)); + message.setBodyInputStream(ServiceTestBase.createFakeLargeStream(LARGE_MESSAGE_SIZE)); } catch (Exception e) { @@ -164,7 +163,7 @@ public abstract class FailoverTestBase extends ServiceTestBase for (int j = 0; j < LARGE_MESSAGE_SIZE; j++) { Assert.assertTrue("msg " + i + ", expecting " + LARGE_MESSAGE_SIZE + " bytes, got " + j, buffer.readable()); - Assert.assertEquals("equal at " + j, UnitTestCase.getSamplebyte(j), buffer.readByte()); + Assert.assertEquals("equal at " + j, ServiceTestBase.getSamplebyte(j), buffer.readByte()); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/LiveToLiveFailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/LiveToLiveFailoverTest.java index 16647e9b10..ed99b57722 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/LiveToLiveFailoverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/LiveToLiveFailoverTest.java @@ -32,6 +32,7 @@ import org.apache.activemq.artemis.tests.util.TransportConfigurationUtils; import org.junit.Assert; import org.junit.Test; +import java.util.HashMap; import java.util.Map; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -56,7 +57,7 @@ public class LiveToLiveFailoverTest extends FailoverTest TransportConfiguration liveConnector0 = getConnectorTransportConfiguration(true, 0); TransportConfiguration liveConnector1 = getConnectorTransportConfiguration(true, 1); - backupConfig = super.createDefaultConfig(1) + backupConfig = super.createDefaultConfig(1, new HashMap(), INVM_ACCEPTOR_FACTORY) .clearAcceptorConfigurations() .addAcceptorConfiguration(getAcceptorTransportConfiguration(true, 1)) .setHAPolicyConfiguration(new ColocatedPolicyConfiguration() @@ -72,7 +73,7 @@ public class LiveToLiveFailoverTest extends FailoverTest backupServer = createColocatedTestableServer(backupConfig, nodeManager1, nodeManager0, 1); - liveConfig = super.createDefaultConfig(0) + liveConfig = super.createDefaultConfig(0, new HashMap(), INVM_ACCEPTOR_FACTORY) .clearAcceptorConfigurations() .addAcceptorConfiguration(getAcceptorTransportConfiguration(true, 0)) .setHAPolicyConfiguration(new ColocatedPolicyConfiguration() diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleLivesMultipleBackupsFailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleLivesMultipleBackupsFailoverTest.java index 5e1b64130e..3c6c2d73a2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleLivesMultipleBackupsFailoverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleLivesMultipleBackupsFailoverTest.java @@ -33,9 +33,7 @@ import org.apache.activemq.artemis.tests.integration.cluster.util.TestableServer import org.junit.After; import org.junit.Test; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; /** @@ -177,12 +175,12 @@ public class MultipleLivesMultipleBackupsFailoverTest extends MultipleBackupsFai TransportConfiguration backupConnector = createTransportConfiguration(isNetty(), false, generateParams(nodeid, isNetty())); config1.addConnectorConfiguration(backupConnector.getName(), backupConnector); - List clusterNodes = new ArrayList(); - for (int node : otherClusterNodes) + String[] clusterNodes = new String[otherClusterNodes.length]; + for (int i = 0; i < otherClusterNodes.length; i++) { - TransportConfiguration connector = createTransportConfiguration(isNetty(), false, generateParams(node, isNetty())); + TransportConfiguration connector = createTransportConfiguration(isNetty(), false, generateParams(otherClusterNodes[i], isNetty())); config1.addConnectorConfiguration(connector.getName(), connector); - clusterNodes.add(connector.getName()); + clusterNodes[i] = connector.getName(); } config1.addClusterConfiguration(basicClusterConnectionConfig(backupConnector.getName(), clusterNodes)); @@ -204,12 +202,12 @@ public class MultipleLivesMultipleBackupsFailoverTest extends MultipleBackupsFai .setLargeMessagesDirectory(getLargeMessagesDir() + "_" + liveNode) .addConnectorConfiguration(liveConnector.getName(), liveConnector); - List pairs = new ArrayList(); - for (int node : otherLiveNodes) + String[] pairs = new String[otherLiveNodes.length]; + for (int i = 0; i < otherLiveNodes.length; i++) { - TransportConfiguration otherLiveConnector = createTransportConfiguration(isNetty(), false, generateParams(node, isNetty())); + TransportConfiguration otherLiveConnector = createTransportConfiguration(isNetty(), false, generateParams(otherLiveNodes[i], isNetty())); config0.addConnectorConfiguration(otherLiveConnector.getName(), otherLiveConnector); - pairs.add(otherLiveConnector.getName()); + pairs[i] = otherLiveConnector.getName(); } config0.addClusterConfiguration(basicClusterConnectionConfig(liveConnector.getName(), pairs)); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleServerFailoverTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleServerFailoverTestBase.java index 86c1b9b16a..f4ca1c6a7f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleServerFailoverTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleServerFailoverTestBase.java @@ -129,7 +129,9 @@ public abstract class MultipleServerFailoverTestBase extends ServiceTestBase } } - configuration.addClusterConfiguration(basicClusterConnectionConfig(livetc.getName(), connectors)); + String[] input = new String[connectors.size()]; + connectors.toArray(input); + configuration.addClusterConfiguration(basicClusterConnectionConfig(livetc.getName(), input)); liveConfigs.add(configuration); ActiveMQServer server = createServer(true, configuration); TestableServer activeMQServer = new SameProcessActiveMQServer(server); @@ -190,7 +192,9 @@ public abstract class MultipleServerFailoverTestBase extends ServiceTestBase connectors.add(staticTc.getName()); } } - configuration.addClusterConfiguration(basicClusterConnectionConfig(backuptc.getName(), connectors)); + String[] input = new String[connectors.size()]; + connectors.toArray(input); + configuration.addClusterConfiguration(basicClusterConnectionConfig(backuptc.getName(), input)); backupConfigs.add(configuration); ActiveMQServer server = createServer(true, configuration); TestableServer testableServer = new SameProcessActiveMQServer(server); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/QuorumVoteServerConnectTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/QuorumVoteServerConnectTest.java index d6631ec514..93d3f17bc8 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/QuorumVoteServerConnectTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/QuorumVoteServerConnectTest.java @@ -17,7 +17,7 @@ package org.apache.activemq.artemis.tests.integration.cluster.failover; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.server.cluster.qourum.BooleanVote; import org.apache.activemq.artemis.core.server.cluster.qourum.QuorumVoteServerConnect; import org.apache.activemq.artemis.tests.integration.server.FakeStorageManager; @@ -29,7 +29,7 @@ import java.util.Arrays; import java.util.Collection; @RunWith(Parameterized.class) -public class QuorumVoteServerConnectTest extends UnitTestCase +public class QuorumVoteServerConnectTest extends ServiceTestBase { private final int size; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java index f0a34af8da..efed08058c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java @@ -33,9 +33,7 @@ import org.apache.activemq.artemis.tests.integration.cluster.util.TestableServer import org.junit.After; import org.junit.Test; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; /** @@ -146,13 +144,12 @@ public class SingleLiveMultipleBackupsFailoverTest extends MultipleBackupsFailov .setPagingDirectory(getPageDir() + "_" + liveNode) .setLargeMessagesDirectory(getLargeMessagesDir() + "_" + liveNode); - List staticConnectors = new ArrayList(); - - for (int node : nodes) + String[] staticConnectors = new String[nodes.length]; + for (int i = 0; i < nodes.length; i++) { - TransportConfiguration liveConnector = createTransportConfiguration(isNetty(), false, generateParams(node, isNetty())); + TransportConfiguration liveConnector = createTransportConfiguration(isNetty(), false, generateParams(nodes[i], isNetty())); config1.addConnectorConfiguration(liveConnector.getName(), liveConnector); - staticConnectors.add(liveConnector.getName()); + staticConnectors[i] = liveConnector.getName(); } config1.addClusterConfiguration(basicClusterConnectionConfig(backupConnector.getName(), staticConnectors)); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/MultiThreadRandomReattachTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/MultiThreadRandomReattachTestBase.java index c23177b22d..65fb198239 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/MultiThreadRandomReattachTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/MultiThreadRandomReattachTestBase.java @@ -17,7 +17,7 @@ package org.apache.activemq.artemis.tests.integration.cluster.reattach; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Before; import org.junit.After; @@ -1277,7 +1277,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt @After public void tearDown() throws Exception { - UnitTestCase.stopComponent(liveServer); + ServiceTestBase.stopComponent(liveServer); liveServer = null; @@ -1317,7 +1317,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt @Override protected void stop() throws Exception { - UnitTestCase.stopComponent(liveServer); + ServiceTestBase.stopComponent(liveServer); System.gc(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/MultiThreadReattachSupportTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/MultiThreadReattachSupportTestBase.java index 7c5ac0a56e..cb6c3ada16 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/MultiThreadReattachSupportTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/MultiThreadReattachSupportTestBase.java @@ -15,17 +15,8 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.integration.cluster.reattach; + import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; -import org.junit.Before; -import org.junit.After; - -import java.util.ArrayList; -import java.util.List; -import java.util.Timer; -import java.util.TimerTask; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; @@ -35,7 +26,14 @@ import org.apache.activemq.artemis.core.protocol.core.impl.RemotingConnectionImp import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnector; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; + +import java.util.ArrayList; +import java.util.List; +import java.util.Timer; +import java.util.TimerTask; public abstract class MultiThreadReattachSupportTestBase extends ServiceTestBase { @@ -122,7 +120,7 @@ public abstract class MultiThreadReattachSupportTestBase extends ServiceTestBase // Case a failure happened here, it should print the Thread dump // Sending it to System.out, as it would show on the Tests report - System.out.println(UnitTestCase.threadDump(" - fired by MultiThreadRandomReattachTestBase::runTestMultipleThreads (" + t.getLocalizedMessage() + + System.out.println(ServiceTestBase.threadDump(" - fired by MultiThreadRandomReattachTestBase::runTestMultipleThreads (" + t.getLocalizedMessage() + ")")); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/RandomReattachTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/RandomReattachTest.java index 18acd0787b..bc573c4ea2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/RandomReattachTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/RandomReattachTest.java @@ -16,6 +16,32 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.reattach; +import org.apache.activemq.artemis.api.core.ActiveMQException; +import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; +import org.apache.activemq.artemis.api.core.client.ClientConsumer; +import org.apache.activemq.artemis.api.core.client.ClientMessage; +import org.apache.activemq.artemis.api.core.client.ClientProducer; +import org.apache.activemq.artemis.api.core.client.ClientSession; +import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; +import org.apache.activemq.artemis.api.core.client.MessageHandler; +import org.apache.activemq.artemis.api.core.client.ServerLocator; +import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl; +import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal; +import org.apache.activemq.artemis.core.config.Configuration; +import org.apache.activemq.artemis.core.remoting.impl.invm.InVMRegistry; +import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.core.server.ActiveMQServers; +import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + import java.util.ArrayList; import java.util.HashSet; import java.util.Set; @@ -24,34 +50,7 @@ import java.util.TimerTask; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.api.core.client.ClientConsumer; -import org.apache.activemq.artemis.api.core.client.ClientMessage; -import org.apache.activemq.artemis.api.core.client.ClientProducer; -import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; -import org.apache.activemq.artemis.api.core.client.MessageHandler; -import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; -import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl; -import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal; -import org.apache.activemq.artemis.core.config.Configuration; -import org.apache.activemq.artemis.core.remoting.impl.invm.InVMRegistry; -import org.apache.activemq.artemis.core.server.ActiveMQServer; -import org.apache.activemq.artemis.core.server.ActiveMQServers; -import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -public class RandomReattachTest extends UnitTestCase +public class RandomReattachTest extends ServiceTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/topology/IsolatedTopologyTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/topology/IsolatedTopologyTest.java index ba2b163c6b..e27e1034c8 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/topology/IsolatedTopologyTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/topology/IsolatedTopologyTest.java @@ -16,23 +16,22 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.topology; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.core.client.impl.Topology; import org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl; import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Assert; import org.junit.Test; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + public class IsolatedTopologyTest extends ServiceTestBase { @@ -109,7 +108,7 @@ public class IsolatedTopologyTest extends ServiceTestBase params.put(TransportConstants.CLUSTER_CONNECTION, "cc1"); params.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, "1"); - TransportConfiguration acceptor1VM1 = new TransportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY, + TransportConfiguration acceptor1VM1 = new TransportConfiguration(ServiceTestBase.INVM_ACCEPTOR_FACTORY, params, "acceptor-cc1"); @@ -117,7 +116,7 @@ public class IsolatedTopologyTest extends ServiceTestBase params.put(TransportConstants.CLUSTER_CONNECTION, "cc2"); params.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, "2"); - TransportConfiguration acceptor2VM1 = new TransportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY, + TransportConfiguration acceptor2VM1 = new TransportConfiguration(ServiceTestBase.INVM_ACCEPTOR_FACTORY, params, "acceptor-cc2"); @@ -166,7 +165,7 @@ public class IsolatedTopologyTest extends ServiceTestBase params.put(TransportConstants.CLUSTER_CONNECTION, "cc1"); params.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, "3"); - TransportConfiguration acceptor1VM1 = new TransportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY, + TransportConfiguration acceptor1VM1 = new TransportConfiguration(ServiceTestBase.INVM_ACCEPTOR_FACTORY, params, "acceptor-cc1"); @@ -174,7 +173,7 @@ public class IsolatedTopologyTest extends ServiceTestBase params.put(TransportConstants.CLUSTER_CONNECTION, "cc2"); params.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, "4"); - TransportConfiguration acceptor2VM1 = new TransportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY, + TransportConfiguration acceptor2VM1 = new TransportConfiguration(ServiceTestBase.INVM_ACCEPTOR_FACTORY, params, "acceptor-cc2"); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/topology/TopologyClusterTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/topology/TopologyClusterTestBase.java index 6388083462..54c3734208 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/topology/TopologyClusterTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/topology/TopologyClusterTestBase.java @@ -16,11 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.topology; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CountDownLatch; - import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; import org.apache.activemq.artemis.api.core.ActiveMQObjectClosedException; @@ -32,21 +27,25 @@ import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ClusterTopologyListener; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.api.core.client.TopologyMember; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.integration.cluster.distribution.ClusterTestBase; -import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.cluster.ClusterConnection; import org.apache.activemq.artemis.core.server.cluster.ClusterManager; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.apache.activemq.artemis.tests.integration.cluster.distribution.ClusterTestBase; import org.apache.activemq.artemis.tests.util.RandomUtil; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CountDownLatch; + import static java.util.concurrent.TimeUnit.SECONDS; public abstract class TopologyClusterTestBase extends ClusterTestBase @@ -396,7 +395,7 @@ public abstract class TopologyClusterTestBase extends ClusterTestBase s.getConfiguration().setSecurityEnabled(true); } } - Assert.assertEquals(UnitTestCase.CLUSTER_PASSWORD, config.getClusterPassword()); + Assert.assertEquals(ServiceTestBase.CLUSTER_PASSWORD, config.getClusterPassword()); config.setClusterPassword(config.getClusterPassword() + "-1-2-3-"); startServers(0, 1, 2, 4, 3); int n = 0; @@ -412,7 +411,7 @@ public abstract class TopologyClusterTestBase extends ClusterTestBase final String address = "foo1235"; ServerLocator locator = createNonHALocator(isNetty()); ClientSessionFactory sf = createSessionFactory(locator); - ClientSession session = sf.createSession(config.getClusterUser(), UnitTestCase.CLUSTER_PASSWORD, false, true, true, false, 1); + ClientSession session = sf.createSession(config.getClusterUser(), ServiceTestBase.CLUSTER_PASSWORD, false, true, true, false, 1); session.createQueue(address, address, true); ClientProducer producer = session.createProducer(address); sendMessages(session, producer, 100); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryBaseTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryBaseTest.java index bf610a3973..0cc4e4ce3a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryBaseTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryBaseTest.java @@ -28,7 +28,7 @@ import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.cluster.DiscoveryEntry; import org.apache.activemq.artemis.core.cluster.DiscoveryGroup; import org.apache.activemq.artemis.core.cluster.DiscoveryListener; @@ -39,7 +39,7 @@ import org.apache.activemq.artemis.core.server.management.NotificationService; import org.apache.activemq.artemis.utils.UUIDGenerator; import org.junit.Assert; -public class DiscoveryBaseTest extends UnitTestCase +public class DiscoveryBaseTest extends ServiceTestBase { protected static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/PersistentDivertTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/PersistentDivertTest.java index 7d46b2ea3b..fa3d076462 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/PersistentDivertTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/PersistentDivertTest.java @@ -16,27 +16,24 @@ */ package org.apache.activemq.artemis.tests.integration.divert; -import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.DivertConfiguration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; +import org.junit.Assert; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; public class PersistentDivertTest extends ServiceTestBase { @@ -144,7 +141,7 @@ public class PersistentDivertTest extends ServiceTestBase if (largeMessage) { - message.setBodyInputStream(UnitTestCase.createFakeLargeStream(minLargeMessageSize)); + message.setBodyInputStream(ServiceTestBase.createFakeLargeStream(minLargeMessageSize)); } message.putIntProperty(propKey, i); @@ -235,7 +232,7 @@ public class PersistentDivertTest extends ServiceTestBase { for (int j = 0; j < minLargeMessageSize; j++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(j), message.getBodyBuffer().readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(j), message.getBodyBuffer().readByte()); } } @@ -332,7 +329,7 @@ public class PersistentDivertTest extends ServiceTestBase if (largeMessage) { - message.setBodyInputStream(UnitTestCase.createFakeLargeStream(minLargeMessageSize)); + message.setBodyInputStream(ServiceTestBase.createFakeLargeStream(minLargeMessageSize)); } producer.send(message); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/embedded/ValidateAIOTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/embedded/ValidateAIOTest.java index 81e9f74b97..afc2129c73 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/embedded/ValidateAIOTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/embedded/ValidateAIOTest.java @@ -32,7 +32,7 @@ public class ValidateAIOTest extends ServiceTestBase @Test public void testValidateAIO() throws Exception { - Configuration config = createDefaultConfig(false) + Configuration config = createDefaultConfig() // This will force AsyncIO .setJournalType(JournalType.ASYNCIO); ActiveMQServer server = ActiveMQServers.newActiveMQServer(config, true); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/http/CoreClientOverHttpTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/http/CoreClientOverHttpTest.java index 485a28a026..611bcb5c2f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/http/CoreClientOverHttpTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/http/CoreClientOverHttpTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.integration.http; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Before; import org.junit.Test; @@ -40,7 +40,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; -public class CoreClientOverHttpTest extends UnitTestCase +public class CoreClientOverHttpTest extends ServiceTestBase { private static final SimpleString QUEUE = new SimpleString("CoreClientOverHttpTestQueue"); private Configuration conf; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/ActiveMQConnectionFactoryTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/ActiveMQConnectionFactoryTest.java index e4d1898c98..15d14286de 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/ActiveMQConnectionFactoryTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/ActiveMQConnectionFactoryTest.java @@ -16,7 +16,7 @@ */ package org.apache.activemq.artemis.tests.integration.jms; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration; import org.junit.Before; @@ -50,7 +50,7 @@ import org.apache.activemq.artemis.tests.util.RandomUtil; * * A ActiveMQConnectionFactoryTest */ -public class ActiveMQConnectionFactoryTest extends UnitTestCase +public class ActiveMQConnectionFactoryTest extends ServiceTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/FloodServerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/FloodServerTest.java index 7603397375..68f93d28fe 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/FloodServerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/FloodServerTest.java @@ -45,13 +45,13 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; /** * * A FloodServerTest */ -public class FloodServerTest extends UnitTestCase +public class FloodServerTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/SimpleJNDIClientTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/SimpleJNDIClientTest.java index 73cc9f600f..ed0c9bbadb 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/SimpleJNDIClientTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/SimpleJNDIClientTest.java @@ -40,7 +40,7 @@ import org.apache.activemq.artemis.api.core.JGroupsPropertiesBroadcastEndpointFa import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory; import org.apache.activemq.artemis.api.jms.JMSFactoryType; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; @@ -56,7 +56,7 @@ import org.junit.Test; * * A ActiveMQConnectionFactoryTest */ -public class SimpleJNDIClientTest extends UnitTestCase +public class SimpleJNDIClientTest extends ServiceTestBase { private final String groupAddress = getUDPDiscoveryAddress(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/ReSendMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/ReSendMessageTest.java index 2f70bf3834..fb6f12514b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/ReSendMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/ReSendMessageTest.java @@ -34,7 +34,7 @@ import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.jms.ActiveMQJMSConstants; import org.apache.activemq.artemis.api.jms.JMSFactoryType; import org.apache.activemq.artemis.tests.util.JMSTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -71,7 +71,7 @@ public class ReSendMessageTest extends JMSTestBase { BytesMessage bm = sess.createBytesMessage(); bm.setObjectProperty(ActiveMQJMSConstants.JMS_ACTIVEMQ_INPUT_STREAM, - UnitTestCase.createFakeLargeStream(2 * ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE)); + ServiceTestBase.createFakeLargeStream(2 * ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE)); msgs.add(bm); MapMessage mm = sess.createMapMessage(); @@ -168,7 +168,7 @@ public class ReSendMessageTest extends JMSTestBase for (int i = 0; i < copiedBytes.getBodyLength(); i++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(i), copiedBytes.readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(i), copiedBytes.readByte()); } } else if (copiedMessage instanceof MapMessage) diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/JMSReconnectTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/JMSReconnectTest.java index 4434ea0ee8..f9912452e5 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/JMSReconnectTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/JMSReconnectTest.java @@ -17,7 +17,7 @@ package org.apache.activemq.artemis.tests.integration.jms.cluster; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Before; import org.junit.After; @@ -54,7 +54,7 @@ import org.apache.activemq.artemis.jms.client.ActiveMQSession; import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; import org.apache.activemq.artemis.tests.util.RandomUtil; -public class JMSReconnectTest extends UnitTestCase +public class JMSReconnectTest extends ServiceTestBase { private ActiveMQServer liveService; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/CloseConnectionOnGCTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/CloseConnectionOnGCTest.java index 4d25c25b4e..a47eb6a0b6 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/CloseConnectionOnGCTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/CloseConnectionOnGCTest.java @@ -16,7 +16,7 @@ */ package org.apache.activemq.artemis.tests.integration.jms.connection; import org.apache.activemq.artemis.tests.util.JMSTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Before; import org.junit.After; @@ -93,7 +93,7 @@ public class CloseConnectionOnGCTest extends JMSTestBase conn = null; - UnitTestCase.checkWeakReferences(wr); + ServiceTestBase.checkWeakReferences(wr); latch.await(5000, TimeUnit.MILLISECONDS); Assert.assertEquals(0, server.getRemotingService().getConnections().size()); @@ -130,7 +130,7 @@ public class CloseConnectionOnGCTest extends JMSTestBase conn2 = null; conn3 = null; - UnitTestCase.checkWeakReferences(wr1, wr2, wr3); + ServiceTestBase.checkWeakReferences(wr1, wr2, wr3); latch.await(5000, TimeUnit.MILLISECONDS); @@ -174,7 +174,7 @@ public class CloseConnectionOnGCTest extends JMSTestBase conn2 = null; conn3 = null; - UnitTestCase.checkWeakReferences(wr1, wr2, wr3); + ServiceTestBase.checkWeakReferences(wr1, wr2, wr3); latch.await(5000, TimeUnit.MILLISECONDS); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/ExceptionListenerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/ExceptionListenerTest.java index b89fa13c0d..4f4724cbb9 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/ExceptionListenerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/connection/ExceptionListenerTest.java @@ -16,7 +16,7 @@ */ package org.apache.activemq.artemis.tests.integration.jms.connection; import org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.registry.JndiBindingRegistry; import org.junit.Before; import org.junit.After; @@ -50,7 +50,7 @@ import org.apache.activemq.artemis.tests.integration.jms.server.management.NullI * * A ExceptionListenerTest */ -public class ExceptionListenerTest extends UnitTestCase +public class ExceptionListenerTest extends ServiceTestBase { private ActiveMQServer server; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/largemessage/JMSLargeMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/largemessage/JMSLargeMessageTest.java index 11d40b1262..8c63be557a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/largemessage/JMSLargeMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/largemessage/JMSLargeMessageTest.java @@ -31,7 +31,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import org.apache.activemq.artemis.tests.util.JMSTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.utils.UUIDGenerator; import org.junit.After; import org.junit.Assert; @@ -86,7 +86,7 @@ public class JMSLargeMessageTest extends JMSTestBase BytesMessage m = session.createBytesMessage(); - m.setObjectProperty("JMS_AMQ_InputStream", UnitTestCase.createFakeLargeStream(1024 * 1024)); + m.setObjectProperty("JMS_AMQ_InputStream", ServiceTestBase.createFakeLargeStream(1024 * 1024)); prod.send(m); @@ -112,7 +112,7 @@ public class JMSLargeMessageTest extends JMSTestBase Assert.assertEquals(1024, numberOfBytes); for (int j = 0; j < 1024; j++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(i + j), data[j]); + Assert.assertEquals(ServiceTestBase.getSamplebyte(i + j), data[j]); } } @@ -130,7 +130,7 @@ public class JMSLargeMessageTest extends JMSTestBase BytesMessage m = session.createBytesMessage(); - m.setObjectProperty("JMS_AMQ_InputStream", UnitTestCase.createFakeLargeStream(10)); + m.setObjectProperty("JMS_AMQ_InputStream", ServiceTestBase.createFakeLargeStream(10)); prod.send(m); @@ -154,7 +154,7 @@ public class JMSLargeMessageTest extends JMSTestBase Assert.assertEquals(10, numberOfBytes); for (int j = 0; j < numberOfBytes; j++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(j), data[j]); + Assert.assertEquals(ServiceTestBase.getSamplebyte(j), data[j]); } Assert.assertNotNull(rm); @@ -171,7 +171,7 @@ public class JMSLargeMessageTest extends JMSTestBase try { - msg.setObjectProperty("JMS_AMQ_InputStream", UnitTestCase.createFakeLargeStream(10)); + msg.setObjectProperty("JMS_AMQ_InputStream", ServiceTestBase.createFakeLargeStream(10)); Assert.fail("Exception was expected"); } catch (JMSException e) @@ -232,7 +232,7 @@ public class JMSLargeMessageTest extends JMSTestBase BytesMessage m = session.createBytesMessage(); - m.setObjectProperty("JMS_AMQ_InputStream", UnitTestCase.createFakeLargeStream(msgSize)); + m.setObjectProperty("JMS_AMQ_InputStream", ServiceTestBase.createFakeLargeStream(msgSize)); prod.send(m); @@ -262,7 +262,7 @@ public class JMSLargeMessageTest extends JMSTestBase public void write(final int b) throws IOException { numberOfBytes.incrementAndGet(); - if (UnitTestCase.getSamplebyte(position++) != b) + if (ServiceTestBase.getSamplebyte(position++) != b) { System.out.println("Wrong byte at position " + position); numberOfErrors.incrementAndGet(); @@ -273,7 +273,7 @@ public class JMSLargeMessageTest extends JMSTestBase try { - rm.setObjectProperty("JMS_AMQ_InputStream", UnitTestCase.createFakeLargeStream(100)); + rm.setObjectProperty("JMS_AMQ_InputStream", ServiceTestBase.createFakeLargeStream(100)); Assert.fail("Exception expected!"); } catch (MessageNotWriteableException expected) diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/JMSServerStartStopTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/JMSServerStartStopTest.java index 5699bf2d40..88c67f7231 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/JMSServerStartStopTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/JMSServerStartStopTest.java @@ -29,7 +29,7 @@ import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.api.jms.JMSFactoryType; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.config.FileDeploymentManager; import org.apache.activemq.artemis.core.config.impl.FileConfiguration; import org.apache.activemq.artemis.core.server.ActiveMQServer; @@ -44,7 +44,7 @@ import org.junit.After; import org.junit.Assert; import org.junit.Test; -public class JMSServerStartStopTest extends UnitTestCase +public class JMSServerStartStopTest extends ServiceTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/config/JMSConfigurationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/config/JMSConfigurationTest.java index f341af2cea..048e710c73 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/config/JMSConfigurationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/config/JMSConfigurationTest.java @@ -56,7 +56,7 @@ public class JMSConfigurationTest extends ServiceTestBase { Context context = new InVMNamingContext(); - Configuration coreConfiguration = createDefaultConfig(false); + Configuration coreConfiguration = createDefaultConfig(); ActiveMQServer coreServer = new ActiveMQServerImpl(coreConfiguration); JMSConfiguration jmsConfiguration = new JMSConfigurationImpl(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/ConnectionFactoryControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/ConnectionFactoryControlTest.java index 46be23cf14..d810dbfac2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/ConnectionFactoryControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/ConnectionFactoryControlTest.java @@ -23,7 +23,7 @@ import javax.management.Notification; import org.apache.activemq.artemis.tests.integration.management.ManagementControlHelper; import org.apache.activemq.artemis.tests.integration.management.ManagementTestBase; import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.registry.JndiBindingRegistry; import org.junit.Assert; import org.junit.Before; @@ -155,11 +155,11 @@ public class ConnectionFactoryControlTest extends ManagementTestBase */ protected void startServer() throws Exception { - Configuration conf = createDefaultConfig(false) - .addConnectorConfiguration("invm", new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)) + Configuration conf = createDefaultConfig() + .addConnectorConfiguration("invm", new TransportConfiguration(INVM_CONNECTOR_FACTORY)) .setSecurityEnabled(false) .setJMXManagementEnabled(true) - .addAcceptorConfiguration(new TransportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY)); + .addAcceptorConfiguration(new TransportConfiguration(ServiceTestBase.INVM_ACCEPTOR_FACTORY)); server = ActiveMQServers.newActiveMQServer(conf, mbeanServer, true); server.start(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSQueueControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSQueueControlTest.java index 558480bab7..6e61753e98 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSQueueControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSQueueControlTest.java @@ -1388,7 +1388,8 @@ public class JMSQueueControlTest extends ManagementTestBase Configuration conf = createBasicConfig() .addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY)); - server = createServer(this.getName().contains("WithRealData"), conf, mbeanServer); + server = createServer(this.getName().contains("WithRealData"), conf); + server.setMBeanServer(mbeanServer); serverManager = new JMSServerManagerImpl(server); context = new InVMNamingContext(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlRestartTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlRestartTest.java index 014c5c115a..9d4c8dbf98 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlRestartTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlRestartTest.java @@ -32,7 +32,7 @@ import org.apache.activemq.artemis.api.jms.management.JMSServerControl; import org.apache.activemq.artemis.tests.integration.management.ManagementControlHelper; import org.apache.activemq.artemis.tests.integration.management.ManagementTestBase; import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.registry.JndiBindingRegistry; import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory; @@ -61,13 +61,13 @@ public class JMSServerControlRestartTest extends ManagementTestBase String queueName = RandomUtil.randomString(); String binding = RandomUtil.randomString(); - UnitTestCase.checkNoBinding(context, binding); + ServiceTestBase.checkNoBinding(context, binding); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName)); JMSServerControl control = ManagementControlHelper.createJMSServerControl(mbeanServer); control.createQueue(queueName, binding); - Object o = UnitTestCase.checkBinding(context, binding); + Object o = ServiceTestBase.checkBinding(context, binding); Assert.assertTrue(o instanceof Queue); Queue queue = (Queue) o; Assert.assertEquals(queueName, queue.getQueueName()); @@ -75,13 +75,13 @@ public class JMSServerControlRestartTest extends ManagementTestBase serverManager.stop(); - UnitTestCase.checkNoBinding(context, binding); + ServiceTestBase.checkNoBinding(context, binding); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName)); serverManager = createJMSServer(); serverManager.start(); - o = UnitTestCase.checkBinding(context, binding); + o = ServiceTestBase.checkBinding(context, binding); Assert.assertTrue(o instanceof Queue); queue = (Queue) o; Assert.assertEquals(queueName, queue.getQueueName()); @@ -94,7 +94,7 @@ public class JMSServerControlRestartTest extends ManagementTestBase String queueName = RandomUtil.randomString(); String binding = RandomUtil.randomString(); - UnitTestCase.checkNoBinding(context, binding); + ServiceTestBase.checkNoBinding(context, binding); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName)); TransportConfiguration config = new TransportConfiguration(InVMConnectorFactory.class.getName()); @@ -109,7 +109,7 @@ public class JMSServerControlRestartTest extends ManagementTestBase Assert.assertTrue(JMSManagementHelper.hasOperationSucceeded(reply)); connection.close(); - Object o = UnitTestCase.checkBinding(context, binding); + Object o = ServiceTestBase.checkBinding(context, binding); Assert.assertTrue(o instanceof Queue); Queue queue = (Queue) o; Assert.assertEquals(queueName, queue.getQueueName()); @@ -117,13 +117,13 @@ public class JMSServerControlRestartTest extends ManagementTestBase serverManager.stop(); - UnitTestCase.checkNoBinding(context, binding); + ServiceTestBase.checkNoBinding(context, binding); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName)); serverManager = createJMSServer(); serverManager.start(); - o = UnitTestCase.checkBinding(context, binding); + o = ServiceTestBase.checkBinding(context, binding); Assert.assertTrue(o instanceof Queue); queue = (Queue) o; Assert.assertEquals(queueName, queue.getQueueName()); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlTest.java index 82a395cd4a..2cecabb345 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlTest.java @@ -51,7 +51,7 @@ import org.apache.activemq.artemis.api.jms.management.JMSServerControl; import org.apache.activemq.artemis.tests.integration.management.ManagementControlHelper; import org.apache.activemq.artemis.tests.integration.management.ManagementTestBase; import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.postoffice.QueueBinding; import org.apache.activemq.artemis.core.registry.JndiBindingRegistry; @@ -134,22 +134,22 @@ public class JMSServerControlTest extends ManagementTestBase String queueName = RandomUtil.randomString(); String bindingsCSV = JMSServerControlTest.toCSV(bindings); - UnitTestCase.checkNoBinding(context, bindingsCSV); + ServiceTestBase.checkNoBinding(context, bindingsCSV); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName)); JMSServerControl control = createManagementControl(); control.createQueue(queueName, bindingsCSV); - Object o = UnitTestCase.checkBinding(context, bindings[0]); + Object o = ServiceTestBase.checkBinding(context, bindings[0]); Assert.assertTrue(o instanceof Queue); Queue queue = (Queue) o; Assert.assertEquals(queueName, queue.getQueueName()); - o = UnitTestCase.checkBinding(context, bindings[1]); + o = ServiceTestBase.checkBinding(context, bindings[1]); Assert.assertTrue(o instanceof Queue); queue = (Queue) o; Assert.assertEquals(queueName, queue.getQueueName()); - o = UnitTestCase.checkBinding(context, bindings[2]); + o = ServiceTestBase.checkBinding(context, bindings[2]); Assert.assertTrue(o instanceof Queue); queue = (Queue) o; Assert.assertEquals(queueName, queue.getQueueName()); @@ -172,22 +172,22 @@ public class JMSServerControlTest extends ManagementTestBase String queueName = RandomUtil.randomString(); String bindingsCSV = JMSServerControlTest.toCSV(bindings); - UnitTestCase.checkNoBinding(context, bindingsCSV); + ServiceTestBase.checkNoBinding(context, bindingsCSV); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName)); JMSServerControl control = createManagementControl(); control.createQueue(queueName, bindingsCSV); - Object o = UnitTestCase.checkBinding(context, "first,first"); + Object o = ServiceTestBase.checkBinding(context, "first,first"); Assert.assertTrue(o instanceof Queue); Queue queue = (Queue) o; Assert.assertEquals(queueName, queue.getQueueName()); - o = UnitTestCase.checkBinding(context, "second,second"); + o = ServiceTestBase.checkBinding(context, "second,second"); Assert.assertTrue(o instanceof Queue); queue = (Queue) o; Assert.assertEquals(queueName, queue.getQueueName()); - o = UnitTestCase.checkBinding(context, "third,third"); + o = ServiceTestBase.checkBinding(context, "third,third"); Assert.assertTrue(o instanceof Queue); queue = (Queue) o; Assert.assertEquals(queueName, queue.getQueueName()); @@ -210,7 +210,7 @@ public class JMSServerControlTest extends ManagementTestBase String queueName = RandomUtil.randomString(); String bindingsCSV = JMSServerControlTest.toCSV(bindings); - UnitTestCase.checkNoBinding(context, bindingsCSV); + ServiceTestBase.checkNoBinding(context, bindingsCSV); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName)); @@ -218,7 +218,7 @@ public class JMSServerControlTest extends ManagementTestBase String selector = "foo='bar'"; control.createQueue(queueName, bindingsCSV, selector); - Object o = UnitTestCase.checkBinding(context, bindings[0]); + Object o = ServiceTestBase.checkBinding(context, bindings[0]); Assert.assertTrue(o instanceof Queue); Queue queue = (Queue) o; // assertEquals(((ActiveMQDestination)queue).get); @@ -228,7 +228,7 @@ public class JMSServerControlTest extends ManagementTestBase .getFilter() .getFilterString() .toString()); - o = UnitTestCase.checkBinding(context, bindings[1]); + o = ServiceTestBase.checkBinding(context, bindings[1]); Assert.assertTrue(o instanceof Queue); queue = (Queue) o; Assert.assertEquals(queueName, queue.getQueueName()); @@ -237,7 +237,7 @@ public class JMSServerControlTest extends ManagementTestBase .getFilter() .getFilterString() .toString()); - o = UnitTestCase.checkBinding(context, bindings[2]); + o = ServiceTestBase.checkBinding(context, bindings[2]); Assert.assertTrue(o instanceof Queue); queue = (Queue) o; Assert.assertEquals(queueName, queue.getQueueName()); @@ -261,13 +261,13 @@ public class JMSServerControlTest extends ManagementTestBase String queueName = RandomUtil.randomString(); String binding = RandomUtil.randomString(); - UnitTestCase.checkNoBinding(context, binding); + ServiceTestBase.checkNoBinding(context, binding); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName)); JMSServerControl control = createManagementControl(); control.createQueue(queueName, binding, null, false); - Object o = UnitTestCase.checkBinding(context, binding); + Object o = ServiceTestBase.checkBinding(context, binding); Assert.assertTrue(o instanceof Queue); Queue queue = (Queue) o; Assert.assertEquals(queueName, queue.getQueueName()); @@ -287,18 +287,18 @@ public class JMSServerControlTest extends ManagementTestBase String queueJNDIBinding = RandomUtil.randomString(); String queueName = RandomUtil.randomString(); - UnitTestCase.checkNoBinding(context, queueJNDIBinding); + ServiceTestBase.checkNoBinding(context, queueJNDIBinding); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName)); JMSServerControl control = createManagementControl(); control.createQueue(queueName, queueJNDIBinding); - UnitTestCase.checkBinding(context, queueJNDIBinding); + ServiceTestBase.checkBinding(context, queueJNDIBinding); checkResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName)); control.destroyQueue(queueName); - UnitTestCase.checkNoBinding(context, queueJNDIBinding); + ServiceTestBase.checkNoBinding(context, queueJNDIBinding); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName)); Assert.assertNull(fakeJMSStorageManager.destinationMap.get(queueName)); @@ -310,17 +310,17 @@ public class JMSServerControlTest extends ManagementTestBase String queueJNDIBinding = RandomUtil.randomString(); String queueName = RandomUtil.randomString(); - UnitTestCase.checkNoBinding(context, queueJNDIBinding); + ServiceTestBase.checkNoBinding(context, queueJNDIBinding); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName)); JMSServerControl control = createManagementControl(); control.createQueue(queueName, queueJNDIBinding); - UnitTestCase.checkBinding(context, queueJNDIBinding); + ServiceTestBase.checkBinding(context, queueJNDIBinding); checkResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName)); ActiveMQConnectionFactory cf = - new ActiveMQConnectionFactory(false, new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + new ActiveMQConnectionFactory(false, new TransportConfiguration(INVM_CONNECTOR_FACTORY)); ActiveMQConnection connection = (ActiveMQConnection) cf.createConnection(); try { @@ -330,7 +330,7 @@ public class JMSServerControlTest extends ManagementTestBase control.destroyQueue(queueName, true); - UnitTestCase.checkNoBinding(context, queueJNDIBinding); + ServiceTestBase.checkNoBinding(context, queueJNDIBinding); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName)); Assert.assertNull(fakeJMSStorageManager.destinationMap.get(queueName)); @@ -367,16 +367,16 @@ public class JMSServerControlTest extends ManagementTestBase String queueJNDIBinding = RandomUtil.randomString(); String queueName = RandomUtil.randomString(); - UnitTestCase.checkNoBinding(context, queueJNDIBinding); + ServiceTestBase.checkNoBinding(context, queueJNDIBinding); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName)); JMSServerControl control = createManagementControl(); control.createQueue(queueName, queueJNDIBinding); - UnitTestCase.checkBinding(context, queueJNDIBinding); + ServiceTestBase.checkBinding(context, queueJNDIBinding); checkResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName)); - ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(false, new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(false, new TransportConfiguration(INVM_CONNECTOR_FACTORY)); ActiveMQConnection connection = (ActiveMQConnection) cf.createConnection(); connection.start(); try @@ -397,7 +397,7 @@ public class JMSServerControlTest extends ManagementTestBase Assert.assertTrue(e.getMessage().startsWith("AMQ119025")); } - UnitTestCase.checkBinding(context, queueJNDIBinding); + ServiceTestBase.checkBinding(context, queueJNDIBinding); checkResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName)); Assert.assertNotNull(fakeJMSStorageManager.destinationMap.get(queueName)); @@ -422,16 +422,16 @@ public class JMSServerControlTest extends ManagementTestBase String topicJNDIBinding = RandomUtil.randomString(); String topicName = RandomUtil.randomString(); - UnitTestCase.checkNoBinding(context, topicJNDIBinding); + ServiceTestBase.checkNoBinding(context, topicJNDIBinding); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSTopicObjectName(topicName)); JMSServerControl control = createManagementControl(); control.createTopic(topicName, topicJNDIBinding); - UnitTestCase.checkBinding(context, topicJNDIBinding); + ServiceTestBase.checkBinding(context, topicJNDIBinding); checkResource(ObjectNameBuilder.DEFAULT.getJMSTopicObjectName(topicName)); - ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(false, new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(false, new TransportConfiguration(INVM_CONNECTOR_FACTORY)); ActiveMQConnection connection = (ActiveMQConnection) cf.createConnection(); connection.start(); try @@ -452,7 +452,7 @@ public class JMSServerControlTest extends ManagementTestBase Assert.assertTrue(e.getMessage().startsWith("AMQ119025")); } - UnitTestCase.checkBinding(context, topicJNDIBinding); + ServiceTestBase.checkBinding(context, topicJNDIBinding); checkResource(ObjectNameBuilder.DEFAULT.getJMSTopicObjectName(topicName)); Assert.assertFalse(cons.isClosed()); @@ -474,17 +474,17 @@ public class JMSServerControlTest extends ManagementTestBase String topicJNDIBinding = RandomUtil.randomString(); String topicName = RandomUtil.randomString(); - UnitTestCase.checkNoBinding(context, topicJNDIBinding); + ServiceTestBase.checkNoBinding(context, topicJNDIBinding); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSTopicObjectName(topicName)); JMSServerControl control = createManagementControl(); control.createTopic(topicName, topicJNDIBinding); - UnitTestCase.checkBinding(context, topicJNDIBinding); + ServiceTestBase.checkBinding(context, topicJNDIBinding); checkResource(ObjectNameBuilder.DEFAULT.getJMSTopicObjectName(topicName)); ActiveMQConnectionFactory cf = - new ActiveMQConnectionFactory(false, new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + new ActiveMQConnectionFactory(false, new TransportConfiguration(INVM_CONNECTOR_FACTORY)); ActiveMQConnection connection = (ActiveMQConnection) cf.createConnection(); try { @@ -494,7 +494,7 @@ public class JMSServerControlTest extends ManagementTestBase control.destroyTopic(topicName, true); - UnitTestCase.checkNoBinding(context, topicJNDIBinding); + ServiceTestBase.checkNoBinding(context, topicJNDIBinding); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSTopicObjectName(topicName)); long time = System.currentTimeMillis(); @@ -529,17 +529,17 @@ public class JMSServerControlTest extends ManagementTestBase String queueJNDIBinding = RandomUtil.randomString(); String queueName = RandomUtil.randomString(); - UnitTestCase.checkNoBinding(context, queueJNDIBinding); + ServiceTestBase.checkNoBinding(context, queueJNDIBinding); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName)); JMSServerControl control = createManagementControl(); control.createQueue(queueName, queueJNDIBinding); - UnitTestCase.checkBinding(context, queueJNDIBinding); + ServiceTestBase.checkBinding(context, queueJNDIBinding); checkResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName)); ActiveMQConnectionFactory cf = - new ActiveMQConnectionFactory(false, new TransportConfiguration(UnitTestCase.NETTY_CONNECTOR_FACTORY)); + new ActiveMQConnectionFactory(false, new TransportConfiguration(ServiceTestBase.NETTY_CONNECTOR_FACTORY)); cf.setReconnectAttempts(-1); ActiveMQConnection connection = (ActiveMQConnection) cf.createConnection(); try @@ -550,7 +550,7 @@ public class JMSServerControlTest extends ManagementTestBase control.destroyQueue(queueName, true); - UnitTestCase.checkNoBinding(context, queueJNDIBinding); + ServiceTestBase.checkNoBinding(context, queueJNDIBinding); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName)); Assert.assertNull(fakeJMSStorageManager.destinationMap.get(queueName)); @@ -610,24 +610,24 @@ public class JMSServerControlTest extends ManagementTestBase bindings[1] = RandomUtil.randomString(); bindings[2] = RandomUtil.randomString(); String topicJNDIBinding = JMSServerControlTest.toCSV(bindings); - UnitTestCase.checkNoBinding(context, topicJNDIBinding); + ServiceTestBase.checkNoBinding(context, topicJNDIBinding); String topicName = RandomUtil.randomString(); - UnitTestCase.checkNoBinding(context, topicJNDIBinding); + ServiceTestBase.checkNoBinding(context, topicJNDIBinding); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSTopicObjectName(topicName)); JMSServerControl control = createManagementControl(); control.createTopic(topicName, topicJNDIBinding); - Object o = UnitTestCase.checkBinding(context, bindings[0]); + Object o = ServiceTestBase.checkBinding(context, bindings[0]); Assert.assertTrue(o instanceof Topic); Topic topic = (Topic) o; Assert.assertEquals(topicName, topic.getTopicName()); - o = UnitTestCase.checkBinding(context, bindings[1]); + o = ServiceTestBase.checkBinding(context, bindings[1]); Assert.assertTrue(o instanceof Topic); topic = (Topic) o; Assert.assertEquals(topicName, topic.getTopicName()); - o = UnitTestCase.checkBinding(context, bindings[2]); + o = ServiceTestBase.checkBinding(context, bindings[2]); Assert.assertTrue(o instanceof Topic); topic = (Topic) o; Assert.assertEquals(topicName, topic.getTopicName()); @@ -646,7 +646,7 @@ public class JMSServerControlTest extends ManagementTestBase String topicJNDIBinding = RandomUtil.randomString(); String topicName = RandomUtil.randomString(); - UnitTestCase.checkNoBinding(context, topicJNDIBinding); + ServiceTestBase.checkNoBinding(context, topicJNDIBinding); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSTopicObjectName(topicName)); JMSServerControl control = createManagementControl(); @@ -673,7 +673,7 @@ public class JMSServerControlTest extends ManagementTestBase control.destroyTopic(topicName); Assert.assertNull(server.getManagementService().getResource(ResourceNames.CORE_ADDRESS + topicAddress)); - UnitTestCase.checkNoBinding(context, topicJNDIBinding); + ServiceTestBase.checkNoBinding(context, topicJNDIBinding); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSTopicObjectName(topicName)); Assert.assertNull(fakeJMSStorageManager.destinationMap.get(topicName)); @@ -685,7 +685,7 @@ public class JMSServerControlTest extends ManagementTestBase String topicJNDIBinding = RandomUtil.randomString(); String topicName = RandomUtil.randomString(); - UnitTestCase.checkNoBinding(context, topicJNDIBinding); + ServiceTestBase.checkNoBinding(context, topicJNDIBinding); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSTopicObjectName(topicName)); JMSServerControl control = createManagementControl(); @@ -695,7 +695,7 @@ public class JMSServerControlTest extends ManagementTestBase Topic topic = (Topic) context.lookup(topicJNDIBinding); Assert.assertNotNull(topic); ActiveMQConnectionFactory cf = - new ActiveMQConnectionFactory(false, new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + new ActiveMQConnectionFactory(false, new TransportConfiguration(INVM_CONNECTOR_FACTORY)); Connection connection = cf.createConnection(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); // create a consumer will create a Core queue bound to the topic address @@ -722,7 +722,7 @@ public class JMSServerControlTest extends ManagementTestBase control.destroyTopic(topicName); Assert.assertNull(server.getManagementService().getResource(ResourceNames.CORE_ADDRESS + topicAddress)); - UnitTestCase.checkNoBinding(context, topicJNDIBinding); + ServiceTestBase.checkNoBinding(context, topicJNDIBinding); checkNoResource(ObjectNameBuilder.DEFAULT.getJMSTopicObjectName(topicName)); Assert.assertNull(fakeJMSStorageManager.destinationMap.get(topicName)); @@ -753,7 +753,7 @@ public class JMSServerControlTest extends ManagementTestBase { server.getConfiguration() .getConnectorConfigurations() - .put("tst", new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + .put("tst", new TransportConfiguration(INVM_CONNECTOR_FACTORY)); doCreateConnectionFactory(new ConnectionFactoryCreator() { @@ -930,7 +930,7 @@ public class JMSServerControlTest extends ManagementTestBase server.getConfiguration() .getConnectorConfigurations() - .put("tst", new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + .put("tst", new TransportConfiguration(INVM_CONNECTOR_FACTORY)); control.createConnectionFactory(cfName, false, false, 3, "tst", cfJNDIBinding); @@ -971,7 +971,7 @@ public class JMSServerControlTest extends ManagementTestBase server.getConfiguration() .getConnectorConfigurations() - .put("tst", new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + .put("tst", new TransportConfiguration(INVM_CONNECTOR_FACTORY)); control.createConnectionFactory(cfName, false, false, 3, "tst", cfJNDIBinding); @@ -1066,10 +1066,10 @@ public class JMSServerControlTest extends ManagementTestBase { Configuration conf = createBasicConfig() .setPersistenceEnabled(true) - .addAcceptorConfiguration(new TransportConfiguration(UnitTestCase.NETTY_ACCEPTOR_FACTORY)) - .addAcceptorConfiguration(new TransportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY)) - .addConnectorConfiguration("netty", new TransportConfiguration(UnitTestCase.NETTY_CONNECTOR_FACTORY)) - .addConnectorConfiguration("invm", new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + .addAcceptorConfiguration(new TransportConfiguration(ServiceTestBase.NETTY_ACCEPTOR_FACTORY)) + .addAcceptorConfiguration(new TransportConfiguration(ServiceTestBase.INVM_ACCEPTOR_FACTORY)) + .addConnectorConfiguration("netty", new TransportConfiguration(ServiceTestBase.NETTY_CONNECTOR_FACTORY)) + .addConnectorConfiguration("invm", new TransportConfiguration(INVM_CONNECTOR_FACTORY)); server = addServer(ActiveMQServers.newActiveMQServer(conf, mbeanServer, true)); @@ -1130,7 +1130,7 @@ public class JMSServerControlTest extends ManagementTestBase for (Object cfJNDIBinding : cfJNDIBindings) { - UnitTestCase.checkNoBinding(context, cfJNDIBinding.toString()); + ServiceTestBase.checkNoBinding(context, cfJNDIBinding.toString()); } checkNoResource(ObjectNameBuilder.DEFAULT.getConnectionFactoryObjectName(cfName)); @@ -1139,7 +1139,7 @@ public class JMSServerControlTest extends ManagementTestBase for (Object cfJNDIBinding : cfJNDIBindings) { - Object o = UnitTestCase.checkBinding(context, cfJNDIBinding.toString()); + Object o = ServiceTestBase.checkBinding(context, cfJNDIBinding.toString()); Assert.assertTrue(o instanceof ConnectionFactory); ConnectionFactory cf = (ConnectionFactory) o; Connection connection = cf.createConnection(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/AIOImportExportTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/AIOImportExportTest.java index bba40ffe63..4b3ea24f46 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/AIOImportExportTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/AIOImportExportTest.java @@ -18,7 +18,7 @@ package org.apache.activemq.artemis.tests.integration.journal; import java.io.File; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.journal.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.impl.AIOSequentialFileFactory; import org.junit.BeforeClass; @@ -36,7 +36,7 @@ public class AIOImportExportTest extends NIOImportExportTest { File file = new File(getTestDir()); - UnitTestCase.deleteDirectory(file); + ServiceTestBase.deleteDirectory(file); file.mkdir(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/AIOJournalCompactTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/AIOJournalCompactTest.java index f71326703a..dd63460027 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/AIOJournalCompactTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/AIOJournalCompactTest.java @@ -18,7 +18,7 @@ package org.apache.activemq.artemis.tests.integration.journal; import java.io.File; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.journal.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.impl.AIOSequentialFileFactory; import org.apache.activemq.artemis.core.journal.impl.JournalConstants; @@ -37,7 +37,7 @@ public class AIOJournalCompactTest extends NIOJournalCompactTest { File file = new File(getTestDir()); - UnitTestCase.deleteDirectory(file); + ServiceTestBase.deleteDirectory(file); file.mkdir(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/JournalPerfTuneTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/JournalPerfTuneTest.java index 8c70ae827c..02efaa3f65 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/JournalPerfTuneTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/JournalPerfTuneTest.java @@ -21,7 +21,7 @@ import java.util.concurrent.atomic.AtomicLong; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.journal.EncodingSupport; import org.apache.activemq.artemis.core.journal.IOCompletion; import org.apache.activemq.artemis.core.journal.Journal; @@ -37,7 +37,7 @@ import org.junit.Ignore; import org.junit.Test; @Ignore -public class JournalPerfTuneTest extends UnitTestCase +public class JournalPerfTuneTest extends ServiceTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOBufferedJournalCompactTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOBufferedJournalCompactTest.java index 1e358f69ab..da39e88beb 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOBufferedJournalCompactTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOBufferedJournalCompactTest.java @@ -18,7 +18,7 @@ package org.apache.activemq.artemis.tests.integration.journal; import java.io.File; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.journal.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory; @@ -30,7 +30,7 @@ public class NIOBufferedJournalCompactTest extends NIOJournalCompactTest { File file = new File(getTestDir()); - UnitTestCase.deleteDirectory(file); + ServiceTestBase.deleteDirectory(file); file.mkdir(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOImportExportTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOImportExportTest.java index a31ead76e5..66e001b322 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOImportExportTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOImportExportTest.java @@ -17,7 +17,7 @@ package org.apache.activemq.artemis.tests.integration.journal; import org.apache.activemq.artemis.tests.unit.core.journal.impl.JournalImplTestBase; import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.After; import org.junit.Test; @@ -39,7 +39,7 @@ public class NIOImportExportTest extends JournalImplTestBase { File file = new File(getTestDir()); - UnitTestCase.deleteDirectory(file); + ServiceTestBase.deleteDirectory(file); file.mkdir(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java index 028a8f3cf2..acc98c8baa 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java @@ -48,7 +48,7 @@ import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContex import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl; import org.apache.activemq.artemis.tests.unit.core.journal.impl.JournalImplTestBase; import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.utils.IDGenerator; import org.apache.activemq.artemis.utils.OrderedExecutorFactory; import org.apache.activemq.artemis.utils.SimpleIDGenerator; @@ -556,7 +556,7 @@ public class NIOJournalCompactTest extends JournalImplTestBase System.out.println("Waiting on Compact"); try { - UnitTestCase.waitForLatch(latchWait); + ServiceTestBase.waitForLatch(latchWait); } catch (InterruptedException e) { @@ -650,7 +650,7 @@ public class NIOJournalCompactTest extends JournalImplTestBase t.start(); - UnitTestCase.waitForLatch(latchDone); + ServiceTestBase.waitForLatch(latchDone); int nextID = NIOJournalCompactTest.NUMBER_OF_RECORDS; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalImplTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalImplTest.java index 660b9d55c9..e99775b2fe 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalImplTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalImplTest.java @@ -20,7 +20,7 @@ import java.io.File; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.unit.core.journal.impl.JournalImplTestUnit; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.journal.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory; @@ -35,7 +35,7 @@ public class NIOJournalImplTest extends JournalImplTestUnit NIOJournalImplTest.log.debug("deleting directory " + getTestDir()); - UnitTestCase.deleteDirectory(file); + ServiceTestBase.deleteDirectory(file); file.mkdir(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/ValidateTransactionHealthTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/ValidateTransactionHealthTest.java index e1a916075b..95ce97cc39 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/ValidateTransactionHealthTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/ValidateTransactionHealthTest.java @@ -21,7 +21,7 @@ import java.util.List; import java.util.concurrent.atomic.AtomicLong; import org.apache.activemq.artemis.tests.util.SpawnedVMSupport; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.asyncio.impl.AsynchronousFileImpl; import org.apache.activemq.artemis.core.journal.LoaderCallback; import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; @@ -37,7 +37,7 @@ import org.junit.Test; /** * This test spawns a remote VM, as we want to "crash" the VM right after the journal is filled with data */ -public class ValidateTransactionHealthTest extends UnitTestCase +public class ValidateTransactionHealthTest extends ServiceTestBase { private static final int OK = 10; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/largemessage/LargeMessageTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/largemessage/LargeMessageTestBase.java index 801fce69a8..d80ee587bd 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/largemessage/LargeMessageTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/largemessage/LargeMessageTestBase.java @@ -16,17 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.largemessage; -import javax.transaction.xa.XAResource; -import javax.transaction.xa.Xid; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Random; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; - import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffers; import org.apache.activemq.artemis.api.core.ActiveMQException; @@ -43,11 +32,21 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.utils.DataConstants; import org.apache.activemq.artemis.utils.DeflaterReader; import org.junit.Assert; +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Random; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; + public abstract class LargeMessageTestBase extends ServiceTestBase { @@ -300,7 +299,7 @@ public abstract class LargeMessageTestBase extends ServiceTestBase @Override public void write(final byte[] b) throws IOException { - if (b[0] == UnitTestCase.getSamplebyte(bytesRead.get())) + if (b[0] == ServiceTestBase.getSamplebyte(bytesRead.get())) { bytesRead.addAndGet(b.length); LargeMessageTestBase.log.debug("Read position " + bytesRead.get() + " on consumer"); @@ -314,7 +313,7 @@ public abstract class LargeMessageTestBase extends ServiceTestBase @Override public void write(final int b) throws IOException { - if (b == UnitTestCase.getSamplebyte(bytesRead.get())) + if (b == ServiceTestBase.getSamplebyte(bytesRead.get())) { bytesRead.incrementAndGet(); } @@ -339,7 +338,7 @@ public abstract class LargeMessageTestBase extends ServiceTestBase LargeMessageTestBase.log.debug("Read " + b + " bytes"); } - Assert.assertEquals(UnitTestCase.getSamplebyte(b), buffer.readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(b), buffer.readByte()); } try @@ -419,7 +418,7 @@ public abstract class LargeMessageTestBase extends ServiceTestBase @Override public void write(final byte[] b) throws IOException { - if (b[0] == UnitTestCase.getSamplebyte(bytesRead.get())) + if (b[0] == ServiceTestBase.getSamplebyte(bytesRead.get())) { bytesRead.addAndGet(b.length); } @@ -461,7 +460,7 @@ public abstract class LargeMessageTestBase extends ServiceTestBase { LargeMessageTestBase.log.debug("Read " + b + " bytes"); } - Assert.assertEquals(UnitTestCase.getSamplebyte(b), buffer.readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(b), buffer.readByte()); } } @@ -547,7 +546,7 @@ public abstract class LargeMessageTestBase extends ServiceTestBase if (numberOfBytes > 1024 * 1024 || i % 2 == 0) { LargeMessageTestBase.log.debug("Sending message (stream)" + i); - message.setBodyInputStream(UnitTestCase.createFakeLargeStream(numberOfBytes)); + message.setBodyInputStream(ServiceTestBase.createFakeLargeStream(numberOfBytes)); } else { @@ -555,7 +554,7 @@ public abstract class LargeMessageTestBase extends ServiceTestBase byte[] bytes = new byte[(int) numberOfBytes]; for (int j = 0; j < bytes.length; j++) { - bytes[j] = UnitTestCase.getSamplebyte(j); + bytes[j] = ServiceTestBase.getSamplebyte(j); } message.getBodyBuffer().writeBytes(bytes); } @@ -607,7 +606,7 @@ public abstract class LargeMessageTestBase extends ServiceTestBase ClientMessage clientMessage = session.createMessage(persistent); - clientMessage.setBodyInputStream(UnitTestCase.createFakeLargeStream(numberOfBytes)); + clientMessage.setBodyInputStream(ServiceTestBase.createFakeLargeStream(numberOfBytes)); return clientMessage; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/largemessage/ServerLargeMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/largemessage/ServerLargeMessageTest.java index e2c1114f55..83aa6d533b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/largemessage/ServerLargeMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/largemessage/ServerLargeMessageTest.java @@ -17,14 +17,13 @@ package org.apache.activemq.artemis.tests.integration.largemessage; import org.apache.activemq.artemis.api.core.Message; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager; import org.apache.activemq.artemis.core.persistence.impl.journal.LargeServerMessageImpl; import org.apache.activemq.artemis.core.server.ActiveMQServer; @@ -67,7 +66,7 @@ public class ServerLargeMessageTest extends ServiceTestBase for (int i = 0; i < 2 * ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE; i++) { - fileMessage.addBytes(new byte[]{UnitTestCase.getSamplebyte(i)}); + fileMessage.addBytes(new byte[]{ServiceTestBase.getSamplebyte(i)}); } // The server would be doing this fileMessage.putLongProperty(Message.HDR_LARGE_BODY_SIZE, 2 * ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE); @@ -97,7 +96,7 @@ public class ServerLargeMessageTest extends ServiceTestBase for (int i = 0; i < 2 * ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE; i++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(i), msg.getBodyBuffer().readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(i), msg.getBodyBuffer().readByte()); } msg.acknowledge(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AcceptorControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AcceptorControlTest.java index a89d6152ed..1f73935797 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AcceptorControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AcceptorControlTest.java @@ -53,7 +53,8 @@ public class AcceptorControlTest extends ManagementTestBase Configuration conf = createBasicConfig() .addAcceptorConfiguration(acceptorConfig); - ActiveMQServer service = createServer(false, conf, mbeanServer); + ActiveMQServer service = createServer(false, conf); + service.setMBeanServer(mbeanServer); service.start(); AcceptorControl acceptorControl = createManagementControl(acceptorConfig.getName()); @@ -70,7 +71,8 @@ public class AcceptorControlTest extends ManagementTestBase RandomUtil.randomString()); Configuration conf = createBasicConfig() .addAcceptorConfiguration(acceptorConfig); - ActiveMQServer service = createServer(false, conf, mbeanServer); + ActiveMQServer service = createServer(false, conf); + service.setMBeanServer(mbeanServer); service.start(); AcceptorControl acceptorControl = createManagementControl(acceptorConfig.getName()); @@ -129,7 +131,8 @@ public class AcceptorControlTest extends ManagementTestBase RandomUtil.randomString()); Configuration conf = createBasicConfig() .addAcceptorConfiguration(acceptorConfig); - ActiveMQServer service = createServer(false, conf, mbeanServer); + ActiveMQServer service = createServer(false, conf); + service.setMBeanServer(mbeanServer); service.start(); AcceptorControl acceptorControl = createManagementControl(acceptorConfig.getName()); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AcceptorControlUsingCoreTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AcceptorControlUsingCoreTest.java index 9b600a499c..259360b578 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AcceptorControlUsingCoreTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AcceptorControlUsingCoreTest.java @@ -16,18 +16,14 @@ */ package org.apache.activemq.artemis.tests.integration.management; -import org.junit.Test; - -import java.util.Map; - -import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.api.core.management.AcceptorControl; import org.apache.activemq.artemis.api.core.management.ResourceNames; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.junit.Test; + +import java.util.Map; public class AcceptorControlUsingCoreTest extends AcceptorControlTest { @@ -47,7 +43,7 @@ public class AcceptorControlUsingCoreTest extends AcceptorControlTest @Override protected AcceptorControl createManagementControl(final String name) throws Exception { - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); addServerLocator(locator); ClientSessionFactory sf = createSessionFactory(locator); session = sf.createSession(false, true, true); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java index 75fe771221..7df47ea785 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java @@ -16,24 +16,19 @@ */ package org.apache.activemq.artemis.tests.integration.management; -import javax.transaction.xa.XAResource; -import javax.transaction.xa.Xid; -import java.util.HashMap; -import java.util.Map; - import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; +import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl; import org.apache.activemq.artemis.api.core.management.AddressSettingsInfo; import org.apache.activemq.artemis.api.core.management.BridgeControl; import org.apache.activemq.artemis.api.core.management.DivertControl; -import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl; import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder; import org.apache.activemq.artemis.api.core.management.QueueControl; import org.apache.activemq.artemis.api.core.management.RoleInfo; @@ -48,7 +43,6 @@ import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.core.settings.impl.SlowConsumerPolicy; import org.apache.activemq.artemis.core.transaction.impl.XidImpl; import org.apache.activemq.artemis.tests.util.RandomUtil; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.utils.UUIDGenerator; import org.apache.activemq.artemis.utils.json.JSONArray; import org.apache.activemq.artemis.utils.json.JSONObject; @@ -57,6 +51,11 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; +import java.util.HashMap; +import java.util.Map; + public class ActiveMQServerControlTest extends ManagementTestBase { @@ -690,7 +689,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase assertEquals(name, divertNames[0]); // check that a message sent to the address is diverted exclusively - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory csf = createSessionFactory(locator); ClientSession session = csf.createSession(); @@ -756,7 +755,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase checkNoResource(ObjectNameBuilder.DEFAULT.getBridgeObjectName(name)); assertEquals(0, serverControl.getBridgeNames().length); - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory csf = createSessionFactory(locator); ClientSession session = csf.createSession(); @@ -840,7 +839,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase SimpleString atestq = new SimpleString("BasicXaTestq"); Xid xid = newXID(); - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory csf = createSessionFactory(locator); ClientSession clientSession = csf.createSession(true, false, false); clientSession.createQueue(atestq, atestq, null, true); @@ -886,7 +885,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase SimpleString atestq = new SimpleString("BasicXaTestq"); Xid xid = newXID(); - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory csf = createSessionFactory(locator); ClientSession clientSession = csf.createSession(true, false, false); clientSession.createQueue(atestq, atestq, null, true); @@ -929,7 +928,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase byte[] globalTransactionId = UUIDGenerator.getInstance().generateStringUUID().getBytes(); Xid xid = new XidImpl("xa1".getBytes(), 1, globalTransactionId); Xid xid2 = new XidImpl("xa2".getBytes(), 1, globalTransactionId); - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory csf = createSessionFactory(locator); ClientSession clientSession = csf.createSession(true, false, false); clientSession.createQueue(recQueue, recQueue, null, true); @@ -941,13 +940,13 @@ public class ActiveMQServerControlTest extends ManagementTestBase locator.close(); - ServerLocator receiveLocator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator receiveLocator = createInVMNonHALocator(); ClientSessionFactory receiveCsf = createSessionFactory(receiveLocator); ClientSession receiveClientSession = receiveCsf.createSession(true, false, false); ClientConsumer consumer = receiveClientSession.createConsumer(recQueue); - ServerLocator sendLocator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator sendLocator = createInVMNonHALocator(); ClientSessionFactory sendCsf = createSessionFactory(sendLocator); ClientSession sendClientSession = sendCsf.createSession(true, false, false); ClientProducer producer = sendClientSession.createProducer(sendQueue); @@ -1009,7 +1008,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase protected void scaleDown(ScaleDownHandler handler) throws Exception { SimpleString address = new SimpleString("testQueue"); - Configuration conf = createDefaultConfig(false, 2); + Configuration conf = createDefaultConfig(2, new HashMap(), INVM_ACCEPTOR_FACTORY); conf.setSecurityEnabled(false); conf.getAcceptorConfigurations().clear(); HashMap params = new HashMap(); @@ -1017,13 +1016,13 @@ public class ActiveMQServerControlTest extends ManagementTestBase conf.getAcceptorConfigurations().add(new TransportConfiguration(InVMAcceptorFactory.class.getName(), params)); ActiveMQServer server2 = ActiveMQServers.newActiveMQServer(conf, null, true); this.conf.getConnectorConfigurations().clear(); - this.conf.getConnectorConfigurations().put("server2-connector", new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY, params)); + this.conf.getConnectorConfigurations().put("server2-connector", new TransportConfiguration(INVM_CONNECTOR_FACTORY, params)); try { server2.start(); server.createQueue(address, address, null, true, false); server2.createQueue(address, address, null, true, false); - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory csf = createSessionFactory(locator); ClientSession session = csf.createSession(); ClientProducer producer = session.createProducer(address); @@ -1037,7 +1036,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase ActiveMQServerControl managementControl = createManagementControl(); handler.scaleDown(managementControl); locator.close(); - locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY, params)); + locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(INVM_CONNECTOR_FACTORY, params)); csf = createSessionFactory(locator); session = csf.createSession(); session.start(); @@ -1072,7 +1071,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase params, RandomUtil.randomString()); - conf = createDefaultConfig(false) + conf = createDefaultConfig() .setSecurityEnabled(false) .setJMXManagementEnabled(true) .clearAcceptorConfigurations() diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java index 7c664d493f..451c16d705 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java @@ -16,15 +16,12 @@ */ package org.apache.activemq.artemis.tests.integration.management; -import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl; import org.apache.activemq.artemis.api.core.management.Parameter; import org.apache.activemq.artemis.api.core.management.ResourceNames; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.junit.After; import org.junit.Before; @@ -62,7 +59,7 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes { super.setUp(); - locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); session = sf.createSession(false, true, true); session.start(); @@ -88,7 +85,7 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes super.restartServer(); - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); session = sf.createSession(false, true, true); session.start(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlTest.java index 8622f678ca..93bff07156 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlTest.java @@ -16,21 +16,17 @@ */ package org.apache.activemq.artemis.tests.integration.management; -import java.util.HashSet; -import java.util.Set; - import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.api.core.management.AddressControl; import org.apache.activemq.artemis.api.core.management.RoleInfo; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory; import org.apache.activemq.artemis.core.security.CheckType; @@ -43,6 +39,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import java.util.HashSet; +import java.util.Set; + import static org.apache.activemq.artemis.tests.util.RandomUtil.randomString; public class AddressControlTest extends ManagementTestBase @@ -221,7 +220,7 @@ public class AddressControlTest extends ManagementTestBase server.start(); ServerLocator locator2 = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration( - UnitTestCase.INVM_CONNECTOR_FACTORY)); + INVM_CONNECTOR_FACTORY)); addServerLocator(locator2); ClientSessionFactory sf2 = createSessionFactory(locator2); @@ -289,7 +288,7 @@ public class AddressControlTest extends ManagementTestBase server.getAddressSettingsRepository().addMatch(address.toString(), addressSettings); server.start(); ServerLocator locator2 = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration( - UnitTestCase.INVM_CONNECTOR_FACTORY)); + INVM_CONNECTOR_FACTORY)); addServerLocator(locator2); ClientSessionFactory sf2 = createSessionFactory(locator2); @@ -310,7 +309,8 @@ public class AddressControlTest extends ManagementTestBase Configuration conf = createBasicConfig() .addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName())); - server = createServer(false, conf, mbeanServer); + server = createServer(false, conf); + server.setMBeanServer(mbeanServer); server.start(); locator = createInVMNonHALocator(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlUsingCoreTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlUsingCoreTest.java index f1853f8c98..cf1fdb67cd 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlUsingCoreTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlUsingCoreTest.java @@ -181,7 +181,8 @@ public class AddressControlUsingCoreTest extends ManagementTestBase Configuration conf = createBasicConfig() .addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName())); - server = createServer(false, conf, mbeanServer); + server = createServer(false, conf); + server.setMBeanServer(mbeanServer); server.start(); ServerLocator locator = createInVMNonHALocator(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BroadcastGroupControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BroadcastGroupControlTest.java index bd0c0cb067..ed5db0b5be 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BroadcastGroupControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BroadcastGroupControlTest.java @@ -16,7 +16,7 @@ */ package org.apache.activemq.artemis.tests.integration.management; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Test; import java.util.ArrayList; @@ -66,7 +66,7 @@ public class BroadcastGroupControlTest extends ManagementTestBase @Test public void testAttributes() throws Exception { - TransportConfiguration connectorConfiguration = new TransportConfiguration(UnitTestCase.NETTY_CONNECTOR_FACTORY); + TransportConfiguration connectorConfiguration = new TransportConfiguration(ServiceTestBase.NETTY_CONNECTOR_FACTORY); List connectorInfos = new ArrayList(); connectorInfos.add(connectorConfiguration.getName()); BroadcastGroupConfiguration broadcastGroupConfig = BroadcastGroupControlTest.randomBroadcastGroupConfiguration(connectorInfos); @@ -74,7 +74,7 @@ public class BroadcastGroupControlTest extends ManagementTestBase Configuration conf = createBasicConfig() .addConnectorConfiguration(connectorConfiguration.getName(), connectorConfiguration) .addBroadcastGroupConfiguration(broadcastGroupConfig) - .addAcceptorConfiguration(new TransportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY)); + .addAcceptorConfiguration(new TransportConfiguration(ServiceTestBase.INVM_ACCEPTOR_FACTORY)); service = addServer(ActiveMQServers.newActiveMQServer(conf, mbeanServer, false)); service.start(); @@ -104,7 +104,7 @@ public class BroadcastGroupControlTest extends ManagementTestBase @Test public void testStartStop() throws Exception { - TransportConfiguration connectorConfiguration = new TransportConfiguration(UnitTestCase.NETTY_CONNECTOR_FACTORY); + TransportConfiguration connectorConfiguration = new TransportConfiguration(ServiceTestBase.NETTY_CONNECTOR_FACTORY); List connectorInfos = new ArrayList(); connectorInfos.add(connectorConfiguration.getName()); BroadcastGroupConfiguration broadcastGroupConfig = BroadcastGroupControlTest.randomBroadcastGroupConfiguration(connectorInfos); @@ -112,7 +112,7 @@ public class BroadcastGroupControlTest extends ManagementTestBase Configuration conf = createBasicConfig() .addConnectorConfiguration(connectorConfiguration.getName(), connectorConfiguration) .addBroadcastGroupConfiguration(broadcastGroupConfig) - .addAcceptorConfiguration(new TransportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY)); + .addAcceptorConfiguration(new TransportConfiguration(ServiceTestBase.INVM_ACCEPTOR_FACTORY)); service = addServer(ActiveMQServers.newActiveMQServer(conf, mbeanServer, false)); service.start(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControl2Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControl2Test.java index 03cd26a82d..34f046ff46 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControl2Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControl2Test.java @@ -15,7 +15,7 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.integration.management; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Before; import org.junit.After; @@ -108,12 +108,12 @@ public class ClusterConnectionControl2Test extends ManagementTestBase Map acceptorParams_1 = new HashMap(); acceptorParams_1.put(TransportConstants.PORT_PROP_NAME, port_1); - TransportConfiguration acceptorConfig_0 = new TransportConfiguration(UnitTestCase.NETTY_ACCEPTOR_FACTORY); + TransportConfiguration acceptorConfig_0 = new TransportConfiguration(ServiceTestBase.NETTY_ACCEPTOR_FACTORY); - TransportConfiguration acceptorConfig_1 = new TransportConfiguration(UnitTestCase.NETTY_ACCEPTOR_FACTORY, acceptorParams_1); + TransportConfiguration acceptorConfig_1 = new TransportConfiguration(ServiceTestBase.NETTY_ACCEPTOR_FACTORY, acceptorParams_1); - TransportConfiguration connectorConfig_1 = new TransportConfiguration(UnitTestCase.NETTY_CONNECTOR_FACTORY, acceptorParams_1); - TransportConfiguration connectorConfig_0 = new TransportConfiguration(UnitTestCase.NETTY_CONNECTOR_FACTORY); + TransportConfiguration connectorConfig_1 = new TransportConfiguration(ServiceTestBase.NETTY_CONNECTOR_FACTORY, acceptorParams_1); + TransportConfiguration connectorConfig_0 = new TransportConfiguration(ServiceTestBase.NETTY_CONNECTOR_FACTORY); CoreQueueConfiguration queueConfig = new CoreQueueConfiguration() .setAddress(RandomUtil.randomString()) diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControlUsingCoreTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControlUsingCoreTest.java index 45a17937d4..874184da80 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControlUsingCoreTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControlUsingCoreTest.java @@ -16,19 +16,16 @@ */ package org.apache.activemq.artemis.tests.integration.management; -import java.util.Map; - -import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.api.core.management.ClusterConnectionControl; import org.apache.activemq.artemis.api.core.management.ResourceNames; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.junit.After; import org.junit.Before; +import java.util.Map; + public class ClusterConnectionControlUsingCoreTest extends ClusterConnectionControlTest { @@ -148,7 +145,7 @@ public class ClusterConnectionControlUsingCoreTest extends ClusterConnectionCont { super.setUp(); - locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + locator = createInVMNonHALocator(); } @Override diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/DivertControlUsingCoreTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/DivertControlUsingCoreTest.java index 98b77e52b0..402a0df1cf 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/DivertControlUsingCoreTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/DivertControlUsingCoreTest.java @@ -16,14 +16,11 @@ */ package org.apache.activemq.artemis.tests.integration.management; -import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.api.core.management.DivertControl; import org.apache.activemq.artemis.api.core.management.ResourceNames; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.junit.After; import org.junit.Before; @@ -105,7 +102,7 @@ public class DivertControlUsingCoreTest extends DivertControlTest { super.setUp(); - locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + locator = createInVMNonHALocator(); } @Override diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementServiceImplTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementServiceImplTest.java index 9db746fa0a..0cf3b95b5f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementServiceImplTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementServiceImplTest.java @@ -17,7 +17,7 @@ package org.apache.activemq.artemis.tests.integration.management; import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Test; import org.junit.Assert; @@ -38,7 +38,7 @@ import org.apache.activemq.artemis.core.server.management.impl.ManagementService import org.apache.activemq.artemis.tests.integration.server.FakeStorageManager; import org.apache.activemq.artemis.tests.util.RandomUtil; -public class ManagementServiceImplTest extends UnitTestCase +public class ManagementServiceImplTest extends ServiceTestBase { @Test public void testHandleManagementMessageWithOperation() throws Exception diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/NotificationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/NotificationTest.java index aec091c1a5..8f691408ba 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/NotificationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/NotificationTest.java @@ -27,7 +27,7 @@ import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.api.core.management.ManagementHelper; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory; @@ -45,7 +45,7 @@ import static org.apache.activemq.artemis.api.core.management.CoreNotificationTy import static org.apache.activemq.artemis.api.core.management.CoreNotificationType.CONSUMER_CLOSED; import static org.apache.activemq.artemis.api.core.management.CoreNotificationType.CONSUMER_CREATED; -public class NotificationTest extends UnitTestCase +public class NotificationTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java index e3e00c7be4..b96d8024e7 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java @@ -16,13 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.management; -import java.util.LinkedList; -import java.util.Map; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import javax.management.Notification; - import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; @@ -32,12 +25,11 @@ import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.core.client.ServerLocator; +import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl; import org.apache.activemq.artemis.api.core.management.CoreNotificationType; import org.apache.activemq.artemis.api.core.management.DayCounterInfo; -import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl; import org.apache.activemq.artemis.api.core.management.MessageCounterInfo; import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder; import org.apache.activemq.artemis.api.core.management.QueueControl; @@ -56,6 +48,12 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import javax.management.Notification; +import java.util.LinkedList; +import java.util.Map; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + public class QueueControlTest extends ManagementTestBase { @@ -391,7 +389,7 @@ public class QueueControlTest extends ManagementTestBase @Test public void testListDeliveringMessagesWithRASession() throws Exception { - ServerLocator locator1 = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(INVM_CONNECTOR_FACTORY)); + ServerLocator locator1 = createInVMNonHALocator(); locator1.setBlockOnNonDurableSend(true); locator1.setConsumerWindowSize(10240); locator1.setAckBatchSize(0); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SecurityManagementTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SecurityManagementTestBase.java index c3770c103a..e3d303529c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SecurityManagementTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SecurityManagementTestBase.java @@ -16,7 +16,7 @@ */ package org.apache.activemq.artemis.tests.integration.management; import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Before; import org.junit.After; @@ -33,7 +33,7 @@ import org.apache.activemq.artemis.api.core.management.ManagementHelper; import org.apache.activemq.artemis.api.core.management.ResourceNames; import org.apache.activemq.artemis.core.server.ActiveMQServer; -public abstract class SecurityManagementTestBase extends UnitTestCase +public abstract class SecurityManagementTestBase extends ServiceTestBase { // Constants ----------------------------------------------------- @@ -78,7 +78,7 @@ public abstract class SecurityManagementTestBase extends UnitTestCase { ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration( - UnitTestCase.INVM_CONNECTOR_FACTORY))); + INVM_CONNECTOR_FACTORY))); ClientSessionFactory sf = locator.createSessionFactory(); try { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SecurityNotificationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SecurityNotificationTest.java index 90ac2bbb30..ec8fc6f242 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SecurityNotificationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SecurityNotificationTest.java @@ -15,30 +15,15 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.integration.management; -import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManagerImpl; -import org.apache.activemq.artemis.tests.util.UnitTestCase; -import org.junit.Before; -import org.junit.After; - -import org.junit.Test; - -import static org.apache.activemq.artemis.api.core.management.CoreNotificationType.SECURITY_AUTHENTICATION_VIOLATION; -import static org.apache.activemq.artemis.api.core.management.CoreNotificationType.SECURITY_PERMISSION_VIOLATION; - -import java.util.HashSet; -import java.util.Set; - -import org.junit.Assert; import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; +import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.api.core.management.ManagementHelper; import org.apache.activemq.artemis.core.config.Configuration; @@ -47,9 +32,21 @@ import org.apache.activemq.artemis.core.security.CheckType; import org.apache.activemq.artemis.core.security.Role; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; +import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManagerImpl; import org.apache.activemq.artemis.tests.util.RandomUtil; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; -public class SecurityNotificationTest extends UnitTestCase +import java.util.HashSet; +import java.util.Set; + +import static org.apache.activemq.artemis.api.core.management.CoreNotificationType.SECURITY_AUTHENTICATION_VIOLATION; +import static org.apache.activemq.artemis.api.core.management.CoreNotificationType.SECURITY_PERMISSION_VIOLATION; + +public class SecurityNotificationTest extends ServiceTestBase { // Constants ----------------------------------------------------- @@ -77,7 +74,7 @@ public class SecurityNotificationTest extends UnitTestCase SecurityNotificationTest.flush(notifConsumer); - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); try @@ -111,7 +108,7 @@ public class SecurityNotificationTest extends UnitTestCase SecurityNotificationTest.flush(notifConsumer); - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); ClientSession guestSession = sf.createSession("guest", "guest", false, true, true, false, 1); @@ -169,7 +166,7 @@ public class SecurityNotificationTest extends UnitTestCase securityManager.getConfiguration().addRole("admin", "notif"); - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); ClientSessionFactory sf = createSessionFactory(locator); adminSession = sf.createSession("admin", "admin", false, true, true, false, 1); adminSession.start(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/MultipleProducersPagingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/MultipleProducersPagingTest.java index 878f551851..6b2f15df04 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/MultipleProducersPagingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/MultipleProducersPagingTest.java @@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; @@ -52,7 +52,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -public class MultipleProducersPagingTest extends UnitTestCase +public class MultipleProducersPagingTest extends ServiceTestBase { private static final int CONSUMER_WAIT_TIME_MS = 250; private static final int PRODUCERS = 5; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/SpawnedServerSupport.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/SpawnedServerSupport.java index eb9b6cabe4..7dce83fe31 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/SpawnedServerSupport.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/SpawnedServerSupport.java @@ -29,6 +29,7 @@ import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.HAPolicyConfiguration; import org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration; import org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration; +import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; import org.apache.activemq.artemis.core.server.ActiveMQServer; @@ -57,10 +58,21 @@ public class SpawnedServerSupport settings.setPageSizeBytes(10 * 1024); settings.setMaxSizeBytes(100 * 1024); - Configuration conf = ServiceTestBase.createBasicConfig(folder, 0) - .setPersistenceEnabled(true) - .addAddressesSetting("#", settings) - .addAcceptorConfiguration(new TransportConfiguration("org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory")); + Configuration conf = new ConfigurationImpl() + .setSecurityEnabled(false) + .setJournalMinFiles(2) + .setJournalFileSize(100 * 1024) + .setJournalType(ServiceTestBase.getDefaultJournalType()) + .setJournalCompactMinFiles(0) + .setJournalCompactPercentage(0) + .setClusterPassword(ServiceTestBase.CLUSTER_PASSWORD) + .setJournalDirectory(ServiceTestBase.getJournalDir(folder, 0, false)) + .setBindingsDirectory(ServiceTestBase.getBindingsDir(folder, 0, false)) + .setPagingDirectory(ServiceTestBase.getPageDir(folder, 0, false)) + .setLargeMessagesDirectory(ServiceTestBase.getLargeMessagesDir(folder, 0, false)) + .setPersistenceEnabled(true) + .addAddressesSetting("#", settings) + .addAcceptorConfiguration(new TransportConfiguration("org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory")); return conf; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerTest.java index 0c0a7a7b2b..3564e235a7 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerTest.java @@ -16,14 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.ra; -import javax.jms.Message; -import javax.resource.ResourceException; -import javax.resource.spi.InvalidPropertyException; -import java.lang.reflect.Method; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -38,9 +30,16 @@ import org.apache.activemq.artemis.ra.ActiveMQResourceAdapter; import org.apache.activemq.artemis.ra.inflow.ActiveMQActivation; import org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.junit.Test; +import javax.jms.Message; +import javax.resource.ResourceException; +import javax.resource.spi.InvalidPropertyException; +import java.lang.reflect.Method; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + public class ActiveMQMessageHandlerTest extends ActiveMQRATestBase { @@ -199,7 +198,7 @@ public class ActiveMQMessageHandlerTest extends ActiveMQRATestBase protected ActiveMQResourceAdapter newResourceAdapter() { ActiveMQResourceAdapter qResourceAdapter = new ActiveMQResourceAdapter(); - qResourceAdapter.setConnectorClassName(UnitTestCase.INVM_CONNECTOR_FACTORY); + qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY); return qResourceAdapter; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerXATest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerXATest.java index 03231e73c4..d49a186f1d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerXATest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQMessageHandlerXATest.java @@ -16,18 +16,16 @@ */ package org.apache.activemq.artemis.tests.integration.ra; -import org.apache.activemq.artemis.core.postoffice.Binding; -import org.apache.activemq.artemis.core.server.Queue; -import org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec; -import org.junit.Test; - import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; +import org.apache.activemq.artemis.core.postoffice.Binding; +import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.transaction.impl.XidImpl; import org.apache.activemq.artemis.ra.ActiveMQResourceAdapter; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec; import org.apache.activemq.artemis.utils.UUIDGenerator; +import org.junit.Test; import javax.jms.Message; import javax.resource.ResourceException; @@ -163,7 +161,7 @@ public class ActiveMQMessageHandlerXATest extends ActiveMQRATestBase { setupDLQ(10); ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter(); - qResourceAdapter.setConnectorClassName(UnitTestCase.INVM_CONNECTOR_FACTORY); + qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY); MyBootstrapContext ctx = new MyBootstrapContext(); qResourceAdapter.start(ctx); ActiveMQActivationSpec spec = new ActiveMQActivationSpec(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQRAClusteredTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQRAClusteredTestBase.java index 55fadcfcbd..45fc6cb078 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQRAClusteredTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQRAClusteredTestBase.java @@ -25,7 +25,7 @@ import org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Before; public class ActiveMQRAClusteredTestBase extends ActiveMQRATestBase @@ -96,7 +96,7 @@ public class ActiveMQRAClusteredTestBase extends ActiveMQRATestBase .setPagingDirectory(getTestDir() + "/" + directoryPrefix + "Page / ") .addConnectorConfiguration(secondaryConnectorName, secondaryConnector) .addConnectorConfiguration(primaryConnectorName, primaryConnector) - .addClusterConfiguration(UnitTestCase.basicClusterConnectionConfig(secondaryConnectorName, primaryConnectorName)); + .addClusterConfiguration(ServiceTestBase.basicClusterConnectionConfig(secondaryConnectorName, primaryConnectorName)); return configuration; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQRATestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQRATestBase.java index eccdb96549..fde184e166 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQRATestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ActiveMQRATestBase.java @@ -16,6 +16,16 @@ */ package org.apache.activemq.artemis.tests.integration.ra; +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.api.core.client.ServerLocator; +import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.jms.client.ActiveMQMessage; +import org.apache.activemq.artemis.ra.ActiveMQResourceAdapter; +import org.apache.activemq.artemis.ra.inflow.ActiveMQActivation; +import org.apache.activemq.artemis.tests.util.JMSTestBase; +import org.junit.After; +import org.junit.Before; + import javax.jms.Message; import javax.jms.MessageListener; import javax.resource.ResourceException; @@ -36,17 +46,6 @@ import java.util.Map; import java.util.Timer; import java.util.concurrent.CountDownLatch; -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.JMSTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; -import org.apache.activemq.artemis.core.settings.impl.AddressSettings; -import org.apache.activemq.artemis.jms.client.ActiveMQMessage; -import org.apache.activemq.artemis.ra.ActiveMQResourceAdapter; -import org.apache.activemq.artemis.ra.inflow.ActiveMQActivation; -import org.junit.After; -import org.junit.Before; - public abstract class ActiveMQRATestBase extends JMSTestBase { protected ServerLocator locator; @@ -95,7 +94,7 @@ public abstract class ActiveMQRATestBase extends JMSTestBase protected ActiveMQResourceAdapter newResourceAdapter() { ActiveMQResourceAdapter qResourceAdapter = new ActiveMQResourceAdapter(); - qResourceAdapter.setConnectorClassName(UnitTestCase.INVM_CONNECTOR_FACTORY); + qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY); return qResourceAdapter; } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java index 4ea46c8a55..246e50c860 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ra/ResourceAdapterTest.java @@ -16,6 +16,25 @@ */ package org.apache.activemq.artemis.tests.integration.ra; +import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration; +import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory; +import org.apache.activemq.artemis.api.core.client.ClientSession; +import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; +import org.apache.activemq.artemis.api.core.client.ServerLocator; +import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; +import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal; +import org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl; +import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; +import org.apache.activemq.artemis.jms.client.ActiveMQDestination; +import org.apache.activemq.artemis.ra.ActiveMQResourceAdapter; +import org.apache.activemq.artemis.ra.inflow.ActiveMQActivation; +import org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec; +import org.apache.activemq.artemis.service.extensions.xa.recovery.XARecoveryConfig; +import org.apache.activemq.artemis.tests.unit.ra.BootstrapContext; +import org.apache.activemq.artemis.tests.unit.ra.MessageEndpointFactory; +import org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec; +import org.junit.Test; + import javax.jms.Connection; import javax.resource.ResourceException; import javax.resource.spi.endpoint.MessageEndpoint; @@ -26,26 +45,6 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.CountDownLatch; -import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration; -import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory; -import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; -import org.apache.activemq.artemis.tests.unit.ra.BootstrapContext; -import org.apache.activemq.artemis.tests.unit.ra.MessageEndpointFactory; -import org.apache.activemq.artemis.tests.util.UnitTestCase; -import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal; -import org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl; -import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; -import org.apache.activemq.artemis.jms.client.ActiveMQDestination; -import org.apache.activemq.artemis.ra.ActiveMQResourceAdapter; -import org.apache.activemq.artemis.ra.inflow.ActiveMQActivation; -import org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec; -import org.apache.activemq.artemis.service.extensions.xa.recovery.XARecoveryConfig; -import org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec; -import org.junit.Test; - public class ResourceAdapterTest extends ActiveMQRATestBase { @Test @@ -120,7 +119,7 @@ public class ResourceAdapterTest extends ActiveMQRATestBase public void testStartStop() throws Exception { ActiveMQResourceAdapter qResourceAdapter = new ActiveMQResourceAdapter(); - qResourceAdapter.setConnectorClassName(UnitTestCase.INVM_CONNECTOR_FACTORY); + qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY); ActiveMQRATestBase.MyBootstrapContext ctx = new ActiveMQRATestBase.MyBootstrapContext(); qResourceAdapter.start(ctx); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/scheduling/DelayedMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/scheduling/DelayedMessageTest.java index 0e287b6fef..cff46fd927 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/scheduling/DelayedMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/scheduling/DelayedMessageTest.java @@ -15,11 +15,6 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.integration.scheduling; -import org.junit.Before; - -import org.junit.Test; - -import org.junit.Assert; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -33,7 +28,9 @@ import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; public class DelayedMessageTest extends ServiceTestBase { @@ -90,7 +87,7 @@ public class DelayedMessageTest extends ServiceTestBase final int NUM_MESSAGES = 5; - UnitTestCase.forceGC(); + ServiceTestBase.forceGC(); for (int i = 0; i < NUM_MESSAGES; i++) { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/scheduling/MultipliedDelayedMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/scheduling/MultipliedDelayedMessageTest.java index 33d32bbb0a..7ffef991a6 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/scheduling/MultipliedDelayedMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/scheduling/MultipliedDelayedMessageTest.java @@ -22,13 +22,12 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -94,7 +93,7 @@ public class MultipliedDelayedMessageTest extends ServiceTestBase // Session for sending the message session = sessionFactory.createSession(false, true, true); ClientProducer producer = session.createProducer(queueName); - UnitTestCase.forceGC(); + ServiceTestBase.forceGC(); ClientMessage tm = createDurableMessage(session, "message"); producer.send(tm); session.close(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/scheduling/ScheduledMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/scheduling/ScheduledMessageTest.java index b9528c4842..377166b564 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/scheduling/ScheduledMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/scheduling/ScheduledMessageTest.java @@ -16,11 +16,6 @@ */ package org.apache.activemq.artemis.tests.integration.scheduling; -import javax.transaction.xa.XAResource; -import javax.transaction.xa.Xid; -import java.util.ArrayList; -import java.util.concurrent.atomic.AtomicInteger; - import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; @@ -29,19 +24,23 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.core.transaction.impl.XidImpl; import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; +import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.utils.UUIDGenerator; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; +import java.util.ArrayList; +import java.util.concurrent.atomic.AtomicInteger; + public class ScheduledMessageTest extends ServiceTestBase { private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER; @@ -864,7 +863,7 @@ public class ScheduledMessageTest extends ServiceTestBase private void scheduledDelivery(final boolean tx) throws Exception { - UnitTestCase.forceGC(); + ServiceTestBase.forceGC(); Xid xid = new XidImpl("xa1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes()); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/SecurityTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/SecurityTest.java index 5f9c50b447..0ad440e328 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/SecurityTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/SecurityTest.java @@ -92,7 +92,7 @@ public class SecurityTest extends ServiceTestBase */ private ActiveMQServer createServer() throws Exception { - configuration = createDefaultConfig(false) + configuration = createDefaultConfig() .setSecurityEnabled(true); ActiveMQServer server = createServer(false, configuration); return server; @@ -569,7 +569,7 @@ public class SecurityTest extends ServiceTestBase @Test public void testSendMessageUpdateRoleCached() throws Exception { - Configuration configuration = createDefaultConfig(false) + Configuration configuration = createDefaultConfig() .setSecurityEnabled(true) .setSecurityInvalidationInterval(10000); ActiveMQServer server = createServer(false, configuration); @@ -625,7 +625,7 @@ public class SecurityTest extends ServiceTestBase @Test public void testSendMessageUpdateRoleCached2() throws Exception { - Configuration configuration = createDefaultConfig(false) + Configuration configuration = createDefaultConfig() .setSecurityEnabled(true) .setSecurityInvalidationInterval(0); ActiveMQServer server = createServer(false, configuration); @@ -695,7 +695,7 @@ public class SecurityTest extends ServiceTestBase @Test public void testSendMessageUpdateSender() throws Exception { - Configuration configuration = createDefaultConfig(false) + Configuration configuration = createDefaultConfig() .setSecurityEnabled(true) .setSecurityInvalidationInterval(-1); ActiveMQServer server = createServer(false, configuration); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ConnectionLimitTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ConnectionLimitTest.java index 0832f24f25..fc9f5f150f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ConnectionLimitTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ConnectionLimitTest.java @@ -26,14 +26,14 @@ import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Before; import org.junit.Test; import java.util.HashMap; import java.util.Map; -public class ConnectionLimitTest extends UnitTestCase +public class ConnectionLimitTest extends ServiceTestBase { private ActiveMQServer server; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ExpiryRunnerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ExpiryRunnerTest.java index d4038cc73e..cbeb225574 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ExpiryRunnerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ExpiryRunnerTest.java @@ -15,20 +15,8 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.integration.server; + import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.tests.util.UnitTestCase; -import org.junit.Before; -import org.junit.After; - -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientConsumer; @@ -36,15 +24,24 @@ import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; -public class ExpiryRunnerTest extends UnitTestCase +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +public class ExpiryRunnerTest extends ServiceTestBase { private ActiveMQServer server; @@ -265,12 +262,12 @@ public class ExpiryRunnerTest extends UnitTestCase ConfigurationImpl configuration = createBasicConfig() .setMessageExpiryScanPeriod(1000) - .addAcceptorConfiguration(new TransportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY)); + .addAcceptorConfiguration(new TransportConfiguration(ServiceTestBase.INVM_ACCEPTOR_FACTORY)); server = ActiveMQServers.newActiveMQServer(configuration, false); // start the server server.start(); // then we create a client as normal - locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + locator = createInVMNonHALocator(); locator.setBlockOnAcknowledge(true); ClientSessionFactory sessionFactory = createSessionFactory(locator); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/LVQRecoveryTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/LVQRecoveryTest.java index 2a1236e5bf..de24818e3a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/LVQRecoveryTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/LVQRecoveryTest.java @@ -16,21 +16,15 @@ */ package org.apache.activemq.artemis.tests.integration.server; -import javax.transaction.xa.XAResource; -import javax.transaction.xa.Xid; - import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; @@ -41,6 +35,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; + public class LVQRecoveryTest extends ServiceTestBase { private ActiveMQServer server; @@ -231,7 +228,7 @@ public class LVQRecoveryTest extends ServiceTestBase qs.setLastValueQueue(true); server.getAddressSettingsRepository().addMatch(address.toString(), qs); // then we create a client as normal - locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + locator = createInVMNonHALocator(); locator.setBlockOnAcknowledge(true); locator.setAckBatchSize(0); @@ -255,7 +252,7 @@ public class LVQRecoveryTest extends ServiceTestBase server.getAddressSettingsRepository().addMatch(address.toString(), qs1); // then we create a client as normal locator.close(); - locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + locator = createInVMNonHALocator(); locator.setBlockOnAcknowledge(true); locator.setAckBatchSize(0); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/LVQTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/LVQTest.java index 663e073e14..83a432e4a3 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/LVQTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/LVQTest.java @@ -15,16 +15,8 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.integration.server; + import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.tests.util.UnitTestCase; -import org.apache.activemq.artemis.core.server.Queue; -import org.junit.Before; -import org.junit.After; - -import org.junit.Test; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.TransportConfiguration; @@ -33,14 +25,19 @@ import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; +import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; -public class LVQTest extends UnitTestCase +public class LVQTest extends ServiceTestBase { private ActiveMQServer server; @@ -675,7 +672,7 @@ public class LVQTest extends UnitTestCase super.setUp(); ConfigurationImpl configuration = createBasicConfig() - .addAcceptorConfiguration(new TransportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY)); + .addAcceptorConfiguration(new TransportConfiguration(ServiceTestBase.INVM_ACCEPTOR_FACTORY)); server = ActiveMQServers.newActiveMQServer(configuration, false); // start the server server.start(); @@ -684,7 +681,7 @@ public class LVQTest extends UnitTestCase qs.setLastValueQueue(true); server.getAddressSettingsRepository().addMatch(address.toString(), qs); // then we create a client as normalServer - ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY)); + ServerLocator locator = createInVMNonHALocator(); locator.setBlockOnAcknowledge(true); locator.setAckBatchSize(0); ClientSessionFactory sessionFactory = createSessionFactory(locator); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ResourceLimitTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ResourceLimitTest.java index 08d193c99c..b96b9bcc1b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ResourceLimitTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ResourceLimitTest.java @@ -26,11 +26,11 @@ import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.core.settings.impl.ResourceLimitSettings; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Before; import org.junit.Test; -public class ResourceLimitTest extends UnitTestCase +public class ResourceLimitTest extends ServiceTestBase { private ActiveMQServer server; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDown3NodeTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDown3NodeTest.java index 29e6d0e9d5..0b76a60a27 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDown3NodeTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDown3NodeTest.java @@ -33,7 +33,7 @@ import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.integration.cluster.distribution.ClusterTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -149,7 +149,7 @@ public class ScaleDown3NodeTest extends ClusterTestBase for (int i = 0; i < 2 * ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE; i++) { - fileMessage.addBytes(new byte[]{UnitTestCase.getSamplebyte(i)}); + fileMessage.addBytes(new byte[]{ServiceTestBase.getSamplebyte(i)}); } fileMessage.putLongProperty(Message.HDR_LARGE_BODY_SIZE, 2 * ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE); @@ -254,7 +254,7 @@ public class ScaleDown3NodeTest extends ClusterTestBase for (int j = 0; j < 2 * ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE; j++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(j), clientMessage.getBodyBuffer().readByte()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(j), clientMessage.getBodyBuffer().readByte()); } } IntegrationTestLogger.LOGGER.info("Received: " + clientMessage); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDownTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDownTest.java index ac77bf9c17..65a3af52b8 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDownTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDownTest.java @@ -34,7 +34,7 @@ import org.apache.activemq.artemis.core.postoffice.Binding; import org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.tests.integration.cluster.distribution.ClusterTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -414,7 +414,7 @@ public class ScaleDownTest extends ClusterTestBase for (int i = 0; i < 2 * ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE; i++) { byte byteRead = msg.getBodyBuffer().readByte(); - Assert.assertEquals(msg + " Is different", UnitTestCase.getSamplebyte(i), byteRead); + Assert.assertEquals(msg + " Is different", ServiceTestBase.getSamplebyte(i), byteRead); } msg.acknowledge(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SuppliedThreadPoolTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SuppliedThreadPoolTest.java index d574d5b1e2..64f4ef3b72 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SuppliedThreadPoolTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SuppliedThreadPoolTest.java @@ -24,7 +24,7 @@ import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl; import org.apache.activemq.artemis.core.server.impl.ServiceRegistry; @@ -32,7 +32,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -public class SuppliedThreadPoolTest extends UnitTestCase +public class SuppliedThreadPoolTest extends ServiceTestBase { private ActiveMQServer server; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/spring/SpringIntegrationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/spring/SpringIntegrationTest.java index 3bac31dc3a..1bd1e42f02 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/spring/SpringIntegrationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/spring/SpringIntegrationTest.java @@ -19,7 +19,7 @@ package org.apache.activemq.artemis.tests.integration.spring; import java.util.concurrent.TimeUnit; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; import org.junit.Assert; @@ -29,7 +29,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.jms.listener.DefaultMessageListenerContainer; -public class SpringIntegrationTest extends UnitTestCase +public class SpringIntegrationTest extends ServiceTestBase { IntegrationTestLogger log = IntegrationTestLogger.LOGGER; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTestBase.java index 1ea8764b6b..f40d4bb770 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTestBase.java @@ -51,7 +51,7 @@ import io.netty.handler.codec.string.StringDecoder; import io.netty.handler.codec.string.StringEncoder; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManagerFactory; import org.apache.activemq.artemis.core.registry.JndiBindingRegistry; @@ -72,7 +72,7 @@ import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl; import org.junit.After; import org.junit.Before; -public abstract class StompTestBase extends UnitTestCase +public abstract class StompTestBase extends ServiceTestBase { protected final int port = 61613; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompWebSocketTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompWebSocketTest.java index 547386cf0d..4db04656b5 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompWebSocketTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompWebSocketTest.java @@ -20,7 +20,7 @@ import java.util.HashMap; import java.util.Map; import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.CoreQueueConfiguration; import org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManagerFactory; @@ -37,7 +37,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -public class StompWebSocketTest extends UnitTestCase +public class StompWebSocketTest extends ServiceTestBase { private JMSServerManager server; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11TestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11TestBase.java index abeaa899b3..4e884c8c55 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11TestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11TestBase.java @@ -16,7 +16,7 @@ */ package org.apache.activemq.artemis.tests.integration.stomp.v11; import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.registry.JndiBindingRegistry; import org.junit.Before; import org.junit.After; @@ -52,7 +52,7 @@ import org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationI import org.apache.activemq.artemis.jms.server.config.impl.TopicConfigurationImpl; import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl; -public abstract class StompV11TestBase extends UnitTestCase +public abstract class StompV11TestBase extends ServiceTestBase { protected String hostname = "127.0.0.1"; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/transports/netty/ActiveMQFrameDecoder2Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/transports/netty/ActiveMQFrameDecoder2Test.java index ee638843d6..defb673914 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/transports/netty/ActiveMQFrameDecoder2Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/transports/netty/ActiveMQFrameDecoder2Test.java @@ -23,14 +23,14 @@ import java.util.Random; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.embedded.EmbeddedChannel; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.remoting.impl.netty.ActiveMQFrameDecoder2; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -public class ActiveMQFrameDecoder2Test extends UnitTestCase +public class ActiveMQFrameDecoder2Test extends ServiceTestBase { private static final int MSG_CNT = 10000; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/transports/netty/NettyConnectorWithHTTPUpgradeTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/transports/netty/NettyConnectorWithHTTPUpgradeTest.java index a086de690d..e3ccde3212 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/transports/netty/NettyConnectorWithHTTPUpgradeTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/transports/netty/NettyConnectorWithHTTPUpgradeTest.java @@ -45,7 +45,7 @@ import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor; import org.apache.activemq.artemis.core.remoting.impl.netty.PartialPooledByteBufAllocator; @@ -69,7 +69,7 @@ import static org.apache.activemq.artemis.tests.util.RandomUtil.randomString; /** * Test that Netty Connector can connect to a Web Server and upgrade from a HTTP request to its remoting protocol. */ -public class NettyConnectorWithHTTPUpgradeTest extends UnitTestCase +public class NettyConnectorWithHTTPUpgradeTest extends ServiceTestBase { private static final SimpleString QUEUE = new SimpleString("NettyConnectorWithHTTPUpgradeTest"); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/vertx/ActiveMQVertxUnitTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/vertx/ActiveMQVertxUnitTest.java index f0ef01b386..f4806558b6 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/vertx/ActiveMQVertxUnitTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/vertx/ActiveMQVertxUnitTest.java @@ -16,17 +16,14 @@ */ package org.apache.activemq.artemis.tests.integration.vertx; -import java.util.HashMap; - import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration; import org.apache.activemq.artemis.core.config.CoreQueueConfiguration; @@ -48,6 +45,8 @@ import org.vertx.java.platform.PlatformLocator; import org.vertx.java.platform.PlatformManager; import org.vertx.java.spi.cluster.impl.hazelcast.HazelcastClusterManagerFactory; +import java.util.HashMap; + /** * This class tests the basics of ActiveMQ * vertx integration @@ -156,7 +155,7 @@ public class ActiveMQVertxUnitTest extends ServiceTestBase .setParams(config5) .setName("test-vertx-outgoing-connector2"); - Configuration configuration = createDefaultConfig(false) + Configuration configuration = createDefaultConfig() .addQueueConfiguration(qc1) .addQueueConfiguration(qc2) .addQueueConfiguration(qc3) @@ -682,7 +681,7 @@ public class ActiveMQVertxUnitTest extends ServiceTestBase try { - TransportConfiguration tpconf = new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY); + TransportConfiguration tpconf = new TransportConfiguration(INVM_CONNECTOR_FACTORY); locator = ActiveMQClient.createServerLocatorWithoutHA(tpconf); sf = createSessionFactory(locator); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/BasicXaRecoveryTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/BasicXaRecoveryTest.java index 2141bfa178..7ee1a39c8a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/BasicXaRecoveryTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/BasicXaRecoveryTest.java @@ -15,14 +15,6 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.integration.xa; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import javax.management.MBeanServer; -import javax.management.MBeanServerFactory; -import javax.transaction.xa.XAResource; -import javax.transaction.xa.Xid; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.SimpleString; @@ -42,13 +34,20 @@ import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.integration.management.ManagementControlHelper; import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.utils.UUIDGenerator; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + public class BasicXaRecoveryTest extends ServiceTestBase { private static IntegrationTestLogger log = IntegrationTestLogger.LOGGER; @@ -88,7 +87,8 @@ public class BasicXaRecoveryTest extends ServiceTestBase mbeanServer = MBeanServerFactory.createMBeanServer(); - server = createServer(true, configuration, -1, -1, addressSettings, mbeanServer); + server = createServer(true, configuration, -1, -1, addressSettings); + server.setMBeanServer(mbeanServer); // start the server server.start(); @@ -334,8 +334,8 @@ public class BasicXaRecoveryTest extends ServiceTestBase Xid[] xids = clientSession.recover(XAResource.TMSTARTRSCAN); Assert.assertEquals(xids.length, 1); Assert.assertEquals(xids[0].getFormatId(), xid.getFormatId()); - UnitTestCase.assertEqualsByteArrays(xids[0].getBranchQualifier(), xid.getBranchQualifier()); - UnitTestCase.assertEqualsByteArrays(xids[0].getGlobalTransactionId(), xid.getGlobalTransactionId()); + ServiceTestBase.assertEqualsByteArrays(xids[0].getBranchQualifier(), xid.getBranchQualifier()); + ServiceTestBase.assertEqualsByteArrays(xids[0].getGlobalTransactionId(), xid.getGlobalTransactionId()); clientSession.commit(xid, false); @@ -413,8 +413,8 @@ public class BasicXaRecoveryTest extends ServiceTestBase Xid[] xids = clientSession.recover(XAResource.TMSTARTRSCAN); Assert.assertEquals(1, xids.length); Assert.assertEquals(xids[0].getFormatId(), xid.getFormatId()); - UnitTestCase.assertEqualsByteArrays(xids[0].getBranchQualifier(), xid.getBranchQualifier()); - UnitTestCase.assertEqualsByteArrays(xids[0].getGlobalTransactionId(), xid.getGlobalTransactionId()); + ServiceTestBase.assertEqualsByteArrays(xids[0].getBranchQualifier(), xid.getBranchQualifier()); + ServiceTestBase.assertEqualsByteArrays(xids[0].getGlobalTransactionId(), xid.getGlobalTransactionId()); clientSession.rollback(xid); @@ -458,8 +458,8 @@ public class BasicXaRecoveryTest extends ServiceTestBase Assert.assertEquals(xids.length, 1); Assert.assertEquals(xids[0].getFormatId(), xid.getFormatId()); - UnitTestCase.assertEqualsByteArrays(xids[0].getBranchQualifier(), xid.getBranchQualifier()); - UnitTestCase.assertEqualsByteArrays(xids[0].getGlobalTransactionId(), xid.getGlobalTransactionId()); + ServiceTestBase.assertEqualsByteArrays(xids[0].getBranchQualifier(), xid.getBranchQualifier()); + ServiceTestBase.assertEqualsByteArrays(xids[0].getGlobalTransactionId(), xid.getGlobalTransactionId()); xids = clientSession.recover(XAResource.TMENDRSCAN); Assert.assertEquals(xids.length, 0); if (commit) @@ -537,8 +537,8 @@ public class BasicXaRecoveryTest extends ServiceTestBase Xid[] xids = clientSession.recover(XAResource.TMSTARTRSCAN); Assert.assertEquals(xids.length, 1); Assert.assertEquals(xids[0].getFormatId(), xid.getFormatId()); - UnitTestCase.assertEqualsByteArrays(xids[0].getBranchQualifier(), xid.getBranchQualifier()); - UnitTestCase.assertEqualsByteArrays(xids[0].getGlobalTransactionId(), xid.getGlobalTransactionId()); + ServiceTestBase.assertEqualsByteArrays(xids[0].getBranchQualifier(), xid.getBranchQualifier()); + ServiceTestBase.assertEqualsByteArrays(xids[0].getGlobalTransactionId(), xid.getGlobalTransactionId()); xids = clientSession.recover(XAResource.TMENDRSCAN); Assert.assertEquals(xids.length, 0); @@ -593,8 +593,8 @@ public class BasicXaRecoveryTest extends ServiceTestBase Assert.assertEquals(xids.length, 1); Assert.assertEquals(xids[0].getFormatId(), xid.getFormatId()); - UnitTestCase.assertEqualsByteArrays(xids[0].getBranchQualifier(), xid.getBranchQualifier()); - UnitTestCase.assertEqualsByteArrays(xids[0].getGlobalTransactionId(), xid.getGlobalTransactionId()); + ServiceTestBase.assertEqualsByteArrays(xids[0].getBranchQualifier(), xid.getBranchQualifier()); + ServiceTestBase.assertEqualsByteArrays(xids[0].getGlobalTransactionId(), xid.getGlobalTransactionId()); xids = clientSession.recover(XAResource.TMENDRSCAN); Assert.assertEquals(xids.length, 0); clientSession.rollback(xid); @@ -642,8 +642,8 @@ public class BasicXaRecoveryTest extends ServiceTestBase Assert.assertEquals(xids.length, 1); Assert.assertEquals(xids[0].getFormatId(), xid.getFormatId()); - UnitTestCase.assertEqualsByteArrays(xids[0].getBranchQualifier(), xid.getBranchQualifier()); - UnitTestCase.assertEqualsByteArrays(xids[0].getGlobalTransactionId(), xid.getGlobalTransactionId()); + ServiceTestBase.assertEqualsByteArrays(xids[0].getBranchQualifier(), xid.getBranchQualifier()); + ServiceTestBase.assertEqualsByteArrays(xids[0].getGlobalTransactionId(), xid.getGlobalTransactionId()); xids = clientSession.recover(XAResource.TMENDRSCAN); Assert.assertEquals(xids.length, 0); clientSession.commit(xid, false); @@ -893,8 +893,8 @@ public class BasicXaRecoveryTest extends ServiceTestBase Assert.assertEquals(xids.length, 1); Assert.assertEquals(xids[0].getFormatId(), xid.getFormatId()); - UnitTestCase.assertEqualsByteArrays(xids[0].getBranchQualifier(), xid.getBranchQualifier()); - UnitTestCase.assertEqualsByteArrays(xids[0].getGlobalTransactionId(), xid.getGlobalTransactionId()); + ServiceTestBase.assertEqualsByteArrays(xids[0].getBranchQualifier(), xid.getBranchQualifier()); + ServiceTestBase.assertEqualsByteArrays(xids[0].getGlobalTransactionId(), xid.getGlobalTransactionId()); xids = clientSession.recover(XAResource.TMENDRSCAN); Assert.assertEquals(xids.length, 0); clientSession.commit(xid, false); @@ -973,8 +973,8 @@ public class BasicXaRecoveryTest extends ServiceTestBase Assert.assertEquals(xids.length, 1); Assert.assertEquals(xids[0].getFormatId(), xid.getFormatId()); - UnitTestCase.assertEqualsByteArrays(xids[0].getBranchQualifier(), xid.getBranchQualifier()); - UnitTestCase.assertEqualsByteArrays(xids[0].getGlobalTransactionId(), xid.getGlobalTransactionId()); + ServiceTestBase.assertEqualsByteArrays(xids[0].getBranchQualifier(), xid.getBranchQualifier()); + ServiceTestBase.assertEqualsByteArrays(xids[0].getGlobalTransactionId(), xid.getGlobalTransactionId()); xids = clientSession.recover(XAResource.TMENDRSCAN); Assert.assertEquals(xids.length, 0); clientSession.commit(xid, false); @@ -1047,8 +1047,8 @@ public class BasicXaRecoveryTest extends ServiceTestBase Assert.assertEquals(1, xids.length); Assert.assertEquals(xids[0].getFormatId(), xid.getFormatId()); - UnitTestCase.assertEqualsByteArrays(xids[0].getBranchQualifier(), xid.getBranchQualifier()); - UnitTestCase.assertEqualsByteArrays(xids[0].getGlobalTransactionId(), xid.getGlobalTransactionId()); + ServiceTestBase.assertEqualsByteArrays(xids[0].getBranchQualifier(), xid.getBranchQualifier()); + ServiceTestBase.assertEqualsByteArrays(xids[0].getGlobalTransactionId(), xid.getGlobalTransactionId()); xids = clientSession.recover(XAResource.TMENDRSCAN); Assert.assertEquals(xids.length, 0); clientSession.rollback(xid); @@ -1268,7 +1268,8 @@ public class BasicXaRecoveryTest extends ServiceTestBase clientSession = null; server.stop(); server = null; - server = createServer(true, configuration, -1, -1, addressSettings, mbeanServer); + server = createServer(true, configuration, -1, -1, addressSettings); + server.setMBeanServer(mbeanServer); server.start(); createClients(); @@ -1346,8 +1347,8 @@ public class BasicXaRecoveryTest extends ServiceTestBase if (found) { Assert.assertEquals(xid.getFormatId(), origXid.getFormatId()); - UnitTestCase.assertEqualsByteArrays(xid.getBranchQualifier(), origXid.getBranchQualifier()); - UnitTestCase.assertEqualsByteArrays(xid.getGlobalTransactionId(), origXid.getGlobalTransactionId()); + ServiceTestBase.assertEqualsByteArrays(xid.getBranchQualifier(), origXid.getBranchQualifier()); + ServiceTestBase.assertEqualsByteArrays(xid.getGlobalTransactionId(), origXid.getGlobalTransactionId()); break; } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/XaTimeoutTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/XaTimeoutTest.java index 3bcdbb37ef..09cd7a2557 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/XaTimeoutTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/xa/XaTimeoutTest.java @@ -38,7 +38,7 @@ import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; import org.apache.activemq.artemis.core.protocol.core.Packet; import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionXAStartMessage; @@ -56,7 +56,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -public class XaTimeoutTest extends UnitTestCase +public class XaTimeoutTest extends ServiceTestBase { private final Map addressSettings = new HashMap(); @@ -86,7 +86,7 @@ public class XaTimeoutTest extends UnitTestCase addressSettings.clear(); configuration = createBasicConfig() .setTransactionTimeoutScanPeriod(500) - .addAcceptorConfiguration(new TransportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY)); + .addAcceptorConfiguration(new TransportConfiguration(ServiceTestBase.INVM_ACCEPTOR_FACTORY)); messagingService = addServer(ActiveMQServers.newActiveMQServer(configuration, false)); // start the server messagingService.start(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/ReplicatedBackupUtils.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/ReplicatedBackupUtils.java index ba20df8a07..379d761279 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/ReplicatedBackupUtils.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/ReplicatedBackupUtils.java @@ -49,14 +49,14 @@ public final class ReplicatedBackupUtils backupConfig.addConnectorConfiguration(BACKUP_NODE_NAME, backupConnector) .addConnectorConfiguration(LIVE_NODE_NAME, liveConnector) - .addClusterConfiguration(UnitTestCase.basicClusterConnectionConfig(BACKUP_NODE_NAME, LIVE_NODE_NAME)) + .addClusterConfiguration(ServiceTestBase.basicClusterConnectionConfig(BACKUP_NODE_NAME, LIVE_NODE_NAME)) .setHAPolicyConfiguration(new ReplicaPolicyConfiguration()); liveConfig.setName(LIVE_NODE_NAME) .addConnectorConfiguration(LIVE_NODE_NAME, liveConnector) .addConnectorConfiguration(BACKUP_NODE_NAME, backupConnector) .setSecurityEnabled(false) - .addClusterConfiguration(UnitTestCase.basicClusterConnectionConfig(LIVE_NODE_NAME, BACKUP_NODE_NAME)) + .addClusterConfiguration(ServiceTestBase.basicClusterConnectionConfig(LIVE_NODE_NAME, BACKUP_NODE_NAME)) .setHAPolicyConfiguration(new ReplicatedPolicyConfiguration()); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/TransportConfigurationUtils.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/TransportConfigurationUtils.java index c7e80604d5..d373b7e68e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/TransportConfigurationUtils.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/TransportConfigurationUtils.java @@ -32,52 +32,52 @@ public final class TransportConfigurationUtils public static TransportConfiguration getInVMAcceptor(final boolean live) { - return transportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY, live); + return transportConfiguration(ServiceTestBase.INVM_ACCEPTOR_FACTORY, live); } public static TransportConfiguration getInVMConnector(final boolean live) { - return transportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY, live); + return transportConfiguration(ServiceTestBase.INVM_CONNECTOR_FACTORY, live); } public static TransportConfiguration getInVMAcceptor(final boolean live, int server) { - return transportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY, live, server); + return transportConfiguration(ServiceTestBase.INVM_ACCEPTOR_FACTORY, live, server); } public static TransportConfiguration getInVMConnector(final boolean live, int server) { - return transportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY, live, server); + return transportConfiguration(ServiceTestBase.INVM_CONNECTOR_FACTORY, live, server); } public static TransportConfiguration getNettyAcceptor(final boolean live, int server) { - return transportConfiguration(UnitTestCase.NETTY_ACCEPTOR_FACTORY, live, server); + return transportConfiguration(ServiceTestBase.NETTY_ACCEPTOR_FACTORY, live, server); } public static TransportConfiguration getNettyConnector(final boolean live, int server) { - return transportConfiguration(UnitTestCase.NETTY_CONNECTOR_FACTORY, live, server); + return transportConfiguration(ServiceTestBase.NETTY_CONNECTOR_FACTORY, live, server); } public static TransportConfiguration getInVMAcceptor(final boolean live, int server, String name) { - return transportConfiguration(UnitTestCase.INVM_ACCEPTOR_FACTORY, live, server, name); + return transportConfiguration(ServiceTestBase.INVM_ACCEPTOR_FACTORY, live, server, name); } public static TransportConfiguration getInVMConnector(final boolean live, int server, String name) { - return transportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY, live, server, name); + return transportConfiguration(ServiceTestBase.INVM_CONNECTOR_FACTORY, live, server, name); } public static TransportConfiguration getNettyAcceptor(final boolean live, int server, String name) { - return transportConfiguration(UnitTestCase.NETTY_ACCEPTOR_FACTORY, live, server, name); + return transportConfiguration(ServiceTestBase.NETTY_ACCEPTOR_FACTORY, live, server, name); } public static TransportConfiguration getNettyConnector(final boolean live, int server, String name) { - return transportConfiguration(UnitTestCase.NETTY_CONNECTOR_FACTORY, live, server, name); + return transportConfiguration(ServiceTestBase.NETTY_CONNECTOR_FACTORY, live, server, name); } /** diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MessageConsumerTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MessageConsumerTest.java index 9133ce8237..c88b1395e7 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MessageConsumerTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MessageConsumerTest.java @@ -45,7 +45,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.artemis.jms.tests.util.ProxyAssertSupport; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Assert; import org.junit.Test; @@ -4336,7 +4336,7 @@ public class MessageConsumerTest extends JMSTestCase public void waitForMessages() throws InterruptedException { - UnitTestCase.waitForLatch(latch); + ServiceTestBase.waitForLatch(latch); } public ExceptionRedelMessageListenerImpl(final Session sess) @@ -4459,7 +4459,7 @@ public class MessageConsumerTest extends JMSTestCase */ public void waitForMessages() throws InterruptedException { - UnitTestCase.waitForLatch(latch); + ServiceTestBase.waitForLatch(latch); } public void onMessage(final Message m) @@ -4557,7 +4557,7 @@ public class MessageConsumerTest extends JMSTestCase */ public void waitForMessages() throws InterruptedException { - UnitTestCase.waitForLatch(latch); + ServiceTestBase.waitForLatch(latch); } public void onMessage(final Message m) diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSExpirationHeaderTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSExpirationHeaderTest.java index e37e5ae409..8aa175ee9e 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSExpirationHeaderTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSExpirationHeaderTest.java @@ -23,7 +23,7 @@ import javax.jms.Message; import org.apache.activemq.artemis.jms.client.ActiveMQMessage; import org.apache.activemq.artemis.jms.tests.util.ProxyAssertSupport; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -141,7 +141,7 @@ public class JMSExpirationHeaderTest extends MessageHeaderTestBase }, "receiver thread"); receiverThread.start(); - UnitTestCase.waitForLatch(latch); + ServiceTestBase.waitForLatch(latch); ProxyAssertSupport.assertNull(expectedMessage); } @@ -213,8 +213,8 @@ public class JMSExpirationHeaderTest extends MessageHeaderTestBase }, "sender thread"); senderThread.start(); - UnitTestCase.waitForLatch(senderLatch); - UnitTestCase.waitForLatch(receiverLatch); + ServiceTestBase.waitForLatch(senderLatch); + ServiceTestBase.waitForLatch(receiverLatch); if (testFailed) { @@ -298,7 +298,7 @@ public class JMSExpirationHeaderTest extends MessageHeaderTestBase queueConsumer.close(); // wait for the reading thread to conclude - UnitTestCase.waitForLatch(latch); + ServiceTestBase.waitForLatch(latch); log.trace("Expected message:" + expectedMessage); diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/selector/SelectorTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/selector/SelectorTest.java index 43804f9d57..93e741f4bd 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/selector/SelectorTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/selector/SelectorTest.java @@ -31,7 +31,7 @@ import java.util.concurrent.CountDownLatch; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.artemis.jms.tests.ActiveMQServerTestCase; import org.apache.activemq.artemis.jms.tests.util.ProxyAssertSupport; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Assert; import org.junit.Test; @@ -635,8 +635,8 @@ public class SelectorTest extends ActiveMQServerTestCase } }, "consumer thread 2").start(); - UnitTestCase.waitForLatch(latch); - UnitTestCase.waitForLatch(latch2); + ServiceTestBase.waitForLatch(latch); + ServiceTestBase.waitForLatch(latch2); ProxyAssertSupport.assertEquals(5, received.size()); for (Message m : received) diff --git a/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/paging/MeasurePagingMultiThreadTest.java b/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/paging/MeasurePagingMultiThreadTest.java index c5b847bda3..6d70818043 100644 --- a/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/paging/MeasurePagingMultiThreadTest.java +++ b/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/paging/MeasurePagingMultiThreadTest.java @@ -15,8 +15,6 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.performance.paging; -import java.util.HashMap; -import java.util.concurrent.CountDownLatch; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.SimpleString; @@ -29,9 +27,11 @@ import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.junit.Test; +import java.util.HashMap; +import java.util.concurrent.CountDownLatch; + public class MeasurePagingMultiThreadTest extends ServiceTestBase { @@ -98,7 +98,7 @@ public class MeasurePagingMultiThreadTest extends ServiceTestBase try { latchAlign.countDown(); - UnitTestCase.waitForLatch(latchStart); + ServiceTestBase.waitForLatch(latchStart); long start = System.currentTimeMillis(); sendMessages(NUMBER_OF_MESSAGES, producer, msg); @@ -125,7 +125,7 @@ public class MeasurePagingMultiThreadTest extends ServiceTestBase senders[i].start(); } - UnitTestCase.waitForLatch(latchAlign); + ServiceTestBase.waitForLatch(latchAlign); long timeStart = System.currentTimeMillis(); diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/AddAndRemoveStressTest.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/AddAndRemoveStressTest.java index 4c96ad69f6..3cbe91f355 100644 --- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/AddAndRemoveStressTest.java +++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/AddAndRemoveStressTest.java @@ -19,7 +19,7 @@ import java.util.ArrayList; import java.util.List; import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.journal.LoaderCallback; import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; import org.apache.activemq.artemis.core.journal.RecordInfo; @@ -29,7 +29,7 @@ import org.apache.activemq.artemis.core.journal.impl.JournalImpl; import org.junit.Assert; import org.junit.Test; -public class AddAndRemoveStressTest extends UnitTestCase +public class AddAndRemoveStressTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/CompactingStressTest.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/CompactingStressTest.java index c72e8ec702..5b5b0093bb 100644 --- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/CompactingStressTest.java +++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/CompactingStressTest.java @@ -17,15 +17,6 @@ package org.apache.activemq.artemis.tests.stress.journal; import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; -import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; -import org.junit.Test; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.atomic.AtomicInteger; - -import org.junit.Assert; - import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -37,6 +28,12 @@ import org.apache.activemq.artemis.core.asyncio.impl.AsynchronousFileImpl; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.JournalType; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; +import org.junit.Assert; +import org.junit.Test; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.atomic.AtomicInteger; public class CompactingStressTest extends ServiceTestBase { @@ -236,7 +233,7 @@ public class CompactingStressTest extends ServiceTestBase latchReady.countDown(); try { - UnitTestCase.waitForLatch(latchStart); + ServiceTestBase.waitForLatch(latchStart); session = sf.createSession(true, true); sessionSlow = sf.createSession(false, false); ClientProducer prod = session.createProducer(CompactingStressTest.AD2); @@ -299,7 +296,7 @@ public class CompactingStressTest extends ServiceTestBase latchReady.countDown(); try { - UnitTestCase.waitForLatch(latchStart); + ServiceTestBase.waitForLatch(latchStart); session = sf.createSession(true, true); session.start(); ClientConsumer cons = session.createConsumer(CompactingStressTest.Q2); @@ -335,7 +332,7 @@ public class CompactingStressTest extends ServiceTestBase FastProducer p1 = new FastProducer(); p1.start(); - UnitTestCase.waitForLatch(latchReady); + ServiceTestBase.waitForLatch(latchReady); latchStart.countDown(); p1.join(); diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/JournalCleanupCompactStressTest.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/JournalCleanupCompactStressTest.java index 54bfc7393b..36fcaed384 100644 --- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/JournalCleanupCompactStressTest.java +++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/JournalCleanupCompactStressTest.java @@ -16,6 +16,26 @@ */ package org.apache.activemq.artemis.tests.stress.journal; +import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; +import org.apache.activemq.artemis.core.asyncio.impl.AsynchronousFileImpl; +import org.apache.activemq.artemis.core.journal.IOAsyncTask; +import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; +import org.apache.activemq.artemis.core.journal.RecordInfo; +import org.apache.activemq.artemis.core.journal.SequentialFileFactory; +import org.apache.activemq.artemis.core.journal.TransactionFailureCallback; +import org.apache.activemq.artemis.core.journal.impl.AIOSequentialFileFactory; +import org.apache.activemq.artemis.core.journal.impl.JournalImpl; +import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory; +import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl; +import org.apache.activemq.artemis.tests.util.RandomUtil; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; +import org.apache.activemq.artemis.utils.OrderedExecutorFactory; +import org.apache.activemq.artemis.utils.SimpleIDGenerator; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import java.io.File; import java.util.ArrayList; import java.util.Collection; @@ -32,27 +52,6 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; -import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; -import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; -import org.apache.activemq.artemis.core.asyncio.impl.AsynchronousFileImpl; -import org.apache.activemq.artemis.core.journal.IOAsyncTask; -import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; -import org.apache.activemq.artemis.core.journal.RecordInfo; -import org.apache.activemq.artemis.core.journal.SequentialFileFactory; -import org.apache.activemq.artemis.core.journal.TransactionFailureCallback; -import org.apache.activemq.artemis.core.journal.impl.AIOSequentialFileFactory; -import org.apache.activemq.artemis.core.journal.impl.JournalImpl; -import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory; -import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl; -import org.apache.activemq.artemis.tests.util.RandomUtil; -import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; -import org.apache.activemq.artemis.utils.OrderedExecutorFactory; -import org.apache.activemq.artemis.utils.SimpleIDGenerator; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - public class JournalCleanupCompactStressTest extends ServiceTestBase { @@ -267,7 +266,7 @@ public class JournalCleanupCompactStressTest extends ServiceTestBase } }); - UnitTestCase.waitForLatch(latchExecutorDone); + ServiceTestBase.waitForLatch(latchExecutorDone); journal.stop(); diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/LargeJournalStressTest.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/LargeJournalStressTest.java index 9431f0b6b3..aef89244b2 100644 --- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/LargeJournalStressTest.java +++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/LargeJournalStressTest.java @@ -16,9 +16,6 @@ */ package org.apache.activemq.artemis.tests.stress.journal; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.atomic.AtomicInteger; - import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; @@ -26,16 +23,18 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.JournalType; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.atomic.AtomicInteger; + public class LargeJournalStressTest extends ServiceTestBase { @@ -104,7 +103,7 @@ public class LargeJournalStressTest extends ServiceTestBase latchReady.countDown(); try { - UnitTestCase.waitForLatch(latchStart); + ServiceTestBase.waitForLatch(latchStart); session = sf.createSession(true, true); sessionSlow = sf.createSession(false, false); ClientProducer prod = session.createProducer(LargeJournalStressTest.AD2); @@ -170,7 +169,7 @@ public class LargeJournalStressTest extends ServiceTestBase latchReady.countDown(); try { - UnitTestCase.waitForLatch(latchStart); + ServiceTestBase.waitForLatch(latchStart); session = sf.createSession(true, true); session.start(); ClientConsumer cons = session.createConsumer(LargeJournalStressTest.Q2); @@ -206,7 +205,7 @@ public class LargeJournalStressTest extends ServiceTestBase FastProducer p1 = new FastProducer(); p1.start(); - UnitTestCase.waitForLatch(latchReady); + ServiceTestBase.waitForLatch(latchReady); latchStart.countDown(); p1.join(); diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/MultiThreadConsumerStressTest.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/MultiThreadConsumerStressTest.java index 97a6a0eb13..3f13c3e16b 100644 --- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/MultiThreadConsumerStressTest.java +++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/MultiThreadConsumerStressTest.java @@ -16,9 +16,6 @@ */ package org.apache.activemq.artemis.tests.stress.journal; -import java.util.ArrayList; -import java.util.concurrent.CountDownLatch; - import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; @@ -27,7 +24,6 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.JournalType; @@ -36,6 +32,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import java.util.ArrayList; +import java.util.concurrent.CountDownLatch; + /** * A MultiThreadConsumerStressTest *

@@ -113,7 +112,7 @@ public class MultiThreadConsumerStressTest extends ServiceTestBase threads.add(cons[i]); } - UnitTestCase.waitForLatch(latchReady); + ServiceTestBase.waitForLatch(latchReady); latchStart.countDown(); for (BaseThread t : threads) @@ -243,7 +242,7 @@ public class MultiThreadConsumerStressTest extends ServiceTestBase latchReady.countDown(); try { - UnitTestCase.waitForLatch(latchStart); + ServiceTestBase.waitForLatch(latchStart); session = sf.createSession(false, false); ClientProducer prod = session.createProducer(ADDRESS); for (int i = 0; i < numberOfMessages; i++) @@ -304,7 +303,7 @@ public class MultiThreadConsumerStressTest extends ServiceTestBase latchReady.countDown(); try { - UnitTestCase.waitForLatch(latchStart); + ServiceTestBase.waitForLatch(latchStart); session = sf.createSession(false, false); session.start(); ClientConsumer cons = session.createConsumer(QUEUE); diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/NIOMultiThreadCompactorStressTest.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/NIOMultiThreadCompactorStressTest.java index c5913d2f44..0a85c5388e 100644 --- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/NIOMultiThreadCompactorStressTest.java +++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/NIOMultiThreadCompactorStressTest.java @@ -16,12 +16,6 @@ */ package org.apache.activemq.artemis.tests.stress.journal; -import javax.transaction.xa.XAResource; -import javax.transaction.xa.Xid; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CountDownLatch; - import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.SimpleString; @@ -40,11 +34,16 @@ import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.JournalType; import org.apache.activemq.artemis.tests.util.ServiceTestBase; -import org.apache.activemq.artemis.tests.util.UnitTestCase; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CountDownLatch; + public class NIOMultiThreadCompactorStressTest extends ServiceTestBase { @@ -231,7 +230,7 @@ public class NIOMultiThreadCompactorStressTest extends ServiceTestBase threads.add(cons[i]); } - UnitTestCase.waitForLatch(latchReady); + ServiceTestBase.waitForLatch(latchReady); latchStart.countDown(); for (BaseThread t : threads) @@ -440,7 +439,7 @@ public class NIOMultiThreadCompactorStressTest extends ServiceTestBase latchReady.countDown(); try { - UnitTestCase.waitForLatch(latchStart); + ServiceTestBase.waitForLatch(latchStart); session = sf.createSession(!transactional, !transactional); ClientProducer prod = session.createProducer(ADDRESS); for (int i = 0; i < numberOfMessages; i++) @@ -509,7 +508,7 @@ public class NIOMultiThreadCompactorStressTest extends ServiceTestBase latchReady.countDown(); try { - UnitTestCase.waitForLatch(latchStart); + ServiceTestBase.waitForLatch(latchStart); session = sf.createSession(!transactional, !transactional); session.start(); ClientConsumer cons = session.createConsumer(QUEUE); diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/stomp/StompStressTest.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/stomp/StompStressTest.java index e06dcce757..e9d440479c 100644 --- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/stomp/StompStressTest.java +++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/stomp/StompStressTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.stress.stomp; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Before; import org.junit.After; @@ -43,7 +43,7 @@ import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServers; -public class StompStressTest extends UnitTestCase +public class StompStressTest extends ServiceTestBase { private static final int COUNT = 1000; diff --git a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/journal/impl/AIOJournalImplTest.java b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/journal/impl/AIOJournalImplTest.java index 7182ebc25b..972828d8f6 100644 --- a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/journal/impl/AIOJournalImplTest.java +++ b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/journal/impl/AIOJournalImplTest.java @@ -17,7 +17,7 @@ package org.apache.activemq.artemis.tests.timing.core.journal.impl; import java.io.File; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.journal.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.impl.AIOSequentialFileFactory; import org.junit.BeforeClass; @@ -35,7 +35,7 @@ public class AIOJournalImplTest extends JournalImplTestUnit { File file = new File(getTestDir()); - UnitTestCase.deleteDirectory(file); + ServiceTestBase.deleteDirectory(file); file.mkdir(); diff --git a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/journal/impl/NIOJournalImplTest.java b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/journal/impl/NIOJournalImplTest.java index 71477d1947..c4654dfb82 100644 --- a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/journal/impl/NIOJournalImplTest.java +++ b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/journal/impl/NIOJournalImplTest.java @@ -18,7 +18,7 @@ package org.apache.activemq.artemis.tests.timing.core.journal.impl; import java.io.File; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.journal.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory; import org.apache.activemq.artemis.tests.unit.UnitTestLogger; @@ -36,7 +36,7 @@ public class NIOJournalImplTest extends JournalImplTestUnit NIOJournalImplTest.log.debug("deleting directory " + journalDir); - UnitTestCase.deleteDirectory(file); + ServiceTestBase.deleteDirectory(file); file.mkdir(); diff --git a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueConcurrentTest.java b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueConcurrentTest.java index b57903ca0b..1bdbb33165 100644 --- a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueConcurrentTest.java +++ b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueConcurrentTest.java @@ -16,7 +16,7 @@ */ package org.apache.activemq.artemis.tests.timing.core.server.impl; import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakeQueueFactory; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Before; import org.junit.After; @@ -40,7 +40,7 @@ import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakeConsume * * All the concurrent queue tests go in here */ -public class QueueConcurrentTest extends UnitTestCase +public class QueueConcurrentTest extends ServiceTestBase { private static final UnitTestLogger log = UnitTestLogger.LOGGER; diff --git a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueImplTest.java b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueImplTest.java index 30fb6c493b..96d1f62a08 100644 --- a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueImplTest.java +++ b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueImplTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.timing.core.server.impl; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Before; import org.junit.After; @@ -38,7 +38,7 @@ import org.apache.activemq.artemis.core.server.MessageReference; import org.apache.activemq.artemis.core.server.impl.QueueImpl; import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakeConsumer; -public class QueueImplTest extends UnitTestCase +public class QueueImplTest extends ServiceTestBase { private static final SimpleString queue1 = new SimpleString("queue1"); diff --git a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/jms/bridge/impl/JMSBridgeImplTest.java b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/jms/bridge/impl/JMSBridgeImplTest.java index b4905a5d17..a7c7440290 100644 --- a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/jms/bridge/impl/JMSBridgeImplTest.java +++ b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/jms/bridge/impl/JMSBridgeImplTest.java @@ -50,7 +50,7 @@ import org.apache.activemq.artemis.api.jms.JMSFactoryType; import org.apache.activemq.artemis.api.jms.management.JMSQueueControl; import org.apache.activemq.artemis.tests.unit.UnitTestLogger; import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.registry.JndiBindingRegistry; import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory; @@ -71,7 +71,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -public class JMSBridgeImplTest extends UnitTestCase +public class JMSBridgeImplTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/ReusableLatchTest.java b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/ReusableLatchTest.java index 2189b4ec2c..47ea01fcd0 100644 --- a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/ReusableLatchTest.java +++ b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/ReusableLatchTest.java @@ -16,14 +16,14 @@ */ package org.apache.activemq.artemis.tests.timing.util; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Test; import org.junit.Assert; import org.apache.activemq.artemis.utils.ReusableLatch; -public class ReusableLatchTest extends UnitTestCase +public class ReusableLatchTest extends ServiceTestBase { @Test public void testTimeout() throws Exception diff --git a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/TokenBucketLimiterImplTest.java b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/TokenBucketLimiterImplTest.java index 6e0af14585..eabc9fb717 100644 --- a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/TokenBucketLimiterImplTest.java +++ b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/TokenBucketLimiterImplTest.java @@ -21,12 +21,12 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.artemis.tests.unit.UnitTestLogger; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.utils.TokenBucketLimiterImpl; import org.junit.Assert; import org.junit.Test; -public class TokenBucketLimiterImplTest extends UnitTestCase +public class TokenBucketLimiterImplTest extends ServiceTestBase { private static final UnitTestLogger log = UnitTestLogger.LOGGER; diff --git a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/UTF8Test.java b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/UTF8Test.java index ab37d4aded..a864a2ea42 100644 --- a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/UTF8Test.java +++ b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/util/UTF8Test.java @@ -23,10 +23,10 @@ import org.junit.Test; import org.junit.Assert; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.utils.UTF8Util; -public class UTF8Test extends UnitTestCase +public class UTF8Test extends ServiceTestBase { private final String str = "abcdef&^*&!^ghijkl\uB5E2\uCAC7\uB2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5" + "abcdef&^*&!^ghijkl\uB5E2\uCAC7\uB2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5" diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/AIOTestBase.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/AIOTestBase.java index d0d5db4aaa..ae88e0feed 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/AIOTestBase.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/AIOTestBase.java @@ -22,7 +22,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.asyncio.AIOCallback; import org.apache.activemq.artemis.core.asyncio.impl.AsynchronousFileImpl; import org.junit.After; @@ -32,7 +32,7 @@ import org.junit.Before; /** * The base class for AIO Tests */ -public abstract class AIOTestBase extends UnitTestCase +public abstract class AIOTestBase extends ServiceTestBase { // The AIO Test must use a local filesystem. Sometimes $HOME is on a NFS on // most enterprise systems diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/AsynchronousFileTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/AsynchronousFileTest.java index 4e099837f4..55471a9049 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/AsynchronousFileTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/AsynchronousFileTest.java @@ -39,7 +39,7 @@ import org.apache.activemq.artemis.core.asyncio.BufferCallback; import org.apache.activemq.artemis.core.asyncio.impl.AsynchronousFileImpl; import org.apache.activemq.artemis.core.journal.impl.AIOSequentialFileFactory; import org.apache.activemq.artemis.tests.unit.UnitTestLogger; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.junit.After; import org.junit.Assert; @@ -151,7 +151,7 @@ public class AsynchronousFileTest extends AIOTestBase for (int i = 0; i < 1024; i++) { - write.put(UnitTestCase.getSamplebyte(i)); + write.put(ServiceTestBase.getSamplebyte(i)); } final CountDownLatch latch = new CountDownLatch(1); @@ -177,7 +177,7 @@ public class AsynchronousFileTest extends AIOTestBase write = null; - UnitTestCase.forceGC(bufferCheck2, 5000); + ServiceTestBase.forceGC(bufferCheck2, 5000); assertNull(bufferCheck2.get()); @@ -185,7 +185,7 @@ public class AsynchronousFileTest extends AIOTestBase controller = null; - UnitTestCase.forceGC(bufferCheck, 5000); + ServiceTestBase.forceGC(bufferCheck, 5000); assertNull(bufferCheck.get()); } @@ -272,8 +272,8 @@ public class AsynchronousFileTest extends AIOTestBase } - UnitTestCase.waitForLatch(latchDone); - UnitTestCase.waitForLatch(latchDone2); + ServiceTestBase.waitForLatch(latchDone); + ServiceTestBase.waitForLatch(latchDone2); CountDownCallback.checkResults(numberOfLines, listResult1); CountDownCallback.checkResults(numberOfLines, listResult2); @@ -626,7 +626,7 @@ public class AsynchronousFileTest extends AIOTestBase final ByteBuffer buffer0 = AsynchronousFileImpl.newBuffer(SIZE); for (int j = 0; j < SIZE; j++) { - buffer0.put(UnitTestCase.getSamplebyte(j)); + buffer0.put(ServiceTestBase.getSamplebyte(j)); } CountDownCallback aio = new CountDownCallback(latch, errors, result, i); @@ -673,7 +673,7 @@ public class AsynchronousFileTest extends AIOTestBase for (int count = 0; count < SIZE; count++) { Assert.assertEquals("byte position " + count + " differs on line " + i + " position = " + count, - UnitTestCase.getSamplebyte(count), + ServiceTestBase.getSamplebyte(count), bytesRead[count]); } } @@ -803,7 +803,7 @@ public class AsynchronousFileTest extends AIOTestBase } - UnitTestCase.waitForLatch(latchDone); + ServiceTestBase.waitForLatch(latchDone); long timeTotal = System.currentTimeMillis() - valueInitial; @@ -853,7 +853,7 @@ public class AsynchronousFileTest extends AIOTestBase CountDownLatch latchDone = new CountDownLatch(1); CountDownCallback aioBlock = new CountDownCallback(latchDone, null, null, 0); controller.write(i * 512, 512, buffer, aioBlock); - UnitTestCase.waitForLatch(latchDone); + ServiceTestBase.waitForLatch(latchDone); assertTrue(aioBlock.doneCalled); assertEquals(0, aioBlock.errorCalled); } @@ -922,7 +922,7 @@ public class AsynchronousFileTest extends AIOTestBase CountDownCallback aioBlock = new CountDownCallback(latchDone, null, null, 0); controller.write(11, 512, buffer, aioBlock); - UnitTestCase.waitForLatch(latchDone); + ServiceTestBase.waitForLatch(latchDone); assertTrue(aioBlock.errorCalled != 0); assertFalse(aioBlock.doneCalled); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java index 560735f4a5..be37b8336a 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java @@ -25,7 +25,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.asyncio.AIOCallback; import org.apache.activemq.artemis.core.asyncio.impl.AsynchronousFileImpl; import org.apache.activemq.artemis.core.journal.impl.AIOSequentialFileFactory; @@ -125,7 +125,7 @@ public class MultiThreadAsynchronousFileTest extends AIOTestBase } latchStart.countDown(); - UnitTestCase.waitForLatch(latchStart); + ServiceTestBase.waitForLatch(latchStart); long startTime = System.currentTimeMillis(); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/client/impl/LargeMessageBufferTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/client/impl/LargeMessageBufferTest.java index 71b78b0fd5..4aa7391fc4 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/client/impl/LargeMessageBufferTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/client/impl/LargeMessageBufferTest.java @@ -36,7 +36,7 @@ import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.MessageHandler; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.client.impl.ClientConsumerInternal; import org.apache.activemq.artemis.core.client.impl.ClientLargeMessageInternal; import org.apache.activemq.artemis.core.client.impl.ClientMessageInternal; @@ -52,7 +52,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -public class LargeMessageBufferTest extends UnitTestCase +public class LargeMessageBufferTest extends ServiceTestBase { // Constants ----------------------------------------------------- @@ -340,7 +340,7 @@ public class LargeMessageBufferTest extends UnitTestCase t.start(); - UnitTestCase.waitForLatch(latchGo); + ServiceTestBase.waitForLatch(latchGo); buffer.cancel(); @@ -632,7 +632,7 @@ public class LargeMessageBufferTest extends UnitTestCase } }); - UnitTestCase.waitForLatch(latchBytesWritten1); + ServiceTestBase.waitForLatch(latchBytesWritten1); try { diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/ConfigurationValidationTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/ConfigurationValidationTest.java index 5972d3dda5..a2f5d33df3 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/ConfigurationValidationTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/ConfigurationValidationTest.java @@ -22,11 +22,11 @@ import org.junit.Test; import org.junit.Assert; import org.apache.activemq.artemis.core.config.impl.FileConfiguration; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.utils.XMLUtil; import org.w3c.dom.Element; -public class ConfigurationValidationTest extends UnitTestCase +public class ConfigurationValidationTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/ConnectorsServiceTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/ConnectorsServiceTest.java index b508feb6d9..a1557be5b9 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/ConnectorsServiceTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/ConnectorsServiceTest.java @@ -21,7 +21,7 @@ import java.util.HashMap; import java.util.List; import org.apache.activemq.artemis.tests.unit.core.config.impl.fakes.FakeConnectorServiceFactory; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration; import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; @@ -32,7 +32,7 @@ import org.apache.activemq.artemis.tests.unit.core.config.impl.fakes.FakeConnect import org.junit.Before; import org.junit.Test; -public class ConnectorsServiceTest extends UnitTestCase +public class ConnectorsServiceTest extends ServiceTestBase { private Configuration configuration; diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/TransportConfigurationTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/TransportConfigurationTest.java index 41058d9639..cd3b0e24fb 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/TransportConfigurationTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/config/impl/TransportConfigurationTest.java @@ -16,14 +16,14 @@ */ package org.apache.activemq.artemis.tests.unit.core.config.impl; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Test; import org.junit.Assert; import org.apache.activemq.artemis.api.core.TransportConfiguration; -public class TransportConfigurationTest extends UnitTestCase +public class TransportConfigurationTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/AlignedJournalImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/AlignedJournalImplTest.java index 9a99707b0b..ebf8f6c5bb 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/AlignedJournalImplTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/AlignedJournalImplTest.java @@ -16,7 +16,7 @@ */ package org.apache.activemq.artemis.tests.unit.core.journal.impl; import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Before; import org.junit.After; @@ -44,7 +44,7 @@ import org.apache.activemq.artemis.core.journal.impl.JournalImpl; import org.apache.activemq.artemis.tests.unit.UnitTestLogger; import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding; -public class AlignedJournalImplTest extends UnitTestCase +public class AlignedJournalImplTest extends ServiceTestBase { // Constants ----------------------------------------------------- @@ -1223,7 +1223,7 @@ public class AlignedJournalImplTest extends UnitTestCase try { latchReady.countDown(); - UnitTestCase.waitForLatch(latchStart); + ServiceTestBase.waitForLatch(latchStart); for (int i = 0; i < NUMBER_OF_ELEMENTS; i++) { journalImpl.appendAddRecordTransactional(i, i, (byte)1, new SimpleEncoding(50, (byte)1)); @@ -1247,7 +1247,7 @@ public class AlignedJournalImplTest extends UnitTestCase try { latchReady.countDown(); - UnitTestCase.waitForLatch(latchStart); + ServiceTestBase.waitForLatch(latchStart); for (int i = 0; i < NUMBER_OF_ELEMENTS; i++) { Integer toDelete = queueDelete.poll(10, TimeUnit.SECONDS); @@ -1269,7 +1269,7 @@ public class AlignedJournalImplTest extends UnitTestCase t1.start(); t2.start(); - UnitTestCase.waitForLatch(latchReady); + ServiceTestBase.waitForLatch(latchReady); latchStart.countDown(); t1.join(); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/CleanBufferTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/CleanBufferTest.java index 980a4a64c3..498d22c973 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/CleanBufferTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/CleanBufferTest.java @@ -17,7 +17,7 @@ package org.apache.activemq.artemis.tests.unit.core.journal.impl; import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Test; import java.nio.ByteBuffer; @@ -29,7 +29,7 @@ import org.apache.activemq.artemis.core.journal.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.impl.AIOSequentialFileFactory; import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory; -public class CleanBufferTest extends UnitTestCase +public class CleanBufferTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/FileFactoryTestBase.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/FileFactoryTestBase.java index c1a6e5f761..7063f15604 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/FileFactoryTestBase.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/FileFactoryTestBase.java @@ -15,7 +15,7 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.unit.core.journal.impl; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Before; import java.nio.ByteBuffer; @@ -25,7 +25,7 @@ import org.junit.Assert; import org.apache.activemq.artemis.core.journal.SequentialFile; import org.apache.activemq.artemis.core.journal.SequentialFileFactory; -public abstract class FileFactoryTestBase extends UnitTestCase +public abstract class FileFactoryTestBase extends ServiceTestBase { protected abstract SequentialFileFactory createFactory(); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalAsyncTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalAsyncTest.java index b6b1cce7ff..758f9d7d4d 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalAsyncTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalAsyncTest.java @@ -22,7 +22,7 @@ import java.util.concurrent.TimeUnit; import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory; import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; import org.apache.activemq.artemis.core.journal.RecordInfo; import org.apache.activemq.artemis.core.journal.impl.JournalImpl; @@ -31,7 +31,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -public class JournalAsyncTest extends UnitTestCase +public class JournalAsyncTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java index 9648ed611f..edec8d1636 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java @@ -33,13 +33,13 @@ import org.apache.activemq.artemis.core.journal.RecordInfo; import org.apache.activemq.artemis.core.journal.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.TestableJournal; import org.apache.activemq.artemis.core.journal.impl.JournalImpl; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.utils.ReusableLatch; import org.junit.After; import org.junit.Assert; import org.junit.Before; -public abstract class JournalImplTestBase extends UnitTestCase +public abstract class JournalImplTestBase extends ServiceTestBase { protected List records = new LinkedList(); @@ -568,7 +568,7 @@ public abstract class JournalImplTestBase extends UnitTestCase Assert.assertEquals("type not same", rexpected.isUpdate, ractual.isUpdate); - UnitTestCase.assertEqualsByteArrays(rexpected.data, ractual.data); + ServiceTestBase.assertEqualsByteArrays(rexpected.data, ractual.data); } } @@ -602,7 +602,7 @@ public abstract class JournalImplTestBase extends UnitTestCase for (int i = 0; i < length; i++) { // record[i] = RandomUtil.randomByte(); - record[i] = UnitTestCase.getSamplebyte(i); + record[i] = ServiceTestBase.getSamplebyte(i); } return record; } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/ReclaimerTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/ReclaimerTest.java index bcdd00cc46..01e188696a 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/ReclaimerTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/ReclaimerTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.unit.core.journal.impl; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Before; import org.junit.Test; @@ -32,7 +32,7 @@ import org.apache.activemq.artemis.core.journal.impl.JournalFile; import org.apache.activemq.artemis.core.journal.impl.JournalImpl; import org.apache.activemq.artemis.core.journal.impl.Reclaimer; -public class ReclaimerTest extends UnitTestCase +public class ReclaimerTest extends ServiceTestBase { private JournalFile[] files; diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java index 5c5914baec..146a8f9040 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java @@ -17,7 +17,7 @@ package org.apache.activemq.artemis.tests.unit.core.journal.impl; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffers; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Before; import org.junit.After; @@ -35,7 +35,7 @@ import org.apache.activemq.artemis.core.asyncio.impl.AsynchronousFileImpl; import org.apache.activemq.artemis.core.journal.SequentialFile; import org.apache.activemq.artemis.core.journal.SequentialFileFactory; -public abstract class SequentialFileFactoryTestBase extends UnitTestCase +public abstract class SequentialFileFactoryTestBase extends ServiceTestBase { @Override @Before @@ -58,7 +58,7 @@ public abstract class SequentialFileFactoryTestBase extends UnitTestCase factory = null; - UnitTestCase.forceGC(); + ServiceTestBase.forceGC(); super.tearDown(); } @@ -337,14 +337,14 @@ public abstract class SequentialFileFactoryTestBase extends UnitTestCase Assert.assertEquals(rb3.limit(), bytesRead); rb3.rewind(); rb3.get(rbytes3); - UnitTestCase.assertEqualsByteArrays(bytes3, rbytes3); + ServiceTestBase.assertEqualsByteArrays(bytes3, rbytes3); sf.position(rb1.limit()); bytesRead = sf.read(rb2); Assert.assertEquals(rb2.limit(), bytesRead); rb2.get(rbytes2); - UnitTestCase.assertEqualsByteArrays(bytes2, rbytes2); + ServiceTestBase.assertEqualsByteArrays(bytes2, rbytes2); sf.position(0); @@ -352,7 +352,7 @@ public abstract class SequentialFileFactoryTestBase extends UnitTestCase Assert.assertEquals(rb1.limit(), bytesRead); rb1.get(rbytes1); - UnitTestCase.assertEqualsByteArrays(bytes1, rbytes1); + ServiceTestBase.assertEqualsByteArrays(bytes1, rbytes1); } finally diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/TimedBufferTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/TimedBufferTest.java index 42258ea41b..2a2caea84c 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/TimedBufferTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/TimedBufferTest.java @@ -18,7 +18,7 @@ package org.apache.activemq.artemis.tests.unit.core.journal.impl; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffers; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Test; import java.nio.ByteBuffer; @@ -34,7 +34,7 @@ import org.apache.activemq.artemis.core.journal.IOAsyncTask; import org.apache.activemq.artemis.core.journal.impl.TimedBuffer; import org.apache.activemq.artemis.core.journal.impl.TimedBufferObserver; -public class TimedBufferTest extends UnitTestCase +public class TimedBufferTest extends ServiceTestBase { // Constants ----------------------------------------------------- @@ -104,7 +104,7 @@ public class TimedBufferTest extends UnitTestCase byte[] bytes = new byte[10]; for (int j = 0; j < 10; j++) { - bytes[j] = UnitTestCase.getSamplebyte(x++); + bytes[j] = ServiceTestBase.getSamplebyte(x++); } ActiveMQBuffer buff = ActiveMQBuffers.wrappedBuffer(bytes); @@ -127,7 +127,7 @@ public class TimedBufferTest extends UnitTestCase for (int i = 0; i < 100; i++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(i), flushedBuffer.get()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(i), flushedBuffer.get()); } } finally @@ -178,7 +178,7 @@ public class TimedBufferTest extends UnitTestCase byte[] bytes = new byte[10]; for (int j = 0; j < 10; j++) { - bytes[j] = UnitTestCase.getSamplebyte(x++); + bytes[j] = ServiceTestBase.getSamplebyte(x++); } ActiveMQBuffer buff = ActiveMQBuffers.wrappedBuffer(bytes); @@ -193,7 +193,7 @@ public class TimedBufferTest extends UnitTestCase bytes = new byte[10]; for (int j = 0; j < 10; j++) { - bytes[j] = UnitTestCase.getSamplebyte(x++); + bytes[j] = ServiceTestBase.getSamplebyte(x++); } buff = ActiveMQBuffers.wrappedBuffer(bytes); @@ -215,7 +215,7 @@ public class TimedBufferTest extends UnitTestCase for (int i = 0; i < 20; i++) { - Assert.assertEquals(UnitTestCase.getSamplebyte(i), flushedBuffer.get()); + Assert.assertEquals(ServiceTestBase.getSamplebyte(i), flushedBuffer.get()); } } finally @@ -291,7 +291,7 @@ public class TimedBufferTest extends UnitTestCase byte[] bytes = new byte[10]; for (int j = 0; j < 10; j++) { - bytes[j] = UnitTestCase.getSamplebyte(x++); + bytes[j] = ServiceTestBase.getSamplebyte(x++); } ActiveMQBuffer buff = ActiveMQBuffers.wrappedBuffer(bytes); @@ -378,7 +378,7 @@ public class TimedBufferTest extends UnitTestCase byte[] bytes = new byte[10]; for (int j = 0; j < 10; j++) { - bytes[j] = UnitTestCase.getSamplebyte(x++); + bytes[j] = ServiceTestBase.getSamplebyte(x++); } ActiveMQBuffer buff = ActiveMQBuffers.wrappedBuffer(bytes); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/message/impl/MessageImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/message/impl/MessageImplTest.java index 49cdf32d73..d51b5988bc 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/message/impl/MessageImplTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/message/impl/MessageImplTest.java @@ -23,7 +23,7 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.client.impl.ClientMessageImpl; import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendMessage; import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl; @@ -31,7 +31,7 @@ import org.apache.activemq.artemis.tests.util.RandomUtil; import org.junit.Assert; import org.junit.Test; -public class MessageImplTest extends UnitTestCase +public class MessageImplTest extends ServiceTestBase { @Test public void getSetAttributes() diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagePositionTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagePositionTest.java index dc8c884608..1b41cef7e8 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagePositionTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagePositionTest.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.artemis.tests.unit.core.paging.impl; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Test; -public class PagePositionTest extends UnitTestCase +public class PagePositionTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PageTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PageTest.java index d4dd29534e..3e56780462 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PageTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PageTest.java @@ -23,7 +23,7 @@ import java.util.List; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.journal.SequentialFile; import org.apache.activemq.artemis.core.journal.SequentialFileFactory; import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory; @@ -36,7 +36,7 @@ import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl; import org.junit.Assert; import org.junit.Test; -public class PageTest extends UnitTestCase +public class PageTest extends ServiceTestBase { // Constants ----------------------------------------------------- @@ -114,7 +114,7 @@ public class PageTest extends UnitTestCase { Assert.assertEquals(simpleDestination, msgs.get(i).getMessage().getAddress()); - UnitTestCase.assertEqualsByteArrays(buffers.get(i).toByteBuffer().array(), msgs.get(i) + ServiceTestBase.assertEqualsByteArrays(buffers.get(i).toByteBuffer().array(), msgs.get(i) .getMessage() .getBodyBuffer() .toByteBuffer() @@ -186,7 +186,7 @@ public class PageTest extends UnitTestCase { Assert.assertEquals(simpleDestination, msgs.get(i).getMessage().getAddress()); - UnitTestCase.assertEqualsByteArrays(buffers.get(i).toByteBuffer().array(), msgs.get(i) + ServiceTestBase.assertEqualsByteArrays(buffers.get(i).toByteBuffer().array(), msgs.get(i) .getMessage() .getBodyBuffer() .toByteBuffer() diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingManagerImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingManagerImplTest.java index 47a9e98955..0ae40d96c9 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingManagerImplTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingManagerImplTest.java @@ -38,12 +38,12 @@ import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository; import org.apache.activemq.artemis.tests.util.RandomUtil; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -public class PagingManagerImplTest extends UnitTestCase +public class PagingManagerImplTest extends ServiceTestBase { private final ReadLock lock = new ReentrantReadWriteLock().readLock(); @@ -86,7 +86,7 @@ public class PagingManagerImplTest extends UnitTestCase Assert.assertEquals(1, msgs.size()); - UnitTestCase.assertEqualsByteArrays(msg.getBodyBuffer().writerIndex(), msg.getBodyBuffer().toByteBuffer().array(), msgs.get(0) + ServiceTestBase.assertEqualsByteArrays(msg.getBodyBuffer().writerIndex(), msg.getBodyBuffer().toByteBuffer().array(), msgs.get(0) .getMessage() .getBodyBuffer() .toByteBuffer() diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingStoreImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingStoreImplTest.java index 5a80874796..1d468ba346 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingStoreImplTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingStoreImplTest.java @@ -55,14 +55,14 @@ import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory; import org.apache.activemq.artemis.tests.unit.util.FakePagingManager; import org.apache.activemq.artemis.tests.util.RandomUtil; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.utils.ExecutorFactory; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -public class PagingStoreImplTest extends UnitTestCase +public class PagingStoreImplTest extends ServiceTestBase { private static final SimpleString destinationTestName = new SimpleString("test"); @@ -130,7 +130,7 @@ public class PagingStoreImplTest extends UnitTestCase @Test public void testPageWithNIO() throws Exception { - UnitTestCase.recreateDirectory(getTestDir()); + ServiceTestBase.recreateDirectory(getTestDir()); testConcurrentPaging(new NIOSequentialFileFactory(getTestDir()), 1); } @@ -327,7 +327,7 @@ public class PagingStoreImplTest extends UnitTestCase for (int i = 0; i < 5; i++) { Assert.assertEquals(sequence++, msg.get(i).getMessage().getMessageID()); - UnitTestCase.assertEqualsBuffers(18, buffers.get(pageNr * 5 + i), msg.get(i).getMessage().getBodyBuffer()); + ServiceTestBase.assertEqualsBuffers(18, buffers.get(pageNr * 5 + i), msg.get(i).getMessage().getBodyBuffer()); } } @@ -378,7 +378,7 @@ public class PagingStoreImplTest extends UnitTestCase Assert.assertEquals(1L, msgs.get(0).getMessage().getMessageID()); - UnitTestCase.assertEqualsBuffers(18, buffers.get(0), msgs.get(0).getMessage().getBodyBuffer()); + ServiceTestBase.assertEqualsBuffers(18, buffers.get(0), msgs.get(0).getMessage().getBodyBuffer()); Assert.assertEquals(1, store.getNumberOfPages()); @@ -496,7 +496,7 @@ public class PagingStoreImplTest extends UnitTestCase try { // Wait every producer to produce at least one message - UnitTestCase.waitForLatch(latchStart); + ServiceTestBase.waitForLatch(latchStart); while (aliveProducers.get() > 0) { @@ -559,7 +559,7 @@ public class PagingStoreImplTest extends UnitTestCase buffers2.put(id, msg.getMessage()); Assert.assertNotNull(msgWritten); Assert.assertEquals(msg.getMessage().getAddress(), msgWritten.getAddress()); - UnitTestCase.assertEqualsBuffers(10, msgWritten.getBodyBuffer(), msg.getMessage().getBodyBuffer()); + ServiceTestBase.assertEqualsBuffers(10, msgWritten.getBodyBuffer(), msg.getMessage().getBodyBuffer()); } } @@ -627,7 +627,7 @@ public class PagingStoreImplTest extends UnitTestCase ServerMessage msgWritten = buffers2.remove(id); Assert.assertNotNull(msgWritten); Assert.assertEquals(msg.getMessage().getAddress(), msgWritten.getAddress()); - UnitTestCase.assertEqualsByteArrays(msgWritten.getBodyBuffer().writerIndex(), msgWritten.getBodyBuffer() + ServiceTestBase.assertEqualsByteArrays(msgWritten.getBodyBuffer().writerIndex(), msgWritten.getBodyBuffer() .toByteBuffer() .array(), msg.getMessage().getBodyBuffer().toByteBuffer().array()); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/BatchIDGeneratorUnitTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/BatchIDGeneratorUnitTest.java index 37fabd54aa..b68f3efcf3 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/BatchIDGeneratorUnitTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/BatchIDGeneratorUnitTest.java @@ -19,7 +19,7 @@ import java.util.ArrayList; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffers; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.journal.Journal; import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo; import org.apache.activemq.artemis.core.journal.RecordInfo; @@ -32,7 +32,7 @@ import org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManag import org.junit.Assert; import org.junit.Test; -public class BatchIDGeneratorUnitTest extends UnitTestCase +public class BatchIDGeneratorUnitTest extends ServiceTestBase { @Test diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/OperationContextUnitTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/OperationContextUnitTest.java index 7faf089eca..540085513d 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/OperationContextUnitTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/OperationContextUnitTest.java @@ -23,13 +23,13 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.journal.IOAsyncTask; import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl; import org.junit.Assert; import org.junit.Test; -public class OperationContextUnitTest extends UnitTestCase +public class OperationContextUnitTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/AddressImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/AddressImplTest.java index e541a452e6..2dbc354812 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/AddressImplTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/AddressImplTest.java @@ -16,7 +16,7 @@ */ package org.apache.activemq.artemis.tests.unit.core.postoffice.impl; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Test; import org.junit.Assert; @@ -25,7 +25,7 @@ import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.postoffice.Address; import org.apache.activemq.artemis.core.postoffice.impl.AddressImpl; -public class AddressImplTest extends UnitTestCase +public class AddressImplTest extends ServiceTestBase { @Test public void testNoDots() diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/BindingsImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/BindingsImplTest.java index 330ee6126f..905f5ca87b 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/BindingsImplTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/BindingsImplTest.java @@ -17,7 +17,7 @@ package org.apache.activemq.artemis.tests.unit.core.postoffice.impl; import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.server.impl.RefsOperation; import org.junit.Test; @@ -42,7 +42,7 @@ import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl; import org.apache.activemq.artemis.core.transaction.Transaction; import org.apache.activemq.artemis.core.transaction.TransactionOperation; -public class BindingsImplTest extends UnitTestCase +public class BindingsImplTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/WildcardAddressManagerUnitTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/WildcardAddressManagerUnitTest.java index f6360c2c09..4b3f51c529 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/WildcardAddressManagerUnitTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/WildcardAddressManagerUnitTest.java @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.Collection; import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.filter.Filter; import org.apache.activemq.artemis.core.postoffice.Binding; import org.apache.activemq.artemis.core.postoffice.BindingType; @@ -37,7 +37,7 @@ import org.junit.Test; /** * This test is replicating the behaviour from https://issues.jboss.org/browse/HORNETQ-988. */ -public class WildcardAddressManagerUnitTest extends UnitTestCase +public class WildcardAddressManagerUnitTest extends ServiceTestBase { diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/ActiveMQBufferTestBase.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/ActiveMQBufferTestBase.java index c93a3bbda2..9268bf693f 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/ActiveMQBufferTestBase.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/ActiveMQBufferTestBase.java @@ -16,7 +16,7 @@ */ package org.apache.activemq.artemis.tests.unit.core.remoting; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Before; import org.junit.After; @@ -27,7 +27,7 @@ import org.junit.Assert; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.tests.util.RandomUtil; -public abstract class ActiveMQBufferTestBase extends UnitTestCase +public abstract class ActiveMQBufferTestBase extends ServiceTestBase { // Constants ----------------------------------------------------- @@ -100,7 +100,7 @@ public abstract class ActiveMQBufferTestBase extends UnitTestCase SimpleString result = putAndGetNullableSimpleString(emptySimpleString); Assert.assertNotNull(result); - UnitTestCase.assertEqualsByteArrays(emptySimpleString.getData(), result.getData()); + ServiceTestBase.assertEqualsByteArrays(emptySimpleString.getData(), result.getData()); } @Test @@ -110,7 +110,7 @@ public abstract class ActiveMQBufferTestBase extends UnitTestCase SimpleString result = putAndGetNullableSimpleString(junk); Assert.assertNotNull(result); - UnitTestCase.assertEqualsByteArrays(junk.getData(), result.getData()); + ServiceTestBase.assertEqualsByteArrays(junk.getData(), result.getData()); } @Test @@ -144,7 +144,7 @@ public abstract class ActiveMQBufferTestBase extends UnitTestCase byte[] b = new byte[bytes.length]; wrapper.readBytes(b); - UnitTestCase.assertEqualsByteArrays(bytes, b); + ServiceTestBase.assertEqualsByteArrays(bytes, b); } @Test @@ -156,7 +156,7 @@ public abstract class ActiveMQBufferTestBase extends UnitTestCase byte[] b = new byte[bytes.length / 2]; wrapper.readBytes(b, 0, b.length); - UnitTestCase.assertEqualsByteArrays(b.length, bytes, b); + ServiceTestBase.assertEqualsByteArrays(b.length, bytes, b); } @Test @@ -289,7 +289,7 @@ public abstract class ActiveMQBufferTestBase extends UnitTestCase byte[] array = wrapper.toByteBuffer().array(); Assert.assertEquals(wrapper.capacity(), array.length); - UnitTestCase.assertEqualsByteArrays(128, bytes, wrapper.toByteBuffer().array()); + ServiceTestBase.assertEqualsByteArrays(128, bytes, wrapper.toByteBuffer().array()); } @Test diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorFactoryTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorFactoryTest.java index ef018ca32f..e74a414ab7 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorFactoryTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorFactoryTest.java @@ -30,11 +30,11 @@ import org.apache.activemq.artemis.spi.core.remoting.Acceptor; import org.apache.activemq.artemis.spi.core.remoting.BufferHandler; import org.apache.activemq.artemis.spi.core.remoting.Connection; import org.apache.activemq.artemis.spi.core.remoting.ConnectionLifeCycleListener; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Assert; import org.junit.Test; -public class NettyAcceptorFactoryTest extends UnitTestCase +public class NettyAcceptorFactoryTest extends ServiceTestBase { @Test public void testCreateAcceptor() throws Exception diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java index 8ac99f7636..a6626962c8 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java @@ -25,7 +25,7 @@ import java.util.concurrent.TimeUnit; import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.core.server.ActiveMQComponent; @@ -37,7 +37,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -public class NettyAcceptorTest extends UnitTestCase +public class NettyAcceptorTest extends ServiceTestBase { private ScheduledExecutorService pool2; @@ -47,7 +47,7 @@ public class NettyAcceptorTest extends UnitTestCase { super.setUp(); - UnitTestCase.checkFreePort(TransportConstants.DEFAULT_PORT); + ServiceTestBase.checkFreePort(TransportConstants.DEFAULT_PORT); } @Override @@ -56,7 +56,7 @@ public class NettyAcceptorTest extends UnitTestCase { try { - UnitTestCase.checkFreePort(TransportConstants.DEFAULT_PORT); + ServiceTestBase.checkFreePort(TransportConstants.DEFAULT_PORT); } finally { @@ -111,13 +111,13 @@ public class NettyAcceptorTest extends UnitTestCase Assert.assertTrue(acceptor.isStarted()); acceptor.stop(); Assert.assertFalse(acceptor.isStarted()); - UnitTestCase.checkFreePort(TransportConstants.DEFAULT_PORT); + ServiceTestBase.checkFreePort(TransportConstants.DEFAULT_PORT); acceptor.start(); Assert.assertTrue(acceptor.isStarted()); acceptor.stop(); Assert.assertFalse(acceptor.isStarted()); - UnitTestCase.checkFreePort(TransportConstants.DEFAULT_PORT); + ServiceTestBase.checkFreePort(TransportConstants.DEFAULT_PORT); pool2.shutdown(); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyConnectionTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyConnectionTest.java index 39dd7afe59..f63064af84 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyConnectionTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyConnectionTest.java @@ -26,7 +26,7 @@ import io.netty.channel.embedded.EmbeddedChannel; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffers; import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnection; import org.apache.activemq.artemis.core.server.ActiveMQComponent; import org.apache.activemq.artemis.spi.core.remoting.Connection; @@ -34,7 +34,7 @@ import org.apache.activemq.artemis.spi.core.remoting.ConnectionLifeCycleListener import org.junit.Assert; import org.junit.Test; -public class NettyConnectionTest extends UnitTestCase +public class NettyConnectionTest extends ServiceTestBase { private static final Map emptyMap = Collections.emptyMap(); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyConnectorTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyConnectorTest.java index b32a810f95..ea341ef713 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyConnectorTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyConnectorTest.java @@ -18,7 +18,7 @@ package org.apache.activemq.artemis.tests.unit.core.remoting.impl.netty; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Test; import java.util.HashMap; @@ -34,7 +34,7 @@ import org.apache.activemq.artemis.spi.core.remoting.BufferHandler; import org.apache.activemq.artemis.spi.core.remoting.Connection; import org.apache.activemq.artemis.spi.core.remoting.ConnectionLifeCycleListener; -public class NettyConnectorTest extends UnitTestCase +public class NettyConnectorTest extends ServiceTestBase { @Test diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/ssl/SSLSupportTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/ssl/SSLSupportTest.java index eb0d19975e..99789cf43b 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/ssl/SSLSupportTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/ssl/SSLSupportTest.java @@ -21,7 +21,7 @@ import java.net.URL; import java.util.Arrays; import java.util.Collection; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.remoting.impl.ssl.SSLSupport; import org.junit.Assert; import org.junit.Before; @@ -30,7 +30,7 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @RunWith(value = Parameterized.class) -public class SSLSupportTest extends UnitTestCase +public class SSLSupportTest extends ServiceTestBase { @Parameterized.Parameters(name = "storeType={0}") public static Collection getParameters() diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/security/impl/ActiveMQSecurityManagerImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/security/impl/ActiveMQSecurityManagerImplTest.java index 5bf1338f22..51fa4b56c5 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/security/impl/ActiveMQSecurityManagerImplTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/security/impl/ActiveMQSecurityManagerImplTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.unit.core.security.impl; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Before; import org.junit.After; @@ -32,7 +32,7 @@ import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManagerImpl /** * tests ActiveMQSecurityManagerImpl */ -public class ActiveMQSecurityManagerImplTest extends UnitTestCase +public class ActiveMQSecurityManagerImplTest extends ServiceTestBase { private ActiveMQSecurityManagerImpl securityManager; diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/cluster/impl/ClusterConnectionBridgeTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/cluster/impl/ClusterConnectionBridgeTest.java index fd763faca5..48f66537c7 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/cluster/impl/ClusterConnectionBridgeTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/cluster/impl/ClusterConnectionBridgeTest.java @@ -17,11 +17,11 @@ package org.apache.activemq.artemis.tests.unit.core.server.cluster.impl; import org.apache.activemq.artemis.api.core.management.ManagementHelper; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.server.cluster.impl.ClusterConnectionBridge; import org.junit.Test; -public class ClusterConnectionBridgeTest extends UnitTestCase +public class ClusterConnectionBridgeTest extends ServiceTestBase { @Test public void testCreateSelectorFromAddressForNormalMatches() diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/cluster/impl/RemoteQueueBindImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/cluster/impl/RemoteQueueBindImplTest.java index 11363a2d1e..4023192259 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/cluster/impl/RemoteQueueBindImplTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/cluster/impl/RemoteQueueBindImplTest.java @@ -17,7 +17,7 @@ package org.apache.activemq.artemis.tests.unit.core.server.cluster.impl; import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Test; import org.apache.activemq.artemis.api.core.SimpleString; @@ -25,7 +25,7 @@ import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.server.cluster.impl.RemoteQueueBindingImpl; import org.apache.activemq.artemis.tests.util.RandomUtil; -public class RemoteQueueBindImplTest extends UnitTestCase +public class RemoteQueueBindImplTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/group/impl/SystemPropertyOverrideTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/group/impl/SystemPropertyOverrideTest.java index ba5d738747..736e6e958f 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/group/impl/SystemPropertyOverrideTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/group/impl/SystemPropertyOverrideTest.java @@ -17,10 +17,10 @@ package org.apache.activemq.artemis.tests.unit.core.server.group.impl; import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.server.group.impl.GroupingHandlerConfiguration; -public class SystemPropertyOverrideTest extends UnitTestCase +public class SystemPropertyOverrideTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/FileLockTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/FileLockTest.java index 80c45dee37..3e71f4e2d8 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/FileLockTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/FileLockTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ package org.apache.activemq.artemis.tests.unit.core.server.impl; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Before; import org.junit.Test; @@ -26,7 +26,7 @@ import org.apache.activemq.artemis.core.asyncio.impl.AsynchronousFileImpl; import org.apache.activemq.artemis.core.server.impl.AIOFileLockNodeManager; import org.apache.activemq.artemis.core.server.impl.FileLockNodeManager; -public class FileLockTest extends UnitTestCase +public class FileLockTest extends ServiceTestBase { @Override diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/QueueImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/QueueImplTest.java index add2da0e52..202079d106 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/QueueImplTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/QueueImplTest.java @@ -34,7 +34,7 @@ import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakeConsumer; import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakeFilter; import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakePostOffice; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.filter.Filter; import org.apache.activemq.artemis.core.filter.impl.FilterImpl; import org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding; @@ -54,7 +54,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -public class QueueImplTest extends UnitTestCase +public class QueueImplTest extends ServiceTestBase { // The tests ---------------------------------------------------------------- @@ -1327,7 +1327,7 @@ public class QueueImplTest extends UnitTestCase final String MY_ADDRESS = "myAddress"; final String MY_QUEUE = "myQueue"; - ActiveMQServer server = ActiveMQServers.newActiveMQServer(createDefaultConfig(false), true); + ActiveMQServer server = ActiveMQServers.newActiveMQServer(createDefaultConfig(), true); AddressSettings defaultSetting = new AddressSettings(); defaultSetting.setPageSizeBytes(10 * 1024); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/ActiveMQDestinationTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/ActiveMQDestinationTest.java index 0f6089774d..7ae56d3db8 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/ActiveMQDestinationTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/ActiveMQDestinationTest.java @@ -16,7 +16,7 @@ */ package org.apache.activemq.artemis.tests.unit.jms; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Test; import javax.jms.JMSRuntimeException; @@ -28,7 +28,7 @@ import org.junit.Assert; import org.apache.activemq.artemis.jms.client.ActiveMQDestination; import org.apache.activemq.artemis.tests.util.RandomUtil; -public class ActiveMQDestinationTest extends UnitTestCase +public class ActiveMQDestinationTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/ActiveMQMapMessageTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/ActiveMQMapMessageTest.java index ee8f0a87ed..ad25b34754 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/ActiveMQMapMessageTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/ActiveMQMapMessageTest.java @@ -18,13 +18,13 @@ package org.apache.activemq.artemis.tests.unit.jms.client; import javax.jms.MessageFormatException; import org.apache.activemq.artemis.tests.util.RandomUtil; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.jms.client.ActiveMQMapMessage; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -public class ActiveMQMapMessageTest extends UnitTestCase +public class ActiveMQMapMessageTest extends ServiceTestBase { // Constants ----------------------------------------------------- @@ -693,7 +693,7 @@ public class ActiveMQMapMessageTest extends UnitTestCase ActiveMQMapMessage message = new ActiveMQMapMessage(); message.setBytes(itemName, value); - UnitTestCase.assertEqualsByteArrays(value, message.getBytes(itemName)); + ServiceTestBase.assertEqualsByteArrays(value, message.getBytes(itemName)); } @Test diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/ActiveMQStreamMessageTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/ActiveMQStreamMessageTest.java index 76e4fda51b..a29148da40 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/ActiveMQStreamMessageTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/ActiveMQStreamMessageTest.java @@ -16,7 +16,7 @@ */ package org.apache.activemq.artemis.tests.unit.jms.client; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Test; import java.util.ArrayList; @@ -29,7 +29,7 @@ import org.junit.Assert; import org.apache.activemq.artemis.jms.client.ActiveMQStreamMessage; import org.apache.activemq.artemis.tests.util.RandomUtil; -public class ActiveMQStreamMessageTest extends UnitTestCase +public class ActiveMQStreamMessageTest extends ServiceTestBase { // Constants ----------------------------------------------------- @@ -180,7 +180,7 @@ public class ActiveMQStreamMessageTest extends UnitTestCase byte[] v = new byte[value.length]; message.readBytes(v); - UnitTestCase.assertEqualsByteArrays(value, v); + ServiceTestBase.assertEqualsByteArrays(value, v); } @Test @@ -195,7 +195,7 @@ public class ActiveMQStreamMessageTest extends UnitTestCase byte[] v = new byte[256]; message.readBytes(v); - UnitTestCase.assertEqualsByteArrays(256, value, v); + ServiceTestBase.assertEqualsByteArrays(256, value, v); } @Test @@ -922,7 +922,7 @@ public class ActiveMQStreamMessageTest extends UnitTestCase message.reset(); byte[] v = (byte[])message.readObject(); - UnitTestCase.assertEqualsByteArrays(value, v); + ServiceTestBase.assertEqualsByteArrays(value, v); } @Test @@ -1041,7 +1041,7 @@ public class ActiveMQStreamMessageTest extends UnitTestCase Object v = reader.readType(message); if (value instanceof byte[]) { - UnitTestCase.assertEqualsByteArrays((byte[])value, (byte[])v); + ServiceTestBase.assertEqualsByteArrays((byte[])value, (byte[])v); } else { diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/JMSExceptionHelperTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/JMSExceptionHelperTest.java index d4a22f20c1..82a98a6c44 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/JMSExceptionHelperTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/JMSExceptionHelperTest.java @@ -28,12 +28,12 @@ import javax.jms.JMSSecurityException; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.jms.client.JMSExceptionHelper; import org.junit.Assert; import org.junit.Test; -public class JMSExceptionHelperTest extends UnitTestCase +public class JMSExceptionHelperTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/SelectorTranslatorTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/SelectorTranslatorTest.java index ca931e67bd..5f23ec9fd4 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/SelectorTranslatorTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/SelectorTranslatorTest.java @@ -16,14 +16,14 @@ */ package org.apache.activemq.artemis.tests.unit.jms.client; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Test; import org.junit.Assert; import org.apache.activemq.artemis.jms.client.SelectorTranslator; -public class SelectorTranslatorTest extends UnitTestCase +public class SelectorTranslatorTest extends ServiceTestBase { @Test public void testParseNull() diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/misc/ManifestTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/misc/ManifestTest.java index 559a96d902..857cc0fa22 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/misc/ManifestTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/misc/ManifestTest.java @@ -16,7 +16,7 @@ */ package org.apache.activemq.artemis.tests.unit.jms.misc; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Test; import java.io.File; @@ -35,7 +35,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionMetaData; import org.apache.activemq.artemis.tests.unit.UnitTestLogger; -public class ManifestTest extends UnitTestCase +public class ManifestTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/referenceable/ConnectionFactoryObjectFactoryTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/referenceable/ConnectionFactoryObjectFactoryTest.java index 9884c7e54a..fe4f89cac7 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/referenceable/ConnectionFactoryObjectFactoryTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/referenceable/ConnectionFactoryObjectFactoryTest.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.artemis.tests.unit.jms.referenceable; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Test; -public class ConnectionFactoryObjectFactoryTest extends UnitTestCase +public class ConnectionFactoryObjectFactoryTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/referenceable/DestinationObjectFactoryTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/referenceable/DestinationObjectFactoryTest.java index 9b79d8414d..82d19ca6b4 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/referenceable/DestinationObjectFactoryTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/referenceable/DestinationObjectFactoryTest.java @@ -16,7 +16,7 @@ */ package org.apache.activemq.artemis.tests.unit.jms.referenceable; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Test; import javax.naming.Reference; @@ -28,7 +28,7 @@ import org.apache.activemq.artemis.jms.client.ActiveMQDestination; import org.apache.activemq.artemis.jms.referenceable.DestinationObjectFactory; import org.apache.activemq.artemis.tests.util.RandomUtil; -public class DestinationObjectFactoryTest extends UnitTestCase +public class DestinationObjectFactoryTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ActiveMQResourceAdapterConfigTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ActiveMQResourceAdapterConfigTest.java index 1aa4168f66..ca3a81f1f3 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ActiveMQResourceAdapterConfigTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ActiveMQResourceAdapterConfigTest.java @@ -25,7 +25,7 @@ import java.util.HashMap; import java.util.Map; import org.apache.activemq.artemis.ra.ActiveMQResourceAdapter; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -39,7 +39,7 @@ import org.xml.sax.InputSource; * this test should fail, if it does paste the new commented out configs into the ra.xml file and in here. don't forget to * add a description for each new property added and try and put it in the config some where appropriate. */ -public class ActiveMQResourceAdapterConfigTest extends UnitTestCase +public class ActiveMQResourceAdapterConfigTest extends ServiceTestBase { private static String config = "" + "\n" + diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ConnectionFactoryPropertiesTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ConnectionFactoryPropertiesTest.java index a90d09f78b..335edf54bb 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ConnectionFactoryPropertiesTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/ra/ConnectionFactoryPropertiesTest.java @@ -21,14 +21,14 @@ import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.artemis.ra.ActiveMQResourceAdapter; import org.junit.Test; import static java.beans.Introspector.getBeanInfo; -public class ConnectionFactoryPropertiesTest extends UnitTestCase +public class ConnectionFactoryPropertiesTest extends ServiceTestBase { private static final SortedSet UNSUPPORTED_CF_PROPERTIES; diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/ActiveMQBufferInputStreamTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/ActiveMQBufferInputStreamTest.java index cf42ed4d3b..1adcdf9da2 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/ActiveMQBufferInputStreamTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/ActiveMQBufferInputStreamTest.java @@ -18,11 +18,11 @@ package org.apache.activemq.artemis.tests.unit.util; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffers; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.utils.ActiveMQBufferInputStream; import org.junit.Test; -public class ActiveMQBufferInputStreamTest extends UnitTestCase +public class ActiveMQBufferInputStreamTest extends ServiceTestBase { @Test diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/LinkedListTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/LinkedListTest.java index ee4e62ec32..363320d5e3 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/LinkedListTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/LinkedListTest.java @@ -22,13 +22,13 @@ import java.util.List; import java.util.NoSuchElementException; import java.util.concurrent.atomic.AtomicInteger; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.utils.LinkedListImpl; import org.apache.activemq.artemis.utils.LinkedListIterator; import org.junit.Before; import org.junit.Test; -public class LinkedListTest extends UnitTestCase +public class LinkedListTest extends ServiceTestBase { private LinkedListImpl list; diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/ObjectInputStreamWithClassLoaderTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/ObjectInputStreamWithClassLoaderTest.java index 3a41831d6c..21aef5c125 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/ObjectInputStreamWithClassLoaderTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/ObjectInputStreamWithClassLoaderTest.java @@ -16,7 +16,7 @@ */ package org.apache.activemq.artemis.tests.unit.util; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Test; import java.io.ByteArrayInputStream; @@ -40,7 +40,7 @@ import org.junit.Assert; import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader; -public class ObjectInputStreamWithClassLoaderTest extends UnitTestCase +public class ObjectInputStreamWithClassLoaderTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/ReusableLatchTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/ReusableLatchTest.java index 42893cef22..95130c6abc 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/ReusableLatchTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/ReusableLatchTest.java @@ -19,12 +19,12 @@ package org.apache.activemq.artemis.tests.unit.util; import java.util.concurrent.CountDownLatch; import org.apache.activemq.artemis.tests.unit.UnitTestLogger; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.utils.ReusableLatch; import org.junit.Assert; import org.junit.Test; -public class ReusableLatchTest extends UnitTestCase +public class ReusableLatchTest extends ServiceTestBase { @Test public void testLatchWithParameterizedDown() throws Exception diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/SoftValueMapTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/SoftValueMapTest.java index 940bde7b8b..7abea8fa33 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/SoftValueMapTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/SoftValueMapTest.java @@ -16,11 +16,11 @@ */ package org.apache.activemq.artemis.tests.unit.util; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.utils.SoftValueHashMap; import org.junit.Test; -public class SoftValueMapTest extends UnitTestCase +public class SoftValueMapTest extends ServiceTestBase { // Constants ----------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UTF8Test.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UTF8Test.java index 5d6f84d7f3..4b0ba37536 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UTF8Test.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UTF8Test.java @@ -17,7 +17,7 @@ package org.apache.activemq.artemis.tests.unit.util; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQBuffers; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.After; import org.junit.Test; @@ -35,7 +35,7 @@ import org.apache.activemq.artemis.utils.DataConstants; import org.apache.activemq.artemis.utils.Random; import org.apache.activemq.artemis.utils.UTF8Util; -public class UTF8Test extends UnitTestCase +public class UTF8Test extends ServiceTestBase { @Test diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UUIDGeneratorTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UUIDGeneratorTest.java index 1d7a8856ce..08604de6e5 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UUIDGeneratorTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UUIDGeneratorTest.java @@ -16,12 +16,12 @@ */ package org.apache.activemq.artemis.tests.unit.util; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.utils.UUIDGenerator; import org.junit.Assert; import org.junit.Test; -public class UUIDGeneratorTest extends UnitTestCase +public class UUIDGeneratorTest extends ServiceTestBase { // Constants ----------------------------------------------------- @@ -58,15 +58,15 @@ public class UUIDGeneratorTest extends UnitTestCase byte[] fiveBytes = new byte[]{1, 2, 3, 4, 5}; byte[] zeroPaddedFiveBytes = UUIDGenerator.getZeroPaddedSixBytes(fiveBytes); - UnitTestCase.assertEqualsByteArrays(new byte[]{1, 2, 3, 4, 5, 0}, zeroPaddedFiveBytes); + ServiceTestBase.assertEqualsByteArrays(new byte[]{1, 2, 3, 4, 5, 0}, zeroPaddedFiveBytes); byte[] fourBytes = new byte[]{1, 2, 3, 4}; byte[] zeroPaddedFourBytes = UUIDGenerator.getZeroPaddedSixBytes(fourBytes); - UnitTestCase.assertEqualsByteArrays(new byte[]{1, 2, 3, 4, 0, 0}, zeroPaddedFourBytes); + ServiceTestBase.assertEqualsByteArrays(new byte[]{1, 2, 3, 4, 0, 0}, zeroPaddedFourBytes); byte[] threeBytes = new byte[]{1, 2, 3}; byte[] zeroPaddedThreeBytes = UUIDGenerator.getZeroPaddedSixBytes(threeBytes); - UnitTestCase.assertEqualsByteArrays(new byte[]{1, 2, 3, 0, 0, 0}, zeroPaddedThreeBytes); + ServiceTestBase.assertEqualsByteArrays(new byte[]{1, 2, 3, 0, 0, 0}, zeroPaddedThreeBytes); } // Package protected --------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UUIDTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UUIDTest.java index 897d913437..b202c48e02 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UUIDTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/UUIDTest.java @@ -16,7 +16,7 @@ */ package org.apache.activemq.artemis.tests.unit.util; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.junit.Test; import java.util.HashSet; @@ -27,7 +27,7 @@ import org.junit.Assert; import org.apache.activemq.artemis.utils.UUID; import org.apache.activemq.artemis.utils.UUIDGenerator; -public class UUIDTest extends UnitTestCase +public class UUIDTest extends ServiceTestBase { static final int MANY_TIMES = 100000; diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/VersionLoaderTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/VersionLoaderTest.java index 829b516117..cc0a509a49 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/VersionLoaderTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/VersionLoaderTest.java @@ -19,13 +19,13 @@ package org.apache.activemq.artemis.tests.unit.util; import java.util.Properties; import java.util.StringTokenizer; -import org.apache.activemq.artemis.tests.util.UnitTestCase; +import org.apache.activemq.artemis.tests.util.ServiceTestBase; import org.apache.activemq.artemis.core.version.Version; import org.apache.activemq.artemis.utils.VersionLoader; import org.junit.Assert; import org.junit.Test; -public class VersionLoaderTest extends UnitTestCase +public class VersionLoaderTest extends ServiceTestBase { // Constants -----------------------------------------------------