You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2012/12/06 19:11:32 UTC
svn commit: r1418020 [1/2] - in
/qpid/branches/java-broker-config-qpid-4390/qpid/java:
bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/
broker/src/main/java/org/apache/qpid/server/configuration/plugins/
broker/src/main/java/org/apache/qp...
Author: orudyy
Date: Thu Dec 6 18:11:22 2012
New Revision: 1418020
URL: http://svn.apache.org/viewvc?rev=1418020&view=rev
Log:
QPID-4390: Remove references to ApplicationRegistry from broker unit tests
Added:
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/model/BrokerShutdownTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java
Removed:
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/registry/ApplicationRegistryShutdownTest.java
Modified:
qpid/branches/java-broker-config-qpid-4390/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAMessageStoreTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/AbstractConfiguration.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/AMQChannelTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/ack/AcknowledgeTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/QueueConfigurationTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/VirtualHostConfigurationTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/plugins/AbstractConfigurationTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTestBase.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseActorTestCase.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseConnectionActorTestCase.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/HttpManagementActorTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/ManagementActorTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/QueueActorTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/SubscriptionActorTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ExchangeMessagesTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/BindingLogSubjectTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ChannelLogSubjectTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubjectTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubjectTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubjectTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/QueueLogSubjectTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubjectTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MaxChannelsTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactoryTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AckTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/subscription/QueueBrowserUsesNoAckTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/subscription/SubscriptionFactoryImplTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/transport/ServerSessionTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/VirtualHostImplTest.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAMessageStoreTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAMessageStoreTest.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAMessageStoreTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAMessageStoreTest.java Thu Dec 6 18:11:22 2012
@@ -20,16 +20,17 @@
*/
package org.apache.qpid.server.store.berkeleydb;
+import static org.mockito.Mockito.mock;
+
import java.io.File;
import java.net.InetAddress;
import org.apache.commons.configuration.XMLConfiguration;
-import org.apache.qpid.server.logging.SystemOutMessageLogger;
-import org.apache.qpid.server.logging.actors.CurrentActor;
-import org.apache.qpid.server.logging.actors.TestLogActor;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.util.TestApplicationRegistry;
+import org.apache.qpid.server.configuration.VirtualHostConfiguration;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.util.BrokerTestHelper;
import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
import org.apache.qpid.test.utils.QpidTestCase;
import org.apache.qpid.util.FileUtils;
@@ -50,6 +51,7 @@ public class BDBHAMessageStoreTest exten
private int _masterPort;
private String _host;
private XMLConfiguration _configXml;
+ private VirtualHostRegistry _virtualHostRegistry;
public void setUp() throws Exception
{
@@ -69,6 +71,10 @@ public class BDBHAMessageStoreTest exten
public void tearDown() throws Exception
{
FileUtils.delete(new File(_workDir), true);
+ if (_virtualHostRegistry != null)
+ {
+ _virtualHostRegistry.close();
+ }
super.tearDown();
}
@@ -76,27 +82,20 @@ public class BDBHAMessageStoreTest exten
{
// create virtual host configuration, registry and host instance
addVirtualHostConfiguration();
- TestApplicationRegistry registry = initialize();
- try
- {
- VirtualHost virtualhost = registry.getVirtualHostRegistry().getVirtualHost("test" + _masterPort);
- BDBHAMessageStore store = (BDBHAMessageStore) virtualhost.getMessageStore();
-
- // test whether JVM system settings were applied
- Environment env = store.getEnvironment();
- assertEquals("Unexpected number of cleaner threads", TEST_NUMBER_OF_THREADS, env.getConfig().getConfigParam(EnvironmentConfig.CLEANER_THREADS));
- assertEquals("Unexpected log file max", TEST_LOG_FILE_MAX, env.getConfig().getConfigParam(EnvironmentConfig.LOG_FILE_MAX));
-
- ReplicatedEnvironment repEnv = store.getReplicatedEnvironment();
- assertEquals("Unexpected number of elections primary retries", TEST_ELECTION_RETRIES,
- repEnv.getConfig().getConfigParam(ReplicationConfig.ELECTIONS_PRIMARY_RETRIES));
- assertEquals("Unexpected number of elections primary retries", TEST_ENV_CONSISTENCY_TIMEOUT,
- repEnv.getConfig().getConfigParam(ReplicationConfig.ENV_CONSISTENCY_TIMEOUT));
- }
- finally
- {
- ApplicationRegistry.remove();
- }
+ _virtualHostRegistry = BrokerTestHelper.createVirtualHostRegistry();
+ VirtualHost virtualhost = BrokerTestHelper.createVirtualHost(new VirtualHostConfiguration("test" + _masterPort, _configXml, mock(Broker.class)), _virtualHostRegistry);
+ BDBHAMessageStore store = (BDBHAMessageStore) virtualhost.getMessageStore();
+
+ // test whether JVM system settings were applied
+ Environment env = store.getEnvironment();
+ assertEquals("Unexpected number of cleaner threads", TEST_NUMBER_OF_THREADS, env.getConfig().getConfigParam(EnvironmentConfig.CLEANER_THREADS));
+ assertEquals("Unexpected log file max", TEST_LOG_FILE_MAX, env.getConfig().getConfigParam(EnvironmentConfig.LOG_FILE_MAX));
+
+ ReplicatedEnvironment repEnv = store.getReplicatedEnvironment();
+ assertEquals("Unexpected number of elections primary retries", TEST_ELECTION_RETRIES,
+ repEnv.getConfig().getConfigParam(ReplicationConfig.ELECTIONS_PRIMARY_RETRIES));
+ assertEquals("Unexpected number of elections primary retries", TEST_ENV_CONSISTENCY_TIMEOUT,
+ repEnv.getConfig().getConfigParam(ReplicationConfig.ENV_CONSISTENCY_TIMEOUT));
}
private void addVirtualHostConfiguration() throws Exception
@@ -108,10 +107,8 @@ public class BDBHAMessageStoreTest exten
}
String nodeName = getNodeNameForNodeAt(port);
- String vhostName = "test" + port;
- String vhostPrefix = "virtualhosts.virtualhost." + vhostName;
+ String vhostPrefix = "";
- _configXml.addProperty("virtualhosts.virtualhost.name", vhostName);
_configXml.addProperty(vhostPrefix + ".store.class", BDBHAMessageStore.class.getName());
_configXml.addProperty(vhostPrefix + ".store.environment-path", _workDir + File.separator
+ port);
@@ -153,13 +150,4 @@ public class BDBHAMessageStoreTest exten
}
return _host + ":" + _masterPort;
}
-
- private TestApplicationRegistry initialize() throws Exception
- {
- CurrentActor.set(new TestLogActor(new SystemOutMessageLogger()));
- TestApplicationRegistry registry = new TestApplicationRegistry(_configXml);
- ApplicationRegistry.initialise(registry);
- registry.getVirtualHostRegistry().setDefaultVirtualHostName("test" + _masterPort);
- return registry;
- }
}
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/AbstractConfiguration.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/AbstractConfiguration.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/AbstractConfiguration.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugins/AbstractConfiguration.java Thu Dec 6 18:11:22 2012
@@ -315,7 +315,7 @@ public abstract class AbstractConfigurat
}
}
- public String escapeTagName(String name)
+ public static String escapeTagName(String name)
{
return name.replaceAll("\\.", "\\.\\.");
}
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java Thu Dec 6 18:11:22 2012
@@ -111,9 +111,8 @@ public class AMQProtocolEngine implement
private volatile boolean _closed;
- // XXX remove reference on ServerConfiguration
// maximum number of channels this session should have
- private long _maxNoOfChannels = ApplicationRegistry.getInstance().getConfiguration().getMaxChannelCount();
+ private long _maxNoOfChannels;
/* AMQP Version for this session */
private ProtocolVersion _protocolVersion = ProtocolVersion.getLatestSupportedVersion();
@@ -157,6 +156,8 @@ public class AMQProtocolEngine implement
public AMQProtocolEngine(VirtualHostRegistry virtualHostRegistry, NetworkConnection network, final long connectionId)
{
+ // XXX remove references to ServerConfiguration and ApplicationRegistry
+ _maxNoOfChannels = virtualHostRegistry.getApplicationRegistry().getConfiguration().getMaxChannelCount();
_receivedLock = new ReentrantLock();
_stateManager = new AMQStateManager(virtualHostRegistry, this);
_codecFactory = new AMQCodecFactory(true, this);
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/AMQChannelTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/AMQChannelTest.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/AMQChannelTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/AMQChannelTest.java Thu Dec 6 18:11:22 2012
@@ -36,12 +36,14 @@ import org.apache.qpid.server.exchange.E
import org.apache.qpid.server.message.MessageContentSource;
import org.apache.qpid.server.protocol.AMQProtocolSession;
import org.apache.qpid.server.protocol.InternalTestProtocolSession;
-import org.apache.qpid.server.util.InternalBrokerBaseCase;
+import org.apache.qpid.server.util.BrokerTestHelper;
import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class AMQChannelTest extends InternalBrokerBaseCase
+public class AMQChannelTest extends QpidTestCase
{
+ VirtualHostRegistry _registry;
private VirtualHost _virtualHost;
private AMQProtocolSession _protocolSession;
private Map<Integer,String> _replies;
@@ -50,10 +52,10 @@ public class AMQChannelTest extends Inte
public void setUp() throws Exception
{
super.setUp();
- VirtualHostRegistry registry = getRegistry().getVirtualHostRegistry();
- _virtualHost = registry.getVirtualHosts().iterator().next();
+ _registry = BrokerTestHelper.createVirtualHostRegistry();
+ _virtualHost = BrokerTestHelper.createVirtualHost(getTestName(), _registry);
- _protocolSession = new InternalTestProtocolSession(_virtualHost, registry )
+ _protocolSession = new InternalTestProtocolSession(_virtualHost, _registry )
{
@Override
public void writeReturn(MessagePublishInfo messagePublishInfo,
@@ -69,12 +71,25 @@ public class AMQChannelTest extends Inte
_replies = new HashMap<Integer, String>();
}
+ @Override
+ public void tearDown() throws Exception
+ {
+ try
+ {
+ _registry.close();
+ }
+ finally
+ {
+ super.tearDown();
+ }
+ }
+
public void testCompareTo() throws Exception
{
AMQChannel channel1 = new AMQChannel(_protocolSession, 1, _virtualHost.getMessageStore());
// create a channel with the same channelId but on a different session
- AMQChannel channel2 = new AMQChannel(new InternalTestProtocolSession(_virtualHost, getRegistry().getVirtualHostRegistry()), 1, _virtualHost.getMessageStore());
+ AMQChannel channel2 = new AMQChannel(new InternalTestProtocolSession(_virtualHost, _registry), 1, _virtualHost.getMessageStore());
assertFalse("Unexpected compare result", channel1.compareTo(channel2) == 0);
assertEquals("Unexpected compare result", 0, channel1.compareTo(channel1));
}
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/ack/AcknowledgeTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/ack/AcknowledgeTest.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/ack/AcknowledgeTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/ack/AcknowledgeTest.java Thu Dec 6 18:11:22 2012
@@ -22,14 +22,70 @@ package org.apache.qpid.server.ack;
import org.apache.qpid.AMQException;
+import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.server.AMQChannel;
+import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.protocol.InternalTestProtocolSession;
-import org.apache.qpid.server.util.InternalBrokerBaseCase;
+import org.apache.qpid.server.queue.SimpleAMQQueue;
+import org.apache.qpid.server.store.MessageStore;
+import org.apache.qpid.server.store.TestableMemoryMessageStore;
+import org.apache.qpid.server.util.BrokerTestHelper;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.test.utils.QpidTestCase;
import java.util.List;
-public class AcknowledgeTest extends InternalBrokerBaseCase
+public class AcknowledgeTest extends QpidTestCase
{
+ private AMQChannel _channel;
+ private SimpleAMQQueue _queue;
+ private MessageStore _messageStore;
+ private String _queueName;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ _channel = BrokerTestHelper.createChannel();
+ VirtualHost virtualHost = _channel.getVirtualHost();
+ _queueName = getTestName();
+ _queue = BrokerTestHelper.createQueue(_queueName, virtualHost);
+ _messageStore = virtualHost.getMessageStore();
+ Exchange defaultExchange = virtualHost.getExchangeRegistry().getDefaultExchange();
+ virtualHost.getBindingFactory().addBinding(_queueName, _queue, defaultExchange, null);
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ try
+ {
+ if (_channel != null)
+ {
+ _channel.getVirtualHost().close();
+ }
+ }
+ finally
+ {
+ super.tearDown();
+ }
+ }
+
+ private AMQChannel getChannel()
+ {
+ return _channel;
+ }
+
+ private InternalTestProtocolSession getSession()
+ {
+ return (InternalTestProtocolSession)_channel.getProtocolSession();
+ }
+
+ private SimpleAMQQueue getQueue()
+ {
+ return _queue;
+ }
public void testTransactionalSingleAck() throws AMQException
{
@@ -70,7 +126,7 @@ public class AcknowledgeTest extends Int
checkStoreContents(0);
//Send required messsages to the queue
- publishMessages(getSession(), getChannel(), sendMessageCount);
+ BrokerTestHelper.publishMessages(getChannel(), sendMessageCount, _queueName, ExchangeDefaults.DEFAULT_EXCHANGE_NAME.asString());
if (getChannel().isTransactional())
{
@@ -84,7 +140,7 @@ public class AcknowledgeTest extends Int
assertEquals("Channel should have no unacked msgs ", 0, getChannel().getUnacknowledgedMessageMap().size());
//Subscribe to the queue
- AMQShortString subscriber = subscribe(getSession(), getChannel(), getQueue());
+ AMQShortString subscriber = _channel.subscribeToQueue(null, _queue, true, null, false, true);
getQueue().deliverAsync();
@@ -117,4 +173,9 @@ public class AcknowledgeTest extends Int
checkStoreContents(remainingUnackedMessages);
}
+ private void checkStoreContents(int messageCount)
+ {
+ assertEquals("Message header count incorrect in the MetaDataMap", messageCount, ((TestableMemoryMessageStore) _messageStore).getMessageCount());
+ }
+
}
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/QueueConfigurationTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/QueueConfigurationTest.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/QueueConfigurationTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/QueueConfigurationTest.java Thu Dec 6 18:11:22 2012
@@ -26,8 +26,6 @@ import org.apache.commons.configuration.
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.util.TestApplicationRegistry;
import org.mockito.Mockito;
public class QueueConfigurationTest extends TestCase
@@ -59,31 +57,20 @@ public class QueueConfigurationTest exte
public void testMaxDeliveryCount() throws Exception
{
- try
- {
- ApplicationRegistry registry = new TestApplicationRegistry(_env);
- ApplicationRegistry.initialise(registry);
-
- Mockito.when(_broker.getAttribute(Broker.MAXIMUM_DELIVERY_ATTEMPTS)).thenReturn(0);
-
- // Check default value
- QueueConfiguration qConf = new QueueConfiguration("test", _emptyConf);
- assertEquals("Unexpected default server configuration for max delivery count ", 0, qConf.getMaxDeliveryCount());
-
- // Check explicit value
- VirtualHostConfiguration vhostConfig = overrideConfiguration("maximumDeliveryCount", 7);
- qConf = new QueueConfiguration("test", vhostConfig);
- assertEquals("Unexpected host configuration for max delivery count", 7, qConf.getMaxDeliveryCount());
-
- // Check inherited value
- qConf = new QueueConfiguration("test", _fullHostConf);
- assertEquals("Unexpected queue configuration for max delivery count", 5, qConf.getMaxDeliveryCount());
-
- }
- finally
- {
- ApplicationRegistry.remove();
- }
+ Mockito.when(_broker.getAttribute(Broker.MAXIMUM_DELIVERY_ATTEMPTS)).thenReturn(0);
+
+ // Check default value
+ QueueConfiguration qConf = new QueueConfiguration("test", _emptyConf);
+ assertEquals("Unexpected default server configuration for max delivery count ", 0, qConf.getMaxDeliveryCount());
+
+ // Check explicit value
+ VirtualHostConfiguration vhostConfig = overrideConfiguration("maximumDeliveryCount", 7);
+ qConf = new QueueConfiguration("test", vhostConfig);
+ assertEquals("Unexpected host configuration for max delivery count", 7, qConf.getMaxDeliveryCount());
+
+ // Check inherited value
+ qConf = new QueueConfiguration("test", _fullHostConf);
+ assertEquals("Unexpected queue configuration for max delivery count", 5, qConf.getMaxDeliveryCount());
}
/**
@@ -93,30 +80,20 @@ public class QueueConfigurationTest exte
*/
public void testIsDeadLetterQueueEnabled() throws Exception
{
- try
- {
- ApplicationRegistry registry = new TestApplicationRegistry(_env);
- ApplicationRegistry.initialise(registry);
-
- Mockito.when(_broker.getAttribute(Broker.DEAD_LETTER_QUEUE_ENABLED)).thenReturn(false);
-
- // Check default value
- QueueConfiguration qConf = new QueueConfiguration("test", _emptyConf);
- assertFalse("Unexpected queue configuration for dead letter enabled attribute", qConf.isDeadLetterQueueEnabled());
-
- // Check explicit value
- VirtualHostConfiguration vhostConfig = overrideConfiguration("deadLetterQueues", true);
- qConf = new QueueConfiguration("test", vhostConfig);
- assertTrue("Unexpected queue configuration for dead letter enabled attribute", qConf.isDeadLetterQueueEnabled());
-
- // Check inherited value
- qConf = new QueueConfiguration("test", _fullHostConf);
- assertTrue("Unexpected queue configuration for dead letter enabled attribute", qConf.isDeadLetterQueueEnabled());
- }
- finally
- {
- ApplicationRegistry.remove();
- }
+ Mockito.when(_broker.getAttribute(Broker.DEAD_LETTER_QUEUE_ENABLED)).thenReturn(false);
+
+ // Check default value
+ QueueConfiguration qConf = new QueueConfiguration("test", _emptyConf);
+ assertFalse("Unexpected queue configuration for dead letter enabled attribute", qConf.isDeadLetterQueueEnabled());
+
+ // Check explicit value
+ VirtualHostConfiguration vhostConfig = overrideConfiguration("deadLetterQueues", true);
+ qConf = new QueueConfiguration("test", vhostConfig);
+ assertTrue("Unexpected queue configuration for dead letter enabled attribute", qConf.isDeadLetterQueueEnabled());
+
+ // Check inherited value
+ qConf = new QueueConfiguration("test", _fullHostConf);
+ assertTrue("Unexpected queue configuration for dead letter enabled attribute", qConf.isDeadLetterQueueEnabled());
}
public void testGetMaximumMessageAge() throws ConfigurationException
@@ -186,30 +163,20 @@ public class QueueConfigurationTest exte
public void testGetMinimumAlertRepeatGap() throws Exception
{
- try
- {
- ApplicationRegistry registry = new TestApplicationRegistry(_env);
- ApplicationRegistry.initialise(registry);
-
- Mockito.when(_broker.getAttribute(Broker.ALERT_REPEAT_GAP)).thenReturn(ServerConfiguration.DEFAULT_MINIMUM_ALERT_REPEAT_GAP);
-
- // Check default value
- QueueConfiguration qConf = new QueueConfiguration("test", _emptyConf);
- assertEquals(ServerConfiguration.DEFAULT_MINIMUM_ALERT_REPEAT_GAP, qConf.getMinimumAlertRepeatGap());
-
- // Check explicit value
- VirtualHostConfiguration vhostConfig = overrideConfiguration("minimumAlertRepeatGap", 2);
- qConf = new QueueConfiguration("test", vhostConfig);
- assertEquals(2, qConf.getMinimumAlertRepeatGap());
-
- // Check inherited value
- qConf = new QueueConfiguration("test", _fullHostConf);
- assertEquals(1, qConf.getMinimumAlertRepeatGap());
- }
- finally
- {
- ApplicationRegistry.remove();
- }
+ Mockito.when(_broker.getAttribute(Broker.ALERT_REPEAT_GAP)).thenReturn(ServerConfiguration.DEFAULT_MINIMUM_ALERT_REPEAT_GAP);
+
+ // Check default value
+ QueueConfiguration qConf = new QueueConfiguration("test", _emptyConf);
+ assertEquals(ServerConfiguration.DEFAULT_MINIMUM_ALERT_REPEAT_GAP, qConf.getMinimumAlertRepeatGap());
+
+ // Check explicit value
+ VirtualHostConfiguration vhostConfig = overrideConfiguration("minimumAlertRepeatGap", 2);
+ qConf = new QueueConfiguration("test", vhostConfig);
+ assertEquals(2, qConf.getMinimumAlertRepeatGap());
+
+ // Check inherited value
+ qConf = new QueueConfiguration("test", _fullHostConf);
+ assertEquals(1, qConf.getMinimumAlertRepeatGap());
}
public void testSortQueueConfiguration() throws ConfigurationException
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java Thu Dec 6 18:11:22 2012
@@ -24,11 +24,14 @@ import org.apache.commons.configuration.
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.server.configuration.startup.DefaultRecovererProvider;
import org.apache.qpid.server.configuration.store.XMLConfigurationEntryStore;
import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.State;
import org.apache.qpid.server.protocol.AmqpProtocolVersion;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.util.TestApplicationRegistry;
+import org.apache.qpid.server.util.BrokerTestHelper;
import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
import org.apache.qpid.test.utils.QpidTestCase;
@@ -39,6 +42,7 @@ import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
+import java.util.Collection;
import javax.net.ssl.KeyManagerFactory;
@@ -52,14 +56,12 @@ public class ServerConfigurationTest ext
{
super.setUp();
_serverConfig = new ServerConfiguration(_config);
- ApplicationRegistry.initialise(new TestApplicationRegistry(_config));
}
@Override
protected void tearDown() throws Exception
{
super.tearDown();
- ApplicationRegistry.remove();
}
public void testSetJMXPortRegistryServer() throws ConfigurationException
@@ -818,15 +820,8 @@ public class ServerConfigurationTest ext
writeConfigFile(mainFile, false, true, null, "test");
// Load config
- ApplicationRegistry.remove();
-
- ConfigurationEntryStore store = new XMLConfigurationEntryStore(mainFile);
- ApplicationRegistry reg = new ApplicationRegistry(store);
- ApplicationRegistry.initialise(reg);
-
- // Test config
- VirtualHostRegistry virtualHostRegistry = reg.getVirtualHostRegistry();
- String defaultVirtualHost = reg.getConfiguration().getDefaultVirtualHost();
+ VirtualHostRegistry virtualHostRegistry = loadConfigurationAndReturnVirtualHostRegistry(mainFile);
+ String defaultVirtualHost = virtualHostRegistry.getDefaultVirtualHost().getName();
VirtualHost virtualHost = virtualHostRegistry.getVirtualHost("test");
Exchange exchange = virtualHost.getExchangeRegistry().getExchange(new AMQShortString("test.topic"));
@@ -835,6 +830,26 @@ public class ServerConfigurationTest ext
assertEquals("Incorrect virtualhost name", "test", virtualHost.getName());
assertEquals("Incorrect exchange type", "topic", exchange.getType().getName().toString());
}
+
+ private VirtualHostRegistry loadConfigurationAndReturnVirtualHostRegistry(File mainFile) throws ConfigurationException, Exception
+ {
+ VirtualHostRegistry virtualHostRegistry = BrokerTestHelper.createVirtualHostRegistry();
+
+ // load configuration with recoverer
+ ConfigurationEntryStore store = new XMLConfigurationEntryStore(mainFile);
+ RecovererProvider provider = new DefaultRecovererProvider(virtualHostRegistry.getApplicationRegistry());
+ ConfiguredObjectRecoverer<? extends ConfiguredObject> brokerRecoverer = provider.getRecoverer(Broker.class.getSimpleName());
+ Broker broker = (Broker) brokerRecoverer.create(provider, store.getRootEntry());
+ virtualHostRegistry.setDefaultVirtualHostName((String)broker.getAttribute(Broker.DEFAULT_VIRTUAL_HOST));
+
+ // start hosts - this will create VirtualHostImpl
+ Collection<org.apache.qpid.server.model.VirtualHost> hosts = broker.getVirtualHosts();
+ for (org.apache.qpid.server.model.VirtualHost virtualHost : hosts)
+ {
+ virtualHost.setDesiredState(State.INITIALISING, State.ACTIVE);
+ }
+ return virtualHostRegistry;
+ }
/**
* Test that configuration loads correctly when virtual hosts are specified in an external
@@ -852,15 +867,8 @@ public class ServerConfigurationTest ext
writeConfigFile(mainFile, false, false, vhostsFile, null);
writeVirtualHostsFile(vhostsFile, "test");
- // Load config
- ApplicationRegistry.remove();
- ConfigurationEntryStore store = new XMLConfigurationEntryStore(mainFile);
- ApplicationRegistry reg = new ApplicationRegistry(store);
- ApplicationRegistry.initialise(reg);
-
- // Test config
- VirtualHostRegistry virtualHostRegistry = reg.getVirtualHostRegistry();
- String defaultVirtualHost = reg.getConfiguration().getDefaultVirtualHost();
+ VirtualHostRegistry virtualHostRegistry = loadConfigurationAndReturnVirtualHostRegistry(mainFile);
+ String defaultVirtualHost = virtualHostRegistry.getDefaultVirtualHost().getName();
VirtualHost virtualHost = virtualHostRegistry.getVirtualHost("test");
Exchange exchange = virtualHost.getExchangeRegistry().getExchange(new AMQShortString("test.topic"));
@@ -888,14 +896,7 @@ public class ServerConfigurationTest ext
mainFile.deleteOnExit();
writeConfigFile(mainFile, false, false, vhostsFile, null);
- // Load config
- ApplicationRegistry.remove();
- ConfigurationEntryStore store = new XMLConfigurationEntryStore(mainFile);
- ApplicationRegistry reg = new ApplicationRegistry(store);
- ApplicationRegistry.initialise(reg);
-
- // Test config
- VirtualHostRegistry virtualHostRegistry = reg.getVirtualHostRegistry();
+ VirtualHostRegistry virtualHostRegistry = loadConfigurationAndReturnVirtualHostRegistry(mainFile);
assertEquals("Incorrect virtualhost count", 2, virtualHostRegistry.getVirtualHosts().size());
@@ -935,10 +936,7 @@ public class ServerConfigurationTest ext
// Load config
try
{
- ApplicationRegistry.remove();
- ConfigurationEntryStore store = new XMLConfigurationEntryStore(mainFile);
- ApplicationRegistry reg = new ApplicationRegistry(store);
- ApplicationRegistry.initialise(reg);
+ loadConfigurationAndReturnVirtualHostRegistry(mainFile);
fail("Different virtualhost XML configurations not allowed");
}
catch (ConfigurationException ce)
@@ -971,10 +969,7 @@ public class ServerConfigurationTest ext
// Load config
try
{
- ApplicationRegistry.remove();
- ConfigurationEntryStore store = new XMLConfigurationEntryStore(mainFile);
- ApplicationRegistry reg = new ApplicationRegistry(store);
- ApplicationRegistry.initialise(reg);
+ loadConfigurationAndReturnVirtualHostRegistry(mainFile);
fail("Multiple virtualhost XML configurations not allowed");
}
catch (ConfigurationException ce)
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/VirtualHostConfigurationTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/VirtualHostConfigurationTest.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/VirtualHostConfigurationTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/VirtualHostConfigurationTest.java Thu Dec 6 18:11:22 2012
@@ -19,23 +19,69 @@
*/
package org.apache.qpid.server.configuration;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.XMLConfiguration;
import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.queue.AMQPriorityQueue;
import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.security.auth.manager.TestAuthenticationManagerFactory;
import org.apache.qpid.server.store.TestableMemoryMessageStore;
-import org.apache.qpid.server.util.InternalBrokerBaseCase;
+import org.apache.qpid.server.util.BrokerTestHelper;
import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class VirtualHostConfigurationTest extends InternalBrokerBaseCase
+public class VirtualHostConfigurationTest extends QpidTestCase
{
+ private VirtualHostRegistry _virtualHostRegistry;
+ private XMLConfiguration _configXml;
+ private Broker _broker;
@Override
- public void createBroker()
+ public void setUp() throws Exception
{
- // Prevent auto broker startup
+ super.setUp();
+ _configXml = new XMLConfiguration();
+ _configXml.addProperty("security." + TestAuthenticationManagerFactory.TEST_AUTH_MANAGER_MARKER, "");
+ _configXml.addProperty("virtualhosts.virtualhost(-1).name", getName());
+ _configXml.addProperty("virtualhosts.virtualhost(-1)."+getName()+".store.class", TestableMemoryMessageStore.class.getName());
+ _virtualHostRegistry = BrokerTestHelper.createVirtualHostRegistry();
+ _broker = mock(Broker.class);
+ when(_broker.getAttribute(Broker.HOUSEKEEPING_CHECK_PERIOD)).thenReturn(1);
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ try
+ {
+ if (_virtualHostRegistry != null)
+ {
+ _virtualHostRegistry.close();
+ }
+ }
+ finally
+ {
+ super.tearDown();
+ }
+ }
+
+ private XMLConfiguration getConfigXml()
+ {
+ return _configXml;
+ }
+
+ private VirtualHost createVirtualHost(String hostName) throws Exception
+ {
+ Configuration config = getConfigXml().subset("virtualhosts.virtualhost." + VirtualHostConfiguration.escapeTagName(hostName));
+ VirtualHostConfiguration virtualHostConfiguration = new VirtualHostConfiguration(hostName, config, _broker);
+ return BrokerTestHelper.createVirtualHost(virtualHostConfiguration, _virtualHostRegistry);
}
public void testQueuePriority() throws Exception
@@ -64,10 +110,7 @@ public class VirtualHostConfigurationTes
getConfigXml().addProperty("virtualhosts.virtualhost.testQueuePriority.queues.queue.ntest.priority",
"false");
- // Start the broker now.
- super.createBroker();
-
- VirtualHost vhost = getRegistry().getVirtualHostRegistry().getVirtualHost(getName());
+ VirtualHost vhost = createVirtualHost(getName());
// Check that atest was a priority queue with 5 priorities
AMQQueue atest = vhost.getQueueRegistry().getQueue(new AMQShortString("atest"));
@@ -100,10 +143,7 @@ public class VirtualHostConfigurationTes
getConfigXml().addProperty("virtualhosts.virtualhost.testQueueAlerts.queues(-1).queue(-1).name(-1)", "btest");
- // Start the broker now.
- super.createBroker();
-
- VirtualHost vhost = getRegistry().getVirtualHostRegistry().getVirtualHost(getName());
+ VirtualHost vhost = createVirtualHost(getName());
// Check specifically configured values
AMQQueue aTest = vhost.getQueueRegistry().getQueue(new AMQShortString("atest"));
@@ -126,11 +166,7 @@ public class VirtualHostConfigurationTes
getConfigXml().addProperty("virtualhosts.virtualhost." + getName() + ".queues.queue.biggles.maximumDeliveryCount", 4);
getConfigXml().addProperty("virtualhosts.virtualhost." + getName() + ".queues(-1).queue(-1).name", "beetle");
- // Start the broker now.
- super.createBroker();
-
- // Get vhosts
- VirtualHost test = getRegistry().getVirtualHostRegistry().getVirtualHost(getName());
+ VirtualHost test = createVirtualHost(getName());
// Enabled specifically
assertEquals("Test vhost MDC was configured as enabled", 5 ,test.getConfiguration().getMaxDeliveryCount());
@@ -160,12 +196,8 @@ public class VirtualHostConfigurationTes
getConfigXml().addProperty("virtualhosts.virtualhost." + getName() + "Extra.queues(-1).queue(-1).name", "c3p0");
getConfigXml().addProperty("virtualhosts.virtualhost." + getName() + "Extra.store.class", TestableMemoryMessageStore.class.getName());
- // Start the broker now.
- super.createBroker();
-
- // Get vhosts
- VirtualHost test = getRegistry().getVirtualHostRegistry().getVirtualHost(getName());
- VirtualHost extra = getRegistry().getVirtualHostRegistry().getVirtualHost(getName() + "Extra");
+ VirtualHost test = createVirtualHost(getName());
+ VirtualHost extra = createVirtualHost(getName() + "Extra");
// Enabled specifically
assertTrue("Test vhost DLQ was configured as enabled", test.getConfiguration().isDeadLetterQueueEnabled());
@@ -212,10 +244,7 @@ public class VirtualHostConfigurationTes
getConfigXml().addProperty("virtualhosts.virtualhost.testHouseKeepingThreadCount.housekeeping.poolSize",
initialPoolSize);
- // Start the broker now.
- super.createBroker();
-
- VirtualHost vhost = getRegistry().getVirtualHostRegistry().getVirtualHost(getName());
+ VirtualHost vhost = createVirtualHost(getName());
assertEquals("HouseKeeping PoolSize not set correctly.",
initialPoolSize, vhost.getHouseKeepingPoolSize());
@@ -228,10 +257,7 @@ public class VirtualHostConfigurationTes
*/
public void testDefaultHouseKeepingTasks() throws Exception
{
- // Start the broker now.
- super.createBroker();
-
- VirtualHost vhost = getRegistry().getVirtualHostRegistry().getVirtualHost(getName());
+ VirtualHost vhost = createVirtualHost(getName());
assertEquals("Default houseKeeping task count incorrect.", 1,
vhost.getHouseKeepingTaskCount());
@@ -252,10 +278,7 @@ public class VirtualHostConfigurationTes
getConfigXml().addProperty("virtualhosts.virtualhost.testDynamicHouseKeepingPoolSizeChange.housekeeping.poolSize",
initialPoolSize);
- // Start the broker now.
- super.createBroker();
-
- VirtualHost vhost = getRegistry().getVirtualHostRegistry().getVirtualHost(getName());
+ VirtualHost vhost = createVirtualHost(getName());
assertEquals("HouseKeeping PoolSize not set correctly.",
initialPoolSize, vhost.getHouseKeepingPoolSize());
@@ -279,7 +302,7 @@ public class VirtualHostConfigurationTes
try
{
- super.createBroker();
+ createVirtualHost(getName());
fail("Exception not thrown");
}
catch(ConfigurationException ce)
@@ -302,7 +325,7 @@ public class VirtualHostConfigurationTes
try
{
- super.createBroker();
+ createVirtualHost(getName());
fail("Exception not thrown");
}
catch (ConfigurationException ce)
@@ -326,11 +349,7 @@ public class VirtualHostConfigurationTes
// Add a single property which is inside the <dot.in.a.name> queue tag - the maximum delivery count
getConfigXml().addProperty("virtualhosts.virtualhost." + getName() + ".queues.queue.dot..in..a..name.maximumDeliveryCount", 5);
- // Start the broker now.
- super.createBroker();
-
- // Get vhosts
- VirtualHost test = getRegistry().getVirtualHostRegistry().getVirtualHost(getName());
+ VirtualHost test = createVirtualHost(getName());
// Check, that the property stored within the <dot.in.a.name> tag has been properly loaded
assertEquals("queue with dots in its name has been properly loaded", 5, test.getConfiguration().getQueueConfiguration("dot.in.a.name").getMaxDeliveryCount());
@@ -349,11 +368,7 @@ public class VirtualHostConfigurationTes
// Add a single property which is inside the <dot.in.a.name> virtual host tag - the message store
getConfigXml().addProperty("virtualhosts.virtualhost.dot..in..a..name.store.class", TestableMemoryMessageStore.class.getName());
- // Start the broker now.
- super.createBroker();
-
- // Get vhosts
- VirtualHost test = getRegistry().getVirtualHostRegistry().getVirtualHost("dot.in.a.name");
+ VirtualHost test = createVirtualHost("dot.in.a.name");
// Check, that the property stored within the <dot.in.a.name> tag has been properly loaded
assertEquals("virtual host with dots in the name has been properly loaded", TestableMemoryMessageStore.class.getName(), test.getMessageStore().getClass().getName());
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/plugins/AbstractConfigurationTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/plugins/AbstractConfigurationTest.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/plugins/AbstractConfigurationTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/plugins/AbstractConfigurationTest.java Thu Dec 6 18:11:22 2012
@@ -24,7 +24,7 @@ import org.apache.commons.configuration.
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
-import org.apache.qpid.server.util.InternalBrokerBaseCase;
+import org.apache.qpid.test.utils.QpidTestCase;
import java.util.List;
@@ -32,7 +32,7 @@ import java.util.List;
* Test that verifies that given a Configuration a ConfigurationPlugin can
* process and validate that data.
*/
-public class AbstractConfigurationTest extends InternalBrokerBaseCase
+public class AbstractConfigurationTest extends QpidTestCase
{
private static final double DOUBLE = 3.14;
private static final long POSITIVE_LONG = 1000;
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTestBase.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTestBase.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTestBase.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTestBase.java Thu Dec 6 18:11:22 2012
@@ -53,20 +53,48 @@ import org.apache.qpid.server.queue.Inco
import org.apache.qpid.server.queue.MockStoredMessage;
import org.apache.qpid.server.queue.QueueEntry;
import org.apache.qpid.server.queue.SimpleAMQQueue;
-import org.apache.qpid.server.registry.IApplicationRegistry;
import org.apache.qpid.server.store.StoredMessage;
import org.apache.qpid.server.subscription.Subscription;
-import org.apache.qpid.server.util.InternalBrokerBaseCase;
+import org.apache.qpid.server.util.BrokerTestHelper;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class AbstractHeadersExchangeTestBase extends InternalBrokerBaseCase
+public class AbstractHeadersExchangeTestBase extends QpidTestCase
{
private static final Logger _log = Logger.getLogger(AbstractHeadersExchangeTestBase.class);
private final HeadersExchange exchange = new HeadersExchange();
protected final Set<TestQueue> queues = new HashSet<TestQueue>();
-
+ protected VirtualHost _virtualHost;
+ protected VirtualHostRegistry _virtualHostRegistry;
private int count;
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ _virtualHostRegistry = BrokerTestHelper.createVirtualHostRegistry();
+ _virtualHost = BrokerTestHelper.createVirtualHost(getClass().getName(), _virtualHostRegistry);
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ try
+ {
+ if (_virtualHostRegistry != null)
+ {
+ _virtualHostRegistry.close();
+ }
+ }
+ finally
+ {
+ super.tearDown();
+ }
+ }
+
public void testDoNothing()
{
// this is here only to make junit under Eclipse happy
@@ -92,7 +120,7 @@ public class AbstractHeadersExchangeTest
private TestQueue bind(String key, String queueName, Map<String,Object> args) throws AMQException
{
- TestQueue queue = new TestQueue(new AMQShortString(queueName), getRegistry());
+ TestQueue queue = new TestQueue(new AMQShortString(queueName), _virtualHost);
queues.add(queue);
exchange.onBind(new Binding(null, key, queue, exchange, args));
return queue;
@@ -273,10 +301,10 @@ public class AbstractHeadersExchangeTest
return getNameShortString().toString();
}
- public TestQueue(AMQShortString name, IApplicationRegistry registry) throws AMQException
+ public TestQueue(AMQShortString name, VirtualHost host) throws AMQException
{
- super(UUIDGenerator.generateRandomUUID(), name, false, new AMQShortString("test"), true, false, registry.getVirtualHostRegistry().getVirtualHost("test"), Collections.EMPTY_MAP);
- registry.getVirtualHostRegistry().getVirtualHost("test").getQueueRegistry().registerQueue(this);
+ super(UUIDGenerator.generateRandomUUID(), name, false, new AMQShortString("test"), true, false, host, Collections.EMPTY_MAP);
+ host.getQueueRegistry().registerQueue(this);
}
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java Thu Dec 6 18:11:22 2012
@@ -23,8 +23,6 @@ package org.apache.qpid.server.exchange;
import org.apache.qpid.AMQException;
import org.apache.qpid.server.protocol.AMQProtocolSession;
import org.apache.qpid.server.protocol.InternalTestProtocolSession;
-import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
public class HeadersExchangeTest extends AbstractHeadersExchangeTestBase
{
@@ -34,10 +32,8 @@ public class HeadersExchangeTest extends
public void setUp() throws Exception
{
super.setUp();
- // Just use the first vhost.
- VirtualHostRegistry registry = getRegistry().getVirtualHostRegistry();
- VirtualHost virtualHost = registry.getVirtualHosts().iterator().next();
- _protocolSession = new InternalTestProtocolSession(virtualHost, registry);
+
+ _protocolSession = new InternalTestProtocolSession(_virtualHost, _virtualHostRegistry);
}
public void testSimple() throws AMQException
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/TopicExchangeTest.java Thu Dec 6 18:11:22 2012
@@ -31,18 +31,18 @@ import org.apache.qpid.server.binding.Bi
import org.apache.qpid.server.message.AMQMessage;
import org.apache.qpid.server.message.MessageMetaData;
import org.apache.qpid.server.model.UUIDGenerator;
-import org.apache.qpid.server.protocol.InternalTestProtocolSession;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.AMQQueueFactory;
import org.apache.qpid.server.queue.BaseQueue;
import org.apache.qpid.server.queue.IncomingMessage;
import org.apache.qpid.server.store.MemoryMessageStore;
import org.apache.qpid.server.store.MessageStore;
-import org.apache.qpid.server.util.InternalBrokerBaseCase;
+import org.apache.qpid.server.util.BrokerTestHelper;
import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class TopicExchangeTest extends InternalBrokerBaseCase
+public class TopicExchangeTest extends QpidTestCase
{
private TopicExchange _exchange;
@@ -50,18 +50,31 @@ public class TopicExchangeTest extends I
private VirtualHost _vhost;
private MessageStore _store;
- private InternalTestProtocolSession _protocolSession;
-
@Override
public void setUp() throws Exception
{
super.setUp();
_exchange = new TopicExchange();
- VirtualHostRegistry registry = getRegistry().getVirtualHostRegistry();
- _vhost = registry.getVirtualHosts().iterator().next();
+ VirtualHostRegistry registry = BrokerTestHelper.createVirtualHostRegistry();
+ _vhost = BrokerTestHelper.createVirtualHost(getName(), registry);
_store = new MemoryMessageStore();
- _protocolSession = new InternalTestProtocolSession(_vhost, registry);
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ try
+ {
+ if (_vhost != null)
+ {
+ _vhost.close();
+ }
+ }
+ finally
+ {
+ super.tearDown();
+ }
}
public void testNoRoute() throws AMQException
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java Thu Dec 6 18:11:22 2012
@@ -20,7 +20,8 @@
*/
package org.apache.qpid.server.logging.actors;
-import org.apache.qpid.server.configuration.BrokerProperties;
+import org.apache.qpid.server.AMQChannel;
+import org.apache.qpid.server.util.BrokerTestHelper;
import java.util.List;
@@ -35,17 +36,18 @@ import java.util.List;
*/
public class AMQPChannelActorTest extends BaseConnectionActorTestCase
{
- @Override
- public void createBroker() throws Exception
+
+ public void setUp()
{
- //prevent auto-broker startup
+ // do nothing
}
- private void startBrokerNow() throws Exception
+ private void setUpNow() throws Exception
{
- super.createBroker();
+ super.setUp();
+ AMQChannel channel = BrokerTestHelper.createChannel(1, _session);
- _amqpActor = new AMQPChannelActor(getChannel(), _rootLogger);
+ _amqpActor = new AMQPChannelActor(channel, _rootLogger);
}
@@ -58,7 +60,7 @@ public class AMQPChannelActorTest extend
*/
public void testChannel() throws Exception
{
- startBrokerNow();
+ setUpNow();
final String message = sendTestLogMessage(_amqpActor);
@@ -91,10 +93,9 @@ public class AMQPChannelActorTest extend
*/
public void testChannelLoggingOFF() throws Exception
{
- setTestSystemProperty(BrokerProperties.PROPERTY_STATUS_UPDATES, "false");
+ _statusUpdatesEnabled = false;
- // Start the broker now.
- startBrokerNow();
+ setUpNow();
sendTestLogMessage(_amqpActor);
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java Thu Dec 6 18:11:22 2012
@@ -21,7 +21,6 @@
package org.apache.qpid.server.logging.actors;
import org.apache.qpid.AMQException;
-import org.apache.qpid.server.configuration.BrokerProperties;
import org.apache.qpid.server.logging.LogMessage;
import org.apache.qpid.server.logging.LogSubject;
@@ -39,9 +38,9 @@ import java.util.List;
public class AMQPConnectionActorTest extends BaseConnectionActorTestCase
{
@Override
- public void createBroker()
+ public void setUp()
{
- //Prevent auto-broker startup
+ //Prevent logger creation
}
/**
@@ -54,7 +53,7 @@ public class AMQPConnectionActorTest ext
*/
public void testConnection() throws Exception
{
- super.createBroker();
+ super.setUp();
final String message = sendLogMessage();
@@ -82,10 +81,9 @@ public class AMQPConnectionActorTest ext
public void testConnectionLoggingOff() throws Exception, AMQException
{
- setTestSystemProperty(BrokerProperties.PROPERTY_STATUS_UPDATES, "false");
+ _statusUpdatesEnabled = false;
- // Start the broker now.
- super.createBroker();
+ super.setUp();
sendLogMessage();
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseActorTestCase.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseActorTestCase.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseActorTestCase.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseActorTestCase.java Thu Dec 6 18:11:22 2012
@@ -25,30 +25,34 @@ import org.apache.qpid.server.logging.Lo
import org.apache.qpid.server.logging.LogSubject;
import org.apache.qpid.server.logging.RootMessageLogger;
import org.apache.qpid.server.logging.UnitTestMessageLogger;
-import org.apache.qpid.server.util.InternalBrokerBaseCase;
+import org.apache.qpid.test.utils.QpidTestCase;
-public class BaseActorTestCase extends InternalBrokerBaseCase
+public class BaseActorTestCase extends QpidTestCase
{
+ protected boolean _statusUpdatesEnabled = true;
protected LogActor _amqpActor;
protected UnitTestMessageLogger _rawLogger;
protected RootMessageLogger _rootLogger;
@Override
- public void createBroker() throws Exception
+ public void setUp() throws Exception
{
- super.createBroker();
-
- _rawLogger = new UnitTestMessageLogger(getRegistry().getRootMessageLogger().isEnabled());
+ super.setUp();
+ CurrentActor.removeAll();
+ CurrentActor.setDefault(null);
+ _rawLogger = new UnitTestMessageLogger(_statusUpdatesEnabled);
_rootLogger = _rawLogger;
}
+ @Override
public void tearDown() throws Exception
{
if(_rawLogger != null)
{
_rawLogger.clearLogMessages();
}
-
+ CurrentActor.removeAll();
+ CurrentActor.setDefault(null);
super.tearDown();
}
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseConnectionActorTestCase.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseConnectionActorTestCase.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseConnectionActorTestCase.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/BaseConnectionActorTestCase.java Thu Dec 6 18:11:22 2012
@@ -20,13 +20,35 @@
*/
package org.apache.qpid.server.logging.actors;
+import org.apache.qpid.server.protocol.AMQProtocolSession;
+import org.apache.qpid.server.util.BrokerTestHelper;
+
public class BaseConnectionActorTestCase extends BaseActorTestCase
{
+ protected AMQProtocolSession _session;
+
@Override
- public void createBroker() throws Exception
+ public void setUp() throws Exception
{
- super.createBroker();
+ super.setUp();
+
+ _session = BrokerTestHelper.createSession();
+ _amqpActor = new AMQPConnectionActor(_session, _rootLogger);
+ }
- _amqpActor = new AMQPConnectionActor(getSession(), _rootLogger);
+ @Override
+ public void tearDown() throws Exception
+ {
+ try
+ {
+ if (_session != null)
+ {
+ _session.getVirtualHost().close();
+ }
+ }
+ finally
+ {
+ super.tearDown();
+ }
}
}
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java Thu Dec 6 18:11:22 2012
@@ -70,13 +70,8 @@ public class CurrentActorTest extends Ba
*/
public void testLIFO() throws AMQException, ConfigurationException
{
- // This test only needs the local objects created, _session etc.
- // So stopping the broker and making them useless will not affect the
- // test, but the extra actors the test broker adds will so by stopping
- // we remove the session actor and so all is good.
- stopBroker();
-
- AMQPConnectionActor connectionActor = new AMQPConnectionActor(getSession(),
+ assertTrue("Unexpected actor: " + CurrentActor.get(), CurrentActor.get() instanceof TestLogActor);
+ AMQPConnectionActor connectionActor = new AMQPConnectionActor(_session,
new NullRootMessageLogger());
/*
@@ -103,7 +98,7 @@ public class CurrentActorTest extends Ba
*
*/
- AMQChannel channel = new AMQChannel(getSession(), 1, getSession().getVirtualHost().getMessageStore());
+ AMQChannel channel = new AMQChannel(_session, 1, _session.getVirtualHost().getMessageStore());
AMQPChannelActor channelActor = new AMQPChannelActor(channel,
new NullRootMessageLogger());
@@ -219,7 +214,7 @@ public class CurrentActorTest extends Ba
{
LogActor defaultActor = CurrentActor.get();
- AMQPConnectionActor actor = new AMQPConnectionActor(getSession(),
+ AMQPConnectionActor actor = new AMQPConnectionActor(_session,
new NullRootMessageLogger());
CurrentActor.set(actor);
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/HttpManagementActorTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/HttpManagementActorTest.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/HttpManagementActorTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/HttpManagementActorTest.java Thu Dec 6 18:11:22 2012
@@ -34,9 +34,9 @@ public class HttpManagementActorTest ext
private static final String SUFFIX = "(" + IP + ":" + PORT + ")] ";
@Override
- public void createBroker() throws Exception
+ public void setUp() throws Exception
{
- super.createBroker();
+ super.setUp();
_amqpActor = new HttpManagementActor(_rootLogger, IP, PORT);
}
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/ManagementActorTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/ManagementActorTest.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/ManagementActorTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/ManagementActorTest.java Thu Dec 6 18:11:22 2012
@@ -35,9 +35,9 @@ public class ManagementActorTest extends
private String _threadName;
@Override
- public void createBroker() throws Exception
+ public void setUp() throws Exception
{
- super.createBroker();
+ super.setUp();
_amqpActor = new ManagementActor(_rootLogger);
// Set the thread name to be the same as a RMI JMX Connection would use
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/QueueActorTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/QueueActorTest.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/QueueActorTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/QueueActorTest.java Thu Dec 6 18:11:22 2012
@@ -22,14 +22,16 @@ package org.apache.qpid.server.logging.a
import java.util.List;
+import org.apache.qpid.server.util.BrokerTestHelper;
+
public class QueueActorTest extends BaseConnectionActorTestCase
{
@Override
- public void createBroker() throws Exception
+ public void setUp() throws Exception
{
- super.createBroker();
- _amqpActor = new QueueActor(getQueue(), _rootLogger);
+ super.setUp();
+ _amqpActor = new QueueActor(BrokerTestHelper.createQueue(getName(), _session.getVirtualHost()), _rootLogger);
}
/**
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/SubscriptionActorTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/SubscriptionActorTest.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/SubscriptionActorTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/SubscriptionActorTest.java Thu Dec 6 18:11:22 2012
@@ -21,6 +21,7 @@
package org.apache.qpid.server.logging.actors;
import org.apache.qpid.server.subscription.MockSubscription;
+import org.apache.qpid.server.util.BrokerTestHelper;
import java.util.List;
@@ -37,13 +38,13 @@ public class SubscriptionActorTest exten
{
@Override
- public void createBroker() throws Exception
+ public void setUp() throws Exception
{
- super.createBroker();
+ super.setUp();
MockSubscription mockSubscription = new MockSubscription();
- mockSubscription.setQueue(getQueue(), false);
+ mockSubscription.setQueue(BrokerTestHelper.createQueue(getName(), _session.getVirtualHost()), false);
_amqpActor = new SubscriptionActor(_rootLogger, mockSubscription);
}
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java Thu Dec 6 18:11:22 2012
@@ -29,11 +29,11 @@ import org.apache.qpid.server.logging.Lo
import org.apache.qpid.server.logging.UnitTestMessageLogger;
import org.apache.qpid.server.logging.actors.TestLogActor;
import org.apache.qpid.server.logging.subjects.TestBlankSubject;
-import org.apache.qpid.server.util.InternalBrokerBaseCase;
+import org.apache.qpid.test.utils.QpidTestCase;
import java.util.List;
-public abstract class AbstractTestMessages extends InternalBrokerBaseCase
+public abstract class AbstractTestMessages extends QpidTestCase
{
protected Configuration _config = new PropertiesConfiguration();
protected LogMessage _logMessage = null;
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ExchangeMessagesTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ExchangeMessagesTest.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ExchangeMessagesTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ExchangeMessagesTest.java Thu Dec 6 18:11:22 2012
@@ -21,7 +21,7 @@
package org.apache.qpid.server.logging.messages;
import org.apache.qpid.server.exchange.Exchange;
-import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.server.util.BrokerTestHelper;
import java.util.List;
@@ -30,12 +30,9 @@ import java.util.List;
*/
public class ExchangeMessagesTest extends AbstractTestMessages
{
- public void testExchangeCreated_Transient()
+ public void testExchangeCreated_Transient() throws Exception
{
- // Get the Default Exchange on the Test Vhost for testing
- Exchange exchange = getRegistry().
- getVirtualHostRegistry().getVirtualHost("test").
- getExchangeRegistry().getDefaultExchange();
+ Exchange exchange = BrokerTestHelper.createExchange("test");
String type = exchange.getTypeShortString().toString();
String name = exchange.getNameShortString().toString();
@@ -48,12 +45,9 @@ public class ExchangeMessagesTest extend
validateLogMessage(log, "EXH-1001", expected);
}
- public void testExchangeCreated_Persistent()
+ public void testExchangeCreated_Persistent() throws Exception
{
- // Get the Default Exchange on the Test Vhost for testing
- Exchange exchange = getRegistry().
- getVirtualHostRegistry().getVirtualHost("test").
- getExchangeRegistry().getDefaultExchange();
+ Exchange exchange = BrokerTestHelper.createExchange("test");
String type = exchange.getTypeShortString().toString();
String name = exchange.getNameShortString().toString();
@@ -76,12 +70,9 @@ public class ExchangeMessagesTest extend
validateLogMessage(log, "EXH-1002", expected);
}
- public void testExchangeDiscardedMessage()
+ public void testExchangeDiscardedMessage() throws Exception
{
- // Get the Default Exchange on the Test Vhost for testing
- final Exchange exchange = getRegistry().
- getVirtualHostRegistry().getVirtualHost("test").
- getExchangeRegistry().getDefaultExchange();
+ Exchange exchange = BrokerTestHelper.createExchange("test");
final String name = exchange.getNameShortString().toString();
final String routingKey = "routingKey";
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java Thu Dec 6 18:11:22 2012
@@ -27,10 +27,11 @@ import org.apache.qpid.server.logging.Lo
import org.apache.qpid.server.logging.LogMessage;
import org.apache.qpid.server.logging.LogSubject;
import org.apache.qpid.server.logging.UnitTestMessageLogger;
+import org.apache.qpid.server.logging.actors.CurrentActor;
import org.apache.qpid.server.logging.actors.TestLogActor;
import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.util.InternalBrokerBaseCase;
import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.test.utils.QpidTestCase;
import java.util.List;
@@ -45,17 +46,23 @@ import java.util.List;
* The resulting log file is then validated.
*
*/
-public abstract class AbstractTestLogSubject extends InternalBrokerBaseCase
+public abstract class AbstractTestLogSubject extends QpidTestCase
{
protected LogSubject _subject = null;
@Override
- public void setUp() throws Exception
+ public void tearDown() throws Exception
{
- super.setUp();
+ try
+ {
+ CurrentActor.removeAll();
+ }
+ finally
+ {
+ super.tearDown();
+ }
}
-
protected List<Object> performLog(boolean statusUpdatesEnabled)
{
if (_subject == null)
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/BindingLogSubjectTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/BindingLogSubjectTest.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/BindingLogSubjectTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/BindingLogSubjectTest.java Thu Dec 6 18:11:22 2012
@@ -24,6 +24,7 @@ import org.apache.qpid.framing.AMQShortS
import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.MockAMQQueue;
+import org.apache.qpid.server.util.BrokerTestHelper;
import org.apache.qpid.server.virtualhost.VirtualHost;
/**
@@ -37,13 +38,12 @@ public class BindingLogSubjectTest exten
private Exchange _exchange;
private VirtualHost _testVhost;
+ @Override
public void setUp() throws Exception
{
super.setUp();
- _testVhost = getRegistry().getVirtualHostRegistry().
- getVirtualHost("test");
- // Configure items for subjectCreation
+ _testVhost = BrokerTestHelper.createVirtualHost("test");
_routingKey = new AMQShortString("RoutingKey");
_exchange = _testVhost.getExchangeRegistry().getDefaultExchange();
_queue = new MockAMQQueue("BindingLogSubjectTest");
@@ -52,6 +52,16 @@ public class BindingLogSubjectTest exten
_subject = new BindingLogSubject(String.valueOf(_routingKey), _exchange, _queue);
}
+ @Override
+ public void tearDown() throws Exception
+ {
+ if (_testVhost != null)
+ {
+ _testVhost.close();
+ }
+ super.tearDown();
+ }
+
/**
* Validate that the logged Subject message is as expected:
* MESSAGE [Blank][vh(/test)/ex(direct/<<default>>)/qu(BindingLogSubjectTest)/rk(RoutingKey)] <Log Message>
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ChannelLogSubjectTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ChannelLogSubjectTest.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ChannelLogSubjectTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ChannelLogSubjectTest.java Thu Dec 6 18:11:22 2012
@@ -34,7 +34,8 @@ public class ChannelLogSubjectTest exten
{
super.setUp();
- AMQChannel channel = new AMQChannel(getSession(), _channelID, getSession().getVirtualHost().getMessageStore());
+
+ AMQChannel channel = new AMQChannel(_session, _channelID, _session.getVirtualHost().getMessageStore());
_subject = new ChannelLogSubject(channel);
}
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubjectTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubjectTest.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubjectTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubjectTest.java Thu Dec 6 18:11:22 2012
@@ -20,17 +20,34 @@
*/
package org.apache.qpid.server.logging.subjects;
+import org.apache.qpid.server.protocol.InternalTestProtocolSession;
+import org.apache.qpid.server.util.BrokerTestHelper;
+
/**
* Validate ConnectionLogSubjects are logged as expected
*/
public class ConnectionLogSubjectTest extends AbstractTestLogSubject
{
+ protected InternalTestProtocolSession _session;
+
+ @Override
public void setUp() throws Exception
{
super.setUp();
- _subject = new ConnectionLogSubject(getSession());
+ _session = BrokerTestHelper.createSession("test");
+ _subject = new ConnectionLogSubject(_session);
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ if (_session != null)
+ {
+ _session.getVirtualHost().close();
+ }
+ super.tearDown();
}
/**
@@ -40,7 +57,7 @@ public class ConnectionLogSubjectTest ex
*/
protected void validateLogStatement(String message)
{
- verifyConnection(getSession().getSessionID(), "InternalTestProtocolSession", "127.0.0.1:1", "test", message);
+ verifyConnection(_session.getSessionID(), "InternalTestProtocolSession", "127.0.0.1:1", "test", message);
}
}
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubjectTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubjectTest.java?rev=1418020&r1=1418019&r2=1418020&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubjectTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubjectTest.java Thu Dec 6 18:11:22 2012
@@ -21,6 +21,7 @@
package org.apache.qpid.server.logging.subjects;
import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.util.BrokerTestHelper;
import org.apache.qpid.server.virtualhost.VirtualHost;
@@ -32,17 +33,27 @@ public class ExchangeLogSubjectTest exte
private Exchange _exchange;
private VirtualHost _testVhost;
+ @Override
public void setUp() throws Exception
{
super.setUp();
- _testVhost = getRegistry().getVirtualHostRegistry().
- getVirtualHost("test");
+ _testVhost = BrokerTestHelper.createVirtualHost("test");
_exchange = _testVhost.getExchangeRegistry().getDefaultExchange();
_subject = new ExchangeLogSubject(_exchange,_testVhost);
}
+ @Override
+ public void tearDown() throws Exception
+ {
+ if (_testVhost != null)
+ {
+ _testVhost.close();
+ }
+ super.tearDown();
+ }
+
/**
* Validate that the logged Subject message is as expected:
* MESSAGE [Blank][vh(/test)/ex(direct/<<default>>)] <Log Message>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org