You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by an...@apache.org on 2015/05/20 11:47:15 UTC
[10/13] activemq-artemis git commit: Refactor base test classes
Refactor base test classes
This has bothered me for awhile, but writing the hacking guide has
given me an opportunity to refactor some of our test-suite to be
simpler, more consistent, and easier to understand. This is
important if we want users to provide well-written tests. Our
test-suite is an important part of the code-base and it should be
easy to write good tests.
Basically I just consolidated CoreUnitTestCase, UnitTestCase, and
ServiceTestBase into a single class named ServiceTestBase. I also
simplified some of the configuration creation methods to reduce
duplicated code.
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/99147d07
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/99147d07
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/99147d07
Branch: refs/heads/master
Commit: 99147d0713bd1688e4c79b6d2e551bff9203ea4a
Parents: 7025886
Author: jbertram <jb...@apache.org>
Authored: Mon May 18 11:07:28 2015 -0500
Committer: jbertram <jb...@apache.org>
Committed: Tue May 19 15:27:13 2015 -0500
----------------------------------------------------------------------
.../artemis/tests/CoreUnitTestCase.java | 89 -
.../util/TimeAndCounterIDGeneratorTest.java | 15 +-
.../core/server/ActiveMQMessageBundle.java | 3 +
.../artemis/core/server/ActiveMQServer.java | 4 +
.../core/server/impl/ActiveMQServerImpl.java | 12 +-
.../core/config/impl/ConfigurationImplTest.java | 20 +-
.../impl/FileConfigurationParserTest.java | 14 +-
.../config/impl/HAPolicyConfigurationTest.java | 10 +-
.../WrongRoleFileConfigurationParserTest.java | 10 +-
.../group/impl/ClusteredResetMockTest.java | 18 +-
.../core/settings/AddressSettingsTest.java | 4 +-
.../artemis/core/settings/RepositoryTest.java | 12 +-
.../artemis/tests/util/RemoveFolder.java | 2 +-
.../artemis/tests/util/ServiceTestBase.java | 3326 +++++++++++++-----
.../artemis/tests/util/SimpleStringTest.java | 2 +-
.../tests/util/SingleServerTestBase.java | 2 +-
.../artemis/tests/util/UnitTestCase.java | 2137 -----------
docs/hacking-guide/en/tests.md | 14 +-
.../extras/byteman/ClosingConnectionTest.java | 3 +-
.../tests/extras/jms/bridge/BridgeTestBase.java | 6 +-
.../integration/DuplicateDetectionTest.java | 63 +-
.../tests/integration/String64KLimitTest.java | 4 +-
.../aerogear/AeroGearBasicServerTest.java | 29 +-
.../integration/client/ActiveMQCrashTest.java | 17 +-
.../ConcurrentCreateDeleteProduceTest.java | 2 +-
.../integration/client/ConsumerCloseTest.java | 18 +-
.../integration/client/ConsumerStuckTest.java | 10 +-
.../client/DeadLetterAddressTest.java | 27 +-
.../integration/client/ExpiryAddressTest.java | 21 +-
.../integration/client/HangConsumerTest.java | 2 +-
.../integration/client/HeuristicXATest.java | 42 +-
.../client/IncompatibleVersionTest.java | 10 +-
.../client/InterruptedLargeMessageTest.java | 8 +-
.../client/JmsNettyNioStressTest.java | 28 +-
.../LargeMessageAvoidLargeMessagesTest.java | 8 +-
.../integration/client/LargeMessageTest.java | 46 +-
.../client/LibaioDependencyCheckTest.java | 4 +-
.../client/MessageDurabilityTest.java | 5 +-
.../MessageGroupingConnectionFactoryTest.java | 25 +-
.../integration/client/MessageGroupingTest.java | 45 +-
.../integration/client/MessagePriorityTest.java | 5 +-
.../client/MultipleThreadFilterOneTest.java | 2 +-
.../tests/integration/client/NIOvsOIOTest.java | 24 +-
.../client/NewDeadLetterAddressTest.java | 8 +-
.../integration/client/PagingOrderTest.java | 6 +-
.../tests/integration/client/PagingTest.java | 67 +-
.../integration/client/ProducerCloseTest.java | 15 +-
.../client/ProducerFlowControlTest.java | 17 +-
.../client/ReceiveImmediateTest.java | 2 +-
.../tests/integration/client/RequestorTest.java | 5 +-
.../client/SelfExpandingBufferTest.java | 9 +-
.../client/SessionCloseOnGCTest.java | 29 +-
.../integration/client/SessionCloseTest.java | 59 +-
.../integration/client/TemporaryQueueTest.java | 4 +-
.../integration/client/WildCardRoutingTest.java | 21 +-
.../cluster/ClusterControllerTest.java | 8 +-
.../cluster/RealNodeManagerTest.java | 4 +-
.../integration/cluster/bridge/BridgeTest.java | 98 +-
.../cluster/bridge/BridgeTestBase.java | 4 +-
.../cluster/distribution/ClusterTestBase.java | 49 +-
.../MessageRedistributionWithDiscoveryTest.java | 6 +-
.../distribution/SymmetricClusterTest.java | 4 +-
.../SymmetricClusterWithBackupTest.java | 4 +-
.../SymmetricClusterWithDiscoveryTest.java | 6 +-
.../AutomaticColocatedQuorumVoteTest.java | 6 +-
.../failover/BackupSyncLargeMessageTest.java | 8 +-
.../cluster/failover/FailoverTestBase.java | 27 +-
.../failover/LiveToLiveFailoverTest.java | 5 +-
...ultipleLivesMultipleBackupsFailoverTest.java | 18 +-
.../MultipleServerFailoverTestBase.java | 8 +-
.../failover/QuorumVoteServerConnectTest.java | 4 +-
.../SingleLiveMultipleBackupsFailoverTest.java | 11 +-
.../MultiThreadRandomReattachTestBase.java | 6 +-
.../MultiThreadReattachSupportTestBase.java | 22 +-
.../cluster/reattach/RandomReattachTest.java | 25 +-
.../cluster/topology/IsolatedTopologyTest.java | 21 +-
.../topology/TopologyClusterTestBase.java | 21 +-
.../discovery/DiscoveryBaseTest.java | 4 +-
.../divert/PersistentDivertTest.java | 23 +-
.../integration/embedded/ValidateAIOTest.java | 2 +-
.../http/CoreClientOverHttpTest.java | 4 +-
.../jms/ActiveMQConnectionFactoryTest.java | 4 +-
.../tests/integration/jms/FloodServerTest.java | 4 +-
.../integration/jms/SimpleJNDIClientTest.java | 4 +-
.../jms/client/ReSendMessageTest.java | 6 +-
.../jms/cluster/JMSReconnectTest.java | 4 +-
.../jms/connection/CloseConnectionOnGCTest.java | 8 +-
.../jms/connection/ExceptionListenerTest.java | 4 +-
.../jms/largemessage/JMSLargeMessageTest.java | 18 +-
.../jms/server/JMSServerStartStopTest.java | 4 +-
.../jms/server/config/JMSConfigurationTest.java | 2 +-
.../ConnectionFactoryControlTest.java | 8 +-
.../server/management/JMSQueueControlTest.java | 3 +-
.../management/JMSServerControlRestartTest.java | 18 +-
.../server/management/JMSServerControlTest.java | 114 +-
.../journal/AIOImportExportTest.java | 4 +-
.../journal/AIOJournalCompactTest.java | 4 +-
.../journal/JournalPerfTuneTest.java | 4 +-
.../journal/NIOBufferedJournalCompactTest.java | 4 +-
.../journal/NIOImportExportTest.java | 4 +-
.../journal/NIOJournalCompactTest.java | 6 +-
.../integration/journal/NIOJournalImplTest.java | 4 +-
.../journal/ValidateTransactionHealthTest.java | 4 +-
.../largemessage/LargeMessageTestBase.java | 39 +-
.../largemessage/ServerLargeMessageTest.java | 7 +-
.../management/AcceptorControlTest.java | 9 +-
.../AcceptorControlUsingCoreTest.java | 12 +-
.../management/ActiveMQServerControlTest.java | 39 +-
.../ActiveMQServerControlUsingCoreTest.java | 7 +-
.../management/AddressControlTest.java | 16 +-
.../management/AddressControlUsingCoreTest.java | 3 +-
.../management/BroadcastGroupControlTest.java | 10 +-
.../ClusterConnectionControl2Test.java | 10 +-
.../ClusterConnectionControlUsingCoreTest.java | 9 +-
.../management/DivertControlUsingCoreTest.java | 5 +-
.../management/ManagementServiceImplTest.java | 4 +-
.../management/NotificationTest.java | 4 +-
.../management/QueueControlTest.java | 18 +-
.../management/SecurityManagementTestBase.java | 6 +-
.../management/SecurityNotificationTest.java | 37 +-
.../paging/MultipleProducersPagingTest.java | 4 +-
.../paging/SpawnedServerSupport.java | 20 +-
.../ra/ActiveMQMessageHandlerTest.java | 19 +-
.../ra/ActiveMQMessageHandlerXATest.java | 12 +-
.../ra/ActiveMQRAClusteredTestBase.java | 4 +-
.../integration/ra/ActiveMQRATestBase.java | 23 +-
.../integration/ra/ResourceAdapterTest.java | 27 +-
.../scheduling/DelayedMessageTest.java | 11 +-
.../MultipliedDelayedMessageTest.java | 7 +-
.../scheduling/ScheduledMessageTest.java | 15 +-
.../integration/security/SecurityTest.java | 8 +-
.../integration/server/ConnectionLimitTest.java | 4 +-
.../integration/server/ExpiryRunnerTest.java | 31 +-
.../integration/server/LVQRecoveryTest.java | 13 +-
.../tests/integration/server/LVQTest.java | 23 +-
.../integration/server/ResourceLimitTest.java | 4 +-
.../integration/server/ScaleDown3NodeTest.java | 6 +-
.../tests/integration/server/ScaleDownTest.java | 4 +-
.../server/SuppliedThreadPoolTest.java | 4 +-
.../spring/SpringIntegrationTest.java | 4 +-
.../tests/integration/stomp/StompTestBase.java | 4 +-
.../integration/stomp/StompWebSocketTest.java | 4 +-
.../integration/stomp/v11/StompV11TestBase.java | 4 +-
.../netty/ActiveMQFrameDecoder2Test.java | 4 +-
.../NettyConnectorWithHTTPUpgradeTest.java | 4 +-
.../vertx/ActiveMQVertxUnitTest.java | 11 +-
.../integration/xa/BasicXaRecoveryTest.java | 63 +-
.../tests/integration/xa/XaTimeoutTest.java | 6 +-
.../tests/util/ReplicatedBackupUtils.java | 4 +-
.../tests/util/TransportConfigurationUtils.java | 20 +-
.../artemis/jms/tests/MessageConsumerTest.java | 8 +-
.../tests/message/JMSExpirationHeaderTest.java | 10 +-
.../jms/tests/selector/SelectorTest.java | 6 +-
.../paging/MeasurePagingMultiThreadTest.java | 10 +-
.../stress/journal/AddAndRemoveStressTest.java | 4 +-
.../stress/journal/CompactingStressTest.java | 21 +-
.../JournalCleanupCompactStressTest.java | 37 +-
.../stress/journal/LargeJournalStressTest.java | 15 +-
.../journal/MultiThreadConsumerStressTest.java | 13 +-
.../NIOMultiThreadCompactorStressTest.java | 19 +-
.../tests/stress/stomp/StompStressTest.java | 4 +-
.../core/journal/impl/AIOJournalImplTest.java | 4 +-
.../core/journal/impl/NIOJournalImplTest.java | 4 +-
.../core/server/impl/QueueConcurrentTest.java | 4 +-
.../timing/core/server/impl/QueueImplTest.java | 4 +-
.../jms/bridge/impl/JMSBridgeImplTest.java | 4 +-
.../tests/timing/util/ReusableLatchTest.java | 4 +-
.../timing/util/TokenBucketLimiterImplTest.java | 4 +-
.../artemis/tests/timing/util/UTF8Test.java | 4 +-
.../tests/unit/core/asyncio/AIOTestBase.java | 4 +-
.../unit/core/asyncio/AsynchronousFileTest.java | 22 +-
.../MultiThreadAsynchronousFileTest.java | 4 +-
.../client/impl/LargeMessageBufferTest.java | 8 +-
.../impl/ConfigurationValidationTest.java | 4 +-
.../core/config/impl/ConnectorsServiceTest.java | 4 +-
.../config/impl/TransportConfigurationTest.java | 4 +-
.../journal/impl/AlignedJournalImplTest.java | 10 +-
.../unit/core/journal/impl/CleanBufferTest.java | 4 +-
.../core/journal/impl/FileFactoryTestBase.java | 4 +-
.../core/journal/impl/JournalAsyncTest.java | 4 +-
.../core/journal/impl/JournalImplTestBase.java | 8 +-
.../unit/core/journal/impl/ReclaimerTest.java | 4 +-
.../impl/SequentialFileFactoryTestBase.java | 12 +-
.../unit/core/journal/impl/TimedBufferTest.java | 18 +-
.../unit/core/message/impl/MessageImplTest.java | 4 +-
.../unit/core/paging/impl/PagePositionTest.java | 4 +-
.../tests/unit/core/paging/impl/PageTest.java | 8 +-
.../core/paging/impl/PagingManagerImplTest.java | 6 +-
.../core/paging/impl/PagingStoreImplTest.java | 16 +-
.../impl/BatchIDGeneratorUnitTest.java | 4 +-
.../impl/OperationContextUnitTest.java | 4 +-
.../core/postoffice/impl/AddressImplTest.java | 4 +-
.../core/postoffice/impl/BindingsImplTest.java | 4 +-
.../impl/WildcardAddressManagerUnitTest.java | 4 +-
.../core/remoting/ActiveMQBufferTestBase.java | 14 +-
.../impl/netty/NettyAcceptorFactoryTest.java | 4 +-
.../remoting/impl/netty/NettyAcceptorTest.java | 12 +-
.../impl/netty/NettyConnectionTest.java | 4 +-
.../remoting/impl/netty/NettyConnectorTest.java | 4 +-
.../core/remoting/impl/ssl/SSLSupportTest.java | 4 +-
.../impl/ActiveMQSecurityManagerImplTest.java | 4 +-
.../impl/ClusterConnectionBridgeTest.java | 4 +-
.../cluster/impl/RemoteQueueBindImplTest.java | 4 +-
.../group/impl/SystemPropertyOverrideTest.java | 4 +-
.../unit/core/server/impl/FileLockTest.java | 4 +-
.../unit/core/server/impl/QueueImplTest.java | 6 +-
.../tests/unit/jms/ActiveMQDestinationTest.java | 4 +-
.../unit/jms/client/ActiveMQMapMessageTest.java | 6 +-
.../jms/client/ActiveMQStreamMessageTest.java | 12 +-
.../unit/jms/client/JMSExceptionHelperTest.java | 4 +-
.../unit/jms/client/SelectorTranslatorTest.java | 4 +-
.../tests/unit/jms/misc/ManifestTest.java | 4 +-
.../ConnectionFactoryObjectFactoryTest.java | 4 +-
.../DestinationObjectFactoryTest.java | 4 +-
.../ra/ActiveMQResourceAdapterConfigTest.java | 4 +-
.../ra/ConnectionFactoryPropertiesTest.java | 4 +-
.../util/ActiveMQBufferInputStreamTest.java | 4 +-
.../artemis/tests/unit/util/LinkedListTest.java | 4 +-
.../ObjectInputStreamWithClassLoaderTest.java | 4 +-
.../tests/unit/util/ReusableLatchTest.java | 4 +-
.../tests/unit/util/SoftValueMapTest.java | 4 +-
.../artemis/tests/unit/util/UTF8Test.java | 4 +-
.../tests/unit/util/UUIDGeneratorTest.java | 10 +-
.../artemis/tests/unit/util/UUIDTest.java | 4 +-
.../tests/unit/util/VersionLoaderTest.java | 4 +-
225 files changed, 3829 insertions(+), 4307 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/99147d07/artemis-core-client/src/test/java/org/apache/activemq/artemis/tests/CoreUnitTestCase.java
----------------------------------------------------------------------
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 3bdc561..0000000
--- 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).
- * <p/>
- * 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;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/99147d07/artemis-core-client/src/test/java/org/apache/activemq/artemis/util/TimeAndCounterIDGeneratorTest.java
----------------------------------------------------------------------
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 d97fafc..995b65b 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();
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/99147d07/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java
----------------------------------------------------------------------
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 e4396c2..51fcb01 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();
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/99147d07/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java
----------------------------------------------------------------------
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 18a3ce1..7790812 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);
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/99147d07/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
----------------------------------------------------------------------
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 adfa348..1f55131 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;
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/99147d07/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java
----------------------------------------------------------------------
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 de50915..9bfc3a3 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.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;
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/99147d07/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationParserTest.java
----------------------------------------------------------------------
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 1c94a45..6ee3fa4 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 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.tests.util.ServiceTestBase;
import org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec;
import org.junit.Test;
-public class FileConfigurationParserTest extends UnitTestCase
+import java.io.ByteArrayInputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+
+public class FileConfigurationParserTest extends ServiceTestBase
{
/**
* These "InvalidConfigurationTest*.xml" files are modified copies of {@value
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/99147d07/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/HAPolicyConfigurationTest.java
----------------------------------------------------------------------
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 57a7b28..8da767c 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
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/99147d07/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/WrongRoleFileConfigurationParserTest.java
----------------------------------------------------------------------
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 9ec1bc3..d24b5e6 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:<path_to_source>/tests/config/logging.properties
*/
-public class WrongRoleFileConfigurationParserTest extends UnitTestCase
+public class WrongRoleFileConfigurationParserTest extends ServiceTestBase
{
@BeforeClass
public static void prepareLogger()
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/99147d07/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/group/impl/ClusteredResetMockTest.java
----------------------------------------------------------------------
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 7453064..2959eb8 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");
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/99147d07/artemis-server/src/test/java/org/apache/activemq/artemis/core/settings/AddressSettingsTest.java
----------------------------------------------------------------------
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 676aa20..563022c 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()
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/99147d07/artemis-server/src/test/java/org/apache/activemq/artemis/core/settings/RepositoryTest.java
----------------------------------------------------------------------
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 277b26e..97c6544 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<HashSet<Role>> securityRepository;
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/99147d07/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/RemoveFolder.java
----------------------------------------------------------------------
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 e068467..66a41c6 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));
}
}