summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Godfrey <rgodfrey@apache.org>2009-10-05 11:11:05 +0000
committerRobert Godfrey <rgodfrey@apache.org>2009-10-05 11:11:05 +0000
commit2cc551d076f3388539392cd36827ad83654460d6 (patch)
tree40e61f1480e06aa03714b3112b703f33fb8f6f0b
parent6eb1a4b5693bbbc75319e19bc4686aa21f2bc5ec (diff)
downloadqpid-python-2cc551d076f3388539392cd36827ad83654460d6.tar.gz
Merged from trunk up to r802129
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/java-broker-0-10@821755 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/broker/etc/config-systests-derby.xml3
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java160
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java13
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/filter/JMSSelectorFilter.java6
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/filter/NoConsumerFilter.java6
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/filter/SimpleFilterManager.java28
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/logging/StartupRootMessageLogger.java42
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/BrokerActor.java39
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/CurrentActor.java56
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/SubscriptionActor.java42
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/logging/rawloggers/SystemOutMessageLogger.java40
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubject.java (renamed from qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/MessagesStoreLogSubject.java)4
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java19
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ExchangeBinding.java21
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ExchangeBindings.java4
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java69
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java34
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ConfigurationFileApplicationRegistry.java33
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java3
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/store/AbstractMessageStore.java44
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java114
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java23
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/Subscription.java5
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java79
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/Subscription_0_10.java20
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/transport/QpidAcceptor.java44
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java19
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/ExtractResendAndRequeueTest.java2
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/ack/TxAckTest.java15
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java8
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/VirtualHostConfigurationTest.java14
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/DestWildExchangeTest.java2
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java5
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java8
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java12
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java13
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java21
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/SubscriptionActorTest.java132
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/TestLogActor.java (renamed from qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/TestBlankActor.java)6
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java18
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java12
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubjectTest.java2
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubjectTest.java2
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBeanTest.java22
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MaxChannelsTest.java32
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java5
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java2
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java4
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AckTest.java6
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java5
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTest.java4
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java4
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/registry/ApplicationRegistryShutdownTest.java14
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/ACLManagerTest.java8
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/PrincipalPermissionsTest.java14
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/plugins/network/FirewallPluginTest.java10
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java4
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/subscription/MockSubscription.java9
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java2
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/util/NullApplicationRegistry.java (renamed from qpid/java/broker/src/main/java/org/apache/qpid/server/util/NullApplicationRegistry.java)31
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java21
-rw-r--r--qpid/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm59
-rw-r--r--qpid/java/management/eclipse-plugin/build.xml1
-rw-r--r--qpid/java/management/eclipse-plugin/icons/Thumbs.dbbin97280 -> 0 bytes
-rw-r--r--qpid/java/management/eclipse-plugin/icons/configuration_management.gifbin0 -> 343 bytes
-rw-r--r--qpid/java/management/eclipse-plugin/icons/logging_management.gifbin0 -> 381 bytes
-rw-r--r--qpid/java/management/eclipse-plugin/icons/qpidConnections.gifbin168 -> 200 bytes
-rw-r--r--qpid/java/management/eclipse-plugin/icons/refresh.gifbin182 -> 336 bytes
-rw-r--r--qpid/java/management/eclipse-plugin/icons/server_information.gifbin0 -> 614 bytes
-rw-r--r--qpid/java/management/eclipse-plugin/icons/user_management.gifbin0 -> 597 bytes
-rw-r--r--qpid/java/management/eclipse-plugin/icons/virtualhost_manager.gifbin0 -> 607 bytes
-rw-r--r--qpid/java/management/eclipse-plugin/plugin.xml5
-rw-r--r--qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java10
-rw-r--r--qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java5
-rw-r--r--qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java38
-rw-r--r--qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NotificationsTabControl.java11
-rw-r--r--qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/VHNotificationsTabControl.java11
-rw-r--r--qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/queue/QueueOperationsTabControl.java28
-rw-r--r--qpid/java/management/eclipse-plugin/src/test/java/org/apache/qpid/management/ui/ManagementConsoleTest.java3
-rw-r--r--qpid/java/module.xml1
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java2
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java27
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java138
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BindingLoggingTest.java279
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java1007
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java16
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java11
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java511
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DurableQueueLoggingTest.java349
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ExchangeLoggingTest.java203
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java378
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java192
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/QueueLoggingTest.java172
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java299
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/TransientQueueLoggingTest.java30
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/queue/QueueDepthWithSelectorTest.java5
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/queue/SubscriptionTestHelper.java8
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/SimpleACLTest.java10
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/InVMBrokerDecorator.java1
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java12
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java2
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseTest.java16
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/CloseAfterConnectionFailureTest.java47
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java189
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/util/LogMonitor.java33
-rw-r--r--qpid/java/test-profiles/08StandaloneExcludes5
-rw-r--r--qpid/java/test-profiles/Excludes9
-rw-r--r--qpid/java/test-profiles/default.testprofile1
-rw-r--r--qpid/java/test-profiles/java-derby.testprofile3
-rw-r--r--qpid/java/test-profiles/java.testprofile3
110 files changed, 5059 insertions, 510 deletions
diff --git a/qpid/java/broker/etc/config-systests-derby.xml b/qpid/java/broker/etc/config-systests-derby.xml
index 2efc458e26..e9cfa04ab5 100644
--- a/qpid/java/broker/etc/config-systests-derby.xml
+++ b/qpid/java/broker/etc/config-systests-derby.xml
@@ -96,6 +96,7 @@
<localhost>
<store>
<class>org.apache.qpid.server.store.DerbyMessageStore</class>
+ <environment-path>${work}/derbyDB/localhost-store</environment-path>
</store>
<housekeeping>
@@ -110,6 +111,7 @@
<development>
<store>
<class>org.apache.qpid.server.store.DerbyMessageStore</class>
+ <environment-path>${work}/derbyDB/development-store</environment-path>
</store>
</development>
</virtualhost>
@@ -119,6 +121,7 @@
<test>
<store>
<class>org.apache.qpid.server.store.DerbyMessageStore</class>
+ <environment-path>${work}/derbyDB/test-store</environment-path>
</store>
</test>
</virtualhost>
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java
index 27c1705da6..d94e9e7498 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java
@@ -20,14 +20,6 @@
*/
package org.apache.qpid.server;
-import java.io.File;
-import java.io.IOException;
-import java.net.BindException;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-
-import javax.management.NotCompliantMBeanException;
-
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
@@ -54,7 +46,11 @@ import org.apache.qpid.pool.ReadWriteThreadModel;
import org.apache.qpid.server.configuration.ServerConfiguration;
import org.apache.qpid.server.configuration.management.ConfigurationManagementMBean;
import org.apache.qpid.server.information.management.ServerInformationMBean;
+import org.apache.qpid.server.logging.StartupRootMessageLogger;
+import org.apache.qpid.server.logging.actors.BrokerActor;
+import org.apache.qpid.server.logging.actors.CurrentActor;
import org.apache.qpid.server.logging.management.LoggingManagementMBean;
+import org.apache.qpid.server.logging.messages.BrokerMessages;
import org.apache.qpid.server.protocol.AMQPFastProtocolHandler;
import org.apache.qpid.server.protocol.AMQPProtocolProvider;
import org.apache.qpid.server.registry.ApplicationRegistry;
@@ -62,6 +58,13 @@ import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry;
import org.apache.qpid.server.registry.IApplicationRegistry;
import org.apache.qpid.server.security.auth.manager.AuthenticationManager;
import org.apache.qpid.server.transport.ServerConnection;
+import org.apache.qpid.server.transport.QpidAcceptor;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
/**
* Main entry point for AMQPD.
@@ -75,7 +78,7 @@ public class Main
private static final String DEFAULT_CONFIG_FILE = "etc/config.xml";
- private static final String DEFAULT_LOG_CONFIG_FILENAME = "log4j.xml";
+ public static final String DEFAULT_LOG_CONFIG_FILENAME = "log4j.xml";
public static final String QPID_HOME = "QPID_HOME";
private static final int IPV4_ADDRESS_LENGTH = 4;
@@ -197,7 +200,9 @@ public class Main
{
try
{
+ CurrentActor.set(new BrokerActor(new StartupRootMessageLogger()));
startup();
+ CurrentActor.remove();
}
catch (InitException e)
{
@@ -239,7 +244,7 @@ public class Main
}
else
{
- System.out.println("Using configuration file " + configFile.getAbsolutePath());
+ CurrentActor.get().message(BrokerMessages.BRK_1006(configFile.getAbsolutePath()));
}
String logConfig = commandLine.getOptionValue("l");
@@ -274,75 +279,94 @@ public class Main
updateManagementPort(serverConfig, commandLine.getOptionValue("m"));
ApplicationRegistry.initialise(config);
-
- configureLoggingManagementMBean(logConfigFile, logWatchTime);
-
- ConfigurationManagementMBean configMBean = new ConfigurationManagementMBean();
- configMBean.register();
-
- ServerInformationMBean sysInfoMBean =
- new ServerInformationMBean(QpidProperties.getBuildVersion(), QpidProperties.getReleaseVersion());
- sysInfoMBean.register();
-
- //fixme .. use QpidProperties.getVersionString when we have fixed the classpath issues
- // that are causing the broker build to pick up the wrong properties file and hence say
- // Starting Qpid Client
- _brokerLogger.info("Starting Qpid Broker " + QpidProperties.getReleaseVersion()
- + " build: " + QpidProperties.getBuildVersion());
- ByteBuffer.setUseDirectBuffers(serverConfig.getEnableDirectBuffers());
+ // We have already loaded the BrokerMessages class by this point so we
+ // need to refresh the locale setting incase we had a different value in
+ // the configuration.
+ BrokerMessages.reload();
- // the MINA default is currently to use the pooled allocator although this may change in future
- // once more testing of the performance of the simple allocator has been done
- if (!serverConfig.getEnablePooledAllocator())
+ // AR.initialise() sets its own actor so we now need to set the actor
+ // for the remainder of the startup
+ CurrentActor.set(new BrokerActor(config.getRootMessageLogger()));
+ try
{
- ByteBuffer.setAllocator(new FixedSizeByteBufferAllocator());
- }
+ configureLoggingManagementMBean(logConfigFile, logWatchTime);
- if(serverConfig.getUseBiasedWrites())
- {
- System.setProperty("org.apache.qpid.use_write_biased_pool","true");
- }
+ ConfigurationManagementMBean configMBean = new ConfigurationManagementMBean();
+ configMBean.register();
- int port = serverConfig.getPort();
+ ServerInformationMBean sysInfoMBean =
+ new ServerInformationMBean(QpidProperties.getBuildVersion(), QpidProperties.getReleaseVersion());
+ sysInfoMBean.register();
- String portStr = commandLine.getOptionValue("p");
- if (portStr != null)
- {
- try
+ //fixme .. use QpidProperties.getVersionString when we have fixed the classpath issues
+ // that are causing the broker build to pick up the wrong properties file and hence say
+ // Starting Qpid Client
+ _brokerLogger.info("Starting Qpid Broker " + QpidProperties.getReleaseVersion()
+ + " build: " + QpidProperties.getBuildVersion());
+
+ ByteBuffer.setUseDirectBuffers(serverConfig.getEnableDirectBuffers());
+
+ // the MINA default is currently to use the pooled allocator although this may change in future
+ // once more testing of the performance of the simple allocator has been done
+ if (!serverConfig.getEnablePooledAllocator())
{
- port = Integer.parseInt(portStr);
+ ByteBuffer.setAllocator(new FixedSizeByteBufferAllocator());
}
- catch (NumberFormatException e)
+
+ if (serverConfig.getUseBiasedWrites())
{
- throw new InitException("Invalid port: " + portStr, e);
+ System.setProperty("org.apache.qpid.use_write_biased_pool", "true");
}
- }
-
- bind(port, serverConfig);
+ int port = serverConfig.getPort();
- IApplicationRegistry appRegistry = ApplicationRegistry.getInstance();
+ String portStr = commandLine.getOptionValue("p");
+ if (portStr != null)
+ {
+ try
+ {
+ port = Integer.parseInt(portStr);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new InitException("Invalid port: " + portStr, e);
+ }
+ }
- final ConnectionDelegate delegate =
- new org.apache.qpid.server.transport.ServerConnectionDelegate(appRegistry, "localhost");
+ bind(port, serverConfig);
+ // TODO - Fix to use a proper binding
+ int port_0_10 = port + 1;
- ConnectionBinding cb = new ConnectionBinding()
- {
- public Connection connection()
+ IApplicationRegistry appRegistry = ApplicationRegistry.getInstance();
+
+ final ConnectionDelegate delegate =
+ new org.apache.qpid.server.transport.ServerConnectionDelegate(appRegistry, "localhost");
+
+
+ ConnectionBinding cb = new ConnectionBinding()
{
- ServerConnection conn = new ServerConnection();
- conn.setConnectionDelegate(delegate);
- return conn;
- }
- };
+ public Connection connection()
+ {
+ ServerConnection conn = new ServerConnection();
+ conn.setConnectionDelegate(delegate);
+ return conn;
+ }
+ };
+
+ org.apache.qpid.transport.network.io.IoAcceptor ioa = new org.apache.qpid.transport.network.io.IoAcceptor
+ ("0.0.0.0", port_0_10, cb);
+ ioa.start();
+ }
+ finally
+ {
+ // Startup is complete so remove the AR initialised Startup actor
+ CurrentActor.remove();
+ }
+
- int port_0_10 = port + 1;
- org.apache.qpid.transport.network.io.IoAcceptor ioa = new org.apache.qpid.transport.network.io.IoAcceptor
- ("0.0.0.0", port_0_10, cb);
- ioa.start();
}
/**
@@ -415,7 +439,7 @@ public class Main
bindAddress = new InetSocketAddress(InetAddress.getByAddress(parseIP(bindAddr)), port);
}
- bind(acceptor, bindAddress, handler, sconfig);
+ bind(new QpidAcceptor(acceptor,"TCP"), bindAddress, handler, sconfig);
//fixme qpid.AMQP should be using qpidproperties to get value
_brokerLogger.info("Qpid.AMQP listening on non-SSL address " + bindAddress);
@@ -427,7 +451,7 @@ public class Main
try
{
- bind(acceptor, new InetSocketAddress(config.getSSLPort()), handler, sconfig);
+ bind(new QpidAcceptor(acceptor, "TCP/SSL"), new InetSocketAddress(config.getSSLPort()), handler, sconfig);
//fixme qpid.AMQP should be using qpidproperties to get value
_brokerLogger.info("Qpid.AMQP listening on SSL port " + config.getSSLPort());
@@ -442,6 +466,9 @@ public class Main
//fixme qpid.AMQP should be using qpidproperties to get value
_brokerLogger.info("Qpid Broker Ready :" + QpidProperties.getReleaseVersion()
+ " build: " + QpidProperties.getBuildVersion());
+
+ CurrentActor.get().message(BrokerMessages.BRK_1004());
+
}
catch (Exception e)
{
@@ -461,9 +488,11 @@ public class Main
*
* @throws IOException from the acceptor.bind command
*/
- private void bind(IoAcceptor acceptor, InetSocketAddress bindAddress, AMQPFastProtocolHandler handler, SocketAcceptorConfig sconfig) throws IOException
+ private void bind(QpidAcceptor acceptor, InetSocketAddress bindAddress, AMQPFastProtocolHandler handler, SocketAcceptorConfig sconfig) throws IOException
{
- acceptor.bind(bindAddress, handler, sconfig);
+ acceptor.getIoAcceptor().bind(bindAddress, handler, sconfig);
+
+ CurrentActor.get().message(BrokerMessages.BRK_1002(acceptor.toString(), bindAddress.getPort()));
ApplicationRegistry.getInstance().addAcceptor(bindAddress, acceptor);
}
@@ -506,6 +535,7 @@ public class Main
{
if (logConfigFile.exists() && logConfigFile.canRead())
{
+ CurrentActor.get().message(BrokerMessages.BRK_1007(logConfigFile.getAbsolutePath()));
System.out.println("Configuring logger using configuration file " + logConfigFile.getAbsolutePath());
if (logWatchTime > 0)
{
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java
index 04c59fd63f..f3bc543562 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java
@@ -42,6 +42,10 @@ import org.apache.qpid.server.queue.QueueRegistry;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.logging.messages.ExchangeMessages;
+import org.apache.qpid.server.logging.subjects.ExchangeLogSubject;
+import org.apache.qpid.server.logging.LogSubject;
import java.util.Map;
@@ -64,6 +68,9 @@ public abstract class AbstractExchange implements Exchange, Managable
*/
protected boolean _autoDelete;
+ //The logSubject for ths exchange
+ private LogSubject _logSubject;
+
/**
* Abstract MBean class. This has some of the methods implemented from
* management intrerface for exchanges. Any implementaion of an
@@ -163,6 +170,10 @@ public abstract class AbstractExchange implements Exchange, Managable
_ticket = ticket;
_exchangeMbean = createMBean();
_exchangeMbean.register();
+ _logSubject = new ExchangeLogSubject(this, this.getVirtualHost());
+
+ // Log Exchange creation
+ CurrentActor.get().message(ExchangeMessages.EXH_1001(String.valueOf(getType()), String.valueOf(name), durable));
}
public boolean isDurable()
@@ -186,6 +197,8 @@ public abstract class AbstractExchange implements Exchange, Managable
{
_exchangeMbean.unregister();
}
+
+ CurrentActor.get().message(_logSubject, ExchangeMessages.EXH_1002());
}
public String toString()
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/JMSSelectorFilter.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/JMSSelectorFilter.java
index f86f5dab62..dacd047fea 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/JMSSelectorFilter.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/JMSSelectorFilter.java
@@ -53,4 +53,10 @@ public class JMSSelectorFilter implements MessageFilter
{
return _selector;
}
+
+ @Override
+ public String toString()
+ {
+ return "JMSSelector("+_selector+")";
+ }
}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/NoConsumerFilter.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/NoConsumerFilter.java
index f1b3b2511d..65ddf19fc4 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/NoConsumerFilter.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/NoConsumerFilter.java
@@ -39,4 +39,10 @@ public class NoConsumerFilter implements MessageFilter
return true;
}
+ @Override
+ public String toString()
+ {
+ return "NoConsumer";
+ }
+
}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/SimpleFilterManager.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/SimpleFilterManager.java
index 83f537b632..c563569cb4 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/SimpleFilterManager.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/filter/SimpleFilterManager.java
@@ -24,7 +24,6 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import org.apache.log4j.Logger;
import org.apache.qpid.AMQException;
-import org.apache.qpid.server.queue.AMQMessage;
import org.apache.qpid.server.queue.Filterable;
public class SimpleFilterManager implements FilterManager
@@ -32,6 +31,7 @@ public class SimpleFilterManager implements FilterManager
private final Logger _logger = Logger.getLogger(SimpleFilterManager.class);
private final ConcurrentLinkedQueue<MessageFilter> _filters;
+ private String _toString = "";
public SimpleFilterManager()
{
@@ -42,11 +42,13 @@ public class SimpleFilterManager implements FilterManager
public void add(MessageFilter filter)
{
_filters.add(filter);
+ updateStringValue();
}
public void remove(MessageFilter filter)
{
_filters.remove(filter);
+ updateStringValue();
}
public boolean allAllow(Filterable msg)
@@ -65,4 +67,28 @@ public class SimpleFilterManager implements FilterManager
{
return !_filters.isEmpty();
}
+
+
+ @Override
+ public String toString()
+ {
+ return _toString;
+ }
+
+ private void updateStringValue()
+ {
+ StringBuilder toString = new StringBuilder();
+ for (MessageFilter filter : _filters)
+ {
+ toString.append(filter.toString());
+ toString.append(",");
+ }
+
+ if (_filters.size() > 0)
+ {
+ //Remove the last ','
+ toString.deleteCharAt(toString.length()-1);
+ }
+ _toString = toString.toString();
+ }
}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/StartupRootMessageLogger.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/StartupRootMessageLogger.java
new file mode 100644
index 0000000000..0dffde50fa
--- /dev/null
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/StartupRootMessageLogger.java
@@ -0,0 +1,42 @@
+/*
+ *
+ * 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.qpid.server.logging;
+
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.qpid.server.configuration.ServerConfiguration;
+import org.apache.qpid.server.logging.rawloggers.SystemOutMessageLogger;
+
+public class StartupRootMessageLogger extends RootMessageLoggerImpl
+{
+ public StartupRootMessageLogger() throws ConfigurationException
+ {
+ super(new ServerConfiguration(new PropertiesConfiguration()),
+ new SystemOutMessageLogger());
+ }
+
+ @Override
+ public boolean isMessageEnabled(LogActor actor, LogSubject subject)
+ {
+ return true;
+ }
+
+}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/BrokerActor.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/BrokerActor.java
new file mode 100644
index 0000000000..9b928accc0
--- /dev/null
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/BrokerActor.java
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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.qpid.server.logging.actors;
+
+import org.apache.qpid.server.logging.RootMessageLogger;
+
+public class BrokerActor extends AbstractActor
+{
+
+ /**
+ * Create a new BrokerActor
+ *
+ * @param logger
+ */
+ public BrokerActor(RootMessageLogger logger)
+ {
+ super(logger);
+
+ _logString = "[Broker] ";
+ }
+}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/CurrentActor.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/CurrentActor.java
index 221e57eebb..374550a72b 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/CurrentActor.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/CurrentActor.java
@@ -25,28 +25,82 @@ import org.apache.qpid.server.logging.LogActor;
import java.util.LinkedList;
import java.util.Deque;
+/**
+ * The CurrentActor is a ThreadLocal wrapper that allows threads in the broker
+ * to retrieve an actor to perform logging. This approach is used so for two
+ * reasons:
+ * 1) We do not have to pass a logging actor around the system
+ * 2) We can set new actors at the point we have enough information. i.e.
+ * - Set a low level ConnectionActor when processing bytes from the wire.
+ * - Set a ChannelActor when we are processing the frame
+ * - Set a SubscriptionActor when we are handling the subscription.
+ *
+ * The code performing the logging need not worry about what type of actor is
+ * currently set so can perform its logging. The resulting log entry though will
+ * contain customised details from the the currently set Actor.
+ *
+ * The Actor model also allows the pre-creation of fixed messages so the
+ * performance impact of the additional logging data is minimised.
+ *
+ * This class does not perform any checks to ensure that there is an Actor set
+ * when calling remove or get. As a result the application developer must ensure
+ * that they have called set before they attempt to use the actor via get or
+ * remove the set actor.
+ *
+ * The checking of the return via get should not be done as the logging is
+ * desired. It is preferable to cause the NullPointerException to highlight the
+ * programming error rather than miss a log message.
+ *
+ * The same is true for the remove. A NPE will occur if no set has been called
+ * highlighting the programming error.
+ *
+ */
public class CurrentActor
{
+ /**
+ * The ThreadLocal variable with initialiser
+ */
private static final ThreadLocal<Deque<LogActor>> _currentActor = new ThreadLocal<Deque<LogActor>>()
{
+ // Initialise the CurrentActor to be an empty List
protected Deque<LogActor> initialValue()
{
return new LinkedList<LogActor>();
}
};
+ /**
+ * Set a new LogActor to be the Current Actor
+ *
+ * This pushes the Actor in to the LIFO Queue
+ *
+ * @param actor The new LogActor
+ */
public static void set(LogActor actor)
{
Deque<LogActor> stack = _currentActor.get();
stack.addFirst(actor);
}
+ /**
+ * Remove the current LogActor.
+ *
+ * Calling remove without calling set will result in a NoSuchElementException.
+ *
+ */
public static void remove()
{
Deque<LogActor> stack = _currentActor.get();
- stack.remove();
+ stack.removeFirst();
}
+ /**
+ * Return the current head of the list of LogActors.
+ *
+ * If there has been no set call then this will return Null.
+ *
+ * @return Current LogActor
+ */
public static LogActor get()
{
return _currentActor.get().peek();
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/SubscriptionActor.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/SubscriptionActor.java
new file mode 100644
index 0000000000..ab33a29eac
--- /dev/null
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/SubscriptionActor.java
@@ -0,0 +1,42 @@
+/*
+ *
+ * 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.qpid.server.logging.actors;
+
+import org.apache.qpid.server.logging.RootMessageLogger;
+import org.apache.qpid.server.subscription.Subscription;
+
+import java.text.MessageFormat;
+
+public class SubscriptionActor extends AbstractActor
+{
+ public static String SUBSCRIBER_FORMAT = "sub:{0}(vh({1})/qu({2}))";
+
+ public SubscriptionActor(RootMessageLogger logger, Subscription subscription)
+ {
+ super(logger);
+
+ _logString = "[" + MessageFormat.format(SUBSCRIBER_FORMAT,
+ subscription.getSubscriptionID(),
+ subscription.getQueue().getVirtualHost().getName(),
+ subscription.getQueue().getName())
+ + "] ";
+ }
+}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/rawloggers/SystemOutMessageLogger.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/rawloggers/SystemOutMessageLogger.java
new file mode 100644
index 0000000000..b9f0532d05
--- /dev/null
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/rawloggers/SystemOutMessageLogger.java
@@ -0,0 +1,40 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.logging.rawloggers;
+
+import org.apache.qpid.server.logging.RawMessageLogger;
+
+public class SystemOutMessageLogger implements RawMessageLogger
+{
+ public void rawMessage(String message)
+ {
+ rawMessage(message, null);
+ }
+
+ public void rawMessage(String message, Throwable throwable)
+ {
+ System.out.println(message);
+ if (throwable != null)
+ {
+ throwable.printStackTrace(System.out);
+ }
+ }
+}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/MessagesStoreLogSubject.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubject.java
index 28d64de74e..e11cbba4f4 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/MessagesStoreLogSubject.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubject.java
@@ -23,7 +23,7 @@ package org.apache.qpid.server.logging.subjects;
import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.server.store.MessageStore;
-public class MessagesStoreLogSubject extends AbstractLogSubject
+public class MessageStoreLogSubject extends AbstractLogSubject
{
/**
@@ -37,7 +37,7 @@ public class MessagesStoreLogSubject extends AbstractLogSubject
protected static String BINDING_FORMAT = "vh(/{0})/ms({1})";
/** Create an ExchangeLogSubject that Logs in the following format. */
- public MessagesStoreLogSubject(VirtualHost vhost, MessageStore store)
+ public MessageStoreLogSubject(VirtualHost vhost, MessageStore store)
{
setLogStringWithFormat(BINDING_FORMAT, vhost.getName(),
store.getClass().getSimpleName());
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java
index 5a113de5be..38272db845 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java
@@ -27,6 +27,8 @@ import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.registry.IApplicationRegistry;
import org.apache.qpid.server.security.auth.database.PrincipalDatabase;
import org.apache.qpid.server.security.auth.rmi.RMIPasswordAuthenticator;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.logging.messages.ManagementConsoleMessages;
import javax.management.JMException;
import javax.management.MBeanServer;
@@ -91,6 +93,9 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry
public void start() throws IOException, ConfigurationException
{
+
+ CurrentActor.get().message(ManagementConsoleMessages.MNG_1001());
+
//check if system properties are set to use the JVM's out-of-the-box JMXAgent
if (areOutOfTheBoxJMXOptionsSet())
{
@@ -160,6 +165,8 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry
_log.info("JMX ConnectorServer using SSL keystore file " + ksf.getAbsolutePath());
_startupLog.info("JMX ConnectorServer using SSL keystore file " + ksf.getAbsolutePath());
+
+ CurrentActor.get().message(ManagementConsoleMessages.MNG_1006(ksf.getAbsolutePath()));
}
//check the key store password is set
@@ -186,6 +193,10 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry
(port +PORT_EXPORT_OFFSET) + ") with SSL");
_startupLog.warn("Starting JMX ConnectorServer on port '"+ port + "' (+" +
(port +PORT_EXPORT_OFFSET) + ") with SSL");
+
+ CurrentActor.get().message(ManagementConsoleMessages.MNG_1002("SSL RMI Registry", port));
+ CurrentActor.get().message(ManagementConsoleMessages.MNG_1002("SSL RMI ConnectorServer", port + PORT_EXPORT_OFFSET));
+
}
else
{
@@ -195,6 +206,8 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry
_log.warn("Starting JMX ConnectorServer on port '" + port + "' (+" + (port +PORT_EXPORT_OFFSET) + ")");
_startupLog.warn("Starting JMX ConnectorServer on port '" + port + "' (+" + (port +PORT_EXPORT_OFFSET) + ")");
+ CurrentActor.get().message(ManagementConsoleMessages.MNG_1002("RMI Registry", port));
+ CurrentActor.get().message(ManagementConsoleMessages.MNG_1002("RMI ConnectorServer", port + PORT_EXPORT_OFFSET));
}
//add a JMXAuthenticator implementation the env map to authenticate the RMI based JMX connector server
@@ -233,7 +246,7 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry
try
{
//manually bind the connector server to the registry at key 'jmxrmi', like the out-of-the-box agent
- _rmiRegistry.bind("jmxrmi", rmiConnectorServerStub);
+ _rmiRegistry.bind("jmxrmi", rmiConnectorServerStub);
}
catch (AlreadyBoundException abe)
{
@@ -263,6 +276,8 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry
MBeanServerForwarder mbsf = MBeanInvocationHandlerImpl.newProxyInstance();
cs.setMBeanServerForwarder(mbsf);
cs.start();
+
+ CurrentActor.get().message(ManagementConsoleMessages.MNG_1004());
}
/*
@@ -366,6 +381,8 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry
_log.error("Exception unregistering MBean '"+ name +"': " + e.getMessage());
}
}
+
+ CurrentActor.get().message(ManagementConsoleMessages.MNG_1005());
}
}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ExchangeBinding.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ExchangeBinding.java
index a2fcab9e73..7584a3b7cc 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ExchangeBinding.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ExchangeBinding.java
@@ -21,6 +21,10 @@
package org.apache.qpid.server.queue;
import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.logging.messages.BindingMessages;
+import org.apache.qpid.server.logging.subjects.BindingLogSubject;
+import org.apache.qpid.server.logging.LogSubject;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.framing.FieldTable;
import org.apache.qpid.AMQException;
@@ -31,23 +35,26 @@ public class ExchangeBinding
private final AMQShortString _routingKey;
private final FieldTable _arguments;
- private static final FieldTable EMPTY_ARGUMENTS = new FieldTable();
+ private static final FieldTable EMPTY_ARGUMENTS = new FieldTable();
+ private LogSubject _logSubject;
- ExchangeBinding(AMQShortString routingKey, Exchange exchange)
- {
- this(routingKey, exchange, EMPTY_ARGUMENTS);
- }
-
- ExchangeBinding(AMQShortString routingKey, Exchange exchange, FieldTable arguments)
+ ExchangeBinding(AMQShortString routingKey, Exchange exchange, AMQQueue queue, FieldTable arguments)
{
_routingKey = routingKey == null ? AMQShortString.EMPTY_STRING : routingKey;
_exchange = exchange;
_arguments = arguments == null ? EMPTY_ARGUMENTS : arguments;
+ _logSubject = new BindingLogSubject(routingKey,exchange,queue);
+
+ CurrentActor.get().message(_logSubject, BindingMessages.BND_1001(_arguments.toString(), arguments != null));
}
+
+
void unbind(AMQQueue queue) throws AMQException
{
_exchange.deregisterQueue(_routingKey, queue, _arguments);
+
+ CurrentActor.get().message(_logSubject, BindingMessages.BND_1002());
}
public Exchange getExchange()
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ExchangeBindings.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ExchangeBindings.java
index fb839c1783..89262aee59 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ExchangeBindings.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ExchangeBindings.java
@@ -52,13 +52,13 @@ class ExchangeBindings
*/
void addBinding(AMQShortString routingKey, FieldTable arguments, Exchange exchange)
{
- _bindings.add(new ExchangeBinding(routingKey, exchange, arguments));
+ _bindings.add(new ExchangeBinding(routingKey, exchange, _queue, arguments));
}
public boolean remove(AMQShortString routingKey, FieldTable arguments, Exchange exchange)
{
- return _bindings.remove(new ExchangeBinding(routingKey, exchange, arguments));
+ return _bindings.remove(new ExchangeBinding(routingKey, exchange, _queue, arguments));
}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java
index 8c24acccbf..b0899b62d4 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java
@@ -24,6 +24,10 @@ import org.apache.qpid.server.subscription.SubscriptionList;
import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.server.message.ServerMessage;
import org.apache.qpid.server.PrincipalHolder;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.logging.subjects.QueueLogSubject;
+import org.apache.qpid.server.logging.LogSubject;
+import org.apache.qpid.server.logging.messages.QueueMessages;
/*
*
@@ -140,6 +144,7 @@ public class SimpleAMQQueue implements AMQQueue, Subscription.StateListener
private AtomicReference _asynchronousRunner = new AtomicReference(null);
private AtomicInteger _deliveredMessages = new AtomicInteger();
private AtomicBoolean _stopped = new AtomicBoolean(false);
+ private LogSubject _logSubject;
protected SimpleAMQQueue(AMQShortString name, boolean durable, AMQShortString owner, boolean autoDelete, VirtualHost virtualHost)
throws AMQException
@@ -175,6 +180,27 @@ public class SimpleAMQQueue implements AMQQueue, Subscription.StateListener
_asyncDelivery = ReferenceCountingExecutorService.getInstance().acquireExecutorService();
+ _logSubject = new QueueLogSubject(this);
+
+ // Log the correct creation message
+
+ // Extract the number of priorities for this Queue.
+ // Leave it as 0 if we are a SimpleQueueEntryList
+ int priorities = 0;
+ if (entryListFactory instanceof PriorityQueueList.Factory)
+ {
+ priorities = ((PriorityQueueList)_entries).getPriorities();
+ }
+
+ // Log the creation of this Queue.
+ // The priorities display is toggled on if we set priorities > 0
+ CurrentActor.get().message(_logSubject,
+ QueueMessages.QUE_1001(String.valueOf(_owner),
+ priorities,
+ autoDelete,
+ durable, !durable,
+ priorities > 0));
+
try
{
_managedObject = new AMQQueueMBean(this);
@@ -282,15 +308,6 @@ public class SimpleAMQQueue implements AMQQueue, Subscription.StateListener
}
_bindings.addBinding(routingKey, arguments, exchange);
-// ExchangeBinding binding = new ExchangeBinding(routingKey, exchange, arguments);
-
- //fixme MR logging in progress
-// _bindings.addBinding(binding);
-//
-// if (_logger.isMessageEnabled(binding))
-// {
-// _logger.message(binding, "QM-1001 : Created Binding");
-// }
}
public void unBind(Exchange exchange, AMQShortString routingKey, FieldTable arguments) throws AMQException
@@ -342,7 +359,7 @@ public class SimpleAMQQueue implements AMQQueue, Subscription.StateListener
if (!isDeleted())
{
- subscription.setQueue(this);
+ subscription.setQueue(this, exclusive);
_subscriptionList.add(subscription);
if (isDeleted())
{
@@ -497,7 +514,7 @@ public class SimpleAMQQueue implements AMQQueue, Subscription.StateListener
}
_managedObject.checkForNotification(entry.getMessage());
-
+
return entry;
}
@@ -881,11 +898,11 @@ public class SimpleAMQQueue implements AMQQueue, Subscription.StateListener
return entryList;
}
-
+
/**
* Returns a list of QueEntries from a given range of queue positions, eg messages 5 to 10 on the queue.
- *
- * The 'queue position' index starts from 1. Using 0 in 'from' will be ignored and continue from 1.
+ *
+ * The 'queue position' index starts from 1. Using 0 in 'from' will be ignored and continue from 1.
* Using 0 in the 'to' field will return an empty list regardless of the 'from' value.
* @param fromPosition
* @param toPosition
@@ -894,7 +911,7 @@ public class SimpleAMQQueue implements AMQQueue, Subscription.StateListener
public List<QueueEntry> getMessagesRangeOnTheQueue(final long fromPosition, final long toPosition)
{
List<QueueEntry> queueEntries = new ArrayList<QueueEntry>();
-
+
QueueEntryIterator it = _entries.iterator();
long index = 1;
@@ -902,20 +919,20 @@ public class SimpleAMQQueue implements AMQQueue, Subscription.StateListener
{
it.advance();
}
-
+
if(index < fromPosition)
{
//The queue does not contain enough entries to reach our range.
//return the empty list.
return queueEntries;
}
-
+
for ( ; index <= toPosition && !it.atTail(); index++)
{
it.advance();
queueEntries.add(it.getNode());
}
-
+
return queueEntries;
}
@@ -1201,6 +1218,10 @@ public class SimpleAMQQueue implements AMQQueue, Subscription.StateListener
_deleteTaskList.clear();
stop();
+
+ //Log Queue Deletion
+ CurrentActor.get().message(_logSubject, QueueMessages.QUE_1002());
+
}
return getMessageCount();
@@ -1271,6 +1292,7 @@ public class SimpleAMQQueue implements AMQQueue, Subscription.StateListener
boolean complete = false;
try
{
+ CurrentActor.set(_sub.getLogActor());
complete = flushSubscription(_sub, new Long(MAX_ASYNC_DELIVERIES));
}
@@ -1278,11 +1300,16 @@ public class SimpleAMQQueue implements AMQQueue, Subscription.StateListener
{
_logger.error(e);
}
+ finally
+ {
+ CurrentActor.remove();
+ }
if (!complete && !_sub.isSuspended())
{
_asyncDelivery.execute(this);
}
+
}
public boolean isRead()
@@ -1307,7 +1334,7 @@ public class SimpleAMQQueue implements AMQQueue, Subscription.StateListener
while (!sub.isSuspended() && !atTail && iterations != 0)
{
- try
+ try
{
sub.getSendLock();
atTail = attemptDelivery(sub);
@@ -1538,8 +1565,8 @@ public class SimpleAMQQueue implements AMQQueue, Subscription.StateListener
if (!node.isDeleted() && node.expired() && node.acquire())
{
node.discard(storeContext);
- }
- else
+ }
+ else
{
_managedObject.checkForNotification(node.getMessage());
}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
index b58b849133..b6137e83de 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
@@ -26,7 +26,6 @@ import java.util.Map;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.log4j.Logger;
-import org.apache.mina.common.IoAcceptor;
import org.apache.qpid.server.configuration.ServerConfiguration;
import org.apache.qpid.server.management.ManagedObjectRegistry;
import org.apache.qpid.server.plugins.PluginManager;
@@ -36,6 +35,9 @@ import org.apache.qpid.server.security.auth.manager.AuthenticationManager;
import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
import org.apache.qpid.server.logging.RootMessageLogger;
+import org.apache.qpid.server.logging.messages.BrokerMessages;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.transport.QpidAcceptor;
/**
* An abstract application registry that provides access to configuration information and handles the
@@ -57,7 +59,7 @@ public abstract class ApplicationRegistry implements IApplicationRegistry
public static final String DEFAULT_APPLICATION_REGISTRY = "org.apache.qpid.server.util.NullApplicationRegistry";
public static String _APPLICATION_REGISTRY = DEFAULT_APPLICATION_REGISTRY;
- protected final Map<InetSocketAddress, IoAcceptor> _acceptors = new HashMap<InetSocketAddress, IoAcceptor>();
+ protected final Map<InetSocketAddress, QpidAcceptor> _acceptors = new HashMap<InetSocketAddress, QpidAcceptor>();
protected ManagedObjectRegistry _managedObjectRegistry;
@@ -114,12 +116,29 @@ public abstract class ApplicationRegistry implements IApplicationRegistry
}
}
+ public static boolean isConfigured()
+ {
+ return isConfigured(DEFAULT_INSTANCE);
+ }
+
+ public static boolean isConfigured(int instanceID)
+ {
+ return _instanceMap.containsKey(instanceID);
+ }
+
+ /**
+ * Method to cleanly shutdown the default registry running in this JVM
+ */
+ public static void remove()
+ {
+ remove(DEFAULT_INSTANCE);
+ }
+
/**
* Method to cleanly shutdown specified registry running in this JVM
*
* @param instanceID the instance to shutdown
*/
-
public static void remove(int instanceID)
{
try
@@ -228,6 +247,8 @@ public abstract class ApplicationRegistry implements IApplicationRegistry
}
// _pluginManager.close();
+
+ CurrentActor.get().message(BrokerMessages.BRK_1005());
}
private void unbind()
@@ -236,8 +257,9 @@ public abstract class ApplicationRegistry implements IApplicationRegistry
{
for (InetSocketAddress bindAddress : _acceptors.keySet())
{
- IoAcceptor acceptor = _acceptors.get(bindAddress);
- acceptor.unbind(bindAddress);
+ QpidAcceptor acceptor = _acceptors.get(bindAddress);
+ acceptor.getIoAcceptor().unbind(bindAddress);
+ CurrentActor.get().message(BrokerMessages.BRK_1003(acceptor.toString(), bindAddress.getPort()));
}
}
}
@@ -247,7 +269,7 @@ public abstract class ApplicationRegistry implements IApplicationRegistry
return _configuration;
}
- public void addAcceptor(InetSocketAddress bindAddress, IoAcceptor acceptor)
+ public void addAcceptor(InetSocketAddress bindAddress, QpidAcceptor acceptor)
{
synchronized (_acceptors)
{
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ConfigurationFileApplicationRegistry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ConfigurationFileApplicationRegistry.java
index 31a85b878a..a049d1eb09 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ConfigurationFileApplicationRegistry.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ConfigurationFileApplicationRegistry.java
@@ -20,11 +20,15 @@
*/
package org.apache.qpid.server.registry;
-import java.io.File;
-
import org.apache.commons.configuration.ConfigurationException;
import org.apache.qpid.AMQException;
+import org.apache.qpid.common.QpidProperties;
import org.apache.qpid.server.configuration.ServerConfiguration;
+import org.apache.qpid.server.logging.RootMessageLoggerImpl;
+import org.apache.qpid.server.logging.messages.BrokerMessages;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.logging.actors.BrokerActor;
+import org.apache.qpid.server.logging.rawloggers.Log4jMessageLogger;
import org.apache.qpid.server.management.JMXManagedObjectRegistry;
import org.apache.qpid.server.management.NoopManagedObjectRegistry;
import org.apache.qpid.server.plugins.PluginManager;
@@ -33,8 +37,8 @@ import org.apache.qpid.server.security.auth.database.ConfigurationFilePrincipalD
import org.apache.qpid.server.security.auth.manager.PrincipalDatabaseAuthenticationManager;
import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
-import org.apache.qpid.server.logging.RootMessageLoggerImpl;
-import org.apache.qpid.server.logging.rawloggers.Log4jMessageLogger;
+
+import java.io.File;
public class ConfigurationFileApplicationRegistry extends ApplicationRegistry
{
@@ -48,6 +52,10 @@ public class ConfigurationFileApplicationRegistry extends ApplicationRegistry
{
_rootMessageLogger = new RootMessageLoggerImpl(_configuration,
new Log4jMessageLogger());
+ // Set the Actor for current log messages
+ CurrentActor.set(new BrokerActor(_rootMessageLogger));
+
+ CurrentActor.get().message(BrokerMessages.BRK_1001(QpidProperties.getReleaseVersion(),QpidProperties.getBuildVersion()));
initialiseManagedObjectRegistry();
@@ -67,6 +75,23 @@ public class ConfigurationFileApplicationRegistry extends ApplicationRegistry
initialiseVirtualHosts();
+ // Startup complete pop the current actor
+ CurrentActor.remove();
+ }
+
+ @Override
+ public void close() throws Exception
+ {
+ //Set the Actor for Broker Shutdown
+ CurrentActor.set(new BrokerActor(_rootMessageLogger));
+ try
+ {
+ super.close();
+ }
+ finally
+ {
+ CurrentActor.remove();
+ }
}
private void initialiseVirtualHosts() throws Exception
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java
index 7d17639f22..ddb3fce5d2 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java
@@ -34,6 +34,7 @@ import org.apache.qpid.server.security.access.ACLManager;
import org.apache.qpid.server.security.access.ACLPlugin;
import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
import org.apache.qpid.server.logging.RootMessageLogger;
+import org.apache.qpid.server.transport.QpidAcceptor;
import org.apache.mina.common.IoAcceptor;
public interface IApplicationRegistry
@@ -77,6 +78,6 @@ public interface IApplicationRegistry
* @param bindAddress The address that the acceptor has been bound with
* @param acceptor The acceptor in use
*/
- void addAcceptor(InetSocketAddress bindAddress, IoAcceptor acceptor);
+ void addAcceptor(InetSocketAddress bindAddress, QpidAcceptor acceptor);
}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/AbstractMessageStore.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/AbstractMessageStore.java
new file mode 100644
index 0000000000..fd2d09b777
--- /dev/null
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/AbstractMessageStore.java
@@ -0,0 +1,44 @@
+/*
+ *
+ * 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.qpid.server.store;
+
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.configuration.VirtualHostConfiguration;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.logging.messages.MessageStoreMessages;
+import org.apache.qpid.server.logging.subjects.MessageStoreLogSubject;
+import org.apache.qpid.server.logging.LogSubject;
+
+public abstract class AbstractMessageStore implements MessageStore
+{
+ protected LogSubject _logSubject;
+
+ public void configure(VirtualHost virtualHost, String base, VirtualHostConfiguration hostConfig) throws Exception
+ {
+ _logSubject = new MessageStoreLogSubject(virtualHost, this);
+ CurrentActor.get().message(_logSubject, MessageStoreMessages.MST_1001(this.getClass().getName()));
+ }
+
+ public void close() throws Exception
+ {
+ CurrentActor.get().message(_logSubject,MessageStoreMessages.MST_1003());
+ }
+}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java
index a8ba372f46..2b2c8fb804 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java
@@ -20,49 +20,51 @@
*/
package org.apache.qpid.server.store;
-import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.log4j.Logger;
+import org.apache.mina.common.ByteBuffer;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.ContentHeaderBody;
+import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.abstraction.ContentChunk;
+import org.apache.qpid.framing.abstraction.MessagePublishInfo;
import org.apache.qpid.server.configuration.VirtualHostConfiguration;
import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.logging.actors.BrokerActor;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.logging.messages.MessageStoreMessages;
+import org.apache.qpid.server.logging.subjects.MessageStoreLogSubject;
+import org.apache.qpid.server.queue.AMQMessage;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.AMQQueueFactory;
+import org.apache.qpid.server.queue.MessageHandleFactory;
import org.apache.qpid.server.queue.MessageMetaData;
import org.apache.qpid.server.queue.QueueRegistry;
-
-import org.apache.qpid.server.queue.AMQMessage;
-import org.apache.qpid.server.queue.MessageHandleFactory;
-import org.apache.qpid.server.txn.TransactionalContext;
import org.apache.qpid.server.txn.NonTransactionalContext;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.FieldTable;
-import org.apache.qpid.framing.ContentHeaderBody;
-import org.apache.qpid.framing.abstraction.ContentChunk;
-import org.apache.qpid.framing.abstraction.MessagePublishInfo;
-import org.apache.commons.configuration.Configuration;
-import org.apache.log4j.Logger;
-import org.apache.mina.common.ByteBuffer;
+import org.apache.qpid.server.txn.TransactionalContext;
+import org.apache.qpid.server.virtualhost.VirtualHost;
-import java.io.File;
import java.io.ByteArrayInputStream;
-import java.sql.DriverManager;
-import java.sql.Driver;
+import java.io.File;
+import java.sql.Blob;
import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
+import java.sql.Driver;
+import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
-import java.sql.Blob;
+import java.sql.SQLException;
+import java.sql.Statement;
import java.sql.Types;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.List;
import java.util.ArrayList;
-import java.util.Map;
import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.TreeMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
-public class DerbyMessageStore implements MessageStore
+public class DerbyMessageStore extends AbstractMessageStore
{
private static final Logger _logger = Logger.getLogger(DerbyMessageStore.class);
@@ -93,6 +95,7 @@ public class DerbyMessageStore implements MessageStore
private String _connectionURL;
+ Map<AMQShortString, Integer> _queueRecoveries = new TreeMap<AMQShortString, Integer>();
private static final String CREATE_DB_VERSION_TABLE = "CREATE TABLE "+DB_VERSION_TABLE_NAME+" ( version int not null )";
@@ -145,6 +148,8 @@ public class DerbyMessageStore implements MessageStore
public void configure(VirtualHost virtualHost, String base, VirtualHostConfiguration config) throws Exception
{
+ super.configure(virtualHost,base,config);
+
stateTransition(State.INITIAL, State.CONFIGURING);
initialiseDriver();
@@ -167,12 +172,15 @@ public class DerbyMessageStore implements MessageStore
}
}
+ CurrentActor.get().message(_logSubject, MessageStoreMessages.MST_1002(environmentPath.getAbsolutePath()));
+
createOrOpenDatabase(databasePath);
// this recovers durable queues and persistent messages
recover();
+
stateTransition(State.RECOVERING, State.STARTED);
}
@@ -187,6 +195,7 @@ public class DerbyMessageStore implements MessageStore
private void createOrOpenDatabase(final String environmentPath) throws SQLException
{
+ //fixme this the _vhost name should not be added here.
_connectionURL = "jdbc:derby:" + environmentPath + "/" + _virtualHost.getName() + ";create=true";
Connection conn = newConnection();
@@ -309,7 +318,8 @@ public class DerbyMessageStore implements MessageStore
{
stateTransition(State.CONFIGURING, State.RECOVERING);
- _logger.info("Recovering persistent state...");
+ CurrentActor.get().message(_logSubject,MessageStoreMessages.MST_1004(null, false));
+
StoreContext context = new StoreContext();
try
@@ -324,9 +334,10 @@ public class DerbyMessageStore implements MessageStore
beginTran(context);
deliverMessages(context, queues);
- _logger.info("Persistent state recovered successfully");
commitTran(context);
+ //Recovery Complete
+ CurrentActor.get().message(_logSubject, MessageStoreMessages.MST_1006(null, false));
}
finally
{
@@ -335,6 +346,7 @@ public class DerbyMessageStore implements MessageStore
abortTran(context);
}
}
+
}
catch (SQLException e)
{
@@ -342,6 +354,7 @@ public class DerbyMessageStore implements MessageStore
throw new AMQException("Error recovering persistent state: " + e, e);
}
+
}
private Map<AMQShortString, AMQQueue> loadQueues() throws SQLException, AMQException
@@ -368,6 +381,11 @@ public class DerbyMessageStore implements MessageStore
}
queueMap.put(queueNameShortString,q);
+
+ CurrentActor.get().message(_logSubject,MessageStoreMessages.MST_1004(String.valueOf(q.getName()), true));
+
+ //Record that we have a queue for recovery
+ _queueRecoveries.put(new AMQShortString(queueName), 0);
}
return queueMap;
@@ -486,6 +504,8 @@ public class DerbyMessageStore implements MessageStore
public void close() throws Exception
{
_closed.getAndSet(true);
+
+ super.close();
}
public void removeMessage(StoreContext storeContext, Long messageId) throws AMQException
@@ -1362,7 +1382,6 @@ public class DerbyMessageStore implements MessageStore
_queue.enqueue(_message);
StoreContext.clearCurrentContext();
-
}
}
@@ -1374,13 +1393,11 @@ public class DerbyMessageStore implements MessageStore
Map<Long, AMQMessage> msgMap = new HashMap<Long,AMQMessage>();
List<ProcessAction> actions = new ArrayList<ProcessAction>();
- Map<AMQShortString, Integer> queueRecoveries = new TreeMap<AMQShortString, Integer>();
final boolean inLocaltran = inTran(context);
Connection conn = null;
try
{
-
if(inLocaltran)
{
conn = getConnection(context);
@@ -1390,7 +1407,6 @@ public class DerbyMessageStore implements MessageStore
conn = newConnection();
}
-
MessageHandleFactory messageHandleFactory = new MessageHandleFactory();
long maxId = 1;
@@ -1399,15 +1415,10 @@ public class DerbyMessageStore implements MessageStore
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(SELECT_FROM_QUEUE_ENTRY);
-
while (rs.next())
{
-
-
-
AMQShortString queueName = new AMQShortString(rs.getString(1));
-
AMQQueue queue = queues.get(queueName);
if (queue == null)
{
@@ -1415,6 +1426,9 @@ public class DerbyMessageStore implements MessageStore
_virtualHost.getQueueRegistry().registerQueue(queue);
queues.put(queueName, queue);
+
+ //Log Recovery Start
+ CurrentActor.get().message(_logSubject, MessageStoreMessages.MST_1004(String.valueOf(queue.getName()), true));
}
long messageId = rs.getLong(2);
@@ -1436,20 +1450,15 @@ public class DerbyMessageStore implements MessageStore
_logger.debug("On recovery, delivering " + message.getMessageId() + " to " + queue.getName());
}
- if (_logger.isInfoEnabled())
+ Integer count = _queueRecoveries.get(queueName);
+ if (count == null)
{
- Integer count = queueRecoveries.get(queueName);
- if (count == null)
- {
- count = 0;
- }
-
- queueRecoveries.put(queueName, ++count);
-
+ count = 0;
}
- actions.add(new ProcessAction(queue, context, message));
+ _queueRecoveries.put(queueName, ++count);
+ actions.add(new ProcessAction(queue, context, message));
}
for(ProcessAction action : actions)
@@ -1474,8 +1483,19 @@ public class DerbyMessageStore implements MessageStore
if (_logger.isInfoEnabled())
{
- _logger.info("Recovered message counts: " + queueRecoveries);
+ _logger.info("Recovered message counts: " + _queueRecoveries);
}
+
+ for(Map.Entry<AMQShortString,Integer> entry : _queueRecoveries.entrySet())
+ {
+ CurrentActor.get().message(_logSubject, MessageStoreMessages.MST_1005(entry.getValue(), String.valueOf(entry.getKey())));
+
+ CurrentActor.get().message(_logSubject, MessageStoreMessages.MST_1006(String.valueOf(entry.getKey()), true));
+ }
+
+ // Free the memory
+ _queueRecoveries = null;
+
}
private Connection getConnection(final StoreContext context)
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java
index 4691f02952..87ec66030d 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java
@@ -31,6 +31,10 @@ import org.apache.qpid.server.configuration.VirtualHostConfiguration;
import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.logging.LogSubject;
+import org.apache.qpid.server.logging.messages.MessageStoreMessages;
+import org.apache.qpid.server.logging.subjects.MessageStoreLogSubject;
import java.util.ArrayList;
import java.util.Collections;
@@ -41,7 +45,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
/** A simple message store that stores the messages in a threadsafe structure in memory. */
-public class MemoryMessageStore implements MessageStore
+public class MemoryMessageStore extends AbstractMessageStore
{
private static final Logger _log = Logger.getLogger(MemoryMessageStore.class);
@@ -55,27 +59,18 @@ public class MemoryMessageStore implements MessageStore
private final AtomicLong _messageId = new AtomicLong(1);
private AtomicBoolean _closed = new AtomicBoolean(false);
+ private LogSubject _logSubject;
- public void configure()
+ public void configure(VirtualHost virtualHost, String base, VirtualHostConfiguration config) throws Exception
{
- _log.info("Using capacity " + DEFAULT_HASHTABLE_CAPACITY + " for hash tables");
- _metaDataMap = new ConcurrentHashMap<Long, MessageMetaData>(DEFAULT_HASHTABLE_CAPACITY);
- _contentBodyMap = new ConcurrentHashMap<Long, List<ContentChunk>>(DEFAULT_HASHTABLE_CAPACITY);
- }
+ super.configure(virtualHost,base,config);
- public void configure(String base, VirtualHostConfiguration config)
- {
int hashtableCapacity = config.getStoreConfiguration().getInt(base + "." + HASHTABLE_CAPACITY_CONFIG, DEFAULT_HASHTABLE_CAPACITY);
_log.info("Using capacity " + hashtableCapacity + " for hash tables");
_metaDataMap = new ConcurrentHashMap<Long, MessageMetaData>(hashtableCapacity);
_contentBodyMap = new ConcurrentHashMap<Long, List<ContentChunk>>(hashtableCapacity);
}
- public void configure(VirtualHost virtualHost, String base, VirtualHostConfiguration config) throws Exception
- {
- configure(base, config);
- }
-
public void close() throws Exception
{
_closed.getAndSet(true);
@@ -89,6 +84,8 @@ public class MemoryMessageStore implements MessageStore
_contentBodyMap.clear();
_contentBodyMap = null;
}
+
+ super.close();
}
public void removeMessage(StoreContext context, Long messageId) throws AMQException
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/Subscription.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/Subscription.java
index 2053082fb2..f0d33d1a69 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/Subscription.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/Subscription.java
@@ -23,12 +23,13 @@ package org.apache.qpid.server.subscription;
import org.apache.qpid.AMQException;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.AMQChannel;
+import org.apache.qpid.server.logging.LogActor;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.QueueEntry;
public interface Subscription
{
-
+ LogActor getLogActor();
public static enum State
{
@@ -46,7 +47,7 @@ public interface Subscription
QueueEntry.SubscriptionAcquiredState getOwningState();
- void setQueue(AMQQueue queue);
+ void setQueue(AMQQueue queue, boolean exclusive);
AMQShortString getConsumerTag();
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java
index 26a3e9bebc..f630d04c95 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/SubscriptionImpl.java
@@ -34,6 +34,12 @@ import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.framing.FieldTable;
import org.apache.qpid.server.AMQChannel;
import org.apache.qpid.server.output.ProtocolOutputConverter;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.logging.actors.SubscriptionActor;
+import org.apache.qpid.server.logging.messages.SubscriptionMessages;
+import org.apache.qpid.server.logging.subjects.SubscriptionLogSubject;
+import org.apache.qpid.server.logging.LogSubject;
+import org.apache.qpid.server.logging.LogActor;
import org.apache.qpid.server.queue.QueueEntry;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.AMQMessage;
@@ -66,14 +72,15 @@ public abstract class SubscriptionImpl implements Subscription, FlowCreditManage
private final ClientDeliveryMethod _deliveryMethod;
private final RecordDeliveryMethod _recordMethod;
-
+
private QueueEntry.SubscriptionAcquiredState _owningState = new QueueEntry.SubscriptionAcquiredState(this);
private final Lock _stateChangeLock;
private static final AtomicLong idGenerator = new AtomicLong(0);
// Create a simple ID that increments for ever new Subscription
private final long _subscriptionID = idGenerator.getAndIncrement();
-
+ private LogSubject _logSubject;
+ private LogActor _logActor;
static final class BrowserSubscription extends SubscriptionImpl
{
@@ -281,7 +288,7 @@ public abstract class SubscriptionImpl implements Subscription, FlowCreditManage
-
+
public SubscriptionImpl(AMQChannel channel , AMQProtocolSession protocolSession,
AMQShortString consumerTag, FieldTable arguments,
boolean noLocal, FlowCreditManager creditManager,
@@ -330,13 +337,52 @@ public abstract class SubscriptionImpl implements Subscription, FlowCreditManage
- public synchronized void setQueue(AMQQueue queue)
+ public synchronized void setQueue(AMQQueue queue, boolean exclusive)
{
if(getQueue() != null)
{
throw new IllegalStateException("Attempt to set queue for subscription " + this + " to " + queue + "when already set to " + getQueue());
}
_queue = queue;
+
+ _logSubject = new SubscriptionLogSubject(this);
+ _logActor = new SubscriptionActor(CurrentActor.get().getRootMessageLogger(), this);
+
+ if (CurrentActor.get().getRootMessageLogger().
+ isMessageEnabled(CurrentActor.get(), _logSubject))
+ {
+ // Get the string value of the filters
+ String filterLogString = null;
+ if (_filters != null && _filters.hasFilters())
+ {
+ filterLogString = _filters.toString();
+ }
+
+ if (isAutoClose())
+ {
+ if (filterLogString == null)
+ {
+ filterLogString = "";
+ }
+ else
+ {
+ filterLogString += ",";
+ }
+ filterLogString += "AutoClose";
+ }
+
+ if (isBrowser())
+ {
+ // We do not need to check for null here as all Browsers are AutoClose
+ filterLogString +=",Browser";
+ }
+
+ CurrentActor.get().
+ message(_logSubject,
+ SubscriptionMessages.SUB_1001(filterLogString,
+ queue.isDurable() && exclusive,
+ filterLogString != null));
+ }
}
public String toString()
@@ -494,20 +540,8 @@ public abstract class SubscriptionImpl implements Subscription, FlowCreditManage
}
- if (closed)
- {
- if (_logger.isDebugEnabled())
- {
- _logger.debug("Called close() on a closed subscription");
- }
-
- return;
- }
-
- if (_logger.isInfoEnabled())
- {
- _logger.info("Closing subscription (" + debugIdentity() + "):" + this);
- }
+ //Log Subscription closed
+ CurrentActor.get().message(_logSubject, SubscriptionMessages.SUB_1002());
}
public boolean isClosed()
@@ -551,9 +585,14 @@ public abstract class SubscriptionImpl implements Subscription, FlowCreditManage
return _channel.getProtocolSession();
}
+ public LogActor getLogActor()
+ {
+ return _logActor;
+ }
+
public AMQQueue getQueue()
{
- return _queue;
+ return _queue;
}
public void onDequeue(final QueueEntry queueEntry)
@@ -570,7 +609,7 @@ public abstract class SubscriptionImpl implements Subscription, FlowCreditManage
public void creditStateChanged(boolean hasCredit)
{
-
+
if(hasCredit)
{
if(_state.compareAndSet(State.SUSPENDED, State.ACTIVE))
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/Subscription_0_10.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/Subscription_0_10.java
index dd8f5d75c9..88617d53b8 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/Subscription_0_10.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/Subscription_0_10.java
@@ -29,6 +29,12 @@ import org.apache.qpid.server.flow.CreditCreditManager;
import org.apache.qpid.server.flow.WindowCreditManager;
import org.apache.qpid.server.flow.FlowCreditManager_0_10;
import org.apache.qpid.server.filter.FilterManager;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.logging.actors.SubscriptionActor;
+import org.apache.qpid.server.logging.messages.SubscriptionMessages;
+import org.apache.qpid.server.logging.subjects.SubscriptionLogSubject;
+import org.apache.qpid.server.logging.LogSubject;
+import org.apache.qpid.server.logging.LogActor;
import org.apache.qpid.server.message.ServerMessage;
import org.apache.qpid.server.message.MessageTransferMessage;
import org.apache.qpid.server.transport.ServerSession;
@@ -83,6 +89,9 @@ public class Subscription_0_10 implements Subscription, FlowCreditManager.FlowCr
private ConcurrentHashMap<Integer, QueueEntry> _sentMap = new ConcurrentHashMap<Integer, QueueEntry>();
private static final Struct[] EMPTY_STRUCT_ARRAY = new Struct[0];
+ private LogSubject _logSubject;
+ private LogActor _logActor;
+
public Subscription_0_10(ServerSession session, String destination, MessageAcceptMode acceptMode,
MessageAcquireMode acquireMode,
@@ -100,6 +109,9 @@ public class Subscription_0_10 implements Subscription, FlowCreditManager.FlowCr
_creditManager.addStateListener(this);
_state.set(_creditManager.hasCredit() ? State.ACTIVE : State.SUSPENDED);
+ _logSubject = new SubscriptionLogSubject(this);
+ _logActor = new SubscriptionActor(CurrentActor.get().getRootMessageLogger(), this);
+
}
public AMQQueue getQueue()
@@ -112,7 +124,7 @@ public class Subscription_0_10 implements Subscription, FlowCreditManager.FlowCr
return _owningState;
}
- public void setQueue(AMQQueue queue)
+ public void setQueue(AMQQueue queue, boolean exclusive)
{
if(getQueue() != null)
{
@@ -581,4 +593,10 @@ public class Subscription_0_10 implements Subscription, FlowCreditManager.FlowCr
return _subscriptionID;
}
+ public LogActor getLogActor()
+ {
+ return _logActor;
+ }
+
+
}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/QpidAcceptor.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/QpidAcceptor.java
new file mode 100644
index 0000000000..61cc7cdeb6
--- /dev/null
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/QpidAcceptor.java
@@ -0,0 +1,44 @@
+/*
+ *
+ * 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.qpid.server.transport;
+
+import org.apache.mina.common.IoAcceptor;
+
+public class QpidAcceptor
+{
+ IoAcceptor _acceptor;
+ String _protocol;
+ public QpidAcceptor(IoAcceptor acceptor, String protocol)
+ {
+ _acceptor = acceptor;
+ _protocol = protocol;
+ }
+
+ public IoAcceptor getIoAcceptor()
+ {
+ return _acceptor;
+ }
+
+ public String toString()
+ {
+ return _protocol;
+ }
+}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java
index 68d4de4af4..e3889162ad 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java
@@ -33,6 +33,7 @@ public class AMQBrokerManagerMBeanTest extends TestCase
{
private QueueRegistry _queueRegistry;
private ExchangeRegistry _exchangeRegistry;
+ private VirtualHost _vHost;
public void testExchangeOperations() throws Exception
{
@@ -44,9 +45,8 @@ public class AMQBrokerManagerMBeanTest extends TestCase
assertTrue(_exchangeRegistry.getExchange(new AMQShortString(exchange2)) == null);
assertTrue(_exchangeRegistry.getExchange(new AMQShortString(exchange3)) == null);
- VirtualHost vHost = ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHost("test");
- ManagedBroker mbean = new AMQBrokerManagerMBean((VirtualHost.VirtualHostMBean) vHost.getManagedObject());
+ ManagedBroker mbean = new AMQBrokerManagerMBean((VirtualHost.VirtualHostMBean) _vHost.getManagedObject());
mbean.createNewExchange(exchange1, "direct", false);
mbean.createNewExchange(exchange2, "topic", false);
mbean.createNewExchange(exchange3, "headers", false);
@@ -67,9 +67,8 @@ public class AMQBrokerManagerMBeanTest extends TestCase
public void testQueueOperations() throws Exception
{
String queueName = "testQueue_" + System.currentTimeMillis();
- VirtualHost vHost = ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHost("test");
- ManagedBroker mbean = new AMQBrokerManagerMBean((VirtualHost.VirtualHostMBean) vHost.getManagedObject());
+ ManagedBroker mbean = new AMQBrokerManagerMBean((VirtualHost.VirtualHostMBean) _vHost.getManagedObject());
assertTrue(_queueRegistry.getQueue(new AMQShortString(queueName)) == null);
@@ -85,7 +84,15 @@ public class AMQBrokerManagerMBeanTest extends TestCase
{
super.setUp();
IApplicationRegistry appRegistry = ApplicationRegistry.getInstance();
- _queueRegistry = appRegistry.getVirtualHostRegistry().getVirtualHost("test").getQueueRegistry();
- _exchangeRegistry = appRegistry.getVirtualHostRegistry().getVirtualHost("test").getExchangeRegistry();
+ _vHost = appRegistry.getVirtualHostRegistry().getVirtualHost("test");
+ _queueRegistry = _vHost.getQueueRegistry();
+ _exchangeRegistry = _vHost.getExchangeRegistry();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ //Ensure we close the opened Registry
+ ApplicationRegistry.remove();
}
}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/ExtractResendAndRequeueTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/ExtractResendAndRequeueTest.java
index ad39094d2c..06aef13dde 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/ExtractResendAndRequeueTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/ExtractResendAndRequeueTest.java
@@ -62,7 +62,7 @@ public class ExtractResendAndRequeueTest extends TestCase
UnacknowledgedMessageMapImpl _unacknowledgedMessageMap;
private static final int INITIAL_MSG_COUNT = 10;
- private AMQQueue _queue = new MockAMQQueue();
+ private AMQQueue _queue = new MockAMQQueue(getName());
private LinkedList<QueueEntry> _referenceList = new LinkedList<QueueEntry>();
@Override
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/ack/TxAckTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/ack/TxAckTest.java
index 0b48feddcd..eac887bd60 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/ack/TxAckTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/ack/TxAckTest.java
@@ -28,6 +28,7 @@ import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.framing.ContentHeaderBody;
import org.apache.qpid.framing.abstraction.MessagePublishInfo;
import org.apache.qpid.server.RequiredDeliveryException;
+import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.server.configuration.VirtualHostConfiguration;
import org.apache.qpid.server.queue.AMQMessage;
@@ -53,6 +54,10 @@ public class TxAckTest extends TestCase
{
super.setUp();
+
+ // Highlight that this test will cause the creation of an AR
+ ApplicationRegistry.getInstance();
+
//ack only 5th msg
individual = new Scenario(10, Arrays.asList(5l), Arrays.asList(1l, 2l, 3l, 4l, 6l, 7l, 8l, 9l, 10l));
individual.update(5, false);
@@ -77,6 +82,10 @@ public class TxAckTest extends TestCase
individual.stop();
multiple.stop();
combined.stop();
+
+ // Ensure we close the AR we created
+ ApplicationRegistry.remove();
+ super.tearDown();
}
public void testPrepare() throws AMQException
@@ -121,10 +130,8 @@ public class TxAckTest extends TestCase
new LinkedList<RequiredDeliveryException>()
);
- PropertiesConfiguration env = new PropertiesConfiguration();
- env.setProperty("name", "test");
- VirtualHost virtualHost = new VirtualHost(new VirtualHostConfiguration("test", env), null);
-
+ VirtualHost virtualHost = ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHosts().iterator().next();
+
_queue = AMQQueueFactory.createAMQQueueImpl(new AMQShortString("test"), false, null, false,
virtualHost, null);
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java
index 2879277784..4e20f537f1 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java
@@ -49,13 +49,17 @@ public class ServerConfigurationTest extends TestCase
@Override
public void setUp()
{
+ //Highlight that this test will cause a new AR to be created
+ ApplicationRegistry.getInstance();
+
_config = new XMLConfiguration();
}
@Override
- public void tearDown()
+ public void tearDown() throws Exception
{
- ApplicationRegistry.removeAll();
+ //Correctly Close the AR we created
+ ApplicationRegistry.remove();
}
public void testSetJMXManagementPort() throws ConfigurationException
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/VirtualHostConfigurationTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/VirtualHostConfigurationTest.java
index ba504d3064..5d3b4e681a 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/VirtualHostConfigurationTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/VirtualHostConfigurationTest.java
@@ -21,7 +21,6 @@ package org.apache.qpid.server.configuration;
import junit.framework.TestCase;
-
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.qpid.AMQException;
@@ -39,12 +38,23 @@ public class VirtualHostConfigurationTest extends TestCase
@Override
protected void setUp() throws Exception
- {
+ {
+ super.setUp();
+ //Highlight that this test will cause a new AR to be created
+ ApplicationRegistry.getInstance();
// Fill config file with stuff
configXml = new XMLConfiguration();
configXml.setRootElementName("virtualhosts");
configXml.addProperty("virtualhost(-1).name", "test");
}
+
+ public void tearDown() throws Exception
+ {
+ //Correctly close the AR we created
+ ApplicationRegistry.remove();
+
+ super.tearDown();
+ }
public void testQueuePriority() throws Exception
{
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/DestWildExchangeTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/DestWildExchangeTest.java
index 27ef04431b..507096bd42 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/DestWildExchangeTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/DestWildExchangeTest.java
@@ -62,7 +62,7 @@ public class DestWildExchangeTest extends TestCase
public void tearDown()
{
- ApplicationRegistry.remove(1);
+ ApplicationRegistry.remove();
}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java
index e223ba8d15..ac12e050b4 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java
@@ -131,7 +131,7 @@ public class ExchangeMBeanTest extends TestCase
{
super.setUp();
- IApplicationRegistry applicationRegistry = ApplicationRegistry.getInstance(1);
+ IApplicationRegistry applicationRegistry = ApplicationRegistry.getInstance();
_virtualHost = applicationRegistry.getVirtualHostRegistry().getVirtualHost("test");
_queueRegistry = _virtualHost.getQueueRegistry();
_queue = AMQQueueFactory.createAMQQueueImpl(new AMQShortString("testQueue"), false, new AMQShortString("ExchangeMBeanTest"), false, _virtualHost,
@@ -141,7 +141,8 @@ public class ExchangeMBeanTest extends TestCase
protected void tearDown()
{
- ApplicationRegistry.remove(1);
+ // Correctly Close the AR that we created above
+ ApplicationRegistry.remove();
}
}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java
index 3c6abd0ad9..750a1cd081 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java
@@ -22,7 +22,6 @@ package org.apache.qpid.server.exchange;
import org.apache.qpid.AMQException;
import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.util.NullApplicationRegistry;
import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.server.protocol.InternalTestProtocolSession;
import org.apache.qpid.server.protocol.AMQProtocolSession;
@@ -34,15 +33,16 @@ public class HeadersExchangeTest extends AbstractHeadersExchangeTestBase
protected void setUp() throws Exception
{
super.setUp();
- ApplicationRegistry.initialise(new NullApplicationRegistry(), 1);
+ // AR will use the NullAR by default
// Just use the first vhost.
- VirtualHost virtualHost = ApplicationRegistry.getInstance(1).getVirtualHostRegistry().getVirtualHosts().iterator().next();
+ VirtualHost virtualHost = ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHosts().iterator().next();
_protocolSession = new InternalTestProtocolSession(virtualHost);
}
protected void tearDown()
{
- ApplicationRegistry.remove(1);
+ // Correctly Close the AR that we created above
+ ApplicationRegistry.remove();
}
public void testSimple() throws AMQException
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java
index 009699be35..fb3c96a5d3 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPChannelActorTest.java
@@ -57,8 +57,12 @@ public class AMQPChannelActorTest extends TestCase
AMQProtocolSession _session;
AMQChannel _channel;
- public void setUp() throws ConfigurationException, AMQException
+ public void setUp() throws Exception, AMQException
{
+ super.setUp();
+ //Highlight that this test will cause a new AR to be created
+ ApplicationRegistry.getInstance();
+
Configuration config = new PropertiesConfiguration();
ServerConfiguration serverConfig = new ServerConfiguration(config);
@@ -84,9 +88,13 @@ public class AMQPChannelActorTest extends TestCase
}
- public void tearDown()
+ public void tearDown() throws Exception
{
_rawLogger.clearLogMessages();
+ // Correctly Close the AR we created
+ ApplicationRegistry.remove();
+
+ super.tearDown();
}
/**
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java
index 54eddf1050..0700fd3c1a 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/AMQPConnectionActorTest.java
@@ -54,17 +54,26 @@ public class AMQPConnectionActorTest extends TestCase
LogActor _amqpActor;
UnitTestMessageLogger _rawLogger;
- public void setUp() throws ConfigurationException, AMQException
+ public void setUp() throws Exception, AMQException
{
+ super.setUp();
+ //Highlight that this test will cause a new AR to be created
+ ApplicationRegistry.getInstance();
+
Configuration config = new PropertiesConfiguration();
ServerConfiguration serverConfig = new ServerConfiguration(config);
setUpWithConfig(serverConfig);
}
- public void tearDown()
+ public void tearDown() throws Exception
{
_rawLogger.clearLogMessages();
+
+ // Correctly Close the AR we created
+ ApplicationRegistry.remove();
+
+ super.tearDown();
}
private void setUpWithConfig(ServerConfiguration serverConfig) throws AMQException
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java
index e7dc0ea5da..79fdff2dc6 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/CurrentActorTest.java
@@ -62,8 +62,9 @@ public class CurrentActorTest extends TestCase
// Create a single session for this test.
AMQProtocolSession _session;
- public void setUp() throws AMQException
+ public void setUp() throws Exception
{
+ super.setUp();
// Create a single session for this test.
VirtualHost virtualHost = ApplicationRegistry.getInstance().
getVirtualHostRegistry().getVirtualHosts().iterator().next();
@@ -72,7 +73,17 @@ public class CurrentActorTest extends TestCase
_session = new InternalTestProtocolSession(virtualHost);
}
- public void testFIFO() throws AMQException
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ // Correctly Close the AR we created
+ ApplicationRegistry.remove();
+ super.tearDown();
+ }
+
+
+ public void testLIFO() throws AMQException
{
// Create a new actor using retrieving the rootMessageLogger from
// the default ApplicationRegistry.
@@ -143,11 +154,11 @@ public class CurrentActorTest extends TestCase
assertEquals("Retrieved actor is not as expected ",
connectionActor, CurrentActor.get());
- // Verify that removing the last actor returns us to a null value.
+ // Verify that removing the our last actor it returns us to the test
+ // default that the ApplicationRegistry sets.
CurrentActor.remove();
- assertNull("CurrentActor should be null", CurrentActor.get());
-
+ assertEquals("CurrentActor not the Test default", TestLogActor.class ,CurrentActor.get().getClass());
}
public void testThreadLocal()
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/SubscriptionActorTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/SubscriptionActorTest.java
new file mode 100644
index 0000000000..4e357ec52e
--- /dev/null
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/SubscriptionActorTest.java
@@ -0,0 +1,132 @@
+/*
+ *
+ * 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.qpid.server.logging.actors;
+
+import junit.framework.TestCase;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.qpid.server.configuration.ServerConfiguration;
+import org.apache.qpid.server.logging.LogActor;
+import org.apache.qpid.server.logging.LogMessage;
+import org.apache.qpid.server.logging.LogSubject;
+import org.apache.qpid.server.logging.RootMessageLogger;
+import org.apache.qpid.server.logging.RootMessageLoggerImpl;
+import org.apache.qpid.server.logging.rawloggers.UnitTestMessageLogger;
+import org.apache.qpid.server.subscription.MockSubscription;
+import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.queue.MockAMQQueue;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+
+import java.security.Principal;
+import java.util.List;
+
+/**
+ * Test : AMQPConnectionActorTest
+ * Validate the AMQPConnectionActor class.
+ *
+ * The test creates a new AMQPActor and then logs a message using it.
+ *
+ * The test then verifies that the logged message was the only one created and
+ * that the message contains the required message.
+ */
+public class SubscriptionActorTest extends TestCase
+{
+
+ LogActor _amqpActor;
+ UnitTestMessageLogger _rawLogger;
+
+ public void setUp() throws ConfigurationException
+ {
+ Configuration config = new PropertiesConfiguration();
+ ServerConfiguration serverConfig = new ServerConfiguration(config);
+
+ _rawLogger = new UnitTestMessageLogger();
+ RootMessageLogger rootLogger =
+ new RootMessageLoggerImpl(serverConfig, _rawLogger);
+
+ MockSubscription mockSubscription = new MockSubscription();
+
+ MockAMQQueue queue = new MockAMQQueue(getName());
+
+ queue.setVirtualHost(ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHosts().iterator().next());
+
+ mockSubscription.setQueue(queue,false);
+
+ _amqpActor = new SubscriptionActor(rootLogger, mockSubscription);
+ }
+
+ public void tearDown()
+ {
+ _rawLogger.clearLogMessages();
+ ApplicationRegistry.remove();
+ }
+
+ /**
+ * Test the AMQPActor logging as a Subscription logger.
+ *
+ * The test sends a message then verifies that it entered the logs.
+ *
+ * The log message should be fully repalaced (no '{n}' values) and should
+ * contain subscription identification.
+ */
+ public void testSubscription()
+ {
+ final String message = "test logging";
+
+ _amqpActor.message(new LogSubject()
+ {
+ public String toString()
+ {
+ return "[AMQPActorTest]";
+ }
+
+ }, new LogMessage()
+ {
+ public String toString()
+ {
+ return message;
+ }
+ });
+
+ List<Object> logs = _rawLogger.getLogMessages();
+
+ assertEquals("Message log size not as expected.", 1, logs.size());
+
+ // Verify that the logged message is present in the output
+ assertTrue("Message was not found in log message",
+ logs.get(0).toString().contains(message));
+
+ // Verify that all the values were presented to the MessageFormatter
+ // so we will not end up with '{n}' entries in the log.
+ assertFalse("Verify that the string does not contain any '{'.",
+ logs.get(0).toString().contains("{"));
+
+ // Verify that the message has the correct type
+ assertTrue("Message contains the [sub: prefix",
+ logs.get(0).toString().contains("[sub:"));
+
+ // Verify that the logged message does not contains the 'ch:' marker
+ assertFalse("Message was logged with a channel identifier." + logs.get(0),
+ logs.get(0).toString().contains("/ch:"));
+ }
+
+}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/TestBlankActor.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/TestLogActor.java
index ec84d8bc9b..acab5b28d2 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/TestBlankActor.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/TestLogActor.java
@@ -22,12 +22,12 @@ package org.apache.qpid.server.logging.actors;
import org.apache.qpid.server.logging.RootMessageLogger;
-public class TestBlankActor extends AbstractActor
+public class TestLogActor extends AbstractActor
{
- public TestBlankActor(RootMessageLogger rootLogger)
+ public TestLogActor(RootMessageLogger rootLogger)
{
super(rootLogger);
- _logString = "[Blank]";
+ _logString = "[Test Actor] ";
}
}
\ No newline at end of file
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java
index 17a9d6c591..2656a8b5cb 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java
@@ -30,9 +30,10 @@ import org.apache.qpid.server.logging.LogMessage;
import org.apache.qpid.server.logging.LogSubject;
import org.apache.qpid.server.logging.RootMessageLogger;
import org.apache.qpid.server.logging.RootMessageLoggerImpl;
-import org.apache.qpid.server.logging.actors.TestBlankActor;
+import org.apache.qpid.server.logging.actors.TestLogActor;
import org.apache.qpid.server.logging.rawloggers.UnitTestMessageLogger;
import org.apache.qpid.server.logging.subjects.TestBlankSubject;
+import org.apache.qpid.server.registry.ApplicationRegistry;
import java.util.List;
@@ -44,15 +45,26 @@ public abstract class AbstractTestMessages extends TestCase
protected UnitTestMessageLogger _logger;
protected LogSubject _logSubject = new TestBlankSubject();
- public void setUp() throws ConfigurationException
+ public void setUp() throws Exception
{
+ super.setUp();
+ // Highlight that we create a new AR here
+ ApplicationRegistry.getInstance();
+
ServerConfiguration serverConfig = new ServerConfiguration(_config);
_logger = new UnitTestMessageLogger();
RootMessageLogger rootLogger =
new RootMessageLoggerImpl(serverConfig, _logger);
- _actor = new TestBlankActor(rootLogger);
+ _actor = new TestLogActor(rootLogger);
+ }
+
+ public void tearDown() throws Exception
+ {
+ // Correctly Close the AR that we created above
+ ApplicationRegistry.remove();
+ super.tearDown();
}
protected List<Object> performLog()
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java
index 56d611a44f..74b448b229 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java
@@ -32,7 +32,7 @@ import org.apache.qpid.server.logging.LogMessage;
import org.apache.qpid.server.logging.LogSubject;
import org.apache.qpid.server.logging.RootMessageLogger;
import org.apache.qpid.server.logging.RootMessageLoggerImpl;
-import org.apache.qpid.server.logging.actors.TestBlankActor;
+import org.apache.qpid.server.logging.actors.TestLogActor;
import org.apache.qpid.server.logging.rawloggers.UnitTestMessageLogger;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.virtualhost.VirtualHost;
@@ -60,6 +60,14 @@ public abstract class AbstractTestLogSubject extends TestCase
_session = new InternalTestProtocolSession(virtualHost);
}
+ public void tearDown() throws Exception
+ {
+ // Correctly Close the AR that we created above
+ ApplicationRegistry.remove();
+
+ super.tearDown();
+ }
+
protected List<Object> performLog() throws ConfigurationException
{
if (_subject == null)
@@ -73,7 +81,7 @@ public abstract class AbstractTestLogSubject extends TestCase
RootMessageLogger rootLogger =
new RootMessageLoggerImpl(serverConfig, logger);
- LogActor actor = new TestBlankActor(rootLogger);
+ LogActor actor = new TestLogActor(rootLogger);
actor.message(_subject, new LogMessage()
{
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubjectTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubjectTest.java
index 624421f447..53edf98d79 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubjectTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubjectTest.java
@@ -34,7 +34,7 @@ public class MessageStoreLogSubjectTest extends AbstractTestLogSubject
_testVhost = ApplicationRegistry.getInstance().getVirtualHostRegistry().
getVirtualHost("test");
- _subject = new MessagesStoreLogSubject(_testVhost, _testVhost.getMessageStore());
+ _subject = new MessageStoreLogSubject(_testVhost, _testVhost.getMessageStore());
}
/**
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubjectTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubjectTest.java
index e217497b7b..fda951616e 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubjectTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubjectTest.java
@@ -63,7 +63,7 @@ public class SubscriptionLogSubjectTest extends AbstractTestLogSubject
_acks, _filters, _noLocal,
new LimitlessCreditManager());
- _subscription.setQueue(_queue);
+ _subscription.setQueue(_queue, false);
_subject = new SubscriptionLogSubject(_subscription);
}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBeanTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBeanTest.java
index 6050512679..e199255f50 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBeanTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBeanTest.java
@@ -26,6 +26,7 @@ import org.apache.qpid.AMQException;
import org.apache.qpid.codec.AMQCodecFactory;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.AMQChannel;
+import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.AMQQueueFactory;
import org.apache.qpid.server.registry.ApplicationRegistry;
@@ -109,20 +110,17 @@ public class AMQProtocolSessionMBeanTest extends TestCase
{
super.setUp();
- IApplicationRegistry appRegistry = ApplicationRegistry.getInstance();
- _protocolSession =
- new AMQMinaProtocolSession(new TestIoSession(), appRegistry.getVirtualHostRegistry(), new AMQCodecFactory(true));
- // Need to authenticate session for it to work, (well for logging to work)
- _protocolSession.setAuthorizedID(new Principal()
- {
- public String getName()
- {
- return "AMQProtocolSessionMBeanTestUser";
- }
- });
- _protocolSession.setVirtualHost(appRegistry.getVirtualHostRegistry().getVirtualHost("test"));
+ VirtualHost vhost = ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHost("test");
+ _protocolSession = new InternalTestProtocolSession(vhost);
+
_channel = new AMQChannel(_protocolSession, 1, _messageStore);
_protocolSession.addChannel(_channel);
_mbean = (AMQProtocolSessionMBean) _protocolSession.getManagedObject();
}
+
+ @Override
+ protected void tearDown()
+ {
+ ApplicationRegistry.remove();
+ }
}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MaxChannelsTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MaxChannelsTest.java
index 7e16737a83..8597fc5863 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MaxChannelsTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MaxChannelsTest.java
@@ -25,6 +25,7 @@ import org.apache.qpid.AMQException;
import org.apache.qpid.codec.AMQCodecFactory;
import org.apache.qpid.protocol.AMQConstant;
import org.apache.qpid.server.AMQChannel;
+import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.server.logging.actors.CurrentActor;
import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.registry.IApplicationRegistry;
@@ -36,27 +37,12 @@ import java.security.Principal;
/** Test class to test MBean operations for AMQMinaProtocolSession. */
public class MaxChannelsTest extends TestCase
{
- private IApplicationRegistry _appRegistry;
private AMQMinaProtocolSession _session;
public void testChannels() throws Exception
{
- _session = new AMQMinaProtocolSession(new TestIoSession(), _appRegistry
- .getVirtualHostRegistry(), new AMQCodecFactory(true));
-
- // Set the current Actor for these tests
- CurrentActor.set(_session.getLogActor());
-
- // Need to authenticate session for it to work, (well for logging to work)
- _session.setAuthorizedID(new Principal()
- {
- public String getName()
- {
- return "AMQProtocolSessionMBeanTestUser";
- }
- });
-
- _session.setVirtualHost(_appRegistry.getVirtualHostRegistry().getVirtualHost("test"));
+ VirtualHost vhost = ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHost("test");
+ _session = new InternalTestProtocolSession(vhost);
// check the channel count is correct
int channelCount = _session.getChannels().size();
@@ -84,11 +70,12 @@ public class MaxChannelsTest extends TestCase
@Override
public void setUp()
{
- _appRegistry = ApplicationRegistry.getInstance(1);
+ //Highlight that this test will cause a new AR to be created
+ ApplicationRegistry.getInstance();
}
@Override
- public void tearDown()
+ public void tearDown() throws Exception
{
try {
_session.closeSession();
@@ -98,10 +85,9 @@ public class MaxChannelsTest extends TestCase
}
finally
{
- //Remove the actor set during the test
- CurrentActor.remove();
- }
- ApplicationRegistry.remove(1);
+ // Correctly Close the AR we created
+ ApplicationRegistry.remove();
+ }
}
}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java
index db7312202b..8c6260ca9e 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java
@@ -294,7 +294,7 @@ public class AMQQueueAlertTest extends TestCase
protected void setUp() throws Exception
{
super.setUp();
- IApplicationRegistry applicationRegistry = ApplicationRegistry.getInstance(1);
+ IApplicationRegistry applicationRegistry = ApplicationRegistry.getInstance();
_virtualHost = applicationRegistry.getVirtualHostRegistry().getVirtualHost("test");
_protocolSession = new InternalTestProtocolSession(_virtualHost);
CurrentActor.set(_protocolSession.getLogActor());
@@ -302,8 +302,9 @@ public class AMQQueueAlertTest extends TestCase
protected void tearDown()
{
+ // Remove the Protocol Session Actor set above
CurrentActor.remove();
- ApplicationRegistry.remove(1);
+ ApplicationRegistry.remove();
}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java
index 520e49c56a..e692069663 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java
@@ -46,7 +46,7 @@ public class AMQQueueFactoryTest extends TestCase
public void tearDown()
{
assertEquals("Queue was not registered in virtualhost", 1, _queueRegistry.getQueues().size());
- ApplicationRegistry.remove(1);
+ ApplicationRegistry.remove();
}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java
index 1acf8a3c31..03eb7021ad 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java
@@ -360,7 +360,7 @@ public class AMQQueueMBeanTest extends TestCase
protected void setUp() throws Exception
{
super.setUp();
- IApplicationRegistry applicationRegistry = ApplicationRegistry.getInstance(1);
+ IApplicationRegistry applicationRegistry = ApplicationRegistry.getInstance();
_virtualHost = applicationRegistry.getVirtualHostRegistry().getVirtualHost("test");
_messageStore = _virtualHost.getMessageStore();
@@ -378,7 +378,7 @@ public class AMQQueueMBeanTest extends TestCase
public void tearDown()
{
- ApplicationRegistry.remove(1);
+ ApplicationRegistry.remove();
}
private void sendMessages(int messageCount, boolean persistent) throws AMQException
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AckTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AckTest.java
index d360904dd7..79f7d75aa9 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AckTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AckTest.java
@@ -74,8 +74,8 @@ public class AckTest extends TestCase
protected void setUp() throws Exception
{
super.setUp();
- ApplicationRegistry.initialise(new NullApplicationRegistry(), 1);
-
+ // The NullApplicationRegistry will be created by default when
+ // calling AR.getInstance
_virtualHost = ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHost("test");
_messageStore = new TestMemoryMessageStore();
_protocolSession = new InternalTestProtocolSession(_virtualHost);
@@ -89,7 +89,7 @@ public class AckTest extends TestCase
protected void tearDown()
{
- ApplicationRegistry.remove(1);
+ ApplicationRegistry.remove();
}
private void publishMessages(int count) throws AMQException
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java
index bfbb3e19e5..8e1a6d2348 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java
@@ -55,11 +55,6 @@ public class MockAMQQueue implements AMQQueue
_name = new AMQShortString(name);
}
- public MockAMQQueue()
- {
-
- }
-
public AMQShortString getName()
{
return _name;
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTest.java
index f0a4838cae..852134d9fe 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTest.java
@@ -94,7 +94,7 @@ public class SimpleAMQQueueTest extends TestCase
{
super.setUp();
//Create Application Registry for test
- ApplicationRegistry applicationRegistry = (ApplicationRegistry)ApplicationRegistry.getInstance(1);
+ ApplicationRegistry applicationRegistry = (ApplicationRegistry)ApplicationRegistry.getInstance();
PropertiesConfiguration env = new PropertiesConfiguration();
_virtualHost = new VirtualHost(new VirtualHostConfiguration(getClass().getName(), env), _store);
@@ -107,7 +107,7 @@ public class SimpleAMQQueueTest extends TestCase
protected void tearDown()
{
_queue.stop();
- ApplicationRegistry.remove(1);
+ ApplicationRegistry.remove();
}
public void testCreateQueue() throws AMQException
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java
index 832df80004..02de09c91f 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java
@@ -36,7 +36,7 @@ public class SimpleAMQQueueThreadPoolTest extends TestCase
public void test() throws AMQException
{
int initialCount = ReferenceCountingExecutorService.getInstance().getReferenceCount();
- VirtualHost test = ApplicationRegistry.getInstance(1).getVirtualHostRegistry().getVirtualHost("test");
+ VirtualHost test = ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHost("test");
try
{
@@ -54,7 +54,7 @@ public class SimpleAMQQueueThreadPoolTest extends TestCase
}
finally
{
- ApplicationRegistry.remove(1);
+ ApplicationRegistry.remove();
}
}
}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/registry/ApplicationRegistryShutdownTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/registry/ApplicationRegistryShutdownTest.java
index 939e3436a5..e75ed640aa 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/registry/ApplicationRegistryShutdownTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/registry/ApplicationRegistryShutdownTest.java
@@ -22,6 +22,7 @@ package org.apache.qpid.server.registry;
import junit.framework.TestCase;
import org.apache.qpid.server.util.TestApplicationRegistry;
+import org.apache.qpid.AMQException;
import java.security.Security;
import java.security.Provider;
@@ -37,13 +38,24 @@ import java.util.LinkedList;
public class ApplicationRegistryShutdownTest extends TestCase
{
- ApplicationRegistry _registry;
+ IApplicationRegistry _registry;
public void setUp() throws Exception
{
+ //Highlight that this test will cause a new AR to be created
+ // This must used TestAppRegistry but during the test getInstance()
+ // will be called so we must ensure to do the remove()
_registry = new TestApplicationRegistry();
}
+ @Override
+ public void tearDown() throws Exception
+ {
+ // Correctly Close the AR we created
+ ApplicationRegistry.remove();
+ }
+
+
/**
* QPID-1399 : Ensure that the Authentiction manager unregisters any SASL providers created during
* ApplicationRegistry initialisation.
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/ACLManagerTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/ACLManagerTest.java
index 8262ca0e29..8102360ce0 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/ACLManagerTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/ACLManagerTest.java
@@ -72,6 +72,14 @@ public class ACLManagerTest extends TestCase
// Create a single session for this test.
_session = new InternalTestProtocolSession(virtualHost);
}
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ // Correctly Close the AR we created
+ ApplicationRegistry.remove();
+ super.tearDown();
+ }
public void testACLManagerConfigurationPluginManager() throws Exception
{
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/PrincipalPermissionsTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/PrincipalPermissionsTest.java
index e1e93ae9cb..69c8ccaa5d 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/PrincipalPermissionsTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/PrincipalPermissionsTest.java
@@ -36,6 +36,7 @@ import org.apache.qpid.server.queue.AMQQueueFactory;
import org.apache.qpid.server.security.access.ACLPlugin.AuthzResult;
import org.apache.qpid.server.store.SkeletonMessageStore;
import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.registry.ApplicationRegistry;
public class PrincipalPermissionsTest extends TestCase
{
@@ -65,6 +66,9 @@ public class PrincipalPermissionsTest extends TestCase
@Override
public void setUp()
{
+ //Highlight that this test will cause a new AR to be created
+ ApplicationRegistry.getInstance();
+
_perms = new PrincipalPermissions(_user);
try
{
@@ -78,7 +82,15 @@ public class PrincipalPermissionsTest extends TestCase
fail(e.getMessage());
}
}
-
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ //Ensure we close the opened Registry
+ ApplicationRegistry.remove();
+ }
+
+
public void testPrincipalPermissions()
{
assertNotNull(_perms);
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/plugins/network/FirewallPluginTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/plugins/network/FirewallPluginTest.java
index f56d562354..a497365b06 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/plugins/network/FirewallPluginTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/security/access/plugins/network/FirewallPluginTest.java
@@ -89,6 +89,7 @@ public class FirewallPluginTest extends TestCase
@Override
public void setUp() throws Exception
{
+ super.setUp();
_store = new TestableMemoryMessageStore();
TestIoSession iosession = new TestIoSession();
iosession.setAddress("127.0.0.1");
@@ -100,7 +101,14 @@ public class FirewallPluginTest extends TestCase
AMQCodecFactory codecFactory = new AMQCodecFactory(true);
_session = new AMQMinaProtocolSession(iosession, virtualHostRegistry, codecFactory);
}
-
+
+ public void tearDown() throws Exception
+ {
+ // Correctly Close the AR that we created above
+ ApplicationRegistry.remove();
+ super.tearDown();
+ }
+
private FirewallPlugin initialisePlugin(String defaultAction, RuleInfo[] rules) throws IOException, ConfigurationException
{
// Create sample config file
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java
index 30b571ef63..5802655cfc 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java
@@ -136,12 +136,12 @@ public class MessageStoreTest extends TestCase
protected void setUp()
{
- ApplicationRegistry.getInstance(1);
+ ApplicationRegistry.getInstance();
}
protected void tearDown()
{
- ApplicationRegistry.remove(1);
+ ApplicationRegistry.remove();
}
protected void runTestWithStore(Configuration configuration)
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/subscription/MockSubscription.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/subscription/MockSubscription.java
index 94f7ff33a6..060343d8ae 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/subscription/MockSubscription.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/subscription/MockSubscription.java
@@ -24,6 +24,8 @@ package org.apache.qpid.server.subscription;
import org.apache.qpid.AMQException;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.AMQChannel;
+import org.apache.qpid.server.logging.LogActor;
+import org.apache.qpid.server.filter.FilterManager;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.QueueEntry;
import org.apache.qpid.server.queue.QueueEntry.SubscriptionAcquiredState;
@@ -89,6 +91,11 @@ public class MockSubscription implements Subscription
return new QueueEntry.SubscriptionAcquiredState(this);
}
+ public LogActor getLogActor()
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public AMQQueue getQueue()
{
return queue;
@@ -176,7 +183,7 @@ public class MockSubscription implements Subscription
_queueContext = queueContext;
}
- public void setQueue(AMQQueue queue)
+ public void setQueue(AMQQueue queue, boolean exclusive)
{
this.queue = queue;
}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java
index b706ee51d8..f2096df9d1 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java
@@ -91,7 +91,7 @@ public class InternalBrokerBaseCase extends TestCase
public void tearDown() throws Exception
{
CurrentActor.remove();
- ApplicationRegistry.remove(1);
+ ApplicationRegistry.remove();
super.tearDown();
}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/util/NullApplicationRegistry.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/util/NullApplicationRegistry.java
index 9ef1e029d3..8fef8baa02 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/util/NullApplicationRegistry.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/util/NullApplicationRegistry.java
@@ -25,6 +25,8 @@ import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.qpid.server.configuration.ServerConfiguration;
import org.apache.qpid.server.configuration.VirtualHostConfiguration;
import org.apache.qpid.server.logging.RootMessageLoggerImpl;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.logging.actors.TestLogActor;
import org.apache.qpid.server.logging.rawloggers.Log4jMessageLogger;
import org.apache.qpid.server.management.NoopManagedObjectRegistry;
import org.apache.qpid.server.plugins.PluginManager;
@@ -39,6 +41,7 @@ import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
import java.util.Arrays;
import java.util.Collection;
import java.util.Properties;
+import java.util.NoSuchElementException;
public class NullApplicationRegistry extends ApplicationRegistry
{
@@ -53,6 +56,9 @@ public class NullApplicationRegistry extends ApplicationRegistry
_rootMessageLogger = new RootMessageLoggerImpl(_configuration, new Log4jMessageLogger());
+ //We should use a Test Actor Here not the Broker Actor
+ CurrentActor.set(new TestLogActor(_rootMessageLogger));
+
_configuration.setHousekeepingExpiredMessageCheckPeriod(200);
Properties users = new Properties();
@@ -73,14 +79,37 @@ public class NullApplicationRegistry extends ApplicationRegistry
_virtualHostRegistry.registerVirtualHost(dummyHost);
_virtualHostRegistry.setDefaultVirtualHostName("test");
_pluginManager = new PluginManager("");
+ _startup = new Exception("NAR");
}
-
+ private Exception _startup;
public Collection<String> getVirtualHostNames()
{
String[] hosts = {"test"};
return Arrays.asList(hosts);
}
+
+ @Override
+ public void close() throws Exception
+ {
+ try
+ {
+ super.close();
+ }
+ finally
+ {
+ try
+ {
+ CurrentActor.remove();
+ }
+ catch (NoSuchElementException npe)
+ {
+ _startup.printStackTrace();
+ _startup.printStackTrace(System.err);
+ }
+
+ }
+ }
}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java
index 4ecbffb4b4..43948c05c4 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java
@@ -40,6 +40,8 @@ import org.apache.qpid.server.store.TestableMemoryMessageStore;
import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
import org.apache.qpid.server.logging.RootMessageLoggerImpl;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.logging.actors.TestLogActor;
import org.apache.qpid.server.logging.rawloggers.Log4jMessageLogger;
import java.util.Collection;
@@ -77,7 +79,11 @@ public class TestApplicationRegistry extends ApplicationRegistry
{
_rootMessageLogger = new RootMessageLoggerImpl(_configuration,
new Log4jMessageLogger());
-
+
+ //Add a Test Actor as a lot of our System Tests reach in to the broker
+ // and manipulate it so the CurrentActor is not set.
+ CurrentActor.set(new TestLogActor(_rootMessageLogger));
+
Properties users = new Properties();
users.put("guest", "guest");
@@ -137,6 +143,19 @@ public class TestApplicationRegistry extends ApplicationRegistry
return _messageStore;
}
+ @Override
+ public void close() throws Exception
+ {
+ try
+ {
+ super.close();
+ }
+ finally
+ {
+ CurrentActor.remove();
+ }
+ }
+
}
diff --git a/qpid/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm b/qpid/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm
index 10be2299e9..fecc9a787e 100644
--- a/qpid/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm
+++ b/qpid/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm
@@ -45,7 +45,21 @@ public class ${type.name}Messages
static
{
- Locale currentLocale = ApplicationRegistry.getInstance().getConfiguration().getLocale();
+ reload();
+ }
+
+ public static void reload()
+ {
+ Locale currentLocale;
+
+ if (ApplicationRegistry.isConfigured())
+ {
+ currentLocale = ApplicationRegistry.getInstance().getConfiguration().getLocale();
+ }
+ else
+ {
+ currentLocale = Locale.getDefault();
+ }
_messages = ResourceBundle.getBundle("org.apache.qpid.server.logging.messages.LogMessages",
currentLocale);
@@ -54,6 +68,7 @@ public class ${type.name}Messages
_formatter.setLocale(currentLocale);
}
+
##
## The list stored under key 'list' in the 'type' HashMap contains all the
## log messages that this class should contain. So for each entry in the list
@@ -106,27 +121,11 @@ public class ${type.name}Messages
public static LogMessage ${message.methodName}(#foreach($parameter in ${message.parameters})${parameter.type} ${parameter.name}#if (${velocityCount} != ${message.parameters.size()} ), #end
#end#if(${message.parameters.size()} > 0 && ${message.options.size()} > 0), #end#foreach($option in ${message.options})boolean ${option.name}#if (${velocityCount} != ${message.options.size()} ), #end#end)
{
-##
-## If we don't have any parameters then we don't need the overhead of using the
-## message formatter so we can just set our return message to the retreived
-## fixed string.
-## So we don't need to update the _formatter with the new pattern.
-##
-## Here we setup rawMessage to be the formatted message ready for direct return
-## with the message.name or further processing to remove options.
-##
-#if(${message.parameters.size()} > 0)
- final Object[] messageArguments = {#foreach($parameter in ${message.parameters})${parameter.name}#if (${velocityCount} != ${message.parameters.size()} ), #end#end};
- _formatter.applyPattern(_messages.getString("${message.name}"));
- String rawMessage = _formatter.format(messageArguments);
-#else
- String rawMessage = _messages.getString("${message.name}");
-#end
-
+ String rawMessage = "${message.name} : " + _messages.getString("${message.name}");
## If we have some options then we need to build the message based
## on those values so only provide that logic if we need it.
#if(${message.options.size()} > 0)
- StringBuffer msg =new StringBuffer("${message.name} : ");
+ StringBuffer msg = new StringBuffer();
// Split the formatted message up on the option values so we can
// rebuild the message based on the configured options.
@@ -152,10 +151,26 @@ public class ${type.name}Messages
#end
}
- final String message = msg.toString();
+ rawMessage = msg.toString();
+#end
+
+##
+## If we don't have any parameters then we don't need the overhead of using the
+## message formatter so we can just set our return message to the retreived
+## fixed string.
+## So we don't need to update the _formatter with the new pattern.
+##
+## Here we setup rawMessage to be the formatted message ready for direct return
+## with the message.name or further processing to remove options.
+##
+#if(${message.parameters.size()} > 0)
+ final Object[] messageArguments = {#foreach($parameter in ${message.parameters})${parameter.name}#if (${velocityCount} != ${message.parameters.size()} ), #end#end};
+ _formatter.applyPattern(rawMessage);
+
+ final String message = _formatter.format(messageArguments);
#else
-## If we have no options then we can just format and set the log
- final String message = "${message.name} : " + rawMessage;
+## If we have no parameters then we can skip the formatter and set the log
+ final String message = rawMessage;
#end
return new LogMessage()
diff --git a/qpid/java/management/eclipse-plugin/build.xml b/qpid/java/management/eclipse-plugin/build.xml
index 7168d69c72..9952ff66e3 100644
--- a/qpid/java/management/eclipse-plugin/build.xml
+++ b/qpid/java/management/eclipse-plugin/build.xml
@@ -21,6 +21,7 @@
<project name="Eclipse Plugin" default="build">
<property name="module.depends" value="broker common management/common"/>
+ <property name="module.test.depends" value="broker/test" />
<import file="../../module.xml"/>
diff --git a/qpid/java/management/eclipse-plugin/icons/Thumbs.db b/qpid/java/management/eclipse-plugin/icons/Thumbs.db
deleted file mode 100644
index 306bfb2eda..0000000000
--- a/qpid/java/management/eclipse-plugin/icons/Thumbs.db
+++ /dev/null
Binary files differ
diff --git a/qpid/java/management/eclipse-plugin/icons/configuration_management.gif b/qpid/java/management/eclipse-plugin/icons/configuration_management.gif
new file mode 100644
index 0000000000..d11c996e57
--- /dev/null
+++ b/qpid/java/management/eclipse-plugin/icons/configuration_management.gif
Binary files differ
diff --git a/qpid/java/management/eclipse-plugin/icons/logging_management.gif b/qpid/java/management/eclipse-plugin/icons/logging_management.gif
new file mode 100644
index 0000000000..7f5fe98a73
--- /dev/null
+++ b/qpid/java/management/eclipse-plugin/icons/logging_management.gif
Binary files differ
diff --git a/qpid/java/management/eclipse-plugin/icons/qpidConnections.gif b/qpid/java/management/eclipse-plugin/icons/qpidConnections.gif
index 89489f11f2..17f927e9a4 100644
--- a/qpid/java/management/eclipse-plugin/icons/qpidConnections.gif
+++ b/qpid/java/management/eclipse-plugin/icons/qpidConnections.gif
Binary files differ
diff --git a/qpid/java/management/eclipse-plugin/icons/refresh.gif b/qpid/java/management/eclipse-plugin/icons/refresh.gif
index a063c230ac..1b724a6784 100644
--- a/qpid/java/management/eclipse-plugin/icons/refresh.gif
+++ b/qpid/java/management/eclipse-plugin/icons/refresh.gif
Binary files differ
diff --git a/qpid/java/management/eclipse-plugin/icons/server_information.gif b/qpid/java/management/eclipse-plugin/icons/server_information.gif
new file mode 100644
index 0000000000..716df436f9
--- /dev/null
+++ b/qpid/java/management/eclipse-plugin/icons/server_information.gif
Binary files differ
diff --git a/qpid/java/management/eclipse-plugin/icons/user_management.gif b/qpid/java/management/eclipse-plugin/icons/user_management.gif
new file mode 100644
index 0000000000..d28c326dea
--- /dev/null
+++ b/qpid/java/management/eclipse-plugin/icons/user_management.gif
Binary files differ
diff --git a/qpid/java/management/eclipse-plugin/icons/virtualhost_manager.gif b/qpid/java/management/eclipse-plugin/icons/virtualhost_manager.gif
new file mode 100644
index 0000000000..e7ec2a1544
--- /dev/null
+++ b/qpid/java/management/eclipse-plugin/icons/virtualhost_manager.gif
Binary files differ
diff --git a/qpid/java/management/eclipse-plugin/plugin.xml b/qpid/java/management/eclipse-plugin/plugin.xml
index 947e30fb7c..e151456fa1 100644
--- a/qpid/java/management/eclipse-plugin/plugin.xml
+++ b/qpid/java/management/eclipse-plugin/plugin.xml
@@ -150,6 +150,7 @@
<toolbar id="qpidMC">
<separator name="qpidActionsGroup" visible="false"/>
<separator name="refresh" visible="true"/>
+ <separator name="refresh2" visible="false"/>
<separator name="additions" visible="false"/>
</toolbar>
</menuContribution>
@@ -179,8 +180,8 @@
label="Refresh"
menubarPath="qpidmanager/additions"
style="push"
- toolbarPath="qpidMC/qpidActionsGroup"
- tooltip="Refresh"/>
+ toolbarPath="qpidMC/refresh2"
+ tooltip="Refresh Now"/>
<action
class="org.apache.qpid.management.ui.actions.RemoveServer"
definitionId="org.apache.qpid.management.ui.actions.cmd_remove"
diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java
index 2e87709a28..cb758efa43 100644
--- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java
+++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java
@@ -64,6 +64,16 @@ public abstract class ApplicationRegistry
PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT));
imageRegistry.put(Constants.NOTIFICATION_IMAGE,
org.apache.qpid.management.ui.Activator.getImageDescriptor("/icons/notifications.gif"));
+ imageRegistry.put(Constants.LOGGING_MANAGEMENT_IMAGE,
+ org.apache.qpid.management.ui.Activator.getImageDescriptor("/icons/logging_management.gif"));
+ imageRegistry.put(Constants.USER_MANAGEMENT_IMAGE,
+ org.apache.qpid.management.ui.Activator.getImageDescriptor("/icons/user_management.gif"));
+ imageRegistry.put(Constants.CONFIGURATION_MANAGEMENT_IMAGE,
+ org.apache.qpid.management.ui.Activator.getImageDescriptor("/icons/configuration_management.gif"));
+ imageRegistry.put(Constants.SERVER_INFO_IMAGE,
+ org.apache.qpid.management.ui.Activator.getImageDescriptor("/icons/server_information.gif"));
+ imageRegistry.put(Constants.VHOST_MANAGER_IMAGE,
+ org.apache.qpid.management.ui.Activator.getImageDescriptor("/icons/virtualhost_manager.gif"));
}
static
diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java
index e6f0e227d8..cec9c8a83c 100644
--- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java
+++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java
@@ -104,6 +104,11 @@ public class Constants
public final static String OPEN_FOLDER_IMAGE = "OpenFolderImage";
public final static String MBEAN_IMAGE = "MBeanImage";
public final static String NOTIFICATION_IMAGE = "NotificationImage";
+ public final static String LOGGING_MANAGEMENT_IMAGE = "LoggingManagementImage";
+ public final static String USER_MANAGEMENT_IMAGE = "UserManagementImage";
+ public final static String CONFIGURATION_MANAGEMENT_IMAGE = "ConfigurationManagementImage";
+ public final static String SERVER_INFO_IMAGE = "ServerInfoImage";
+ public final static String VHOST_MANAGER_IMAGE = "VhostManagerImage";
public final static String FONT_BUTTON = "ButtonFont";
public final static String FONT_BOLD = "BoldFont";
diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java
index 2f22a7164d..6563498d41 100644
--- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java
+++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java
@@ -36,6 +36,7 @@ import org.apache.qpid.management.common.mbeans.UserManagement;
import org.apache.qpid.management.ui.ApiVersion;
import org.apache.qpid.management.ui.ApplicationRegistry;
import org.apache.qpid.management.ui.ManagedBean;
+import org.apache.qpid.management.ui.ManagedObject;
import org.apache.qpid.management.ui.ManagedServer;
import org.apache.qpid.management.ui.ServerRegistry;
import org.apache.qpid.management.ui.exceptions.InfoRequiredException;
@@ -1151,7 +1152,42 @@ public class NavigationView extends ViewPart
}
else
{
- return ApplicationRegistry.getImage(MBEAN_IMAGE);
+ ManagedObject obj = node.getManagedObject();
+ if(obj instanceof ManagedBean)
+ {
+ ManagedBean mbean = (ManagedBean) obj;
+ String mbeanType = mbean.getType();
+
+ if(mbeanType.equals(LoggingManagement.TYPE))
+ {
+ return ApplicationRegistry.getImage(LOGGING_MANAGEMENT_IMAGE);
+ }
+ else if(mbeanType.equals(UserManagement.TYPE))
+ {
+ return ApplicationRegistry.getImage(USER_MANAGEMENT_IMAGE);
+ }
+ else if(mbeanType.equals(ConfigurationManagement.TYPE))
+ {
+ return ApplicationRegistry.getImage(CONFIGURATION_MANAGEMENT_IMAGE);
+ }
+ else if(mbeanType.equals(ServerInformation.TYPE))
+ {
+ return ApplicationRegistry.getImage(SERVER_INFO_IMAGE);
+ }
+ else if(mbeanType.equals("VirtualHost.VirtualHostManager"))
+ {
+ return ApplicationRegistry.getImage(VHOST_MANAGER_IMAGE);
+ }
+ else
+ {
+ return ApplicationRegistry.getImage(MBEAN_IMAGE);
+ }
+
+ }
+ else
+ {
+ return ApplicationRegistry.getImage(MBEAN_IMAGE);
+ }
}
}
diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NotificationsTabControl.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NotificationsTabControl.java
index 926bfa2a48..ea49a5c006 100644
--- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NotificationsTabControl.java
+++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NotificationsTabControl.java
@@ -186,10 +186,21 @@ public class NotificationsTabControl extends VHNotificationsTabControl
IStructuredSelection ss = (IStructuredSelection)_tableViewer.getSelection();
if(!ss.isEmpty())
{
+ //clear selected Notifications
serverRegistry.clearNotifications(_mbean, ss.toList());
}
else if(_notifications != null)
{
+ //clear all the notifications, if there are any
+
+ //check the user is certain of this clear-all operation
+ int response = ViewUtility.popupOkCancelConfirmationMessage(
+ "Clear Notifications", "Clear all Notifications for this MBean?");
+ if(response != SWT.OK)
+ {
+ return;
+ }
+
synchronized(this)
{
List<NotificationObject> newList = new ArrayList<NotificationObject>();
diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/VHNotificationsTabControl.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/VHNotificationsTabControl.java
index 5ebe0013bf..4e21e9e865 100644
--- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/VHNotificationsTabControl.java
+++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/VHNotificationsTabControl.java
@@ -136,10 +136,21 @@ public class VHNotificationsTabControl extends TabControl
IStructuredSelection ss = (IStructuredSelection)_tableViewer.getSelection();
if(!ss.isEmpty())
{
+ //clear selected Notifications
serverRegistry.clearNotifications(null, ss.toList());
}
else if(_notifications != null)
{
+ //clear all the notifications, if there are any
+
+ //check the user is certain of this clear-all operation
+ int response = ViewUtility.popupOkCancelConfirmationMessage(
+ "Clear Notifications", "Clear all Notifications for this VirtualHost?");
+ if(response != SWT.OK)
+ {
+ return;
+ }
+
synchronized(this)
{
serverRegistry.clearNotifications(null, _notifications);
diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/queue/QueueOperationsTabControl.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/queue/QueueOperationsTabControl.java
index d04884102d..c838a3e414 100644
--- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/queue/QueueOperationsTabControl.java
+++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/queue/QueueOperationsTabControl.java
@@ -93,15 +93,17 @@ public class QueueOperationsTabControl extends TabControl
private Text _fromMsgText;
private Text _toMsgText;
+ private static final String FROM_DEFAULT = "1";
+ private static final String TO_DEFAULT = "50";
+ private long _interval = 50; //(to-from)+1
private Long _fromMsg = new Long(FROM_DEFAULT);
private Long _toMsg = new Long(TO_DEFAULT);
private TabularDataSupport _messages = null;
private ManagedQueue _qmb;
- private static final String FROM_DEFAULT = "1";
- private static final String TO_DEFAULT = "50";
- private long INTERVAL = 50;
+ private Button _previousButton;
+ private Button _nextButton;
private static final String MSG_AMQ_ID = ManagedQueue.VIEW_MSGS_COMPOSITE_ITEM_NAMES[0];
private static final String MSG_HEADER = ManagedQueue.VIEW_MSGS_COMPOSITE_ITEM_NAMES[1];
@@ -252,9 +254,9 @@ public class QueueOperationsTabControl extends TabControl
_toolkit.createLabel(viewMessageRangeComposite, " "); //spacer
- final Button previousButton = _toolkit.createButton(viewMessageRangeComposite, "< Prev " + INTERVAL, SWT.PUSH);
- previousButton.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false));
- previousButton.addSelectionListener(new SelectionAdapter()
+ _previousButton = _toolkit.createButton(viewMessageRangeComposite, "< Prev " + _interval, SWT.PUSH);
+ _previousButton.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false));
+ _previousButton.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent e)
{
@@ -266,16 +268,16 @@ public class QueueOperationsTabControl extends TabControl
}
//make 'from' be 'from - INTERVAL', or make it 1 if that would make it 0 or less
- _fromMsg = (_fromMsg - INTERVAL < 1) ? 1 : _fromMsg - INTERVAL;
+ _fromMsg = (_fromMsg - _interval < 1) ? 1 : _fromMsg - _interval;
_fromMsgText.setText(_fromMsg.toString());
refresh(_mbean);
}
});
- final Button nextButton = _toolkit.createButton(viewMessageRangeComposite, "Next " + INTERVAL + " >", SWT.PUSH);
- nextButton.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false));
- nextButton.addSelectionListener(new SelectionAdapter()
+ _nextButton = _toolkit.createButton(viewMessageRangeComposite, "Next " + _interval + " >", SWT.PUSH);
+ _nextButton.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false));
+ _nextButton.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent e)
{
@@ -287,7 +289,7 @@ public class QueueOperationsTabControl extends TabControl
}
//make 'to' be 'to + INTERVAL', or make it Long.MAX_VALUE if that would too large
- _toMsg = (Long.MAX_VALUE - _toMsg > INTERVAL) ? _toMsg + INTERVAL : Long.MAX_VALUE;
+ _toMsg = (Long.MAX_VALUE - _toMsg > _interval) ? _toMsg + _interval : Long.MAX_VALUE;
_toMsgText.setText(_toMsg.toString());
refresh(_mbean);
@@ -718,6 +720,10 @@ public class QueueOperationsTabControl extends TabControl
_fromMsg = from;
_toMsg = to;
+ _interval = (to - from) + 1;
+ _previousButton.setText("< Prev " + _interval);
+ _nextButton.setText("Next " + _interval + " >");
+
refresh(_mbean);
}
diff --git a/qpid/java/management/eclipse-plugin/src/test/java/org/apache/qpid/management/ui/ManagementConsoleTest.java b/qpid/java/management/eclipse-plugin/src/test/java/org/apache/qpid/management/ui/ManagementConsoleTest.java
index 11ab6af064..5469bfad5f 100644
--- a/qpid/java/management/eclipse-plugin/src/test/java/org/apache/qpid/management/ui/ManagementConsoleTest.java
+++ b/qpid/java/management/eclipse-plugin/src/test/java/org/apache/qpid/management/ui/ManagementConsoleTest.java
@@ -58,7 +58,8 @@ public class ManagementConsoleTest extends TestCase
@Override
protected void tearDown() throws Exception
{
- ApplicationRegistry.removeAll();
+ // Correctly Close the AR that we created above
+ ApplicationRegistry.remove();
}
/**
diff --git a/qpid/java/module.xml b/qpid/java/module.xml
index f31a52f0ff..0c32414647 100644
--- a/qpid/java/module.xml
+++ b/qpid/java/module.xml
@@ -271,6 +271,7 @@
<sysproperty key="broker.clean" value="${broker.clean}"/>
<sysproperty key="broker.version" value="${broker.version}"/>
<sysproperty key="broker.ready" value="${broker.ready}" />
+ <sysproperty key="broker.stopped" value="${broker.stopped}" />
<sysproperty key="broker.config" value="${broker.config}" />
<sysproperty key="test.output" value="${module.results}"/>
<syspropertyset>
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java
index 422c70d76b..f261858fcd 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java
@@ -87,7 +87,6 @@ public class AMQQueueDeferredOrderingTest extends QpidTestCase
protected void setUp() throws Exception
{
super.setUp();
- TransportConnection.createVMBroker(1);
_logger.info("Create Connection");
con = getConnection();
@@ -135,7 +134,6 @@ public class AMQQueueDeferredOrderingTest extends QpidTestCase
_logger.info("Closing connection");
con.close();
- TransportConnection.killAllVMBrokers();
super.tearDown();
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java
index cb9ba44e27..1683c5e3d6 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java
@@ -23,6 +23,7 @@ package org.apache.qpid.server.failover;
import junit.framework.TestCase;
import org.apache.qpid.AMQDisconnectedException;
import org.apache.qpid.AMQException;
+import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQConnectionURL;
import org.apache.qpid.client.transport.TransportConnection;
@@ -39,12 +40,14 @@ public class FailoverMethodTest extends TestCase implements ExceptionListener
public void setUp() throws AMQVMBrokerCreationException
{
- TransportConnection.createVMBroker(1);
+ ApplicationRegistry.getInstance();
+ TransportConnection.createVMBroker(ApplicationRegistry.DEFAULT_INSTANCE);
}
- public void tearDown() throws AMQVMBrokerCreationException
+ public void tearDown()
{
- TransportConnection.killAllVMBrokers();
+ TransportConnection.killVMBroker(ApplicationRegistry.DEFAULT_INSTANCE);
+ ApplicationRegistry.remove();
}
/**
@@ -61,7 +64,8 @@ public class FailoverMethodTest extends TestCase implements ExceptionListener
//note: The VM broker has no connect delay and the default 1 retry
// while the tcp:localhost broker has 3 retries with a 2s connect delay
String connectionString = "amqp://guest:guest@/test?brokerlist=" +
- "'vm://:1;tcp://localhost:5670?connectdelay='2000',retries='3''";
+ "'vm://:" + ApplicationRegistry.DEFAULT_INSTANCE +
+ ";tcp://localhost:5670?connectdelay='2000',retries='3''";
AMQConnectionURL url = new AMQConnectionURL(connectionString);
@@ -72,7 +76,8 @@ public class FailoverMethodTest extends TestCase implements ExceptionListener
connection.setExceptionListener(this);
- TransportConnection.killAllVMBrokers();
+ TransportConnection.killVMBroker(ApplicationRegistry.DEFAULT_INSTANCE);
+ ApplicationRegistry.remove();
_failoverComplete.await();
@@ -115,7 +120,8 @@ public class FailoverMethodTest extends TestCase implements ExceptionListener
connection.setExceptionListener(this);
- TransportConnection.killAllVMBrokers();
+ TransportConnection.killVMBroker(ApplicationRegistry.DEFAULT_INSTANCE);
+ ApplicationRegistry.remove();
_failoverComplete.await();
@@ -160,7 +166,8 @@ public class FailoverMethodTest extends TestCase implements ExceptionListener
try
{
//Kill initial broker
- TransportConnection.killAllVMBrokers();
+ TransportConnection.killVMBroker(ApplicationRegistry.DEFAULT_INSTANCE);
+ ApplicationRegistry.remove();
//Create a thread to start the broker asynchronously
Thread brokerStart = new Thread(new Runnable()
@@ -172,7 +179,8 @@ public class FailoverMethodTest extends TestCase implements ExceptionListener
//Wait before starting broker
// The wait should allow atleast 1 retries to fail before broker is ready
Thread.sleep(750);
- TransportConnection.createVMBroker(1);
+ ApplicationRegistry.getInstance();
+ TransportConnection.createVMBroker(ApplicationRegistry.DEFAULT_INSTANCE);
}
catch (Exception e)
{
@@ -206,7 +214,8 @@ public class FailoverMethodTest extends TestCase implements ExceptionListener
start = System.currentTimeMillis();
//Kill connection
- TransportConnection.killAllVMBrokers();
+ TransportConnection.killVMBroker(ApplicationRegistry.DEFAULT_INSTANCE);
+ ApplicationRegistry.remove();
_failoverComplete.await();
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java
index 47ae599d2b..e7d1c8b896 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java
@@ -20,13 +20,15 @@
*/
package org.apache.qpid.server.logging;
+import org.apache.qpid.server.logging.subjects.AbstractTestLogSubject;
import org.apache.qpid.test.utils.QpidTestCase;
import org.apache.qpid.util.LogMonitor;
import java.io.IOException;
-import java.util.List;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.LinkedList;
+import java.util.List;
public class AbstractTestLogging extends QpidTestCase
{
@@ -39,6 +41,13 @@ public class AbstractTestLogging extends QpidTestCase
_monitor = new LogMonitor(_outputFile);
}
+ @Override
+ public void tearDown() throws Exception
+ {
+ _monitor.close();
+ super.tearDown();
+ }
+
/**
* assert that the requested log message has not occured
*
@@ -53,10 +62,9 @@ public class AbstractTestLogging extends QpidTestCase
_monitor.findMatches(log).size());
}
-
protected void validateMessageID(String id, String log)
{
- assertEquals("Incorrect message",id, getMessageID(log));
+ assertEquals("Incorrect message", id, getMessageID(log));
}
protected String getMessageID(String log)
@@ -123,6 +131,7 @@ public class AbstractTestLogging extends QpidTestCase
* The brackets '[ ]' are not included in the returned String.
*
* @param log The log message to process
+ *
* @return the Subject string or the empty string ("") if the subject can't be identified.
*/
protected String fromSubject(String log)
@@ -158,6 +167,7 @@ public class AbstractTestLogging extends QpidTestCase
* The brackets '[ ]' are not included in the returned String.
*
* @param log the Log Message
+ *
* @return the Actor segment or "" if unable to locate '[ ]' section
*/
protected String fromActor(String log)
@@ -175,6 +185,21 @@ public class AbstractTestLogging extends QpidTestCase
}
/**
+ * Return the message String from the given message section
+ *
+ * @param log the Message Section
+ *
+ * @return the Message String.
+ */
+ protected String getMessageString(String log)
+ {
+ // Remove the Log ID from the returned String
+ int start = log.indexOf(":") + 1;
+
+ return log.substring(start).trim();
+ }
+
+ /**
* Given our log message extract the connection ID:
*
* The log string will contain the connectionID identified by 'con:'
@@ -189,9 +214,10 @@ public class AbstractTestLogging extends QpidTestCase
* Integer then return -1.
*
* @param log the log String to process
+ *
* @return the connection ID or -1.
*/
- protected int extractConnectionID(String log)
+ protected int getConnectionID(String log)
{
int conIDStart = log.indexOf("con:") + 4;
int conIDEnd = log.indexOf("(", conIDStart);
@@ -213,7 +239,9 @@ public class AbstractTestLogging extends QpidTestCase
* as we know it to be formatted.
*
* This starts with the string MESSAGE
+ *
* @param rawLog the raw log
+ *
* @return the log we are expecting to be printed without the log4j prefixes
*/
protected String getLog(String rawLog)
@@ -223,40 +251,70 @@ public class AbstractTestLogging extends QpidTestCase
}
/**
- * Given a list of messages that have been pulled out of a log file
- * Process the results splitting the log statements in to lists based on the
- * actor's connection ID.
- *
- * So for each log entry extract the Connecition ID from the Actor of the log
- *
- * Then use that as a key to a HashMap storing the list of log messages for
- * that connection.
- *
- * @param logMessages The list of mixed connection log messages
- * @return Map indexed by connection id to a list of log messages just for that connection.
- */
- protected HashMap<Integer,List<String>> splitResultsOnConnectionID(List<String> logMessages)
- {
- HashMap<Integer,List<String>> connectionSplitList = new HashMap<Integer, List<String>>();
-
- for (String log : logMessages)
- {
- // Get the connectionID from the Actor in the Message Log.
- int cID = extractConnectionID(fromActor(getLog(log)));
-
- List<String> connectionData = connectionSplitList.get(cID);
-
- // Create the initial List if we don't have one already
- if (connectionData == null)
- {
- connectionData = new LinkedList<String>();
- connectionSplitList.put(cID, connectionData);
- }
-
- // Store the log
- connectionData.add(log);
- }
-
- return connectionSplitList;
- }
+ * Given a list of messages that have been pulled out of a log file
+ * Process the results splitting the log statements in to lists based on the
+ * actor's connection ID.
+ *
+ * So for each log entry extract the Connecition ID from the Actor of the log
+ *
+ * Then use that as a key to a HashMap storing the list of log messages for
+ * that connection.
+ *
+ * @param logMessages The list of mixed connection log messages
+ *
+ * @return Map indexed by connection id to a list of log messages just for that connection.
+ */
+ protected HashMap<Integer, List<String>> splitResultsOnConnectionID(List<String> logMessages)
+ {
+ HashMap<Integer, List<String>> connectionSplitList = new HashMap<Integer, List<String>>();
+
+ for (String log : logMessages)
+ {
+ // Get the connectionID from the Actor in the Message Log.
+ int cID = getConnectionID(fromActor(getLog(log)));
+
+ List<String> connectionData = connectionSplitList.get(cID);
+
+ // Create the initial List if we don't have one already
+ if (connectionData == null)
+ {
+ connectionData = new LinkedList<String>();
+ connectionSplitList.put(cID, connectionData);
+ }
+
+ // Store the log
+ connectionData.add(log);
+ }
+
+ return connectionSplitList;
+ }
+
+ /**
+ * Filter the give result set by the specficifed virtualhost.
+ * This is done using the getSlice to identify the virtualhost (vh) in the
+ * log message
+ *
+ * @param results full list of logs
+ * @param virtualHostName the virtualhostName to filter on
+ *
+ * @return the list of messages only for that virtualhost
+ */
+ protected List<String> filterResultsByVirtualHost(List<String> results, String virtualHostName)
+ {
+ List<String> filteredResults = new LinkedList<String>();
+ Iterator<String> iterator = results.iterator();
+
+ while (iterator.hasNext())
+ {
+ String log = iterator.next();
+
+ if (AbstractTestLogSubject.getSlice("vh", log).equals(virtualHostName))
+ {
+ filteredResults.add(log);
+ }
+ }
+
+ return filteredResults;
+ }
+
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BindingLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BindingLoggingTest.java
new file mode 100644
index 0000000000..ba05dc6b3e
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BindingLoggingTest.java
@@ -0,0 +1,279 @@
+/*
+ *
+ * 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.qpid.server.logging;
+
+import org.apache.qpid.server.logging.subjects.AbstractTestLogSubject;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.Topic;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Binding
+ *
+ * The Binding test suite validates that the follow log messages as specified in the Functional Specification.
+ *
+ * This suite of tests validate that the Binding messages occur correctly and according to the following format:
+ *
+ * BND-1001 : Create [: Arguments : <key=value>]
+ * BND-1002 : Deleted
+ */
+public class BindingLoggingTest extends AbstractTestLogging
+{
+
+ static final String BND_PREFIX = "BND-";
+
+ Connection _connection;
+ Session _session;
+ Queue _queue;
+ Topic _topic;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ //Ignore broker startup messages
+ _monitor.reset();
+
+ _connection = getConnection();
+
+ _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ _queue = _session.createQueue(getName());
+ _topic = (Topic) getInitialContext().lookup(TOPIC);
+ }
+
+ private void validateLogMessage(String log, String messageID, String exchange, String message)
+ {
+ validateMessageID(messageID, log);
+
+ String subject = fromSubject(log);
+
+ assertEquals("Queue not correct.", getName(),
+ AbstractTestLogSubject.getSlice("qu", subject));
+ assertEquals("Routing Key not correct.", getName(),
+ AbstractTestLogSubject.getSlice("rk", subject));
+ assertEquals("Virtualhost not correct.", "/test",
+ AbstractTestLogSubject.getSlice("vh", subject));
+ assertEquals("Exchange not correct.", exchange,
+ AbstractTestLogSubject.getSlice("ex", subject));
+
+ assertEquals("Log Message not as expected", message, getMessageString(fromMessage(log)));
+ }
+
+ /**
+ * testBindingCreate
+ *
+ * Description:
+ * The binding of a Queue and an Exchange is done via a Binding. When this Binding is created a BND-1001 Create message will be logged.
+ * Input:
+ *
+ * 1. Running Broker
+ * 2. New Client requests that a Queue is bound to a new exchange.
+ * Output:
+ *
+ * <date> BND-1001 : Create
+ *
+ * Validation Steps:
+ * 3. The BND ID is correct
+ * 4. This will be the first message for the given binding
+ */
+ public void testBindingCreate() throws JMSException, IOException
+ {
+ _session.createConsumer(_queue).close();
+
+ List<String> results = _monitor.findMatches(BND_PREFIX);
+
+ // We will have two binds as we bind all queues to the default exchange
+ assertEquals("Result set larger than expected.", 2, results.size());
+
+ String exchange = "direct/<<default>>";
+ String messageID = "BND-1001";
+ String message = "Create";
+
+ validateLogMessage(getLog(results.get(0)), messageID, exchange, message);
+
+ exchange = "direct/amq.direct";
+ validateLogMessage(getLog(results.get(1)), messageID, exchange, message);
+ }
+
+ /**
+ * Description:
+ * A Binding can be made with a set of arguments. When this occurs we logged the key,value pairs as part of the Binding log message. When the subscriber with a JMS Selector consumes from an exclusive queue such as a topic. The binding is made with the JMS Selector as an argument.
+ * Input:
+ *
+ * 1. Running Broker
+ * 2. Java Client consumes from a topic with a JMS selector.
+ * Output:
+ *
+ * <date> BND-1001 : Create : Arguments : <key=value>
+ *
+ * Validation Steps:
+ * 3. The BND ID is correct
+ * 4. The JMS Selector argument is present in the message
+ * 5. This will be the first message for the given binding
+ */
+ public void testBindingCreateWithArguments() throws JMSException, IOException
+ {
+ final String SELECTOR = "Selector='True'";
+
+ _session.createDurableSubscriber(_topic, getName(), SELECTOR, false).close();
+
+ List<String> results = _monitor.findMatches(BND_PREFIX);
+
+ // We will have two binds as we bind all queues to the default exchange
+ assertEquals("Result set larger than expected.", 2, results.size());
+
+ String log = getLog(results.get(0));
+
+ //Verify the first entry is the default binding
+ validateMessageID("BND-1001", log);
+
+ String subject = fromSubject(log);
+
+ assertEquals("Queue not correct.", "clientid:" + getName(),
+ AbstractTestLogSubject.getSlice("qu", subject));
+ // NOTE default binding is the queue name
+ assertEquals("Routing Key not correct.", "clientid:" + getName(),
+ AbstractTestLogSubject.getSlice("rk", subject));
+ assertEquals("Virtualhost not correct.", "/test",
+ AbstractTestLogSubject.getSlice("vh", subject));
+ assertEquals("Exchange not correct.", "direct/<<default>>",
+ AbstractTestLogSubject.getSlice("ex", fromSubject(log)));
+
+ String message = getMessageString(log);
+
+ //Default binding will be without the selector
+ assertTrue("JMSSelector identified in binding:"+message, !message.contains("jms-selector"));
+
+ // Perform full testing on the second non default binding
+ log = getLog(results.get(1));
+ validateMessageID("BND-1001", log);
+
+ subject = fromSubject(log);
+
+ assertEquals("Queue not correct.", "clientid:" + getName(),
+ AbstractTestLogSubject.getSlice("qu", subject));
+ assertEquals("Routing Key not correct.", "topic",
+ AbstractTestLogSubject.getSlice("rk", subject));
+ assertEquals("Virtualhost not correct.", "/test",
+ AbstractTestLogSubject.getSlice("vh", subject));
+ assertEquals("Exchange not correct.", "topic/amq.topic",
+ AbstractTestLogSubject.getSlice("ex", subject));
+
+ message = getMessageString(log);
+
+ assertTrue("JMSSelector not identified in binding:"+message, message.contains("jms-selector"));
+ assertTrue("Selector not part of binding.:"+message, message.contains(SELECTOR));
+
+ }
+
+ /**
+ * Description:
+ * Bindings can be deleted so that a queue can be rebound with a different set of values.
+ * Input:
+ *
+ * 1. Running Broker
+ * 2. AMQP UnBind Request is made
+ * Output:
+ *
+ * <date> BND-1002 : Deleted
+ *
+ * Validation Steps:
+ * 3. The BND ID is correct
+ * 4. There must have been a BND-1001 Create message first.
+ * 5. This will be the last message for the given binding
+ */
+ public void testBindingDelete() throws JMSException, IOException
+ {
+ //Closing a consumer on a temporary queue will cause it to autodelete
+ // and so unbind.
+ _session.createConsumer(_session.createTemporaryQueue()).close();
+
+ List<String> results = _monitor.findMatches(BND_PREFIX);
+
+ // We will have two binds as we bind all queues to the default exchange
+ assertEquals("Result set larger than expected.", 4, results.size());
+
+
+ String messageID = "BND-1001";
+ String message = "Create";
+
+ String log = getLog(results.get(0));
+ validateMessageID(messageID, log);
+ assertEquals("Log Message not as expected", message, getMessageString(fromMessage(log)));
+
+ log = getLog(results.get(1));
+ validateMessageID(messageID, log);
+ assertEquals("Log Message not as expected", message, getMessageString(fromMessage(log)));
+
+
+ String DEFAULT = "direct/<<default>>";
+ String DIRECT = "direct/amq.direct";
+
+ messageID = "BND-1002";
+ message = "Deleted";
+
+ log = getLog(results.get(2));
+ validateMessageID(messageID, log);
+
+ String subject = fromSubject(log);
+
+ assertTrue("Routing Key does not start with TempQueue:"+AbstractTestLogSubject.getSlice("rk", subject),
+ AbstractTestLogSubject.getSlice("rk", subject).startsWith("TempQueue"));
+ assertEquals("Virtualhost not correct.", "/test",
+ AbstractTestLogSubject.getSlice("vh", subject));
+
+ boolean defaultFirst = DEFAULT.equals(AbstractTestLogSubject.getSlice("ex", subject));
+ boolean directFirst = DIRECT.equals(AbstractTestLogSubject.getSlice("ex", subject));
+
+ assertEquals("Log Message not as expected", message, getMessageString(fromMessage(log)));
+
+ log = getLog(results.get(3));
+
+ validateMessageID(messageID, log);
+
+ subject = fromSubject(log);
+
+ assertTrue("Routing Key does not start with TempQueue:"+AbstractTestLogSubject.getSlice("rk", subject),
+ AbstractTestLogSubject.getSlice("rk", subject).startsWith("TempQueue"));
+ assertEquals("Virtualhost not correct.", "/test",
+ AbstractTestLogSubject.getSlice("vh", subject));
+
+ if (!defaultFirst)
+ {
+ assertEquals(DEFAULT, AbstractTestLogSubject.getSlice("ex", subject));
+ assertTrue("First Exchange Log was not a direct exchange delete",directFirst);
+ }
+ else
+ {
+ assertEquals(DIRECT, AbstractTestLogSubject.getSlice("ex", subject));
+ assertTrue("First Exchange Log was not a default exchange delete",defaultFirst);
+ }
+
+ assertEquals("Log Message not as expected", message, getMessageString(fromMessage(log)));
+
+ }
+}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java
new file mode 100644
index 0000000000..d417349c7f
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java
@@ -0,0 +1,1007 @@
+/*
+*
+* 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.qpid.server.logging;
+
+import junit.framework.AssertionFailedError;
+import org.apache.qpid.server.Main;
+import org.apache.qpid.transport.ConnectionException;
+import org.apache.qpid.util.LogMonitor;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.Socket;
+import java.util.List;
+
+/**
+ * Broker Test Suite
+ *
+ * The Broker test suite validates that the follow log messages as specified in the Functional Specification.
+ *
+ * BRK-1001 : Startup : Version: <Version> Build: <Build>
+ * BRK-1002 : Starting : Listening on <Transport> port <Port>
+ * BRK-1003 : Shuting down : <Transport> port <Port>
+ * BRK-1004 : Ready
+ * BRK-1005 : Stopped
+ * BRK-1006 : Using configuration : <path>
+ * BRK-1007 : Using logging configuration : <path>
+ *
+ * These messages should only occur during startup. The tests need to verify the order of messages. In the case of the BRK-1002 and BRK-1003 the respective ports should only be available between the two log messages.
+ */
+public class BrokerLoggingTest extends AbstractTestLogging
+{
+ public void setUp() throws Exception
+ {
+ // We either do this here or have a null check in tearDown.
+ // As when this test is run against profiles other than java it will NPE
+ _monitor = new LogMonitor(_outputFile);
+ //We explicitly do not call super.setUp as starting up the broker is
+ //part of the test case.
+ }
+
+ /**
+ * Description:
+ * On startup the broker must report the active configuration file. The
+ * logging system must output this so that we can know what configuration
+ * is being used for this broker instance.
+ *
+ * Input:
+ * The value of -c specified on the command line.
+ * Output:
+ * <date> MESSAGE BRK-1006 : Using configuration : <config file>
+ * Constraints:
+ * This MUST BE the first BRK log message.
+ *
+ * Validation Steps:
+ * 1. This is first BRK log message.
+ * 2. The BRK ID is correct
+ * 3. The config file is the full path to the file specified on
+ * the commandline.
+ *
+ * @throws Exception caused by broker startup
+ */
+ public void testBrokerStartupConfiguration() throws Exception
+ {
+ // This logging startup code only occurs when you run a Java broker,
+ // that broker must be started via Main so not an InVM broker.
+ if (isJavaBroker() && isExternalBroker())
+ {
+ startBroker();
+
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
+
+ String configFilePath = _configFile.toString();
+
+ List<String> results = _monitor.findMatches("BRK-");
+ try
+ {
+ // Validation
+
+ assertTrue("BRKer message not logged", results.size() > 0);
+
+ String log = getLog(results.get(0));
+
+ //1
+ validateMessageID("BRK-1006", log);
+
+ //2
+ results = _monitor.findMatches("BRK-1006");
+ assertEquals("More than one configuration message found.",
+ 1, results.size());
+
+ //3
+ assertTrue("Config file details not correctly logged",
+ log.endsWith(configFilePath));
+ }
+ catch (AssertionFailedError afe)
+ {
+ System.err.println("Log Dump:");
+ for (String log : results)
+ {
+ System.err.println(log);
+ }
+ throw afe;
+ }
+ }
+ }
+
+ /**
+ * Description:
+ * On startup the broker must report correctly report the log4j file in use. This is important as it can help diagnose why logging messages are not being reported.
+ * Input:
+ * No custom -l value should be provided on the command line so that the default value is correctly reported.
+ * Output:
+ *
+ * <date> MESSAGE BRK-1007 : Using logging configuration : <$QPID_HOME>/etc/log4j.xml
+ *
+ * Validation Steps:
+ *
+ * 1. The BRK ID is correct
+ * 2. This occurs before the BRK-1001 startup message.
+ * 3. The log4j file is the full path to the file specified on the commandline.
+ *
+ * @throws Exception caused by broker startup
+ */
+ public void testBrokerStartupDefaultLog4j() throws Exception
+ {
+ // This logging startup code only occurs when you run a Java broker,
+ // that broker must be started via Main so not an InVM broker.
+ if (isJavaBroker() && isExternalBroker())
+ {
+ String TESTID = "BRK-1007";
+
+// _monitor = new LogMonitor(new File(System.getProperty("QPID_WORK") + "/log/qpid.log"));
+
+ //Remove test Log4j config from the commandline
+ _broker = _broker.substring(0, _broker.indexOf("-l"));
+
+ startBroker();
+
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
+ // Ensure broker has fully started up.
+ getConnection();
+
+ List<String> results = _monitor.findMatches("BRK-");
+ try
+ {
+ // Validation
+
+ assertTrue("BRKer message not logged", results.size() > 0);
+
+ boolean validation = false;
+ for (String rawLog : results)
+ {
+ // We don't care about messages after we have our log config
+ if (validation)
+ {
+ break;
+ }
+
+ String log = getLog(rawLog);
+
+ // Ensure we do not have a BRK-1001 message before
+ if (!getMessageID(log).equals(TESTID))
+ {
+ assertFalse(getMessageID(log).equals("BRK-1001"));
+ continue;
+ }
+
+ //1
+ validateMessageID(TESTID, log);
+
+ //2
+ assertEquals("More than one log4j configuration message found.",
+ 1, _monitor.findMatches(TESTID).size());
+
+ //3
+ String defaultLog4j = _configFile.getParent() + "/" + Main.DEFAULT_LOG_CONFIG_FILENAME;
+ assertTrue("Log4j file(" + defaultLog4j + ") details not correctly logged:" + getMessageString(log),
+ getMessageString(log).endsWith(defaultLog4j));
+
+ validation = true;
+ }
+
+ assertTrue("Validation not performed: " + TESTID + " not logged", validation);
+ }
+ catch (AssertionFailedError afe)
+ {
+ System.err.println("Log Dump:");
+ for (String log : results)
+ {
+ System.err.println(log);
+ }
+
+ if (results.size() == 0)
+ {
+ System.err.println("Monitored file contents:");
+ System.err.println(_monitor.readFile());
+ }
+
+ throw afe;
+ }
+ }
+ }
+
+ /**
+ * Description:
+ * On startup the broker must report correctly report the log4j file in use. This is important as it can help diagnose why logging messages are not being reported. The broker must also be capable of correctly recognising the command line property to specify the custom logging configuration.
+ * Input:
+ * The value of -l specified on the command line.
+ * Output:
+ *
+ * <date> MESSAGE BRK-1007 : Using logging configuration : <log4j file>
+ *
+ * Validation Steps:
+ *
+ * 1. The BRK ID is correct
+ * 2. This should occur before the BRK-1001 : Startup message
+ * 3. The log4j file is the full path to the file specified on the commandline.
+ *
+ * @throws Exception caused by broker startup
+ */
+ public void testBrokerStartupCustomLog4j() throws Exception
+ {
+ // This logging startup code only occurs when you run a Java broker,
+ // that broker must be started via Main so not an InVM broker.
+ if (isJavaBroker() && isExternalBroker())
+ {
+ // Get custom -l value used during testing for the broker startup
+ String customLog4j = _broker.substring(_broker.indexOf("-l") + 2);
+
+ String TESTID = "BRK-1007";
+
+ startBroker();
+
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
+
+ // Ensure broker has fully started up.
+ getConnection();
+
+ List<String> results = _monitor.findMatches("BRK-");
+ try
+ {
+ // Validation
+
+ assertTrue("BRKer message not logged", results.size() > 0);
+
+ boolean validation = false;
+ for (String rawLog : results)
+ {
+ // We don't care about messages after we have our log config
+ if (validation)
+ {
+ break;
+ }
+ String log = getLog(rawLog);
+
+ // Ensure we do not have a BRK-1001 message before
+ if (!getMessageID(log).equals(TESTID))
+ {
+ assertFalse(getMessageID(log).equals("BRK-1001"));
+ continue;
+ }
+
+ //1
+ validateMessageID(TESTID, log);
+
+ //2
+ assertEquals("More than one log4j configuration message found.",
+ 1, _monitor.findMatches(TESTID).size());
+
+ //3
+ assertTrue("Log4j file details not correctly logged:" + getMessageString(log),
+ getMessageString(log).endsWith(customLog4j));
+
+ validation = true;
+ }
+
+ assertTrue("Validation not performed: " + TESTID + " not logged", validation);
+ }
+ catch (AssertionFailedError afe)
+ {
+ System.err.println("Log Dump:");
+ for (String log : results)
+ {
+ System.err.println(log);
+ }
+
+ if (results.size() == 0)
+ {
+ System.err.println("Monitored file contents:");
+ System.err.println(_monitor.readFile());
+ }
+
+ throw afe;
+ }
+ }
+ }
+
+ /**
+ * Description: On startup the broker reports the broker version number and svn build revision. This information is retrieved from the resource 'qpidversion.properties' which is located via the classloader.
+ * Input: The 'qpidversion.properties' file located on the classpath.
+ * Output:
+ *
+ * <date> MESSAGE BRK-1001 : Startup : qpid Version: 0.6 Build: 767150
+ *
+ * Validation Steps:
+ *
+ * 1. The BRK ID is correct
+ * 2. This occurs before any BRK-1002 listening messages are reported.
+ *
+ * @throws Exception caused by broker startup
+ */
+ public void testBrokerStartupStartup() throws Exception
+ {
+ // This logging startup code only occurs when you run a Java broker,
+ // that broker must be started via Main so not an InVM broker.
+ if (isJavaBroker() && isExternalBroker())
+ {
+ String TESTID = "BRK-1001";
+
+ startBroker();
+
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
+ List<String> results = _monitor.findMatches("BRK-");
+ try
+ {
+ // Validation
+
+ assertTrue("BRKer message not logged", results.size() > 0);
+
+ boolean validation = false;
+ for (String rawLog : results)
+ {
+ if (validation)
+ {
+ //Stop checking once we have got to our startup test
+ break;
+ }
+ String log = getLog(rawLog);
+
+ // Ensure we do not have a BRK-1002 message
+ if (!getMessageID(log).equals(TESTID))
+ {
+ assertFalse(getMessageID(log).equals("BRK-1002"));
+ continue;
+ }
+
+ //1
+ validateMessageID(TESTID, log);
+
+ //2
+ assertEquals("More than one startup message found.",
+ 1, _monitor.findMatches(TESTID).size());
+
+ validation = true;
+ }
+
+ assertTrue("Validation not performed: " + TESTID + " not logged", validation);
+ }
+ catch (AssertionFailedError afe)
+ {
+ System.err.println("Log Dump:");
+ for (String log : results)
+ {
+ System.err.println(log);
+ }
+ throw afe;
+ }
+ }
+ }
+
+ /**
+ * Description:
+ * On startup the broker may listen on a number of ports and protocols. Each of these must be reported as they are made available.
+ * Input:
+ * The default configuration with no SSL
+ * Output:
+ *
+ * <date> MESSAGE BRK-1002 : Starting : Listening on TCP port 5672
+ *
+ * Constraints:
+ * Additional broker configuration will occur between the Startup(BRK-1001) and Starting(BRK-1002) messages depending on what VirtualHosts are configured.
+ * Validation Steps:
+ *
+ * 1. The BRK ID is correct
+ * 2. This occurs after the BRK-1001 startup message
+ * 3. Using the default configuration a single BRK-1002 will be printed showing values TCP / 5672
+ *
+ * @throws Exception caused by broker startup
+ */
+ public void testBrokerStartupListeningTCPDefault() throws Exception
+ {
+ // This logging startup code only occurs when you run a Java broker,
+ // that broker must be started via Main so not an InVM broker.
+ if (isJavaBroker() && isExternalBroker())
+ {
+ String TESTID = "BRK-1002";
+
+ startBroker();
+
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
+ // Ensure broker has fully started up.
+ getConnection();
+
+ List<String> results = _monitor.findMatches("BRK-");
+ try
+ {
+ // Validation
+
+ assertTrue("BRKer message not logged", results.size() > 0);
+
+ boolean validation = false;
+ boolean foundBRK1001 = false;
+ for (String rawLog : results)
+ {
+ String log = getLog(rawLog);
+
+ // Ensure we do not have a BRK-1002 message
+ if (!getMessageID(log).equals(TESTID))
+ {
+ if (getMessageID(log).equals("BRK-1001"))
+ {
+ foundBRK1001 = true;
+ }
+ continue;
+ }
+
+ assertTrue("BRK-1001 not logged before this message", foundBRK1001);
+
+ //1
+ validateMessageID(TESTID, log);
+
+ //2
+ assertEquals("More than one listen message found.",
+ 1, _monitor.findMatches(TESTID).size());
+
+ //3
+ String message = getMessageString(log);
+ assertTrue("Expected Listen log not correct" + message,
+ message.endsWith("Listening on TCP port " + getPort()));
+
+ validation = true;
+ }
+
+ assertTrue("Validation not performed: " + TESTID + " not logged", validation);
+ }
+ catch (AssertionFailedError afe)
+ {
+ System.err.println("Log Dump:");
+ for (String log : results)
+ {
+ System.err.println(log);
+ }
+ throw afe;
+ }
+ }
+ }
+
+ /**
+ * Description:
+ * On startup the broker may listen on a number of ports and protocols. Each of these must be reported as they are made available.
+ * Input:
+ * The default configuration with SSL enabled
+ * Output:
+ *
+ * <date> MESSAGE BRK-1002 : Starting : Listening on TCP port 5672
+ * <date> MESSAGE BRK-1002 : Starting : Listening on TCP/SSL port 8672
+ *
+ * Constraints:
+ * Additional broker configuration will occur between the Startup(BRK-1001) and Starting(BRK-1002) messages depending on what VirtualHosts are configured.
+ * Validation Steps:
+ *
+ * 1. The BRK ID is correct
+ * 2. This occurs after the BRK-1001 startup message
+ * 3. With SSL enabled in the configuration two BRK-1002 will be printed (order is not specified)
+ * 1. One showing values TCP / 5672
+ * 2. One showing values TCP/SSL / 5672
+ *
+ * @throws Exception caused by broker startup
+ */
+ public void testBrokerStartupListeningTCPSSL() throws Exception
+ {
+ // This logging startup code only occurs when you run a Java broker,
+ // that broker must be started via Main so not an InVM broker.
+ if (isJavaBroker() && isExternalBroker())
+ {
+ String TESTID = "BRK-1002";
+
+ // Enable SSL on the connection
+ setConfigurationProperty("connector.ssl.enabled", "true");
+ setConfigurationProperty("connector.ssl.sslOnly", "false");
+ setConfigurationProperty("connector.ssl.keyStorePath", getConfigurationStringProperty("management.ssl.keyStorePath"));
+ setConfigurationProperty("connector.ssl.keyStorePassword", getConfigurationStringProperty("management.ssl.keyStorePassword"));
+
+ Integer sslPort = Integer.parseInt(getConfigurationStringProperty("connector.sslport"));
+
+ startBroker();
+
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
+ // Ensure broker has fully started up.
+ getConnection();
+
+ List<String> results = _monitor.findMatches("BRK-");
+ try
+ {
+ // Validation
+
+ assertTrue("BRKer message not logged", results.size() > 0);
+
+ boolean validation = false;
+ boolean foundBRK1001 = false;
+ for (String rawLog : results)
+ {
+ String log = getLog(rawLog);
+
+ // Ensure we do not have a BRK-1002 message
+ if (!getMessageID(log).equals(TESTID))
+ {
+ if (getMessageID(log).equals("BRK-1001"))
+ {
+ foundBRK1001 = true;
+ }
+ continue;
+ }
+
+ assertTrue("BRK-1001 not logged before this message", foundBRK1001);
+
+ //1
+ validateMessageID(TESTID, log);
+
+ //2
+ List<String> listenMessages = _monitor.findMatches(TESTID);
+ assertEquals("Two listen messages should be found.",
+ 2, listenMessages .size());
+
+ //3
+ String message = getMessageString(getLog(listenMessages .get(0)));
+ assertTrue("Expected Listen log not correct" + message,
+ message.endsWith("Listening on TCP port " + getPort()));
+
+ // Check second, ssl, listen.
+ message = getMessageString(getLog(listenMessages .get(1)));
+ assertTrue("Expected Listen log not correct" + message,
+ message.endsWith("Listening on TCP/SSL port " + sslPort));
+
+ //4 Test ports open
+ testSocketOpen(getPort());
+ testSocketOpen(sslPort);
+
+ validation = true;
+ }
+
+ assertTrue("Validation not performed: " + TESTID + " not logged", validation);
+ }
+ catch (AssertionFailedError afe)
+ {
+ System.err.println("Log Dump:");
+ for (String log : results)
+ {
+ System.err.println(log);
+ }
+ throw afe;
+ }
+ }
+ }
+
+ /**
+ * Description:
+ * The final message the broker will print when it has performed all initialisation and listener startups will be to log the BRK-1004 Ready message
+ * Input:
+ * No input, all successful broker startups will show BRK-1004 messages.
+ * Output:
+ *
+ * 2009-07-09 15:50:20 +0100 MESSAGE BRK-1004 : Ready
+ *
+ * Validation Steps:
+ *
+ * 1. The BRK ID is correct
+ * 2. This occurs after the BRK-1001 startup message
+ * 3. This must be the last message the broker prints after startup. Currently, if there is no further interaction with the broker then there should be no more logging.
+ *
+ * @throws Exception caused by broker startup
+ */
+ public void testBrokerStartupReady() throws Exception
+ {
+ // This logging startup code only occurs when you run a Java broker,
+ // that broker must be started via Main so not an InVM broker.
+ if (isJavaBroker() && isExternalBroker())
+ {
+ String TESTID = "BRK-1004";
+
+ startBroker();
+
+ //Ensure the broker has fully started up.
+ getConnection();
+
+ List<String> results = _monitor.findMatches("BRK-");
+ try
+ {
+ // Validation
+
+ assertTrue("BRKer message not logged", results.size() > 0);
+
+ boolean validation = false;
+ boolean foundBRK1001 = false;
+ for (String rawLog : results)
+ {
+ assertFalse("More broker log statements present after ready message", validation);
+ String log = getLog(rawLog);
+
+ // Ensure we do not have a BRK-1002 message
+ if (!getMessageID(log).equals(TESTID))
+ {
+ if (getMessageID(log).equals("BRK-1001"))
+ {
+ foundBRK1001 = true;
+ }
+ continue;
+ }
+
+ assertTrue("BRK-1001 not logged before this message", foundBRK1001);
+
+ //1
+ validateMessageID(TESTID, log);
+
+ //2
+ assertEquals("More than one ready message found.",
+ 1, _monitor.findMatches(TESTID).size());
+
+ //3
+ assertEquals("Ready message not present", "Ready", getMessageString(log));
+
+ validation = true;
+ }
+
+ assertTrue("Validation not performed: " + TESTID + " not logged", validation);
+ }
+ catch (AssertionFailedError afe)
+ {
+ System.err.println("Log Dump:");
+ for (String log : results)
+ {
+ System.err.println(log);
+ }
+ throw afe;
+ }
+ }
+ }
+
+ /**
+ * Description:
+ * On startup the broker may listen on a number of ports and protocols. Each of these must then report a shutting down message as they stop listening.
+ * Input:
+ * The default configuration with no SSL
+ * Output:
+ *
+ * <date> MESSAGE BRK-1003 : Shutting down : TCP port 5672
+ *
+ * Validation Steps:
+ *
+ * 1. The BRK ID is correct
+ * 2. Only TCP is reported with the default configuration with no SSL.
+ * 3. The default port is correct
+ * 4. The port is not accessible after this message
+ *
+ * @throws Exception caused by broker startup
+ */
+ public void testBrokerShutdownListeningTCPDefault() throws Exception
+ {
+ // This logging startup code only occurs when you run a Java broker,
+ // that broker must be started via Main so not an InVM broker.
+ if (isJavaBroker() && isExternalBroker())
+ {
+ String TESTID = "BRK-1003";
+
+ startBroker();
+
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
+ stopBroker();
+
+ //Give broker time to shutdown and flush log
+ checkSocketClosed(getPort());
+
+ List<String> results = _monitor.findMatches("BRK-");
+ try
+ {
+ // Validation
+
+ assertTrue("BRKer message not logged", results.size() > 0);
+
+ boolean validation = false;
+ boolean foundBRK1001 = false;
+ for (String rawLog : results)
+ {
+ String log = getLog(rawLog);
+
+ // Ensure we do not have a BRK-1002 message
+ if (!getMessageID(log).equals(TESTID))
+ {
+ if (getMessageID(log).equals("BRK-1001"))
+ {
+ foundBRK1001 = true;
+ }
+ continue;
+ }
+
+ assertTrue("BRK-1001 not logged before this message", foundBRK1001);
+
+ //1
+ validateMessageID(TESTID, log);
+
+ //2
+ assertEquals("More than one listen message found.",
+ 1, _monitor.findMatches(TESTID).size());
+
+ //3
+ String message = getMessageString(log);
+ assertTrue("Expected shutdown log not correct" + message,
+ message.endsWith("TCP port " + getPort()));
+
+ //4
+ checkSocketClosed(getPort());
+
+ validation = true;
+ }
+
+ assertTrue("Validation not performed: " + TESTID + " not logged", validation);
+ }
+ catch (AssertionFailedError afe)
+ {
+ System.err.println("Log Dump:");
+ for (String log : results)
+ {
+ System.err.println(log);
+ }
+ throw afe;
+ }
+ }
+ }
+
+ /**
+ * Description:
+ * On startup the broker may listen on a number of ports and protocols. Each of these must be reported as they are made available.
+ * Input:
+ * The default configuration with SSL enabled
+ * Output:
+ *
+ * <date> MESSAGE BRK-1002 : Starting : Listening on TCP port 5672
+ * <date> MESSAGE BRK-1002 : Starting : Listening on TCP/SSL port 8672
+ *
+ * Constraints:
+ * Additional broker configuration will occur between the Startup(BRK-1001) and Starting(BRK-1002) messages depending on what VirtualHosts are configured.
+ * Validation Steps:
+ *
+ * 1. The BRK ID is correct
+ * 2. This occurs after the BRK-1001 startup message
+ * 3. With SSL enabled in the configuration two BRK-1002 will be printed (order is not specified)
+ * 1. One showing values TCP / 5672
+ * 2. One showing values TCP/SSL / 5672
+ *
+ * @throws Exception caused by broker startup
+ */
+ public void testBrokerShutdownListeningTCPSSL() throws Exception
+ {
+ // This logging startup code only occurs when you run a Java broker,
+ // that broker must be started via Main so not an InVM broker.
+ if (isJavaBroker() && isExternalBroker())
+ {
+ String TESTID = "BRK-1003";
+
+ // Enable SSL on the connection
+ setConfigurationProperty("connector.ssl.enabled", "true");
+ setConfigurationProperty("connector.ssl.keyStorePath", getConfigurationStringProperty("management.ssl.keyStorePath"));
+ setConfigurationProperty("connector.ssl.keyStorePassword", getConfigurationStringProperty("management.ssl.keyStorePassword"));
+
+ Integer sslPort = Integer.parseInt(getConfigurationStringProperty("connector.sslport"));
+
+ startBroker();
+
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
+
+// //Clear any startup messages as we don't need them for validation
+// _monitor.reset();
+ //Stop the broker to get the log messages for testing
+ stopBroker();
+
+ //Give broker time to shutdown and flush log
+ checkSocketClosed(getPort());
+
+ List<String> results = _monitor.findMatches(TESTID);
+ try
+ {
+ // Validation
+
+ assertTrue(TESTID + " messages not logged", results.size() > 0);
+
+ String log = getLog(results.get(0));
+
+ //1
+ validateMessageID(TESTID, log);
+
+ //2
+ List<String> listenMessages = _monitor.findMatches(TESTID);
+ assertEquals("Two shutdown messages should be found.",
+ 2, listenMessages.size());
+
+ //3
+ String message = getMessageString(getLog(listenMessages.get(0)));
+ assertTrue("Expected shutdown log not correct" + message,
+ message.endsWith("TCP port " + getPort()));
+
+ // Check second, ssl, listen.
+ message = getMessageString(getLog(listenMessages.get(1)));
+ assertTrue("Expected shutdown log not correct" + message,
+ message.endsWith("TCP/SSL port " + sslPort));
+
+ //4
+ //Test Port closed
+ checkSocketClosed(getPort());
+ //Test SSL Port closed
+ checkSocketClosed(sslPort);
+ }
+ catch (AssertionFailedError afe)
+ {
+ System.err.println("Log Dump:");
+ for (String log : results)
+ {
+ System.err.println(log);
+ }
+ throw afe;
+ }
+ }
+ }
+
+ /**
+ * Description:
+ * Input:
+ * No input, all clean broker shutdowns will show BRK-1005 messages.
+ * Output:
+ *
+ * <date> MESSAGE BRK-1005 : Stopped
+ *
+ * Constraints:
+ * This is the LAST message the broker will log.
+ * Validation Steps:
+ *
+ * 1. The BRK ID is correct
+ * 2. This is the last message the broker will log.
+ *
+ * @throws Exception caused by broker startup
+ */
+ public void testBrokerShutdownStopped() throws Exception
+ {
+ // This logging startup code only occurs when you run a Java broker,
+ // that broker must be started via Main so not an InVM broker.
+ if (isJavaBroker() && isExternalBroker())
+ {
+ String TESTID = "BRK-1005";
+
+ startBroker();
+
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
+ getConnection().close();
+
+ stopBroker();
+
+ // Ensure the broker has shutdown before retreving results
+ checkSocketClosed(getPort());
+
+ List<String> results = _monitor.findMatches("BRK-");
+ try
+ {
+ // Validation
+
+ assertTrue("BRKer message not logged", results.size() > 0);
+
+ boolean validation = false;
+ for (String rawLog : results)
+ {
+ assertFalse("More broker log statements present after ready message", validation);
+ String log = getLog(rawLog);
+
+ // Ignore all logs until we get to the test id.
+ if (!getMessageID(log).equals(TESTID))
+ {
+ continue;
+ }
+
+ //1
+ validateMessageID(TESTID, log);
+
+ //2
+ assertEquals("More than one ready message found.",
+ 1, _monitor.findMatches(TESTID).size());
+
+ //3
+ assertEquals("Stopped message not present", "Stopped", getMessageString(log));
+
+ validation = true;
+ }
+
+ assertTrue("Validation not performed: " + TESTID + " not logged", validation);
+ }
+ catch (AssertionFailedError afe)
+ {
+ System.err.println("Log Dump:");
+ for (String log : results)
+ {
+ System.err.println(log);
+ }
+
+ System.err.println("Monitored file contents:");
+ System.err.println(_monitor.readFile());
+
+ throw afe;
+ }
+ }
+ }
+
+ /**
+ * Test that a socket on the given port is closed.
+ *
+ * Does this by attempting to connect to the port and expecting a
+ * ConnectionRefused IOException or a ConnectionException
+ *
+ * @param port the port number
+ */
+ private void checkSocketClosed(int port)
+ {
+ try
+ {
+ Socket socket = new Socket((String) null, port);
+ fail("Socket not closed on port:" + port);
+ }
+ catch (ConnectionException e)
+ {
+ //normal path
+ }
+ catch (IOException e)
+ {
+ if (!e.getMessage().equals("Connection refused"))
+ {
+ fail("Socket not closed on port:" + port + ":" + e.getMessage());
+ // Keep stack trace for diagnosis.
+ e.printStackTrace(System.err);
+ }
+ }
+ }
+
+ /**
+ * Test that a socket on the given port is open.
+ *
+ * Does this by attempting to connect to the port and expecting a
+ * The connection to succeed.
+ * It then closes the socket and expects that to work cleanly.
+ *
+ * @param port the port number
+ */
+ private void testSocketOpen(int port)
+ {
+ try
+ {
+ Socket socket = new Socket((String) null, port);
+ socket.close();
+ }
+ catch (IOException e)
+ {
+ fail("Unable to open and close socket to port:" + port
+ + ". Due to:" + e.getMessage());
+ }
+ }
+}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java
index 2de6b08751..da3f458cef 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java
@@ -119,6 +119,8 @@ public class ChannelLoggingTest extends AbstractTestLogging
List<String> results = _monitor.findMatches(CHANNEL_PREFIX);
+ assertTrue("No CHN messages logged", results.size() > 0);
+
// The last channel message should be:
//
// INFO - MESSAGE [con:0(guest@anonymous(4205299)/test)/ch:1] [con:0(guest@anonymous(4205299)/test)/ch:1] CHN-1002 : Flow Off
@@ -128,7 +130,7 @@ public class ChannelLoggingTest extends AbstractTestLogging
String log = getLog(results.get(resultSize - 1));
validateMessageID("CHN-1002", log);
- assertTrue("Message should be Flow Stopped", fromMessage(log).endsWith("Flow Stopped"));
+ assertEquals("Message should be Flow Stopped", "Flow Stopped", getMessageString(fromMessage(log)));
}
@@ -171,6 +173,8 @@ public class ChannelLoggingTest extends AbstractTestLogging
List<String> results = _monitor.findMatches(CHANNEL_PREFIX);
+ assertTrue("No CHN messages logged", results.size() > 0);
+
// The last two channel messages should be:
//
// INFO - MESSAGE [con:0(guest@anonymous(4205299)/test)/ch:1] [con:0(guest@anonymous(4205299)/test)/ch:1] CHN-1002 : Flow On
@@ -181,7 +185,7 @@ public class ChannelLoggingTest extends AbstractTestLogging
String log = getLog(results.get(resultSize - 1));
validateMessageID("CHN-1002", log);
- assertTrue("Message should be Flow Started", fromMessage(log).endsWith("Flow Started"));
+ assertEquals("Message should be Flow Started", "Flow Started", getMessageString(fromMessage(log)));
}
@@ -218,6 +222,8 @@ public class ChannelLoggingTest extends AbstractTestLogging
List<String> results = _monitor.findMatches(CHANNEL_PREFIX);
+ assertTrue("No CHN messages logged", results.size() > 0);
+
// The last two channel messages should be:
//
// INFO - MESSAGE [con:0(guest@anonymous(4205299)/test)/ch:1] [con:0(guest@anonymous(4205299)/test)/ch:1] CHN-1002 : Flow On
@@ -228,7 +234,7 @@ public class ChannelLoggingTest extends AbstractTestLogging
String log = getLog(results.get(resultSize - 1));
validateMessageID("CHN-1003", log);
- assertTrue("Message should be Close:" + fromMessage(log), fromMessage(log).endsWith("Close"));
+ assertEquals("Message should be Close", "Close",getMessageString(fromMessage(log)));
assertEquals("Incorrect Channel ID closed.", 1, getChannelID(fromActor(log)));
assertEquals("Incorrect Channel ID closed.", 1, getChannelID(fromSubject(log)));
}
@@ -263,6 +269,8 @@ public class ChannelLoggingTest extends AbstractTestLogging
List<String> results = _monitor.findMatches(CHANNEL_PREFIX);
+ assertTrue("No CHN messages logged", results.size() > 0);
+
// The last two channel messages should be:
//
// INFO - MESSAGE [con:0(guest@anonymous(4205299)/test)/ch:1] [con:0(guest@anonymous(4205299)/test)/ch:1] CHN-1002 : Flow On
@@ -273,7 +281,7 @@ public class ChannelLoggingTest extends AbstractTestLogging
String log = getLog(results.get(resultSize - 1));
validateMessageID("CHN-1003", log);
- assertTrue("Message should be Close:" + fromMessage(getLog(log)), fromMessage(log).endsWith("Close"));
+ assertEquals("Message should be Close", "Close",getMessageString(fromMessage(log)));
assertEquals("Incorrect Channel ID closed.", 1, getChannelID(fromActor(log)));
assertEquals("Incorrect Channel ID closed.", 1, getChannelID(fromSubject(log)));
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java
index 46f32b1414..503129072b 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java
@@ -20,15 +20,10 @@
*/
package org.apache.qpid.server.logging;
-import org.apache.qpid.test.unit.client.forwardall.Client;
-
import javax.jms.Connection;
import java.io.File;
import java.util.List;
import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.SortedSet;
-import java.util.Collections;
import java.util.TreeSet;
public class ConnectionLoggingTest extends AbstractTestLogging
@@ -71,6 +66,8 @@ public class ConnectionLoggingTest extends AbstractTestLogging
List<String> results = _monitor.findMatches(CONNECTION_PREFIX);
+ assertTrue("No CON messages logged", results.size() > 0);
+
// Validation
// We should have at least three messages when running InVM but when running External
// we will get 0-10 negotiation on con:0 whcih may close at some random point
@@ -174,12 +171,12 @@ public class ConnectionLoggingTest extends AbstractTestLogging
assertTrue("Message does not end with close:" + log, log.endsWith("Close"));
// Extract connection ID to validate there is a CON-1001 messasge for it
- int connectionID = extractConnectionID(log);
+ int connectionID = getConnectionID(log);
//Previous log message should be the open
log = getLog(results.get(resultsSize - 2));
// MESSAGE [con:1(/127.0.0.1:52540)] CON-1001 : Open : Client ID : clientid : Protocol Version : 0-9
validateMessageID("CON-1001",log);
- assertEquals("Connection IDs do not match", connectionID, extractConnectionID(fromActor(log)));
+ assertEquals("Connection IDs do not match", connectionID, getConnectionID(fromActor(log)));
}
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java
new file mode 100644
index 0000000000..c4e33ade30
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java
@@ -0,0 +1,511 @@
+/*
+ *
+ * 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.qpid.server.logging;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.qpid.server.configuration.ServerConfiguration;
+import org.apache.qpid.server.logging.subjects.AbstractTestLogSubject;
+
+import javax.jms.Connection;
+import javax.jms.Queue;
+import javax.jms.Session;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Iterator;
+
+/**
+ * The MessageStore test suite validates that the follow log messages as
+ * specified in the Functional Specification.
+ *
+ * This suite of tests validate that the MessageStore messages occur correctly
+ * and according to the following format:
+ *
+ * MST-1001 : Created : <name>
+ * MST-1003 : Closed
+ *
+ * NOTE: Only for Persistent Stores
+ * MST-1002 : Store location : <path>
+ * MST-1004 : Recovery Start [: <queue.name>]
+ * MST-1005 : Recovered <count> messages for queue <queue.name>
+ * MST-1006 : Recovery Complete [: <queue.name>]
+ */
+public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest
+{
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ // MemoryMessageStoreLoggingTest setUp itself does not call super.setUp
+ //We call super.setUp but this will not start the broker as that is
+ //part of the test case.
+
+ // Load current configuration file to get the list of defined vhosts
+ Configuration configuration = ServerConfiguration.flatConfig(_configFile);
+ List<String> vhosts = configuration.getList("virtualhosts.virtualhost.name");
+
+ // Make them all persistent i.e. Use DerbyMessageStore and
+ // test that it logs correctly.
+ for (String vhost : vhosts)
+ {
+ makeVirtualHostPersistent(vhost);
+ }
+ }
+
+ /**
+ * Description:
+ * Persistent MessageStores will require space on disk to persist the data.
+ * This value will be logged on startup after the MessageStore has been
+ * created.
+ * Input:
+ * Default configuration
+ * Output:
+ *
+ * <date> MST-1002 : Store location : <path>
+ *
+ * Validation Steps:
+ *
+ * 1. The MST ID is correct
+ * 2. This must occur after MST-1001
+ */
+ public void testMessageStoreStoreLocation() throws Exception
+ {
+ assertLoggingNotYetOccured(MESSAGES_STORE_PREFIX);
+
+ startBroker();
+
+ List<String> results = _monitor.findMatches(MESSAGES_STORE_PREFIX);
+
+ // Validation
+
+ assertTrue("MST messages not logged", results.size() > 0);
+
+ // Load VirtualHost list from file.
+ Configuration configuration = ServerConfiguration.flatConfig(_configFile);
+ List<String> vhosts = configuration.getList("virtualhosts.virtualhost.name");
+
+ //Validate each vhost logs a creation
+ results = _monitor.findMatches("MST-1002");
+
+ assertEquals("Each vhost did not close its store.", vhosts.size(), results.size());
+
+ for (int index = 0; index < results.size(); index++)
+ {
+ String result = getLog(results.get(index));
+
+ // getSlize will return extract the vhost from vh(/test) -> '/test'
+ // so remove the '/' to get the name
+ String vhostName = AbstractTestLogSubject.getSlice("vh", result).substring(1);
+
+ // To get the store class used in the configuration we need to know
+ // the virtualhost name, found above. AND
+ // the index that the virtualhost is within the configuration.
+ // we can retrive that from the vhosts list previously extracted.
+ String fullStoreName = configuration.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
+
+ // Get the Simple class name from the expected class name of o.a.q.s.s.MMS
+ String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
+
+ assertTrue("MST-1002 does not contain a store path" + getMessageString(result),
+ getMessageString(result).length() > 0);
+
+ assertEquals("The store name does not match expected value",
+ storeName, AbstractTestLogSubject.getSlice("ms", fromSubject(result)));
+ }
+ }
+
+ /**
+ * Description:
+ * Persistent message stores may have state on disk that they must recover
+ * during startup. As the MessageStore starts up it will report that it is
+ * about to start the recovery process by logging MST-1004. This message
+ * will always be logged for persistent MessageStores. If there is no data
+ * to recover then there will be no subsequent recovery messages.
+ * Input:
+ * Default persistent configuration
+ * Output:
+ * <date> MST-1004 : Recovery Start
+ *
+ * Validation Steps:
+ *
+ * 1. The MST ID is correct
+ * 2. The MessageStore must have first logged a creation event.
+ */
+ public void testMessageStoreRecoveryStart() throws Exception
+ {
+ assertLoggingNotYetOccured(MESSAGES_STORE_PREFIX);
+
+ startBroker();
+
+ List<String> results = _monitor.findMatches(MESSAGES_STORE_PREFIX);
+
+ // Validation
+
+ assertTrue("MST messages not logged", results.size() > 0);
+
+ // Load VirtualHost list from file.
+ Configuration configuration = ServerConfiguration.flatConfig(_configFile);
+ List<String> vhosts = configuration.getList("virtualhosts.virtualhost.name");
+
+ //Validate each vhost logs a creation
+ results = _monitor.findMatches("MST-1004");
+
+ assertTrue("Each vhost did not close its store.", vhosts.size() <= results.size());
+
+ for (int index = 0; index < results.size(); index++)
+ {
+ String result = getLog(results.get(index));
+
+ if (getMessageString(result).contains("Recovery Start :"))
+ {
+ //Don't test queue start recoveries
+ continue;
+ }
+
+ // getSlize will return extract the vhost from vh(/test) -> '/test'
+ // so remove the '/' to get the name
+ String vhostName = AbstractTestLogSubject.getSlice("vh", result).substring(1);
+
+ // To get the store class used in the configuration we need to know
+ // the virtualhost name, found above. AND
+ // the index that the virtualhost is within the configuration.
+ // we can retrive that from the vhosts list previously extracted.
+ String fullStoreName = configuration.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
+
+ // Get the Simple class name from the expected class name of o.a.q.s.s.MMS
+ String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
+
+ assertEquals("MST-1004 does have expected message", "Recovery Start",
+ getMessageString(result));
+
+ assertEquals("The store name does not match expected value",
+ storeName, AbstractTestLogSubject.getSlice("ms", fromSubject(result)));
+ }
+ }
+
+ /**
+ * Description:
+ * Once all persistent queues have been recovered and the MessageStore has completed all recovery it must logged that the recovery process has completed.
+ * Input:
+ * Default persistent configuration
+ * Output:
+ *
+ * <date> MST-1006 : Recovery Complete
+ *
+ * Validation Steps:
+ *
+ * 1. The MST ID is correct
+ * 2. This is the last message from the MessageStore during startup.
+ * 3. This must be proceeded by a MST-1006 Recovery Start.
+ */
+ public void testMessageStoreRecoveryComplete() throws Exception
+ {
+ assertLoggingNotYetOccured(MESSAGES_STORE_PREFIX);
+
+ startBroker();
+
+ List<String> results = _monitor.findMatches(MESSAGES_STORE_PREFIX);
+
+ // Validation
+
+ assertTrue("MST messages not logged", results.size() > 0);
+
+ // Load VirtualHost list from file.
+ Configuration configuration = ServerConfiguration.flatConfig(_configFile);
+ List<String> vhosts = configuration.getList("virtualhosts.virtualhost.name");
+
+ //Validate each vhost logs a creation
+ results = _monitor.findMatches("MST-1006");
+
+ assertTrue("Each vhost did not close its store.", vhosts.size() <= results.size());
+
+ for (int index = 0; index < results.size(); index++)
+ {
+ String result = getLog(results.get(index));
+
+ if (getMessageString(result).contains("Recovery Complete :"))
+ {
+ //Don't test queue start recoveries
+ continue;
+ }
+
+ // getSlize will return extract the vhost from vh(/test) -> '/test'
+ // so remove the '/' to get the name
+ String vhostName = AbstractTestLogSubject.getSlice("vh", result).substring(1);
+
+ // To get the store class used in the configuration we need to know
+ // the virtualhost name, found above. AND
+ // the index that the virtualhost is within the configuration.
+ // we can retrive that from the vhosts list previously extracted.
+ String fullStoreName = configuration.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
+
+ // Get the Simple class name from the expected class name of o.a.q.s.s.MMS
+ String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
+
+ assertEquals("MST-1006 does have expected message", "Recovery Complete",
+ getMessageString(result));
+
+ assertEquals("The store name does not match expected value",
+ storeName, AbstractTestLogSubject.getSlice("ms", fromSubject(result)));
+ }
+ }
+
+ /**
+ * Description:
+ * A persistent MessageStore may have data to recover from disk. The message store will use MST-1004 to report the start of recovery for a specific queue that it has previously persisted.
+ * Input:
+ * Default persistent configuration
+ * Output:
+ *
+ * <date> MST-1004 : Recovery Start : <queue.name>
+ *
+ * Validation Steps:
+ *
+ * 1. The MST ID is correct
+ * 2. This must occur after the recovery start MST-1004 has been logged.
+ */
+ public void testMessageStoreQueueRecoveryStart() throws Exception
+ {
+ assertLoggingNotYetOccured(MESSAGES_STORE_PREFIX);
+
+ startBroker();
+
+ List<String> results = _monitor.findMatches(MESSAGES_STORE_PREFIX);
+
+ // Validation
+
+ assertTrue("MST messages not logged", results.size() > 0);
+
+ // Load VirtualHost list from file.
+ Configuration configuration = ServerConfiguration.flatConfig(_configFile);
+ List<String> vhosts = configuration.getList("virtualhosts.virtualhost.name");
+
+ //Validate each vhost logs a creation
+ results = _monitor.findMatches("MST-1004 : Recovery Start :");
+
+ // We are only looking for the default queue defined in local host being
+ // recovered. If other tests have made queues in test then we want to
+ // exclude them here.
+ results = filterResultsByVirtualHost(results, "/localhost");
+
+ assertEquals("Recovered test queue not found.", 1, results.size());
+
+ String result = getLog(results.get(0));
+
+ // getSlize will return extract the vhost from vh(/test) -> '/test'
+ // so remove the '/' to get the name
+ String vhostName = AbstractTestLogSubject.getSlice("vh", result).substring(1);
+
+ // To get the store class used in the configuration we need to know
+ // the virtualhost name, found above. AND
+ // the index that the virtualhost is within the configuration.
+ // we can retrive that from the vhosts list previously extracted.
+ String fullStoreName = configuration.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
+
+ // Get the Simple class name from the expected class name of o.a.q.s.s.MMS
+ String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
+
+ assertTrue("MST-1006 does end with queue 'test-queue':" + getMessageString(result),
+ getMessageString(result).endsWith("test-queue"));
+
+ assertEquals("The store name does not match expected value",
+ storeName, AbstractTestLogSubject.getSlice("ms", fromSubject(result)));
+
+ }
+
+ /**
+ * Description:
+ * After the queue has been recovered the store will log that recovery has been completed. The MessageStore must not report further status about the recovery of this queue after this message. In addition every MST-1004 queue recovery start message must be matched with a MST-1006 recovery complete.
+ * Input:
+ * Default persistent configuration
+ * Output:
+ *
+ * <date> MST-1006 : Recovery Complete : <queue.name>
+ *
+ * Validation Steps:
+ *
+ * 1. The MST ID is correct
+ * 2. This must occur after the queue recovery start MST-1004 has been logged.
+ * 3. The queue.name is non-empty
+ * 4. The queue.name correlates with a previous recovery start
+ */
+ public void testMessageStoreQueueRecoveryComplete() throws Exception
+ {
+ assertLoggingNotYetOccured(MESSAGES_STORE_PREFIX);
+
+ startBroker();
+
+ List<String> results = _monitor.findMatches(MESSAGES_STORE_PREFIX);
+
+ // Validation
+
+ assertTrue("MST messages not logged", results.size() > 0);
+
+ // Load VirtualHost list from file.
+ Configuration configuration = ServerConfiguration.flatConfig(_configFile);
+ List<String> vhosts = configuration.getList("virtualhosts.virtualhost.name");
+
+ //Validate each vhost logs a creation
+ results = _monitor.findMatches("MST-1006 : Recovery Complete :");
+
+ // We are only looking for the default queue defined in local host being
+ // recovered. If other tests have made queues in test then we want to
+ // exclude them here.
+ results = filterResultsByVirtualHost(results, "/localhost");
+
+
+ assertEquals("Recovered test queue not found.", 1, results.size());
+
+ String result = getLog(results.get(0));
+
+ // getSlize will return extract the vhost from vh(/test) -> '/test'
+ // so remove the '/' to get the name
+ String vhostName = AbstractTestLogSubject.getSlice("vh", result).substring(1);
+
+ // To get the store class used in the configuration we need to know
+ // the virtualhost name, found above. AND
+ // the index that the virtualhost is within the configuration.
+ // we can retrive that from the vhosts list previously extracted.
+ String fullStoreName = configuration.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
+
+ // Get the Simple class name from the expected class name of o.a.q.s.s.MMS
+ String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
+
+ assertTrue("MST-1006 does end with queue 'test-queue':" + getMessageString(result),
+ getMessageString(result).endsWith("test-queue"));
+
+ assertEquals("The store name does not match expected value",
+ storeName, AbstractTestLogSubject.getSlice("ms", fromSubject(result)));
+
+ results = _monitor.findMatches("MST-1004 : Recovery Start : test-queue");
+
+ assertEquals("MST-1004 for test-queue not found", 1, results.size());
+ }
+
+ /**
+ * Description:
+ * On recovery all the persistent messages that are stored on disk must be returned to the queue. MST-1005 will report the number of messages that have been recovered from disk.
+ * Input:
+ *
+ * 1. Default persistent configuration
+ * 2. Persistent queue with multiple messages enqueued
+ * Output:
+ *
+ * <date> MST-1005 : Recovered <count> messages for queue <queue.name>
+ *
+ * Validation Steps:
+ * 3. The MST ID is correct
+ * 4. This must occur after the queue recovery start MST-1004 has been logged.
+ * 5. The count is > 1
+ * 6. 'messages' is correctly printed
+ * 7. The queue.name is non-empty
+ */
+ public void testMessageStoreQueueRecoveryCountPlural() throws Exception
+ {
+ assertLoggingNotYetOccured(MESSAGES_STORE_PREFIX);
+
+ String queueName = getTestQueueName();
+
+ startBroker();
+ Connection connetion = getConnection();
+ Session session = connetion.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Queue queue = session.createQueue("direct://amq.direct/" + queueName + "/" + queueName + "?durable='true'");
+
+ session.createConsumer(queue).close();
+
+ int COUNT = 10;
+
+ sendMessage(session, queue, COUNT);
+ try
+ {
+ connetion.close();
+
+ stopBroker();
+
+ // Clear our monitor
+ _monitor.reset();
+
+ startBroker();
+
+ List<String> results = _monitor.findMatches(MESSAGES_STORE_PREFIX);
+
+ // Validation
+
+ assertTrue("MST messages not logged", results.size() > 0);
+
+ // Load VirtualHost list from file.
+ Configuration configuration = ServerConfiguration.flatConfig(_configFile);
+ List<String> vhosts = configuration.getList("virtualhosts.virtualhost.name");
+
+ //Validate each vhost logs a creation
+ results = _monitor.findMatches("MST-1004 : Recovery Start : " + queueName);
+
+ assertEquals("Recovered test queue not found.", 1, results.size());
+
+ String result = getLog(results.get(0));
+
+ validateMessageID("MST-1004", result);
+
+ assertTrue("MST-1004 does end with queue '" + queueName + "':" + getMessageString(result),
+ getMessageString(result).endsWith(queueName));
+
+ results = _monitor.findMatches("MST-1005");
+
+ assertEquals("Recovered test queue not found.", 2, results.size());
+
+ result = getLog(results.get(0));
+
+ // If the first message is not our queue the second one will be
+ if (!result.contains(queueName))
+ {
+ result = getLog(results.get(1));
+ }
+
+ // getSlize will return extract the vhost from vh(/test) -> '/test'
+ // so remove the '/' to get the name
+ String vhostName = AbstractTestLogSubject.getSlice("vh", result).substring(1);
+
+ // To get the store class used in the configuration we need to know
+ // the virtualhost name, found above. AND
+ // the index that the virtualhost is within the configuration.
+ // we can retrive that from the vhosts list previously extracted.
+ String fullStoreName = configuration.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
+
+ // Get the Simple class name from the expected class name of o.a.q.s.s.MMS
+ String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
+
+ assertTrue("MST-1005 does end with queue 'test-queue':" + getMessageString(result),
+ getMessageString(result).endsWith(queueName));
+
+ assertTrue("MST-1005 does end show correct count:" + getMessageString(result),
+ getMessageString(result).contains("Recovered " + COUNT + " messages"));
+
+ assertEquals("The store name does not match expected value",
+ storeName, AbstractTestLogSubject.getSlice("ms", fromSubject(result)));
+ }
+ finally
+ {
+ //Ensure we attempt to drain the queue.
+ assertEquals("Unable to drain queue", COUNT, drainQueue(queue));
+ }
+ }
+
+}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DurableQueueLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DurableQueueLoggingTest.java
new file mode 100644
index 0000000000..5ba7dffcdc
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DurableQueueLoggingTest.java
@@ -0,0 +1,349 @@
+/*
+ *
+ * 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.qpid.server.logging;
+
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.framing.AMQShortString;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.naming.NamingException;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The Queue test suite validates that the follow log messages as specified in
+ * the Functional Specification.
+ *
+ * This suite of tests validate that the Queue messages occur correctly and
+ * according to the following format:
+ *
+ * QUE-1001 : Create : [AutoDelete] [Durable|Transient] [Priority:<levels>] [Owner:<name>]
+ */
+public class DurableQueueLoggingTest extends AbstractTestLogging
+{
+
+ protected String DURABLE = "Durable";
+ protected String TRANSIENT = "Transient";
+ protected boolean _durable;
+
+ protected Connection _connection;
+ protected Session _session;
+ private static final String QUEUE_PREFIX = "QUE-";
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ //Ensure we only have logs from our test
+ _monitor.reset();
+
+ _connection = getConnection();
+ _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ _durable = true;
+ }
+
+ /**
+ * Description:
+ * When a simple transient queue is created then a QUE-1001 create message
+ * is expected to be logged.
+ * Input:
+ * 1. Running broker
+ * 2. Persistent Queue is created from a client
+ * Output:
+ *
+ * <date> QUE-1001 : Create : Owner: '<name>' Durable
+ *
+ * Validation Steps:
+ * 3. The QUE ID is correct
+ * 4. The Durable tag is present in the message
+ * 5. The Owner is as expected
+ *
+ * @throws javax.jms.JMSException
+ * @throws javax.naming.NamingException
+ * @throws java.io.IOException
+ */
+ public void testQueueCreateDurableExclusive() throws NamingException, JMSException, IOException
+ {
+ String queueName= getTestQueueName();
+ // To force a queue Creation Event we need to create a consumer.
+ Queue queue = (Queue) _session.createQueue("direct://amq.direct/" + queueName + "/" + queueName + "?durable='" + _durable + "'&exclusive='true'");
+
+ _session.createConsumer(queue);
+
+ // Validation
+ List<String> results = _monitor.findMatches(QUEUE_PREFIX);
+
+ // Only 1 Queue message should hav been logged
+ assertEquals("Result set size not as expected", 1, results.size());
+
+ String log = getLog(results.get(0));
+
+ // Message Should be a QUE-1001
+ validateMessageID("QUE-1001", log);
+
+ // Queue is Durable
+ assertEquals(DURABLE + " keyword not correct in log entry",
+ _durable, fromMessage(log).contains(DURABLE));
+
+ assertEquals(TRANSIENT + " keyword not correct in log entry.",
+ !_durable, fromMessage(log).contains(TRANSIENT));
+
+ assertTrue("Queue does not have correct owner value:" + fromMessage(log),
+ fromMessage(log).contains("Owner: " + _connection.getClientID()));
+ }
+
+ /**
+ * Description:
+ * When a simple transient queue is created then a QUE-1001 create message
+ * is expected to be logged.
+ * Input:
+ * 1. Running broker
+ * 2. Persistent Queue is created from a client
+ * Output:
+ *
+ * <date> QUE-1001 : Create : Owner: '<name>' Durable
+ *
+ * Validation Steps:
+ * 3. The QUE ID is correct
+ * 4. The Durable tag is present in the message
+ * 5. The Owner is as expected
+ *
+ * @throws javax.jms.JMSException
+ * @throws javax.naming.NamingException
+ * @throws java.io.IOException
+ */
+ public void testQueueCreateDurable() throws NamingException, JMSException, IOException
+ {
+ String queueName = getTestQueueName();
+
+ // To force a queue Creation Event we need to create a consumer.
+ Queue queue = (Queue) _session.createQueue("direct://amq.direct/" + queueName + "/" + queueName + "?durable='" + _durable + "'");
+
+ _session.createConsumer(queue);
+
+ // Validation
+ List<String> results = _monitor.findMatches(QUEUE_PREFIX);
+
+ // Only 1 Queue message should hav been logged
+ assertEquals("Result set size not as expected", 1, results.size());
+
+ String log = getLog(results.get(0));
+
+ // Message Should be a QUE-1001
+ validateMessageID("QUE-1001", log);
+
+ // Queue is Durable
+ assertEquals(DURABLE + " keyword not correct in log entry",
+ _durable, fromMessage(log).contains(DURABLE));
+
+ assertEquals(TRANSIENT + " keyword not correct in log entry.",
+ !_durable, fromMessage(log).contains(TRANSIENT));
+
+ assertTrue("Queue does not have correct owner value:" + fromMessage(log),
+ fromMessage(log).contains("Owner: null"));
+ }
+
+ /**
+ * Description:
+ * When a simple transient queue is created then a QUE-1001 create message
+ * is expected to be logged.
+ * Input:
+ * 1. Running broker
+ * 2. AutoDelete Persistent Queue is created from a client
+ * Output:
+ *
+ * <date> QUE-1001 : Create : Owner: '<name>' AutoDelete Durable
+ *
+ * Validation Steps:
+ * 3. The QUE ID is correct
+ * 4. The Durable tag is present in the message
+ * 5. The Owner is as expected
+ * 6. The AutoDelete tag is present in the message
+ *
+ * @throws javax.jms.JMSException
+ * @throws javax.naming.NamingException
+ * @throws java.io.IOException
+ */
+ public void testQueueCreatePersistentAutoDelete() throws NamingException, JMSException, IOException
+ {
+ String queueName = getTestQueueName();
+ // To force a queue Creation Event we need to create a consumer.
+ Queue queue = (Queue) _session.createQueue("direct://amq.direct/"+queueName+"/"+queueName+"?durable='"+_durable+"'&autodelete='true'");
+
+ _session.createConsumer(queue);
+
+ // Validation
+ List<String> results = _monitor.findMatches(QUEUE_PREFIX);
+
+ // Only 1 Queue message should hav been logged
+ assertEquals("Result set size not as expected", 1, results.size());
+
+ String log = getLog(results.get(0));
+
+ // Message Should be a QUE-1001
+ validateMessageID("QUE-1001", log);
+
+ // Queue is Durable
+ assertEquals(DURABLE + " keyword not correct in log entry",
+ _durable, fromMessage(log).contains(DURABLE));
+
+ assertEquals(TRANSIENT + " keyword not correct in log entry.",
+ !_durable, fromMessage(log).contains(TRANSIENT));
+
+ // Queue is AutoDelete
+ assertTrue("Queue does not have the AutoDelete keyword in log:" + fromMessage(log),
+ fromMessage(log).contains("AutoDelete"));
+
+ assertTrue("Queue does not have correct owner value:" + fromMessage(log),
+ fromMessage(log).contains("Owner: null"));
+ }
+
+ /**
+ * Description:
+ * When a simple transient queue is created then a QUE-1001 create message
+ * is expected to be logged.
+ * Input:
+ * 1. Running broker
+ * 2. Persistent Queue is created from a client
+ * Output:
+ *
+ * <date> QUE-1001 : Create : Owner: '<name>' Durable Priority:<levels>
+ *
+ * Validation Steps:
+ * 3. The QUE ID is correct
+ * 4. The Durable tag is present in the message
+ * 5. The Owner is as expected
+ * 6. The Priority level is correctly set
+ *
+ * @throws javax.jms.JMSException
+ * @throws javax.naming.NamingException
+ * @throws java.io.IOException
+ */
+ public void testCreateQueuePersistentPriority() throws NamingException, JMSException, IOException, AMQException
+ {
+ // To Create a Priority queue we need to use AMQSession specific code
+ int PRIORITIES = 6;
+ final Map<String, Object> arguments = new HashMap<String, Object>();
+ arguments.put("x-qpid-priorities", PRIORITIES);
+ // Need to create a queue that does not exist so use test name
+ ((AMQSession) _session).createQueue(new AMQShortString(getTestQueueName()), false, _durable, false, arguments);
+
+ //Need to create a Consumer to ensure that the log has had time to write
+ // as the above Create is Asynchronous
+ _session.createConsumer(_session.createQueue(getTestQueueName()));
+
+ // Validation
+ List<String> results = _monitor.findMatches(QUEUE_PREFIX);
+
+ // Only 1 Queue message should hav been logged
+ assertEquals("Result set size not as expected", 1, results.size());
+
+ String log = getLog(results.get(0));
+
+ // Message Should be a QUE-1001
+ validateMessageID("QUE-1001", log);
+
+ // Queue is Durable
+ assertEquals(DURABLE + " keyword not correct in log entry",
+ _durable, fromMessage(log).contains(DURABLE));
+
+ assertEquals(TRANSIENT + " keyword not correct in log entry.",
+ !_durable, fromMessage(log).contains(TRANSIENT));
+
+ // Queue is AutoDelete
+ assertTrue("Queue does not have the right Priority value keyword in log:" + fromMessage(log),
+ fromMessage(log).contains("Priority: " + PRIORITIES));
+
+ assertTrue("Queue does not have correct owner value:" + fromMessage(log),
+ fromMessage(log).contains("Owner: null"));
+ }
+
+ /**
+ * Description:
+ * When a simple transient queue is created then a QUE-1001 create message
+ * is expected to be logged.
+ * Input:
+ * 1. Running broker
+ * 2. AutoDelete Persistent Queue is created from a client
+ * Output:
+ *
+ * <date> QUE-1001 : Create : Owner: '<name>' Durable Priority:<levels>
+ *
+ * Validation Steps:
+ * 3. The QUE ID is correct
+ * 4. The Durable tag is present in the message
+ * 5. The Owner is as expected
+ * 6. The AutoDelete tag is present in the message
+ * 7. The Priority level is correctly set
+ *
+ * @throws javax.jms.JMSException
+ * @throws javax.naming.NamingException
+ * @throws java.io.IOException
+ */
+ public void testCreateQueuePersistentAutoDeletePriority() throws NamingException, JMSException, IOException, AMQException
+ {
+ // To Create a Priority queue we need to use AMQSession specific code
+ int PRIORITIES = 6;
+ final Map<String, Object> arguments = new HashMap<String, Object>();
+ arguments.put("x-qpid-priorities", PRIORITIES);
+ // Need to create a queue that does not exist so use test name
+ ((AMQSession) _session).createQueue(new AMQShortString(getTestQueueName()), true, _durable, false, arguments);
+
+ //Need to create a Consumer to ensure that the log has had time to write
+ // as the above Create is Asynchronous
+ _session.createConsumer(_session.createQueue(getTestQueueName()));
+
+ // Validation
+ List<String> results = _monitor.findMatches(QUEUE_PREFIX);
+
+ // Only 1 Queue message should hav been logged
+ assertEquals("Result set size not as expected", 1, results.size());
+
+ String log = getLog(results.get(0));
+
+ // Message Should be a QUE-1001
+ validateMessageID("QUE-1001", log);
+
+ // Queue is Durable
+ assertEquals(DURABLE + " keyword not correct in log entry",
+ _durable, fromMessage(log).contains(DURABLE));
+
+ assertEquals(TRANSIENT + " keyword not correct in log entry.",
+ !_durable, fromMessage(log).contains(TRANSIENT));
+
+ // Queue is AutoDelete
+ assertTrue("Queue does not have the right Priority value keyword in log:" + fromMessage(log),
+ fromMessage(log).contains("Priority: " + PRIORITIES));
+
+ // Queue is AutoDelete
+ assertTrue("Queue does not have the AutoDelete keyword in log:" + fromMessage(log),
+ fromMessage(log).contains("AutoDelete"));
+
+ assertTrue("Queue does not have correct owner value:" + fromMessage(log),
+ fromMessage(log).contains("Owner: null"));
+ }
+
+}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ExchangeLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ExchangeLoggingTest.java
new file mode 100644
index 0000000000..778201e3e4
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ExchangeLoggingTest.java
@@ -0,0 +1,203 @@
+/*
+ *
+ * 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.qpid.server.logging;
+
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.framing.AMQFrame;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.ExchangeDeleteBody;
+import org.apache.qpid.framing.ExchangeDeleteOkBody;
+import org.apache.qpid.framing.amqp_8_0.MethodRegistry_8_0;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.Session;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Exchange
+ *
+ * The Exchange test suite validates that the follow log messages as specified in the Functional Specification.
+ *
+ * This suite of tests validate that the Exchange messages occur correctly and according to the following format:
+ *
+ * EXH-1001 : Create : [Durable] Type:<value> Name:<value>
+ * EXH-1002 : Deleted
+ */
+public class ExchangeLoggingTest extends AbstractTestLogging
+{
+
+ static final String EXH_PREFIX = "EXH-";
+
+ Connection _connection;
+ Session _session;
+ Queue _queue;
+ String _name;
+ String _type;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ _connection = getConnection();
+
+ _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ _type = "direct";
+ _name = "testName";
+
+ _queue = _session.createQueue(_type + "://" + _name + "/queue/queue");
+
+ }
+
+ /**
+ * Description:
+ * When a durable exchange is created an EXH-1001 message is logged with the Durable tag. This will be the first message from this exchange.
+ * Input:
+ *
+ * 1. Running broker
+ * 2. Client requests a durable exchange be created.
+ * Output:
+ *
+ * <date> EXH-1001 : Create : Durable Type:<value> Name:<value>
+ *
+ * Validation Steps:
+ * 3. The EXH ID is correct
+ * 4. The Durable tag is present in the message
+ */
+
+ public void testExchangeCreateDurable() throws JMSException, IOException
+ {
+ // The client cannot create durable exchanges lets just look at the
+ // ones the broker creates at startup.
+
+ // They should all be durable
+
+ List<String> results = _monitor.findMatches(EXH_PREFIX);
+
+ assertTrue("No Results found for Exchange.", results.size()>0);
+
+ String log = getLog(results.get(0));
+
+ validateMessageID("EXH-1001", log);
+
+ String message = getMessageString(fromMessage(log));
+ assertTrue("Log Message does not start with create:" + message,
+ message.startsWith("Create"));
+
+ assertTrue("Log Message does not contain Durable:" + message,
+ message.contains("Durable"));
+
+ }
+
+ /**
+ * Description:
+ * When an exchange is created an EXH-1001 message is logged. This will be the first message from this exchange.
+ * Input:
+ *
+ * 1. Running broker
+ * 2. Client requests an exchange be created.
+ * Output:
+ *
+ * <date> EXH-1001 : Create : Type:<value> Name:<value>
+ *
+ * Validation Steps:
+ * 3. The EXH ID is correct
+ */
+ public void testExchangeCreate() throws JMSException, IOException
+ {
+ //Ignore broker startup messages
+ _monitor.reset();
+
+ _session.createConsumer(_queue);
+
+ List<String> results = _monitor.findMatches(EXH_PREFIX);
+
+ assertEquals("Result set larger than expected.", 1, results.size());
+
+ String log = getLog(results.get(0));
+
+ validateMessageID("EXH-1001", log);
+
+ String message = getMessageString(fromMessage(log));
+ assertTrue("Log Message does not start with create:" + message,
+ message.startsWith("Create"));
+ assertTrue("Log Message does not contain Type:" + message,
+ message.contains("Type: " + _type));
+ assertTrue("Log Message does not contain Name:" + message,
+ message.contains("Name: " + _name));
+ }
+
+ /**
+ * Description:
+ * An Exchange can be deleted through an AMQP ExchangeDelete method. When this is successful an EXH-1002 Delete message will be logged. This will be the last message from this exchange.
+ * Input:
+ *
+ * 1. Running broker
+ * 2. A new Exchange has been created
+ * 3. Client requests that the new exchange be deleted.
+ * Output:
+ *
+ * <date> EXH-1002 : Deleted
+ *
+ * Validation Steps:
+ * 4. The EXH ID is correct
+ * 5. There is a corresponding EXH-1001 Create message logged.
+ */
+ public void testExchangeDelete() throws Exception, IOException
+ {
+ //Ignore broker startup messages
+ _monitor.reset();
+
+ _session.createConsumer(_queue);
+
+ MethodRegistry_8_0 registry = new MethodRegistry_8_0();
+
+ ExchangeDeleteBody body = registry.createExchangeDeleteBody(0, new AMQShortString(_name), false, true);
+
+ AMQFrame exchangeDeclare = body.generateFrame(0);
+
+ ((AMQConnection) _connection).getProtocolHandler().syncWrite(exchangeDeclare, ExchangeDeleteOkBody.class);
+
+ List<String> results = _monitor.findMatches(EXH_PREFIX);
+
+ assertEquals("Result set larger than expected.", 2, results.size());
+
+ String log = getLog(results.get(0));
+
+ validateMessageID("EXH-1001", log);
+
+ String message = getMessageString(fromMessage(log));
+ assertTrue("Log Message does start with Create",
+ message.startsWith("Create"));
+
+ log = getLog(results.get(1));
+ validateMessageID("EXH-1002", log);
+
+ message = getMessageString(fromMessage(log));
+ assertEquals("Log Message not as expected", "Deleted", message);
+
+ }
+
+}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java
new file mode 100644
index 0000000000..2eeedf2dfe
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java
@@ -0,0 +1,378 @@
+/*
+ *
+ * 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.qpid.server.logging;
+
+import junit.framework.AssertionFailedError;
+import org.apache.qpid.util.LogMonitor;
+
+import java.util.List;
+
+/**
+ * Management Console Test Suite
+ *
+ * The Management Console test suite validates that the follow log messages as specified in the Functional Specification.
+ *
+ * This suite of tests validate that the management console messages occur correctly and according to the following format:
+ *
+ * MNG-1001 : Startup
+ * MNG-1002 : Starting : <service> : Listening on port <Port>
+ * MNG-1003 : Shutting down : <service> : port <Port>
+ * MNG-1004 : Ready
+ * MNG-1005 : Stopped
+ * MNG-1006 : Using SSL Keystore : <path>
+ */
+public class ManagementLoggingTest extends AbstractTestLogging
+{
+ private static final String MNG_PREFIX = "MNG-";
+
+ public void setUp() throws Exception
+ {
+ // We either do this here or have a null check in tearDown.
+ // As when this test is run against profiles other than java it will NPE
+ _monitor = new LogMonitor(_outputFile);
+ //We explicitly do not call super.setUp as starting up the broker is
+ //part of the test case.
+
+ }
+
+ /**
+ * Description:
+ * Using the startup configuration validate that the management startup
+ * message is logged correctly.
+ * Input:
+ * Standard configuration with management enabled
+ * Output:
+ *
+ * <date> MNG-1001 : Startup
+ *
+ * Constraints:
+ * This is the FIRST message logged by MNG
+ * Validation Steps:
+ *
+ * 1. The BRK ID is correct
+ * 2. This is the FIRST message logged by MNG
+ */
+ public void testManagementStartupEnabled() throws Exception
+ {
+ // This test only works on external java brokers due to the fact that
+ // Management is disabled on InVM brokers.
+ if (isJavaBroker() && isExternalBroker())
+ {
+ //Ensure management is on
+ setConfigurationProperty("management.enabled", "true");
+
+ startBroker();
+
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
+ List<String> results = _monitor.findMatches(MNG_PREFIX);
+ try
+ {
+ // Validation
+
+ assertTrue("MNGer message not logged", results.size() > 0);
+
+ String log = getLog(results.get(0));
+
+ //1
+ validateMessageID("MNG-1001", log);
+
+ //2
+ results = _monitor.findMatches("MNG-1001");
+ assertEquals("More than one startup message found.",
+ 1, results.size());
+
+ //3
+ assertEquals("Startup log message is not 'Startup'.", "Startup",
+ getMessageString(log));
+ }
+ catch (AssertionFailedError afe)
+ {
+ System.err.println("Log Dump:");
+ for (String log : results)
+ {
+ System.err.println(log);
+ }
+ throw afe;
+ }
+ }
+ }
+
+ /**
+ * Description:
+ * Verify that when management is disabled in the configuration file the
+ * startup message is not logged.
+ * Input:
+ * Standard configuration with management disabled
+ * Output:
+ * NO MNG messages
+ * Validation Steps:
+ *
+ * 1. Validate that no MNG messages are produced.
+ */
+ public void testManagementStartupDisabled() throws Exception
+ {
+ // This test only works on external java brokers due to the fact that
+ // Management is disabled on InVM brokers.
+ if (isJavaBroker() && isExternalBroker())
+ {
+ //Ensure management is off
+ setConfigurationProperty("management.enabled", "false");
+
+ startBroker();
+
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
+ List<String> results = _monitor.findMatches(MNG_PREFIX);
+ try
+ {
+ // Validation
+
+ assertEquals("MNGer messages logged", 0, results.size());
+ }
+ catch (AssertionFailedError afe)
+ {
+ System.err.println("Log Dump:");
+ for (String log : results)
+ {
+ System.err.println(log);
+ }
+ throw afe;
+ }
+ }
+ }
+
+ /**
+ * The two MNG-1002 messages are logged at the same time so lets test them
+ * at the same time.
+ *
+ * Description:
+ * Using the default configuration validate that the RMI Registry socket is
+ * correctly reported as being opened
+ *
+ * Input:
+ * The default configuration file
+ * Output:
+ *
+ * <date> MESSAGE MNG-1002 : Starting : RMI Registry : Listening on port 8999
+ *
+ * Constraints:
+ * The RMI ConnectorServer and Registry log messages do not have a prescribed order
+ * Validation Steps:
+ *
+ * 1. The MNG ID is correct
+ * 2. The specified port is the correct '8999'
+ *
+ * Description:
+ * Using the default configuration validate that the RMI ConnectorServer
+ * socket is correctly reported as being opened
+ *
+ * Input:
+ * The default configuration file
+ * Output:
+ *
+ * <date> MESSAGE MNG-1002 : Starting : RMI ConnectorServer : Listening on port 9099
+ *
+ * Constraints:
+ * The RMI ConnectorServer and Registry log messages do not have a prescribed order
+ * Validation Steps:
+ *
+ * 1. The MNG ID is correct
+ * 2. The specified port is the correct '9099'
+ */
+ public void testManagementStartupRMIEntries() throws Exception
+ {
+ // This test only works on external java brokers due to the fact that
+ // Management is disabled on InVM brokers.
+ if (isJavaBroker() && isExternalBroker())
+ {
+ //Ensure management is on
+ setConfigurationProperty("management.enabled", "true");
+
+ startBroker();
+
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
+ List<String> results = _monitor.findMatches("MNG-1002");
+ try
+ {
+ // Validation
+
+ assertEquals("MNGer message not logged expected message", 2, results.size());
+
+ String log = getLog(results.get(0));
+
+ //1
+ validateMessageID("MNG-1002", log);
+
+ // Validate we only have one MNG-1002
+ results = _monitor.findMatches("MNG-1002");
+ assertEquals("More than two RMI entries found.",
+ 2, results.size());
+
+ // We expect the RMI Server port to be 100 higher than
+ // the RMIConnector Server Port
+ int mPort = getPort() + (DEFAULT_MANAGEMENT_PORT - DEFAULT_PORT);
+ assertTrue("RMI Registry port not as expected(" + mPort + ").:" + getMessageString(log),
+ getMessageString(log).endsWith(String.valueOf(mPort)));
+
+ log = getLog(results.get(1));
+
+ //1
+ validateMessageID("MNG-1002", log);
+
+ // We expect the RMIConnector Server port to be 100 higher than
+ // the RMI Server Port
+ mPort = getPort() + (DEFAULT_MANAGEMENT_PORT - DEFAULT_PORT) + 100;
+ assertTrue("RMI ConnectorServer port not as expected(" + mPort + ").:" + getMessageString(log),
+ getMessageString(log).endsWith(String.valueOf(mPort)));
+ }
+ catch (AssertionFailedError afe)
+ {
+ System.err.println("Log Dump:");
+ for (String log : results)
+ {
+ System.err.println(log);
+ }
+ throw afe;
+ }
+ }
+ }
+
+ /**
+ * Description:
+ * Using the default configuration validate that the RMI ConnectorServer socket is correctly reported as being opened
+ * Input:
+ * The default configuration file
+ * Output:
+ *
+ * <date> MESSAGE MNG-1002 : Starting : RMI ConnectorServer : Listening on port 9099
+ *
+ * Constraints:
+ * The RMI ConnectorServer and Registry log messages do not have a prescribed order
+ * Validation Steps:
+ *
+ * 1. The MNG ID is correct
+ * 2. The specified port is the correct '9099'
+ */
+ public void testManagementStartupRMIConnectorServer() throws Exception
+ {
+ // This test only works on external java brokers due to the fact that
+ // Management is disabled on InVM brokers.
+ if (isJavaBroker() && isExternalBroker())
+ {
+ //Ensure management is on
+ setConfigurationProperty("management.enabled", "true");
+
+ startBroker();
+
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
+ List<String> results = _monitor.findMatches(MNG_PREFIX);
+ try
+ {
+ // Validation
+
+ assertTrue("MNGer message not logged", results.size() > 0);
+
+ }
+ catch (AssertionFailedError afe)
+ {
+ System.err.println("Log Dump:");
+ for (String log : results)
+ {
+ System.err.println(log);
+ }
+ throw afe;
+ }
+ }
+ }
+
+ /**
+ * Description:
+ * Using the default configuration with SSL enabled for the management port the SSL Keystore path should be reported via MNG-1006
+ * Input:
+ * Management SSL enabled default configuration.
+ * Output:
+ *
+ * <date> MESSAGE MNG-1006 : Using SSL Keystore : test_resources/ssl/keystore.jks
+ *
+ * Validation Steps:
+ *
+ * 1. The MNG ID is correct
+ * 2. The keystore path is as specified in the configuration
+ */
+ public void testManagementStartupSSLKeystore() throws Exception
+ {
+ // This test only works on external java brokers due to the fact that
+ // Management is disabled on InVM brokers.
+ if (isJavaBroker() && isExternalBroker())
+ {
+ //Ensure management is on
+ setConfigurationProperty("management.enabled", "true");
+ // This test requires we have an ssl connection
+ setConfigurationProperty("management.ssl.enabled", "true");
+
+ startBroker();
+
+ // Now we can create the monitor as _outputFile will now be defined
+ _monitor = new LogMonitor(_outputFile);
+
+ List<String> results = _monitor.findMatches("MNG-1006");
+ try
+ {
+ // Validation
+
+ assertTrue("MNGer message not logged", results.size() > 0);
+
+ String log = getLog(results.get(0));
+
+ //1
+ validateMessageID("MNG-1006", log);
+
+ // Validate we only have one MNG-1002
+ results = _monitor.findMatches("MNG-1006");
+ assertEquals("More than one SSL Keystore entry found.",
+ 1, results.size());
+
+ // We expect the RMIConnector Server port to be 100 higher than
+ // the RMI Server Port
+ int mPort = getPort() + (DEFAULT_MANAGEMENT_PORT - DEFAULT_PORT) + 100;
+ assertTrue("SSL Keystore entry expected(" + mPort + ").:" + getMessageString(log),
+ getMessageString(log).endsWith(getConfigurationStringProperty("management.ssl.keyStorePath")));
+ }
+ catch (AssertionFailedError afe)
+ {
+ System.err.println("Log Dump:");
+ for (String log : results)
+ {
+ System.err.println(log);
+ }
+ throw afe;
+ }
+ }
+
+ }
+}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java
new file mode 100644
index 0000000000..a1cbeca6de
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java
@@ -0,0 +1,192 @@
+/*
+*
+* 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.qpid.server.logging;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.qpid.server.configuration.ServerConfiguration;
+import org.apache.qpid.server.logging.subjects.AbstractTestLogSubject;
+import org.apache.qpid.util.LogMonitor;
+
+import java.util.List;
+
+/**
+ * The MessageStore test suite validates that the follow log messages as
+ * specified in the Functional Specification.
+ *
+ * This suite of tests validate that the MessageStore messages occur correctly
+ * and according to the following format:
+ *
+ * MST-1001 : Created : <name>
+ * MST-1003 : Closed
+ *
+ * NOTE: Only for Persistent Stores
+ * MST-1002 : Store location : <path>
+ * MST-1004 : Recovery Start [: <queue.name>]
+ * MST-1005 : Recovered <count> messages for queue <queue.name>
+ * MST-1006 : Recovery Complete [: <queue.name>]
+ */
+public class MemoryMessageStoreLoggingTest extends AbstractTestLogging
+{
+ protected static final String MESSAGES_STORE_PREFIX = "MST-";
+
+ public void setUp() throws Exception
+ {
+ //We explicitly do not call super.setUp as starting up the broker is
+ //part of the test case.
+ // So we have to make the new Log Monitor here
+
+ _monitor = new LogMonitor(_outputFile);
+ }
+
+ /**
+ * Description:
+ * During Virtualhost startup a MessageStore will be created. The first MST
+ * message that must be logged is the MST-1001 MessageStore creation.
+ * Input:
+ * Default configuration
+ * Output:
+ * <date> MST-1001 : Created : <name>
+ *
+ * Validation Steps:
+ *
+ * 1. The MST ID is correct
+ * 2. The <name> is the correct MessageStore type as specified in the Default configuration
+ *
+ * @throws Exception caused by broker startup
+ */
+ public void testMessageStoreCreation() throws Exception
+ {
+ assertLoggingNotYetOccured(MESSAGES_STORE_PREFIX);
+
+ startBroker();
+
+ List<String> results = _monitor.findMatches(MESSAGES_STORE_PREFIX);
+
+ // Validation
+
+ assertTrue("MST messages not logged", results.size() > 0);
+
+ String log = getLog(results.get(0));
+ //1
+ assertEquals("MST-1001 is not the first MST message", "MST-1001", getMessageID(fromMessage(log)));
+
+ // Load VirtualHost list from file.
+ Configuration configuration = ServerConfiguration.flatConfig(_configFile);
+ List<String> vhosts = configuration.getList("virtualhosts.virtualhost.name");
+
+ //Validate each vhost logs a creation
+ results = _monitor.findMatches("MST-1001");
+
+ assertEquals("Each vhost did not create a store.", vhosts.size(), results.size());
+
+ for (int index = 0; index < results.size(); index++)
+ {
+ String result = getLog(results.get(index));
+
+ // getSlize will return extract the vhost from vh(/test) -> '/test'
+ // so remove the '/' to get the name
+ String vhostName = AbstractTestLogSubject.getSlice("vh", result).substring(1);
+
+ // To get the store class used in the configuration we need to know
+ // the virtualhost name, found above. AND
+ // the index that the virtualhost is within the configuration.
+ // we can retrive that from the vhosts list previously extracted.
+ String fullStoreName = configuration.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
+
+ // Get the Simple class name from the expected class name of o.a.q.s.s.MMS
+ String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
+
+ assertTrue("MST-1001 does not contains correct store name:"
+ + storeName + ":" + result, getMessageString(result).endsWith(storeName));
+
+ assertEquals("The store name does not match expected value",
+ storeName, AbstractTestLogSubject.getSlice("ms", fromSubject(result)));
+ }
+ }
+
+ /**
+ * Description:
+ * During shutdown the MessageStore will also cleanly close. When this has
+ * completed a MST-1003 closed message will be logged. No further messages
+ * from this MessageStore will be logged after this message.
+ *
+ * Input:
+ * Default configuration
+ * Output:
+ * <date> MST-1003 : Closed
+ *
+ * Validation Steps:
+ *
+ * 1. The MST ID is correct
+ * 2. This is teh last log message from this MessageStore
+ *
+ * @throws Exception caused by broker startup
+ */
+ public void testMessageStoreClose() throws Exception
+ {
+ assertLoggingNotYetOccured(MESSAGES_STORE_PREFIX);
+
+ startBroker();
+
+ //Stop the broker so we get the close messages.
+ stopBroker();
+
+ List<String> results = _monitor.findMatches(MESSAGES_STORE_PREFIX);
+
+ // Validation
+
+ assertTrue("MST messages not logged", results.size() > 0);
+
+ // Load VirtualHost list from file.
+ Configuration configuration = ServerConfiguration.flatConfig(_configFile);
+ List<String> vhosts = configuration.getList("virtualhosts.virtualhost.name");
+
+ //Validate each vhost logs a creation
+ results = _monitor.findMatches("MST-1003");
+
+ assertEquals("Each vhost did not close its store.", vhosts.size(), results.size());
+
+ for (int index = 0; index < results.size(); index++)
+ {
+ String result = getLog(results.get(index));
+
+ // getSlize will return extract the vhost from vh(/test) -> '/test'
+ // so remove the '/' to get the name
+ String vhostName = AbstractTestLogSubject.getSlice("vh", result).substring(1);
+
+ // To get the store class used in the configuration we need to know
+ // the virtualhost name, found above. AND
+ // the index that the virtualhost is within the configuration.
+ // we can retrive that from the vhosts list previously extracted.
+ String fullStoreName = configuration.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
+
+ // Get the Simple class name from the expected class name of o.a.q.s.s.MMS
+ String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
+
+ assertEquals("MST-1003 does not close:",
+ "Closed", getMessageString(result));
+
+ assertEquals("The store name does not match expected value",
+ storeName, AbstractTestLogSubject.getSlice("ms", fromSubject(result)));
+ }
+ }
+
+}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/QueueLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/QueueLoggingTest.java
new file mode 100644
index 0000000000..e407f2b626
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/QueueLoggingTest.java
@@ -0,0 +1,172 @@
+/*
+ *
+ * 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.qpid.server.logging;
+
+import org.omg.CORBA.TRANSIENT;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.client.failover.FailoverException;
+import org.apache.qpid.server.logging.subjects.AbstractTestLogSubject;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.AMQException;
+
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.Queue;
+import javax.jms.JMSException;
+import javax.naming.NamingException;
+import java.util.List;
+import java.io.IOException;
+
+/**
+ * The Queue test suite validates that the follow log messages as specified in
+ * the Functional Specification.
+ *
+ * This suite of tests validate that the Queue messages occur correctly and
+ * according to the following format:
+ *
+ * QUE-1002 : Deleted
+ */
+public class QueueLoggingTest extends AbstractTestLogging
+{
+ protected Connection _connection;
+ protected Session _session;
+ private static final String QUEUE_PREFIX = "QUE-";
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ //Remove broker startup logging messages
+ _monitor.reset();
+
+ _connection = getConnection();
+ _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ }
+
+ /**
+ * Description:
+ * An explict QueueDelete request must result in a QUE-1002 Deleted message
+ * being logged. This can be done via an explict AMQP QueueDelete method.
+ * Input:
+ *
+ * 1. Running Broker
+ * 2. Queue created on the broker with no subscribers
+ * 3. Client requests the queue be deleted via a QueueDelete
+ * Output:
+ *
+ * <date> QUE-1002 : Deleted
+ *
+ * Validation Steps:
+ *
+ * 4. The QUE ID is correct
+ *
+ * @throws java.io.IOException
+ * @throws javax.jms.JMSException
+ * @throws javax.naming.NamingException
+ */
+ public void testQueueDelete() throws NamingException, JMSException, IOException, FailoverException, AMQException
+ {
+ // To force a queue Creation Event we need to create a consumer.
+ Queue queue = _session.createQueue(getTestQueueName());
+
+ _session.createConsumer(queue);
+
+ // Delete Queue
+ ((AMQSession)_session).sendQueueDelete(new AMQShortString(queue.getQueueName()));
+
+ //Perform a synchronous action to ensure that the above log will be on disk
+ _session.close();
+
+ // Validation
+ List<String> results = _monitor.findMatches(QUEUE_PREFIX);
+
+ // Only 1 Queue message should hav been logged
+ assertEquals("Result set size not as expected", 2, results.size());
+
+ String log = getLog(results.get(0));
+
+ // Message Should be a QUE-1001
+ validateMessageID("QUE-1001", log);
+
+ String createdQueueName = AbstractTestLogSubject.getSlice("qu", fromSubject(log));
+
+ log = getLog(results.get(1));
+ // Message Should be a QUE-1002
+ validateMessageID("QUE-1002", log);
+
+ assertEquals("Log Message is incorrect ", "Deleted", getMessageString(fromMessage(log)));
+
+ assertEquals("Queue Delete not for created queue:", createdQueueName,
+ AbstractTestLogSubject.getSlice("qu", fromSubject(log)));
+ }
+
+
+ /**
+ * Description:
+ * An explict QueueDelete request must result in a QUE-1002 Deleted message
+ * being logged. This can be done via an explict AMQP QueueDelete method.
+ * Input:
+ *
+ * 1. Running Broker
+ * 2. Queue created on the broker with no subscribers
+ * 3. Client creates a temporary queue then disconnects
+ * Output:
+ *
+ * <date> QUE-1002 : Deleted
+ *
+ * Validation Steps:
+ *
+ * 4. The QUE ID is correct
+ *
+ * @throws java.io.IOException
+ * @throws javax.jms.JMSException
+ * @throws javax.naming.NamingException
+ */
+ public void testQueueAutoDelete() throws NamingException, JMSException, IOException
+ {
+ // Create a temporary queue so that when we consume from it and
+ // then close the consumer it will be autoDeleted.
+ _session.createConsumer(_session.createTemporaryQueue()).close();
+
+ // Validation
+ List<String> results = _monitor.findMatches(QUEUE_PREFIX);
+
+ // Only 1 Queue message should hav been logged
+ assertEquals("Result set size not as expected", 2, results.size());
+
+ String log = getLog(results.get(0));
+
+ // Message Should be a QUE-1001
+ validateMessageID("QUE-1001", log);
+
+ String createdQueueName = AbstractTestLogSubject.getSlice("qu", fromSubject(log));
+
+ log = getLog(results.get(1));
+ // Message Should be a QUE-1002
+ validateMessageID("QUE-1002", log);
+
+ assertEquals("Log Message is incorrect ", "Deleted", getMessageString(fromMessage(log)));
+
+ assertEquals("Queue Delete not for created queue:", createdQueueName,
+ AbstractTestLogSubject.getSlice("qu", fromSubject(log)));
+
+ }
+
+} \ No newline at end of file
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java
new file mode 100644
index 0000000000..11e345de5e
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java
@@ -0,0 +1,299 @@
+/*
+ *
+ * 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.qpid.server.logging;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.Topic;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Subscription
+ *
+ * The Subscription test suite validates that the follow log messages as specified in the Functional Specification.
+ *
+ * This suite of tests validate that the Subscription messages occur correctly and according to the following format:
+ *
+ * SUB-1001 : Create : [Durable] [Arguments : <key=value>]
+ * SUB-1002 : Close
+ */
+public class SubscriptionLoggingTest extends AbstractTestLogging
+{
+ static final String SUB_PREFIX = "SUB-";
+
+ Connection _connection;
+ Session _session;
+ Queue _queue;
+ Topic _topic;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ //Remove broker startup logging messages
+ _monitor.reset();
+
+ _connection = getConnection();
+
+ _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ _queue = (Queue) getInitialContext().lookup(QUEUE);
+ _topic = (Topic) getInitialContext().lookup(TOPIC);
+ }
+
+ /**
+ * Description:
+ * When a Subscription is created it will be logged. This test validates that Subscribing to a transient queue is correctly logged.
+ * Input:
+ *
+ * 1. Running Broker
+ * 2. Create a new Subscription to a transient queue/topic.
+ * Output:
+ *
+ * <date> SUB-1001 : Create
+ *
+ * Validation Steps:
+ * 3. The SUB ID is correct
+ *
+ * @throws java.io.IOException - if there is a problem getting the matches
+ * @throws javax.jms.JMSException - if there is a problem creating the consumer
+ */
+ public void testSubscriptionCreate() throws JMSException, IOException
+ {
+ _session.createConsumer(_queue);
+
+ //Validate
+
+ List<String> results = _monitor.findMatches(SUB_PREFIX);
+
+ assertEquals("Result set larger than expected.", 1, results.size());
+
+ String log = getLog(results.get(0));
+
+ validateMessageID("SUB-1001", log);
+
+ assertEquals("Log Message not as expected", "Create", getMessageString(fromMessage(log)));
+ }
+
+ /**
+ * Description:
+ * The creation of a Durable Subscription, such as a JMS DurableTopicSubscriber will result in an extra Durable tag being included in the Create log message
+ * Input:
+ *
+ * 1. Running Broker
+ * 2. Creation of a JMS DurableTopicSubiber
+ * Output:
+ *
+ * <date> SUB-1001 : Create : Durable
+ *
+ * Validation Steps:
+ * 3. The SUB ID is correct
+ * 4. The Durable tag is present in the message
+ * NOTE: A Subscription is not Durable, the queue it consumes from is.
+ *
+ * @throws java.io.IOException - if there is a problem getting the matches
+ * @throws javax.jms.JMSException - if there is a problem creating the consumer
+ */
+ public void testSubscriptionCreateDurable() throws JMSException, IOException
+ {
+ _session.createDurableSubscriber(_topic, getName());
+
+ //Validate
+
+ List<String> results = _monitor.findMatches(SUB_PREFIX);
+
+ assertEquals("Result set larger than expected.", 1, results.size());
+
+ String log = getLog(results.get(0));
+
+ validateMessageID("SUB-1001", log);
+
+ String message = getMessageString(fromMessage(log));
+ assertTrue("Durable not on log message:" + message, message.contains("Durable"));
+ }
+
+ /**
+ * Description:
+ * The creation of a QueueBrowser will provides a number arguments and so should form part of the SUB-1001 Create message.
+ * Input:
+ *
+ * 1. Running Broker
+ * 2. Java Client creates a QueueBroweser
+ * Output:
+ *
+ * <date> SUB-1001 : Create : Arguments : <key=value>
+ *
+ * Validation Steps:
+ * 3. The SUB ID is correct
+ * 4. The Arguments are present in the message
+ * 5. Arguments keys include AutoClose and Browser.
+ *
+ * @throws java.io.IOException - if there is a problem getting the matches
+ * @throws javax.jms.JMSException - if there is a problem creating the consumer
+ */
+ public void testSubscriptionCreateQueueBrowser() throws JMSException, IOException
+ {
+ _session.createBrowser(_queue);
+
+ //Validate
+ List<String> results = _monitor.findMatches(SUB_PREFIX);
+
+ assertEquals("Result set larger than expected.", 2, results.size());
+
+ String log = getLog(results.get(0));
+
+ validateMessageID("SUB-1001", log);
+
+ String message = getMessageString(fromMessage(log));
+ assertTrue("Browser not on log message:" + message, message.contains("Browser"));
+ assertTrue("AutoClose not on log message:" + message, message.contains("AutoClose"));
+
+ // Beacause it is an auto close and we have no messages on the queue we
+ // will get a close message
+ log = getLog(results.get(1));
+ validateMessageID("SUB-1002", log);
+
+ }
+
+ /**
+ * Description:
+ * The creation of a Subscriber with a JMS Selector will result in the Argument field being populated. These argument key/value pairs are then shown in the log message.
+ * Input:
+ *
+ * 1. Running Broker
+ * 2. Subscriber created with a JMS Selector.
+ * Output:
+ *
+ * <date> SUB-1001 : Create : Arguments : <key=value>
+ *
+ * Validation Steps:
+ * 3. The SUB ID is correct
+ * 4. Argument tag is present in the message
+ *
+ * @throws java.io.IOException - if there is a problem getting the matches
+ * @throws javax.jms.JMSException - if there is a problem creating the consumer
+ */
+ public void testSubscriptionCreateWithArguments() throws JMSException, IOException
+ {
+ final String SELECTOR = "Selector='True'";
+ _session.createConsumer(_queue, SELECTOR);
+
+ //Validate
+
+ List<String> results = _monitor.findMatches(SUB_PREFIX);
+
+ assertEquals("Result set larger than expected.", 1, results.size());
+
+ String log = getLog(results.get(0));
+
+ validateMessageID("SUB-1001", log);
+
+ String message = getMessageString(fromMessage(log));
+ assertTrue("Selector not on log message:" + message, message.contains(SELECTOR));
+ }
+
+ /**
+ * Description:
+ * The final combination of SUB-1001 Create messages involves the creation of a Durable Subscription that also contains a set of Arguments, such as those provided via a JMS Selector.
+ * Input:
+ *
+ * 1. Running Broker
+ * 2. Java Client creates a Durable Subscription with Selector
+ * Output:
+ *
+ * <date> SUB-1001 : Create : Durable Arguments : <key=value>
+ *
+ * Validation Steps:
+ * 3. The SUB ID is correct
+ * 4. The tag Durable is present in the message
+ * 5. The Arguments are present in the message
+ *
+ * @throws java.io.IOException - if there is a problem getting the matches
+ * @throws javax.jms.JMSException - if there is a problem creating the consumer
+ */
+ public void testSubscriptionCreateDurableWithArguments() throws JMSException, IOException
+ {
+ final String SELECTOR = "Selector='True'";
+ _session.createDurableSubscriber(_topic, getName(), SELECTOR, false);
+
+ //Validate
+
+ List<String> results = _monitor.findMatches(SUB_PREFIX);
+
+ assertEquals("Result set larger than expected.", 1, results.size());
+
+ String log = getLog(results.get(0));
+
+ validateMessageID("SUB-1001", log);
+
+ String message = getMessageString(fromMessage(log));
+ assertTrue("Durable not on log message:" + message, message.contains("Durable"));
+ assertTrue("Selector not on log message:" + message, message.contains(SELECTOR));
+ }
+
+ /**
+ * Description:
+ * When a Subscription is closed it will log this so that it can be correlated with the Create.
+ * Input:
+ *
+ * 1. Running Broker
+ * 2. Client with a subscription.
+ * 3. The subscription is then closed.
+ * Output:
+ *
+ * <date> SUB-1002 : Close
+ *
+ * Validation Steps:
+ * 1. The SUB ID is correct
+ * 2. There must be a SUB-1001 Create message preceding this message
+ * 3. This must be the last message from the given Subscription
+ *
+ * @throws java.io.IOException - if there is a problem getting the matches
+ * @throws javax.jms.JMSException - if there is a problem creating the consumer
+ */
+ public void testSubscriptionClose() throws JMSException, IOException
+ {
+ _session.createConsumer(_queue).close();
+
+
+
+ //Validate
+ List<String> results = _monitor.findMatches(SUB_PREFIX);
+
+ //3
+ assertEquals("Result set larger than expected.", 2, results.size());
+
+ // 2
+ String log = getLog(results.get(0));
+ validateMessageID("SUB-1001", log);
+ // 1
+ log = getLog(results.get(1));
+ validateMessageID("SUB-1002", log);
+
+ String message = getMessageString(fromMessage(log));
+ assertEquals("Log message is not close", "Close", message);
+
+ }
+
+}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/TransientQueueLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/TransientQueueLoggingTest.java
new file mode 100644
index 0000000000..29f74c5818
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/TransientQueueLoggingTest.java
@@ -0,0 +1,30 @@
+/*
+ *
+ * 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.qpid.server.logging;
+
+public class TransientQueueLoggingTest extends DurableQueueLoggingTest
+{
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ _durable = false;
+ }
+}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/QueueDepthWithSelectorTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/QueueDepthWithSelectorTest.java
index eb09bbeb16..ded2e0913b 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/QueueDepthWithSelectorTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/QueueDepthWithSelectorTest.java
@@ -25,6 +25,7 @@ import junit.framework.TestCase;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.qpid.AMQException;
+import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.transport.TransportConnection;
@@ -88,6 +89,7 @@ public class QueueDepthWithSelectorTest extends TestCase
if (BROKER.startsWith("vm://"))
{
+ ApplicationRegistry.getInstance(1);
TransportConnection.createVMBroker(1);
}
InitialContextFactory factory = new PropertiesFileInitialContextFactory();
@@ -120,7 +122,8 @@ public class QueueDepthWithSelectorTest extends TestCase
if (BROKER.startsWith("vm://"))
{
- TransportConnection.killAllVMBrokers();
+ TransportConnection.killVMBroker(1);
+ ApplicationRegistry.remove(1);
}
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/SubscriptionTestHelper.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/SubscriptionTestHelper.java
index 2216758c2e..b5de04b7d8 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/SubscriptionTestHelper.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/SubscriptionTestHelper.java
@@ -21,6 +21,7 @@
package org.apache.qpid.server.queue;
import org.apache.qpid.server.AMQChannel;
+import org.apache.qpid.server.logging.LogActor;
import org.apache.qpid.server.subscription.Subscription;
import org.apache.qpid.framing.AMQShortString;
@@ -57,7 +58,7 @@ public class SubscriptionTestHelper implements Subscription
return messages;
}
- public void setQueue(AMQQueue queue)
+ public void setQueue(AMQQueue queue, boolean exclusive)
{
}
@@ -167,6 +168,11 @@ public class SubscriptionTestHelper implements Subscription
//To change body of implemented methods use File | Settings | File Templates.
}
+ public LogActor getLogActor()
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public AMQQueue getQueue()
{
return null;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/SimpleACLTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/SimpleACLTest.java
index 64838cd328..b5c0a87b0f 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/SimpleACLTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/SimpleACLTest.java
@@ -38,7 +38,7 @@ import java.io.File;
public class SimpleACLTest extends QpidTestCase implements ConnectionListener
{
- private String BROKER = "vm://:1";//"tcp://localhost:5672";
+ private String BROKER = "vm://:"+ApplicationRegistry.DEFAULT_INSTANCE;//"tcp://localhost:5672";
public void setUp() throws Exception
{
@@ -61,14 +61,14 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener
}
ConfigurationFileApplicationRegistry config = new ConfigurationFileApplicationRegistry(defaultaclConfigFile);
- ApplicationRegistry.initialise(config, 1);
- TransportConnection.createVMBroker(1);
+ ApplicationRegistry.initialise(config, ApplicationRegistry.DEFAULT_INSTANCE);
+ TransportConnection.createVMBroker(ApplicationRegistry.DEFAULT_INSTANCE);
}
public void tearDown()
{
- TransportConnection.killAllVMBrokers();
- ApplicationRegistry.remove(1);
+ TransportConnection.killVMBroker(ApplicationRegistry.DEFAULT_INSTANCE);
+ ApplicationRegistry.remove(ApplicationRegistry.DEFAULT_INSTANCE);
}
public String createConnectionString(String username, String password, String broker)
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/InVMBrokerDecorator.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/InVMBrokerDecorator.java
index e0fddb10b7..b92a72a654 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/InVMBrokerDecorator.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/InVMBrokerDecorator.java
@@ -88,6 +88,7 @@ public class InVMBrokerDecorator extends WrappedSuiteTestDecorator
// Ensure that the in-vm broker is created.
try
{
+ ApplicationRegistry.getInstance(1);
TransportConnection.createVMBroker(1);
}
catch (AMQVMBrokerCreationException e)
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java
index 4e85c28e9b..4596878935 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java
@@ -148,18 +148,6 @@ public class MultipleConnectionTest extends QpidTestCase
}
}
- protected void setUp() throws Exception
- {
- super.setUp();
- TransportConnection.createVMBroker(1);
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
- TransportConnection.killAllVMBrokers();
- }
-
private static void waitForCompletion(int expected, long wait, Receiver[] receivers) throws InterruptedException
{
for (int i = 0; i < receivers.length; i++)
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java
index b843f7c9c0..2710e7a08d 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java
@@ -67,13 +67,11 @@ public class ChannelCloseOkTest extends QpidTestCase
private final List<Message> _received2 = new ArrayList<Message>();
private static final Logger _log = LoggerFactory.getLogger(ChannelCloseOkTest.class);
- public String _connectionString = "vm://:1";
protected void setUp() throws Exception
{
super.setUp();
- TransportConnection.createVMBroker(1);
_connection = (AMQConnection) getConnection("guest", "guest");
_destination1 = new AMQQueue(_connection, "q1", true);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseTest.java
index d210f5e1a1..eb6adf9b39 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseTest.java
@@ -54,25 +54,13 @@ public class ChannelCloseTest extends QpidTestCase implements ExceptionListener,
private static final long SYNC_TIMEOUT = 500;
private int TEST = 0;
- protected void setUp() throws Exception
- {
- super.setUp();
- TransportConnection.createVMBroker(1);
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
- TransportConnection.killAllVMBrokers();
- }
-
/*
close channel, use chanel with same id ensure error.
*/
public void testReusingChannelAfterFullClosure() throws Exception
{
- // this is testing an 0.8 conneciton
- if(isBroker08())
+ // this is testing an inVM Connetion conneciton
+ if (isJavaBroker() && !isExternalBroker())
{
_connection=newConnection();
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/CloseAfterConnectionFailureTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/CloseAfterConnectionFailureTest.java
index bb9c22f31a..f627d94419 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/CloseAfterConnectionFailureTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/CloseAfterConnectionFailureTest.java
@@ -24,8 +24,6 @@ import org.apache.qpid.AMQException;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQConnectionURL;
import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.qpid.test.utils.QpidTestCase;
import org.apache.qpid.url.URLSyntaxException;
@@ -44,37 +42,42 @@ public class CloseAfterConnectionFailureTest extends QpidTestCase implements Exc
private CountDownLatch _latch = new CountDownLatch(1);
private JMSException _fail;
- public void testNoFailover() throws URLSyntaxException, AMQVMBrokerCreationException,
+ public void testNoFailover() throws URLSyntaxException, Exception,
InterruptedException, JMSException
{
- String connectionString = "amqp://guest:guest@/test?brokerlist='vm://:1?connectdelay='500',retries='3'',failover='nofailover'";
+ //This test uses hard coded connection string so only runs on InVM case
+ if (!isExternalBroker())
+ {
+ String connectionString = "amqp://guest:guest@/test?brokerlist='vm://:1?connectdelay='500',retries='3'',failover='nofailover'";
- AMQConnectionURL url = new AMQConnectionURL(connectionString);
+ AMQConnectionURL url = new AMQConnectionURL(connectionString);
- try
- {
- //Start the connection so it will use the retries
- connection = new AMQConnection(url, null);
+ try
+ {
+ //Start the connection so it will use the retries
+ connection = new AMQConnection(url, null);
- connection.setExceptionListener(this);
+ connection.setExceptionListener(this);
- session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- consumer = session.createConsumer(session.createQueue(this.getName()));
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ consumer = session.createConsumer(session.createQueue(this.getName()));
- //Kill connection
- TransportConnection.killAllVMBrokers();
- _latch.await();
+ //Kill connection
+ stopBroker();
- if (_fail != null)
+ _latch.await();
+
+ if (_fail != null)
+ {
+ _fail.printStackTrace(System.out);
+ fail("Exception thrown:" + _fail.getMessage());
+ }
+ }
+ catch (AMQException e)
{
- _fail.printStackTrace(System.out);
- fail("Exception thrown:" + _fail.getMessage());
+ fail(e.getMessage());
}
}
- catch (AMQException e)
- {
- fail(e.getMessage());
- }
}
public void onException(JMSException e)
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
index c182db5d78..cd8071527c 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
@@ -19,13 +19,28 @@ package org.apache.qpid.test.utils;
import junit.framework.TestCase;
import junit.framework.TestResult;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.XMLConfiguration;
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQConnectionFactory;
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.jms.BrokerDetails;
+import org.apache.qpid.jms.ConnectionURL;
+import org.apache.qpid.server.configuration.ServerConfiguration;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry;
+import org.apache.qpid.server.store.DerbyMessageStore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.jms.Connection;
import javax.jms.Destination;
-import javax.jms.Session;
-import javax.jms.MessageProducer;
-import javax.jms.Message;
import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.io.BufferedReader;
@@ -38,29 +53,12 @@ import java.io.LineNumberReader;
import java.io.PrintStream;
import java.net.MalformedURLException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.HashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.XMLConfiguration;
-
-import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQConnectionFactory;
-import org.apache.qpid.server.configuration.ServerConfiguration;
-import org.apache.qpid.server.store.DerbyMessageStore;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry;
-import org.apache.qpid.jms.BrokerDetails;
-import org.apache.qpid.jms.ConnectionURL;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
*
*
@@ -148,6 +146,7 @@ public class QpidTestCase extends TestCase
private static final String BROKER_CLEAN = "broker.clean";
private static final String BROKER_VERSION = "broker.version";
private static final String BROKER_READY = "broker.ready";
+ private static final String BROKER_STOPPED = "broker.stopped";
private static final String TEST_OUTPUT = "test.output";
// values
@@ -162,6 +161,7 @@ public class QpidTestCase extends TestCase
protected static int DEFAULT_VM_PORT = 1;
protected static int DEFAULT_PORT = Integer.getInteger("test.port", 5672);
+ protected static int DEFAULT_MANAGEMENT_PORT = Integer.getInteger("test.mport", 8999);
protected String _brokerLanguage = System.getProperty(BROKER_LANGUAGE, JAVA);
protected String _broker = System.getProperty(BROKER, VM);
@@ -171,7 +171,7 @@ public class QpidTestCase extends TestCase
protected File _outputFile;
- private Map<Integer,Process> _brokers = new HashMap<Integer,Process>();
+ private Map<Integer, Process> _brokers = new HashMap<Integer, Process>();
private InitialContext _initialContext;
private AMQConnectionFactory _connectionFactory;
@@ -181,6 +181,8 @@ public class QpidTestCase extends TestCase
// the connections created for a given test
protected List<Connection> _connections = new ArrayList<Connection>();
public static final String QUEUE = "queue";
+ public static final String TOPIC = "topic";
+
public QpidTestCase(String name)
{
@@ -204,7 +206,7 @@ public class QpidTestCase extends TestCase
boolean redirected = _output != null && _output.length() > 0;
if (redirected)
{
- _outputFile = new File (String.format("%s/TEST-%s.out", _output, qname));
+ _outputFile = new File(String.format("%s/TEST-%s.out", _output, qname));
out = new PrintStream(_outputFile);
err = new PrintStream(String.format("%s/TEST-%s.err", _output, qname));
System.setOut(out);
@@ -245,7 +247,7 @@ public class QpidTestCase extends TestCase
{
fail("Unable to test without config file:" + _configFile);
}
-
+
startBroker();
}
@@ -271,12 +273,21 @@ public class QpidTestCase extends TestCase
private String ready;
private CountDownLatch latch;
private boolean seenReady;
+ private String stopped;
+ private String stopLine;
public Piper(InputStream in, String ready)
{
+ this(in, ready, null);
+ }
+
+ public Piper(InputStream in, String ready, String stopped)
+ {
this.in = new LineNumberReader(new InputStreamReader(in));
this.ready = ready;
+ this.stopped = stopped;
this.seenReady = false;
+
if (this.ready != null && !this.ready.equals(""))
{
this.latch = new CountDownLatch(1);
@@ -318,6 +329,11 @@ public class QpidTestCase extends TestCase
seenReady = true;
latch.countDown();
}
+
+ if (latch != null && line.contains(stopped))
+ {
+ stopLine = line;
+ }
}
}
catch (IOException e)
@@ -333,6 +349,11 @@ public class QpidTestCase extends TestCase
}
}
}
+
+ public String getStopLine()
+ {
+ return stopLine;
+ }
}
public void startBroker() throws Exception
@@ -340,6 +361,16 @@ public class QpidTestCase extends TestCase
startBroker(0);
}
+ /**
+ * Get the Port that is use by the current broker
+ *
+ * @return the current port
+ */
+ protected int getPort()
+ {
+ return getPort(0);
+ }
+
private int getPort(int port)
{
if (_broker.equals(VM))
@@ -359,10 +390,10 @@ public class QpidTestCase extends TestCase
private String getBrokerCommand(int port) throws MalformedURLException
{
return _broker
- .replace("@PORT", "" + port)
- .replace("@SSL_PORT", "" + (port - 1))
- .replace("@MPORT", "" + (port + (8999 - DEFAULT_PORT)))
- .replace("@CONFIG_FILE", _configFile.toString());
+ .replace("@PORT", "" + port)
+ .replace("@SSL_PORT", "" + (port - 1))
+ .replace("@MPORT", "" + (port + (DEFAULT_MANAGEMENT_PORT - DEFAULT_PORT)))
+ .replace("@CONFIG_FILE", _configFile.toString());
}
public void startBroker(int port) throws Exception
@@ -397,15 +428,19 @@ public class QpidTestCase extends TestCase
process = pb.start();
Piper p = new Piper(process.getInputStream(),
- System.getProperty(BROKER_READY));
+ System.getProperty(BROKER_READY),
+ System.getProperty(BROKER_STOPPED));
p.start();
if (!p.await(30, TimeUnit.SECONDS))
{
- _logger.info("broker failed to become ready");
+ _logger.info("broker failed to become ready:" + p.getStopLine());
+ //Ensure broker has stopped
+ process.destroy();
cleanBroker();
- throw new RuntimeException("broker failed to become ready");
+ throw new RuntimeException("broker failed to become ready:"
+ + p.getStopLine());
}
try
@@ -475,12 +510,12 @@ public class QpidTestCase extends TestCase
ApplicationRegistry.remove(port);
}
}
-
+
public void nukeBroker() throws Exception
{
nukeBroker(0);
}
-
+
public void nukeBroker(int port) throws Exception
{
Process proc = _brokers.get(getPort(port));
@@ -490,21 +525,20 @@ public class QpidTestCase extends TestCase
}
else
{
- String command = "pkill -KILL -f "+getBrokerCommand(getPort(port));
- try
+ String command = "pkill -KILL -f " + getBrokerCommand(getPort(port));
+ try
{
Runtime.getRuntime().exec(command);
}
catch (Exception e)
{
// Can't do that, try the old fashioned way
- _logger.warn("Could not run "+command+", killing with stopBroker()");
+ _logger.warn("Could not run " + command + ", killing with stopBroker()");
stopBroker(port);
}
}
}
-
/**
* Attempt to set the Java Broker to use the BDBMessageStore for persistence
* Falling back to the DerbyMessageStore if
@@ -522,7 +556,7 @@ public class QpidTestCase extends TestCase
Class bdb = null;
try
{
- bdb = Class.forName("org.apache.qpid.store.berkleydb.BDBMessageStore");
+ bdb = Class.forName("org.apache.qpid.server.store.berkeleydb.BDBMessageStore");
}
catch (ClassNotFoundException e)
{
@@ -540,7 +574,7 @@ public class QpidTestCase extends TestCase
".store.class", storeClass.getName());
configuration.setProperty("virtualhosts.virtualhost." + virtualhost +
".store." + DerbyMessageStore.ENVIRONMENT_PATH_PROPERTY,
- "${work}");
+ "${work}/" + virtualhost);
File tmpFile = File.createTempFile("configFile", "test");
tmpFile.deleteOnExit();
@@ -549,6 +583,22 @@ public class QpidTestCase extends TestCase
}
/**
+ * Get a property value from the current configuration file.
+ *
+ * @param property the property to lookup
+ *
+ * @return the requested String Value
+ *
+ * @throws org.apache.commons.configuration.ConfigurationException
+ *
+ */
+ protected String getConfigurationStringProperty(String property) throws ConfigurationException
+ {
+ ServerConfiguration configuration = new ServerConfiguration(_configFile);
+ return configuration.getConfig().getString(property);
+ }
+
+ /**
* Set a configuration Property for this test run.
*
* This creates a new configuration based on the current configuration
@@ -558,9 +608,10 @@ public class QpidTestCase extends TestCase
* configuration files being created.
*
* @param property the configuration property to set
- * @param value the new value
+ * @param value the new value
+ *
* @throws ConfigurationException when loading the current config file
- * @throws IOException when writing the new config file
+ * @throws IOException when writing the new config file
*/
protected void setConfigurationProperty(String property, String value)
throws ConfigurationException, IOException
@@ -613,9 +664,9 @@ public class QpidTestCase extends TestCase
* Set a System property for the duration of this test.
*
* When the test run is complete the value will be reverted.
-
+ *
* @param property the property to set
- * @param value the new value to use
+ * @param value the new value to use
*/
protected void setSystemProperty(String property, String value)
{
@@ -671,7 +722,7 @@ public class QpidTestCase extends TestCase
protected boolean isExternalBroker()
{
return !_broker.equals("vm");
- }
+ }
public void restartBroker() throws Exception
{
@@ -797,6 +848,16 @@ public class QpidTestCase extends TestCase
return con;
}
+ /**
+ * Return a uniqueName for this test.
+ * In this case it returns a queue Named by the TestCase and TestName
+ * @return String name for a queue
+ */
+ protected String getTestQueueName()
+ {
+ return getClass().getSimpleName() + "-" + getName();
+ }
+
protected void tearDown() throws java.lang.Exception
{
// close all the connections used by this test.
@@ -807,18 +868,49 @@ public class QpidTestCase extends TestCase
revertSystemProperties();
}
-
+
+ /**
+ * Consume all the messages in the specified queue. Helper to ensure
+ * persistent tests don't leave data behind.
+ *
+ * @param queue the queue to purge
+ *
+ * @return the count of messages drained
+ *
+ * @throws Exception if a problem occurs
+ */
+ protected int drainQueue(Queue queue) throws Exception
+ {
+ Connection connection = getConnection();
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer consumer = session.createConsumer(queue);
+
+ connection.start();
+
+ int count = 0;
+ while (consumer.receive(1000) != null)
+ {
+ count++;
+ }
+
+ connection.close();
+
+ return count;
+ }
+
public List<Message> sendMessage(Session session, Destination destination,
int count) throws Exception
{
- return sendMessage(session, destination, count, 0);
+ return sendMessage(session, destination, count, 0);
}
public List<Message> sendMessage(Session session, Destination destination,
- int count,int batchSize) throws Exception
+ int count, int batchSize) throws Exception
{
List<Message> messages = new ArrayList<Message>(count);
-
+
MessageProducer producer = session.createProducer(destination);
for (int i = 0; i < count; i++)
@@ -859,7 +951,6 @@ public class QpidTestCase extends TestCase
return getConnectionFactory().getConnectionURL();
}
-
public BrokerDetails getBroker()
{
try
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/util/LogMonitor.java b/qpid/java/systests/src/main/java/org/apache/qpid/util/LogMonitor.java
index 84010453e1..df8dd0b85b 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/util/LogMonitor.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/util/LogMonitor.java
@@ -45,6 +45,9 @@ public class LogMonitor
// The file that the log statements will be written to.
private File _logfile;
+ // The appender we added to the get messages
+ private FileAppender _appender;
+
/**
* Create a new LogMonitor that creates a new Log4j Appender and monitors
* all log4j output via the current configuration.
@@ -78,11 +81,11 @@ public class LogMonitor
{
// This is mostly for running the test outside of the ant setup
_logfile = File.createTempFile("LogMonitor", ".log");
- FileAppender appender = new FileAppender(new SimpleLayout(),
+ _appender = new FileAppender(new SimpleLayout(),
_logfile.getAbsolutePath());
- appender.setFile(_logfile.getAbsolutePath());
- appender.setImmediateFlush(true);
- Logger.getRootLogger().addAppender(appender);
+ _appender.setFile(_logfile.getAbsolutePath());
+ _appender.setImmediateFlush(true);
+ Logger.getRootLogger().addAppender(_appender);
}
}
@@ -169,8 +172,24 @@ public class LogMonitor
*/
public void reset() throws FileNotFoundException, IOException
{
- OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(_logfile));
- writer.write("Log Monitor Reset\n");
- writer.close();
+ new FileOutputStream(_logfile).getChannel().truncate(0);
}
+
+ /**
+ * Stop monitoring this file.
+ *
+ * This is required to be called incase we added a new logger.
+ *
+ * If we don't call close then the new logger will continue to get log entries
+ * after our desired test has finished.
+ */
+ public void close()
+ {
+ //Remove the custom appender we added for this logger
+ if (_appender != null)
+ {
+ Logger.getRootLogger().removeAppender(_appender);
+ }
+ }
+
}
diff --git a/qpid/java/test-profiles/08StandaloneExcludes b/qpid/java/test-profiles/08StandaloneExcludes
index e697201bfd..de876e06bb 100644
--- a/qpid/java/test-profiles/08StandaloneExcludes
+++ b/qpid/java/test-profiles/08StandaloneExcludes
@@ -40,3 +40,8 @@ org.apache.qpid.server.persistent.NoLocalAfterRecoveryTest#*
org.apache.qpid.client.SessionCreateTest#*
org.apache.qpid.test.client.RollbackOrderTest#*
+
+// This test requires the standard configuration file for validation.
+// Excluding here does not reduce test coverage.
+org.apache.qpid.server.configuration.ServerConfigurationFileTest#*
+
diff --git a/qpid/java/test-profiles/Excludes b/qpid/java/test-profiles/Excludes
index a3a61b51db..b4b3fb7cb9 100644
--- a/qpid/java/test-profiles/Excludes
+++ b/qpid/java/test-profiles/Excludes
@@ -5,3 +5,12 @@ org.apache.qpid.server.queue.QueueCreateTest#testCreateFlowToDiskValidNoSize
org.apache.qpid.server.queue.QueueCreateTest#testCreateFlowToDiskInvalid
org.apache.qpid.server.queue.QueueCreateTest#testCreateFlowToDiskInvalidSize
+//
+// QPID-2031 : Broker is not cleanly shutdown by QpidTestCase
+//
+org.apache.qpid.server.logging.BrokerLoggingTest#testBrokerShutdownListeningTCPDefault
+org.apache.qpid.server.logging.BrokerLoggingTest#testBrokerShutdownListeningTCPSSL
+org.apache.qpid.server.logging.BrokerLoggingTest#testBrokerShutdownStopped
+org.apache.qpid.server.logging.MemoryMessageStoreLoggingTest#testMessageStoreClose
+org.apache.qpid.server.logging.DerbyMessageStoreLoggingTest#testMessageStoreClose
+
diff --git a/qpid/java/test-profiles/default.testprofile b/qpid/java/test-profiles/default.testprofile
index 5a08b79e10..864cf149d4 100644
--- a/qpid/java/test-profiles/default.testprofile
+++ b/qpid/java/test-profiles/default.testprofile
@@ -17,6 +17,7 @@ log4j.configuration=file:///${test.profiles}/log4j-test.xml
log4j.debug=false
test.port=15672
+test.mport=18999
test.port.ssl=15671
test.port.alt=15673
diff --git a/qpid/java/test-profiles/java-derby.testprofile b/qpid/java/test-profiles/java-derby.testprofile
index 52b63ae799..0fa6a73a32 100644
--- a/qpid/java/test-profiles/java-derby.testprofile
+++ b/qpid/java/test-profiles/java-derby.testprofile
@@ -1,7 +1,8 @@
broker.language=java
broker=${project.root}/build/bin/qpid-server -p @PORT -m @MPORT -c @CONFIG_FILE -l ${test.profiles}/log4j-test.xml
broker.clean=${test.profiles}/clean-dir ${build.data} ${project.root}/build/work/derbyDB
-broker.ready=Qpid Broker Ready
+broker.ready=Ready
+broker.stopped=Exception
broker.config=${project.root}/build/etc/config-systests-derby.xml
profile.excludes=08StandaloneExcludes
diff --git a/qpid/java/test-profiles/java.testprofile b/qpid/java/test-profiles/java.testprofile
index f920124735..52f1013cf1 100644
--- a/qpid/java/test-profiles/java.testprofile
+++ b/qpid/java/test-profiles/java.testprofile
@@ -1,6 +1,7 @@
broker.language=java
broker=${project.root}/build/bin/qpid-server -p @PORT -m @MPORT -c @CONFIG_FILE -l ${test.profiles}/log4j-test.xml
broker.clean=${test.profiles}/clean-dir ${build.data} ${project.root}/build/work/derbyDB
-broker.ready=Qpid Broker Ready
+broker.ready=Ready
+broker.stopped=Exception
profile.excludes=08TransientExcludes 08StandaloneExcludes