summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Godfrey <rgodfrey@apache.org>2009-10-05 10:24:16 +0000
committerRobert Godfrey <rgodfrey@apache.org>2009-10-05 10:24:16 +0000
commitcd4111bf751210e9e5009d9c5452126e6039a4b4 (patch)
tree3b32b4989e4ca76483a5e6144f98e4e5da50bc1a
parent510ba3ebd76717f1fc3e08537b167f7fea96ee28 (diff)
downloadqpid-python-cd4111bf751210e9e5009d9c5452126e6039a4b4.tar.gz
Merged from trunk up to r797052
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/java-broker-0-10@821739 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/src/qpid/broker/SessionAdapter.cpp16
-rw-r--r--qpid/cpp/src/qpid/sys/DispatchHandle.cpp1
-rw-r--r--qpid/cpp/src/qpid/sys/DispatchHandle.h1
-rw-r--r--qpid/java/broker/build.xml49
-rw-r--r--qpid/java/broker/etc/config-systests.xml5
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java122
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/logging/BrokerMessages.java34
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/logging/RootMessageLoggerImpl.java2
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPChannelActor.java1
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/LogMessages_en_US.properties82
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/subscription/Subscription_0_10.java12
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java77
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/StatusUpdateConfigurationTest.java73
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java104
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/BindingMessagesTest.java49
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/BrokerMessagesTest.java113
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ChannelMessagesTest.java65
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ConnectionMessagesTest.java51
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ExchangeMessagesTest.java58
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ManagementConsoleMessagesTest.java95
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/MessageStoreMessagesTest.java123
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/QueueMessagesTest.java49
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/SubscriptionMessagesTest.java47
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/VirtualHostMessagesTest.java48
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java8
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubjectTest.java5
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/TestBlankSubject.java30
-rw-r--r--qpid/java/broker/src/velocity/java/org/apache/qpid/server/logging/GenerateLogMessages.java354
-rw-r--r--qpid/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm77
-rw-r--r--qpid/java/build.xml3
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java85
31 files changed, 1661 insertions, 178 deletions
diff --git a/qpid/cpp/src/qpid/broker/SessionAdapter.cpp b/qpid/cpp/src/qpid/broker/SessionAdapter.cpp
index 6f1d42249d..8eed673add 100644
--- a/qpid/cpp/src/qpid/broker/SessionAdapter.cpp
+++ b/qpid/cpp/src/qpid/broker/SessionAdapter.cpp
@@ -57,8 +57,8 @@ SessionAdapter::SessionAdapter(SemanticState& s) :
dtxImpl(s)
{}
-static const std::string TRUE("true");
-static const std::string FALSE("false");
+static const std::string _TRUE("true");
+static const std::string _FALSE("false");
void SessionAdapter::ExchangeHandlerImpl::declare(const string& exchange, const string& type,
const string& alternateExchange,
@@ -69,8 +69,8 @@ void SessionAdapter::ExchangeHandlerImpl::declare(const string& exchange, const
std::map<acl::Property, std::string> params;
params.insert(make_pair(acl::PROP_TYPE, type));
params.insert(make_pair(acl::PROP_ALTERNATE, alternateExchange));
- params.insert(make_pair(acl::PROP_PASSIVE, std::string(passive ? TRUE : FALSE) ));
- params.insert(make_pair(acl::PROP_DURABLE, std::string(durable ? TRUE : FALSE)));
+ params.insert(make_pair(acl::PROP_PASSIVE, std::string(passive ? _TRUE : _FALSE) ));
+ params.insert(make_pair(acl::PROP_DURABLE, std::string(durable ? _TRUE : _FALSE)));
if (!acl->authorise(getConnection().getUserId(),acl::ACT_CREATE,acl::OBJ_EXCHANGE,exchange,&params) )
throw NotAllowedException(QPID_MSG("ACL denied exhange declare request from " << getConnection().getUserId()));
}
@@ -327,10 +327,10 @@ void SessionAdapter::QueueHandlerImpl::declare(const string& name, const string&
if (acl) {
std::map<acl::Property, std::string> params;
params.insert(make_pair(acl::PROP_ALTERNATE, alternateExchange));
- params.insert(make_pair(acl::PROP_PASSIVE, std::string(passive ? TRUE : FALSE) ));
- params.insert(make_pair(acl::PROP_DURABLE, std::string(durable ? TRUE : FALSE)));
- params.insert(make_pair(acl::PROP_EXCLUSIVE, std::string(exclusive ? TRUE : FALSE)));
- params.insert(make_pair(acl::PROP_AUTODELETE, std::string(autoDelete ? TRUE : FALSE)));
+ params.insert(make_pair(acl::PROP_PASSIVE, std::string(passive ? _TRUE : _FALSE) ));
+ params.insert(make_pair(acl::PROP_DURABLE, std::string(durable ? _TRUE : _FALSE)));
+ params.insert(make_pair(acl::PROP_EXCLUSIVE, std::string(exclusive ? _TRUE : _FALSE)));
+ params.insert(make_pair(acl::PROP_AUTODELETE, std::string(autoDelete ? _TRUE : _FALSE)));
if (!acl->authorise(getConnection().getUserId(),acl::ACT_CREATE,acl::OBJ_QUEUE,name,&params) )
throw NotAllowedException(QPID_MSG("ACL denied queue create request from " << getConnection().getUserId()));
}
diff --git a/qpid/cpp/src/qpid/sys/DispatchHandle.cpp b/qpid/cpp/src/qpid/sys/DispatchHandle.cpp
index 0a237d837b..d65cd8a427 100644
--- a/qpid/cpp/src/qpid/sys/DispatchHandle.cpp
+++ b/qpid/cpp/src/qpid/sys/DispatchHandle.cpp
@@ -242,7 +242,6 @@ void DispatchHandle::doDelete() {
}
void DispatchHandle::processEvent(Poller::EventType type) {
- CallbackQueue callbacks;
// Phase I
{
diff --git a/qpid/cpp/src/qpid/sys/DispatchHandle.h b/qpid/cpp/src/qpid/sys/DispatchHandle.h
index 37db776a09..115a3c44f7 100644
--- a/qpid/cpp/src/qpid/sys/DispatchHandle.h
+++ b/qpid/cpp/src/qpid/sys/DispatchHandle.h
@@ -61,6 +61,7 @@ private:
Callback writableCallback;
Callback disconnectedCallback;
CallbackQueue interruptedCallbacks;
+ CallbackQueue callbacks; // Double buffer
Poller::shared_ptr poller;
Mutex stateLock;
enum {
diff --git a/qpid/java/broker/build.xml b/qpid/java/broker/build.xml
index 1e8b817320..2a1bbb04e8 100644
--- a/qpid/java/broker/build.xml
+++ b/qpid/java/broker/build.xml
@@ -27,14 +27,61 @@
<property name="output.dir" value="${module.precompiled}/org/apache/qpid/server/filter/jms/selector"/>
+ <property name="gentools.home" location="${project.root}/../gentools" />
+ <property name="generated.package" value="org/apache/qpid/server/logging/messages" />
+ <property name="generated.dir" location="${module.precompiled}/${generated.package}" />
+ <property name="velocity.compile.dir" value="${module.build}/velocity"/>
+ <property name="velocity.timestamp" location="${generated.dir}/velocity.timestamp" />
- <target name="precompile">
+
+ <target name="precompile" depends="gen_logging">
<mkdir dir="${output.dir}"/>
+ <!-- Compile Selcector Code -->
<javacc target="src/main/grammar/SelectorParser.jj"
outputdirectory="${output.dir}"
javacchome="${project.root}/lib"/>
</target>
+ <target name="compile_velocity" >
+ <mkdir dir="${velocity.compile.dir}" />
+ <!-- Compile LogMessages Velocity Generator -->
+ <javac source="${java.source}" target="${java.target}"
+ destdir="${velocity.compile.dir}" debug="on"
+ deprecation="${javac.deprecation}"
+ srcdir="src/velocity/java" >
+ <classpath>
+ <pathelement path="${gentools.home}/lib/velocity-1.4.jar" />
+ </classpath>
+ <compilerarg line="${javac.compiler.args}"/>
+ </javac>
+ </target>
+
+ <property name="velocity.properties.dir" value="${project.root}/broker/src/main/java/org/apache/qpid/server/logging/messages"/>
+
+ <target name="check_velocity_deps">
+ <uptodate property="velocity.notRequired" targetfile="${velocity.timestamp}">
+ <srcfiles dir="${velocity.properties.dir}" includes="LogMessages.properties" />
+ <srcfiles dir="src/velocity/" includes="**/*.java **/*.vm" />
+ </uptodate>
+ </target>
+
+ <target name="gen_logging" depends="compile_velocity,check_velocity_deps" unless="velocity.notRequired">
+ <mkdir dir="${generated.dir}"/>
+ <java classname="org.apache.qpid.server.logging.GenerateLogMessages" fork="true" dir="${gentools.home}/src" failonerror="true">
+ <arg line="-j -o ${generated.dir} -t ${project.root}/broker/src/velocity/templates/org/apache/qpid/server/logging/messages"/>
+ <classpath>
+ <pathelement path="${project.root}/broker/src/main/java"/>
+ <pathelement path="${velocity.compile.dir}" />
+ <fileset dir="${project.root}/lib">
+ <include name="**/*.jar"/>
+ </fileset>
+ <pathelement path="${gentools.home}/lib/velocity-1.4.jar" />
+ </classpath>
+ </java>
+ <touch file="${velocity.timestamp}" />
+ </target>
+
+
<target name="copy-etc-release" if="module.etc.exists" description="copy etc directory if it exists to build tree">
<copy todir="${module.release}/etc" failonerror="false" flatten="true">
<fileset dir="${module.etc}" excludes="*.conf,*.jpp"/>
diff --git a/qpid/java/broker/etc/config-systests.xml b/qpid/java/broker/etc/config-systests.xml
index 9715963873..42e8c9dbba 100644
--- a/qpid/java/broker/etc/config-systests.xml
+++ b/qpid/java/broker/etc/config-systests.xml
@@ -35,6 +35,8 @@
<qpidnio>false</qpidnio>
<protectio>
<enabled>false</enabled>
+ <readBufferLimitSize>262144</readBufferLimitSize>
+ <writeBufferLimitSize>262144</writeBufferLimitSize>
</protectio>
<transport>nio</transport>
<port>5672</port>
@@ -59,6 +61,7 @@
<framesize>65535</framesize>
<compressBufferOnQueue>false</compressBufferOnQueue>
<enableJMSXUserID>false</enableJMSXUserID>
+ <locale>en_US</locale>
</advanced>
<security>
@@ -132,6 +135,8 @@
<auto_register>true</auto_register>
</queue>
+ <status-updates>ON</status-updates>
+
<virtualhosts>${conf}/virtualhosts-systests.xml</virtualhosts>
</broker>
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
index fc16b75e1a..e56f1cda12 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
@@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Locale;
import java.util.Map.Entry;
import org.apache.commons.configuration.CompositeConfiguration;
@@ -37,7 +38,6 @@ import org.apache.qpid.server.configuration.management.ConfigurationManagementMB
import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
-import org.apache.qpid.tools.messagestore.MessageStoreTool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,9 +49,15 @@ public class ServerConfiguration implements SignalHandler
private Configuration _config;
+ // Default Configuration values
+ //todo make these all public, to make validation of configuration easier.
+ public static final int DEFAULT_BUFFER_READ_LIMIT_SIZE = 262144;
+ public static final int DEFAULT_BUFFER_WRITE_LIMIT_SIZE = 262144;
+ public static final boolean DEFAULT_BROKER_CONNECTOR_PROTECTIO_ENABLED = false;
+ public static final String DEFAULT_STATUS_UPDATES = "on";
+ public static final String DEFAULT_ADVANCED_LOCALE = Locale.US.toString();
+
private static final int DEFAULT_FRAME_SIZE = 65536;
- private static final int DEFAULT_BUFFER_READ_LIMIT_SIZE = 262144;
- private static final int DEFAULT_BUFFER_WRITE_LIMIT_SIZE = 262144;
private static final int DEFAULT_PORT = 5672;
private static final int DEFAUL_SSL_PORT = 8672;
private static final long DEFAULT_HOUSEKEEPING_PERIOD = 30000L;
@@ -63,15 +69,23 @@ public class ServerConfiguration implements SignalHandler
private SecurityConfiguration _securityConfiguration = null;
private File _configFile;
-
+
private Logger _log = LoggerFactory.getLogger(this.getClass());
private ConfigurationManagementMBean _mbean;
-
+
// Map of environment variables to config items
private static final Map<String, String> envVarMap = new HashMap<String, String>();
-
+
+ // Configuration values to be read from the configuration file
+ //todo Move all properties to static values to ensure system testing can be performed.
+ public static final String CONNECTOR_PROTECTIO_ENABLED = "connector.protectio.enabled";
+ public static final String CONNECTOR_PROTECTIO_READ_BUFFER_LIMIT_SIZE = "connector.protectio.readBufferLimitSize";
+ public static final String CONNECTOR_PROTECTIO_WRITE_BUFFER_LIMIT_SIZE = "connector.protectio.writeBufferLimitSize";
+ public static final String STATUS_UPDATES = "status-updates";
+ public static final String ADVANCED_LOCALE = "advanced.locale";
+
{
envVarMap.put("QPID_PORT", "connector.port");
envVarMap.put("QPID_ENABLEDIRECTBUFFERS", "advanced.enableDirectBuffers");
@@ -96,16 +110,16 @@ public class ServerConfiguration implements SignalHandler
envVarMap.put("QPID_ENABLEPOOLEDALLOCATOR", "advanced.enablePooledAllocator");
envVarMap.put("QPID_STATUS-UPDATES", "status-updates");
}
-
+
public ServerConfiguration(File configurationURL) throws ConfigurationException
{
this(parseConfig(configurationURL));
_configFile = configurationURL;
- try
+ try
{
Signal sig = new sun.misc.Signal("HUP");
sun.misc.Signal.handle(sig, this);
- }
+ }
catch (IllegalArgumentException e)
{
// We're on something that doesn't handle SIGHUP, how sad, Windows.
@@ -115,16 +129,16 @@ public class ServerConfiguration implements SignalHandler
public ServerConfiguration(Configuration conf) throws ConfigurationException
{
setConfig(conf);
-
+
substituteEnvironmentVariables();
-
+
_jmxPort = getConfig().getInt("management.jmxport", 8999);
_securityConfiguration = new SecurityConfiguration(conf.subset("security"));
setupVirtualHosts(conf);
-
+
}
-
+
private void setupVirtualHosts(Configuration conf) throws ConfigurationException
{
List vhosts = conf.getList("virtualhosts");
@@ -140,7 +154,7 @@ public class ServerConfiguration implements SignalHandler
{
String name = (String) hosts.get(j);
// Add the keys of the virtual host to the main config then bail out
-
+
Configuration myConf = vhostConfiguration.subset("virtualhost." + name);
Iterator k = myConf.getKeys();
while (k.hasNext())
@@ -169,13 +183,13 @@ public class ServerConfiguration implements SignalHandler
String val = System.getenv(var.getKey());
if (val != null)
{
- getConfig().setProperty(var.getValue(), val);
+ getConfig().setProperty(var.getValue(), val);
}
}
}
private final static Configuration parseConfig(File file) throws ConfigurationException
- {
+ {
ConfigurationFactory factory = new ConfigurationFactory();
factory.setConfigurationFileName(file.getAbsolutePath());
Configuration conf = factory.getConfiguration();
@@ -188,9 +202,56 @@ public class ServerConfiguration implements SignalHandler
return conf;
}
- public boolean getStatusEnabled()
+ /**
+ * Check the configuration file to see if status updates are enabled.
+ * @return true if status updates are enabled
+ */
+ public boolean getStatusUpdatesEnabled()
{
- return getConfig().getBoolean("status-updates", true);
+ // Retrieve the setting from configuration but default to on.
+ String value = getConfig().getString(STATUS_UPDATES, DEFAULT_STATUS_UPDATES);
+
+ return value.equalsIgnoreCase("on");
+ }
+
+ /**
+ * The currently defined {@see Locale} for this broker
+ * @return the configuration defined locale
+ */
+ public Locale getLocale()
+ {
+
+ String localeString = getConfig().getString(ADVANCED_LOCALE, DEFAULT_ADVANCED_LOCALE);
+ // Expecting locale of format langauge_country_variant
+
+ String[] parts = localeString.split("_");
+
+ Locale locale = null;
+ switch (parts.length)
+ {
+ case 1:
+ locale = new Locale(localeString);
+ break;
+ case 2:
+ locale = new Locale(parts[0], parts[1]);
+ break;
+ default:
+ String variant = parts[2];
+ // If we have a variant such as the Java doc suggests for Spanish
+ // Traditional_WIN we may end up with more than 3 parts on a
+ // split with '_'. So we should recombine the variant.
+ if (parts.length > 3)
+ {
+ for (int index = 3; index < parts.length; index++)
+ {
+ variant = variant + "_" + parts[index];
+ }
+ }
+
+ locale = new Locale(parts[0], parts[1], variant);
+ }
+
+ return locale;
}
// Our configuration class needs to make the interpolate method
@@ -202,7 +263,7 @@ public class ServerConfiguration implements SignalHandler
return super.interpolate(obj);
}
}
-
+
private final static Configuration flatConfig(File file) throws ConfigurationException
{
// We have to override the interpolate methods so that
@@ -238,7 +299,7 @@ public class ServerConfiguration implements SignalHandler
catch (ConfigurationException e)
{
_log.error("Could not reload configuration file", e);
- }
+ }
}
public void reparseConfigFile() throws ConfigurationException
@@ -248,7 +309,7 @@ public class ServerConfiguration implements SignalHandler
Configuration newConfig = parseConfig(_configFile);
_securityConfiguration = new SecurityConfiguration(newConfig.subset("security"));
ApplicationRegistry.getInstance().getAccessManager().configurePlugins(_securityConfiguration);
-
+
VirtualHostRegistry vhostRegistry = ApplicationRegistry.getInstance().getVirtualHostRegistry();
for (String hostname : _virtualHosts.keySet())
{
@@ -343,17 +404,17 @@ public class ServerConfiguration implements SignalHandler
public boolean getProtectIOEnabled()
{
- return getConfig().getBoolean("broker.connector.protectio.enabled", false);
+ return getConfig().getBoolean(CONNECTOR_PROTECTIO_ENABLED, DEFAULT_BROKER_CONNECTOR_PROTECTIO_ENABLED);
}
public int getBufferReadLimit()
{
- return getConfig().getInt("broker.connector.protectio.readBufferLimitSize", DEFAULT_BUFFER_READ_LIMIT_SIZE);
+ return getConfig().getInt(CONNECTOR_PROTECTIO_READ_BUFFER_LIMIT_SIZE, DEFAULT_BUFFER_READ_LIMIT_SIZE);
}
public int getBufferWriteLimit()
{
- return getConfig().getInt("broker.connector.protectio.writeBufferLimitSize", DEFAULT_BUFFER_WRITE_LIMIT_SIZE);
+ return getConfig().getInt(CONNECTOR_PROTECTIO_WRITE_BUFFER_LIMIT_SIZE, DEFAULT_BUFFER_WRITE_LIMIT_SIZE);
}
public boolean getSynchedClocks()
@@ -543,17 +604,8 @@ public class ServerConfiguration implements SignalHandler
public long getHousekeepingCheckPeriod()
{
- return getConfig().getLong("housekeeping.checkPeriod",
- getConfig().getLong("housekeeping.expiredMessageCheckPeriod",
+ return getConfig().getLong("housekeeping.checkPeriod",
+ getConfig().getLong("housekeeping.expiredMessageCheckPeriod",
DEFAULT_HOUSEKEEPING_PERIOD));
}
-
- public boolean getStatusUpdates()
- {
- // Retrieve the setting from configuration but default to on.
- String value = getConfig().getString("status-updates", "on");
-
- return value.equalsIgnoreCase("on");
- }
-
}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/BrokerMessages.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/BrokerMessages.java
deleted file mode 100644
index e9cc7449cd..0000000000
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/BrokerMessages.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- *
- */
-package org.apache.qpid.server.logging;
-
-public class BrokerMessages
-{
-
- public static LogMessage BRK_1001(String version, String build)
- {
- return new LogMessage()
- {
-
- };
- }
-
-}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/RootMessageLoggerImpl.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/RootMessageLoggerImpl.java
index 9270c316b6..1c2b4e4046 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/RootMessageLoggerImpl.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/RootMessageLoggerImpl.java
@@ -31,7 +31,7 @@ public class RootMessageLoggerImpl implements RootMessageLogger
public RootMessageLoggerImpl(ServerConfiguration configuration, RawMessageLogger rawLogger)
{
- _enabled = configuration.getStatusUpdates();
+ _enabled = configuration.getStatusUpdatesEnabled();
_rawLogger = rawLogger;
}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPChannelActor.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPChannelActor.java
index f4e2793e8b..d4d41bc1d4 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPChannelActor.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPChannelActor.java
@@ -24,7 +24,6 @@ import org.apache.qpid.server.AMQChannel;
import org.apache.qpid.server.logging.RootMessageLogger;
import org.apache.qpid.server.logging.subjects.ChannelLogSubject;
import org.apache.qpid.server.protocol.AMQProtocolSession;
-import org.apache.qpid.server.virtualhost.VirtualHost;
import java.text.MessageFormat;
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/LogMessages_en_US.properties b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/LogMessages_en_US.properties
new file mode 100644
index 0000000000..d393614191
--- /dev/null
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/LogMessages_en_US.properties
@@ -0,0 +1,82 @@
+#Broker
+# 0 - Version
+# 1 = Build
+BRK-1001 = Startup : Version: {0} Build: {1}
+# 0 - Transport
+# 1 - Port
+BRK-1002 = Starting : Listening on {0} port {1, number, #}
+# 0 - Transport
+# 1 - Port
+BRK-1003 = Shuting down : {0} port {1, number, #}
+BRK-1004 = Ready
+BRK-1005 = Stopped
+# 0 - path
+BRK-1006 = Using configuration : {0}
+# 0 - path
+BRK-1007 = Using logging configuration : {0}
+
+#ManagementConsole
+MNG-1001 = Startup
+# 0 - Service
+# 1 - Port
+MNG-1002 = Starting : {0} : Listening on port {1, number, #}
+# 0 - Service
+# 1 - Port
+MNG-1003 = Shuting down : {0} : port {1, number, #}
+MNG-1004 = Ready
+MNG-1005 = Stopped
+# 0 - Path
+MNG-1006 = Using SSL Keystore : {0}
+
+#VirtualHost
+# 0 - name
+VHT-1001 = Created : {0}
+VHT-1002 = Closed
+
+#MessageStore
+# 0 - name
+MST-1001 = Created : {0}
+# 0 - path
+MST-1002 = Store location : {0}
+MST-1003 = Closed
+MST-1004 = Recovery Start
+# 0 - queue name
+MST-1005 = Recovery Start : {0}
+# 0 - count
+# 1 - queue count
+MST-1006 = Recovered {0,number} messages for queue {1}
+MST-1007 = Recovery Complete
+# 0 - queue name
+MST-1008 = Recovery Complete : {0}
+
+#Connection
+# 0 - Client id
+# 1 - Protocol Version
+CON-1001 = Open : Client ID {0} : Protocol Version : {1}
+CON-1002 = Close
+
+#Channel
+# 0 - count
+CHN-1001 = Create : Prefetch {0, number}
+# 0 - flow
+CHN-1002 = Flow {0}
+CHN-1003 = Close
+
+#Queue
+# 0 - owner
+QUE-1001 = Create : Owner:{0} [AutoDelete] [Durable|Transient] [Priority:<levels>]
+QUE-1002 = Deleted
+
+#Exchange
+# 0 - type
+# 1 - name
+EXH-1001 = Create : [Durable] Type:{0} Name:{1}
+EXH-1002 = Deleted
+
+#Binding
+BND-1001 = Create [: Arguments : <key=value>]
+BND-1002 = Deleted
+
+#Subscription
+SUB-1001 = Create : [Durable] [Arguments : <key=value>]
+SUB-1002 = Close
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 9046175c84..dd8f5d75c9 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
@@ -41,11 +41,17 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.ConcurrentHashMap;
import java.util.ArrayList;
public class Subscription_0_10 implements Subscription, FlowCreditManager.FlowCreditManagerListener
{
+
+ 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 final QueueEntry.SubscriptionAcquiredState _owningState = new QueueEntry.SubscriptionAcquiredState(this);
private final Lock _stateChangeLock = new ReentrantLock();
@@ -569,4 +575,10 @@ public class Subscription_0_10 implements Subscription, FlowCreditManager.FlowCr
_queue.flushSubscription(this);
stop();
}
+
+ public long getSubscriptionID()
+ {
+ return _subscriptionID;
+ }
+
}
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 fabd4ce923..2879277784 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
@@ -20,31 +20,26 @@
*/
package org.apache.qpid.server.configuration;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.Iterator;
-import java.util.List;
-
+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.commons.configuration.SystemConfiguration;
import org.apache.commons.configuration.XMLConfiguration;
-import org.apache.qpid.AMQException;
import org.apache.qpid.codec.AMQCodecFactory;
import org.apache.qpid.server.protocol.AMQMinaProtocolSession;
import org.apache.qpid.server.protocol.AMQProtocolSession;
import org.apache.qpid.server.protocol.TestIoSession;
-import org.apache.qpid.server.queue.MockProtocolSession;
import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry;
-import org.apache.qpid.server.security.access.ACLManager;
import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
-import junit.framework.TestCase;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
public class ServerConfigurationTest extends TestCase
{
@@ -200,7 +195,7 @@ public class ServerConfigurationTest extends TestCase
assertEquals(false, serverConfig.getProtectIOEnabled());
// Check value we set
- _config.setProperty("broker.connector.protectio.enabled", true);
+ _config.setProperty(ServerConfiguration.CONNECTOR_PROTECTIO_ENABLED, true);
serverConfig = new ServerConfiguration(_config);
assertEquals(true, serverConfig.getProtectIOEnabled());
}
@@ -212,7 +207,7 @@ public class ServerConfigurationTest extends TestCase
assertEquals(262144, serverConfig.getBufferReadLimit());
// Check value we set
- _config.setProperty("broker.connector.protectio.readBufferLimitSize", 23);
+ _config.setProperty(ServerConfiguration.CONNECTOR_PROTECTIO_READ_BUFFER_LIMIT_SIZE, 23);
serverConfig = new ServerConfiguration(_config);
assertEquals(23, serverConfig.getBufferReadLimit());
}
@@ -224,11 +219,29 @@ public class ServerConfigurationTest extends TestCase
assertEquals(262144, serverConfig.getBufferWriteLimit());
// Check value we set
- _config.setProperty("broker.connector.protectio.writeBufferLimitSize", 23);
+ _config.setProperty(ServerConfiguration.CONNECTOR_PROTECTIO_WRITE_BUFFER_LIMIT_SIZE, 23);
serverConfig = new ServerConfiguration(_config);
assertEquals(23, serverConfig.getBufferWriteLimit());
}
+
+ public void testGetStatusEnabled() throws ConfigurationException
+ {
+ // Check default
+ ServerConfiguration serverConfig = new ServerConfiguration(_config);
+ assertEquals(true, serverConfig.getStatusUpdatesEnabled());
+
+ // Check disabling we set
+ _config.setProperty(ServerConfiguration.STATUS_UPDATES, "off");
+ serverConfig = new ServerConfiguration(_config);
+ assertEquals(false, serverConfig.getStatusUpdatesEnabled());
+
+ // Check invalid values don't cause error but result in disabled
+ _config.setProperty(ServerConfiguration.STATUS_UPDATES, "Yes Please");
+ serverConfig = new ServerConfiguration(_config);
+ assertEquals(false, serverConfig.getStatusUpdatesEnabled());
+
+ }
public void testGetSynchedClocks() throws ConfigurationException
{
// Check default
@@ -241,6 +254,38 @@ public class ServerConfigurationTest extends TestCase
assertEquals(true, serverConfig.getSynchedClocks());
}
+ public void testGetLocale() throws ConfigurationException
+ {
+ // Check default
+ ServerConfiguration serverConfig = new ServerConfiguration(_config);
+
+ String defaultParts[] = ServerConfiguration.DEFAULT_ADVANCED_LOCALE.split("_");
+ // The Default is en_US so will split well
+ Locale defaultLocale = new Locale(defaultParts[0],defaultParts[1]);
+
+ assertEquals(defaultLocale, serverConfig.getLocale());
+
+
+ //Test Language only
+ Locale update = new Locale("es");
+ _config.setProperty(ServerConfiguration.ADVANCED_LOCALE, "es");
+ serverConfig = new ServerConfiguration(_config);
+ assertEquals(update, serverConfig.getLocale());
+
+ //Test Language and Country
+ update = new Locale("es","ES");
+ _config.setProperty(ServerConfiguration.ADVANCED_LOCALE, "es_ES");
+ serverConfig = new ServerConfiguration(_config);
+ assertEquals(update, serverConfig.getLocale());
+
+ //Test Language and Country and Variant
+ update = new Locale("es","ES", "Traditional_WIN");
+ _config.setProperty(ServerConfiguration.ADVANCED_LOCALE, "es_ES_Traditional_WIN");
+ serverConfig = new ServerConfiguration(_config);
+ assertEquals(update, serverConfig.getLocale());
+ }
+
+
public void testGetMsgAuth() throws ConfigurationException
{
// Check default
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/StatusUpdateConfigurationTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/StatusUpdateConfigurationTest.java
deleted file mode 100644
index 9a3c18bf99..0000000000
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/StatusUpdateConfigurationTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- *
- */
-package org.apache.qpid.server.logging;
-
-import junit.framework.TestCase;
-import org.apache.qpid.server.configuration.ServerConfiguration;
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.PropertiesConfiguration;
-
-/**
- * Set of test to validate the effects of the changes made to the
- * ServerConfiguration to enable the enabling/disabling of status update
- * messages.
- *
- * The default is to on.
- */
-public class StatusUpdateConfigurationTest extends TestCase
-{
-
- /**
- * Validate that with no configuration the status updates will default to
- * enabled.
- * @throws org.apache.commons.configuration.ConfigurationException
- * - if there was a problem in creating the configuratino
- */
- public void testEnabled() throws ConfigurationException
- {
-
- ServerConfiguration serverConfig = new ServerConfiguration(
- new PropertiesConfiguration());
-
- assertTrue("Status Updates not enabled as expected.",
- serverConfig.getStatusUpdates());
- }
-
-
- /**
- * Validate that through the config it is possible to disable status updates
- * @throws org.apache.commons.configuration.ConfigurationException
- * - if there was a problem in creating the configuratino
- */
- public void testUpdateControls() throws ConfigurationException
- {
-
- Configuration config = new PropertiesConfiguration();
- ServerConfiguration serverConfig = new ServerConfiguration(config);
-
- config.setProperty("status-updates", "off");
-
-
- assertFalse("Status Updates should not be enabled.",
- serverConfig.getStatusUpdates());
- }
-}
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
new file mode 100644
index 0000000000..6589695146
--- /dev/null
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/AbstractTestMessages.java
@@ -0,0 +1,104 @@
+/*
+ *
+ * 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.messages;
+
+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.actors.TestBlankActor;
+import org.apache.qpid.server.logging.rawloggers.UnitTestMessageLogger;
+import org.apache.qpid.server.logging.subjects.TestBlankSubject;
+
+import java.util.List;
+
+public abstract class AbstractTestMessages extends TestCase
+{
+ protected Configuration _config = new PropertiesConfiguration();
+ protected LogMessage _logMessage = null;
+ protected LogActor _actor;
+ protected UnitTestMessageLogger _logger;
+ protected LogSubject _logSubject = new TestBlankSubject();
+
+ public void setUp() throws ConfigurationException
+ {
+ ServerConfiguration serverConfig = new ServerConfiguration(_config);
+
+ _logger = new UnitTestMessageLogger();
+ RootMessageLogger rootLogger =
+ new RootMessageLoggerImpl(serverConfig, _logger);
+
+ _actor = new TestBlankActor(rootLogger);
+ }
+
+ protected List<Object> performLog()
+ {
+ if (_logMessage == null)
+ {
+ throw new NullPointerException("LogMessage has not been set");
+ }
+
+ _actor.message(_logSubject, _logMessage);
+
+ return _logger.getLogMessages();
+ }
+
+ /**
+ * Validate that only a single log messasge occured and that the message
+ * section starts with the specified tag
+ *
+ * @param logs the logs generated during test run
+ * @param tag the tag to check for
+ * @param expected
+ *
+ * @return the log message section for further testing
+ */
+ protected void validateLogMessage(List<Object> logs, String tag, String[] expected)
+ {
+ assertEquals("Log has incorrect message count", 1, logs.size());
+
+ String log = String.valueOf(logs.get(0));
+
+ int index = log.indexOf(_logSubject.toString());
+
+ assertTrue("Unable to locate Subject:" + log, index != -1);
+
+ String message = log.substring(index + _logSubject.toString().length());
+
+ assertTrue("Message does not start with tag:" + tag + ":" + message,
+ message.startsWith(tag));
+
+ // Test that the expected items occur in order.
+ index = 0;
+ for (String text : expected)
+ {
+ index = message.indexOf(text, index);
+ assertTrue("Message does not contain expected (" + text + ") text :" + message, index != -1);
+ }
+ }
+
+}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/BindingMessagesTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/BindingMessagesTest.java
new file mode 100644
index 0000000000..a12d14239d
--- /dev/null
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/BindingMessagesTest.java
@@ -0,0 +1,49 @@
+/*
+ *
+ * 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.messages;
+
+import java.util.List;
+
+public class BindingMessagesTest extends AbstractTestMessages
+{
+
+ public void testMessage1001()
+ {
+ _logMessage = BindingMessages.BND_1001();
+ List<Object> log = performLog();
+
+ String[] expected = {"Create"};
+
+ validateLogMessage(log, "BND-1001", expected);
+ }
+
+ public void testMessage1002()
+ {
+ _logMessage = BindingMessages.BND_1002();
+
+ List<Object> log = performLog();
+
+ String[] expected = {"Deleted"};
+
+ validateLogMessage(log, "BND-1002", expected);
+ }
+
+}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/BrokerMessagesTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/BrokerMessagesTest.java
new file mode 100644
index 0000000000..65dcea1e25
--- /dev/null
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/BrokerMessagesTest.java
@@ -0,0 +1,113 @@
+/*
+ *
+ * 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.messages;
+
+import java.util.List;
+
+public class BrokerMessagesTest extends AbstractTestMessages
+{
+ public void testMessage1001()
+ {
+ String version = "Qpid 0.6";
+ String build = "796936M";
+
+ _logMessage = BrokerMessages.BRK_1001(version, build);
+ List<Object> log = performLog();
+
+ String[] expected = {"Startup :", "Version:", version, "Build:", build};
+
+ validateLogMessage(log, "BRK-1001", expected);
+ }
+
+ public void testMessage1002()
+ {
+ String transport = "TCP";
+ Integer port = 2765;
+
+ _logMessage = BrokerMessages.BRK_1002(transport, port);
+
+ List<Object> log = performLog();
+
+ String[] expected = {"Starting", "Listening on ",
+ transport, "port ", String.valueOf(port)};
+
+ validateLogMessage(log, "BRK-1002", expected);
+ }
+
+ public void testMessage1003()
+ {
+ String transport = "TCP";
+ Integer port = 2765;
+
+ _logMessage = BrokerMessages.BRK_1003(transport, port);
+
+ List<Object> log = performLog();
+
+ String[] expected = {"Shuting down", transport, "port ", String.valueOf(port)};
+
+ validateLogMessage(log, "BRK-1003", expected);
+ }
+
+ public void testMessage1004()
+ {
+ _logMessage = BrokerMessages.BRK_1004();
+ List<Object> log = performLog();
+
+ String[] expected = {"Ready"};
+
+ validateLogMessage(log, "BRK-1004", expected);
+ }
+
+ public void testMessage1005()
+ {
+ _logMessage = BrokerMessages.BRK_1005();
+ List<Object> log = performLog();
+
+ String[] expected = {"Stopped"};
+
+ validateLogMessage(log, "BRK-1005", expected);
+ }
+
+ public void testMessage1006()
+ {
+ String path = "/file/path/to/configuration.xml";
+
+ _logMessage = BrokerMessages.BRK_1006(path);
+ List<Object> log = performLog();
+
+ String[] expected = {"Using configuration :", path};
+
+ validateLogMessage(log, "BRK-1006", expected);
+ }
+
+ public void testMessage1007()
+ {
+ String path = "/file/path/to/configuration.xml";
+
+ _logMessage = BrokerMessages.BRK_1007(path);
+ List<Object> log = performLog();
+
+ String[] expected = {"Using logging configuration :", path};
+
+ validateLogMessage(log, "BRK-1007", expected);
+ }
+
+}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ChannelMessagesTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ChannelMessagesTest.java
new file mode 100644
index 0000000000..2a37eae728
--- /dev/null
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ChannelMessagesTest.java
@@ -0,0 +1,65 @@
+/*
+ *
+ * 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.messages;
+
+import java.text.MessageFormat;
+import java.util.List;
+
+public class ChannelMessagesTest extends AbstractTestMessages
+{
+ public void testMessage1001()
+ {
+ Integer prefetch = 12345;
+
+ _logMessage = ChannelMessages.CHN_1001(prefetch);
+ List<Object> log = performLog();
+
+ // We use the MessageFormat here as that is what the ChannelMessage
+ // will do, this makes the resulting value 12,345
+ String[] expected = {"Create", "Prefetch",
+ MessageFormat.format("{0, number}", prefetch)};
+
+ validateLogMessage(log, "CHN-1001", expected);
+ }
+
+ public void testMessage1002()
+ {
+ String flow = "ON";
+
+ _logMessage = ChannelMessages.CHN_1002(flow);
+ List<Object> log = performLog();
+
+ String[] expected = {"Flow", flow};
+
+ validateLogMessage(log, "CHN-1002", expected);
+ }
+
+ public void testMessage1003()
+ {
+ _logMessage = ChannelMessages.CHN_1003();
+ List<Object> log = performLog();
+
+ String[] expected = {"Close"};
+
+ validateLogMessage(log, "CHN-1003", expected);
+ }
+
+}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ConnectionMessagesTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ConnectionMessagesTest.java
new file mode 100644
index 0000000000..8723c48476
--- /dev/null
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ConnectionMessagesTest.java
@@ -0,0 +1,51 @@
+/*
+ *
+ * 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.messages;
+
+import java.util.List;
+
+public class ConnectionMessagesTest extends AbstractTestMessages
+{
+ public void testMessage1001()
+ {
+ String clientID = "client";
+ String protocolVersion = "8-0";
+
+ _logMessage = ConnectionMessages.CON_1001(clientID, protocolVersion);
+ List<Object> log = performLog();
+
+ String[] expected = {"Open :", "Client ID", clientID,
+ ": Protocol Version :", protocolVersion};
+
+ validateLogMessage(log, "CON-1001", expected);
+ }
+
+ public void testMessage1002()
+ {
+ _logMessage = ConnectionMessages.CON_1002();
+ List<Object> log = performLog();
+
+ String[] expected = {"Close"};
+
+ validateLogMessage(log, "CON-1002", expected);
+ }
+
+}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ExchangeMessagesTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ExchangeMessagesTest.java
new file mode 100644
index 0000000000..46a911fdc6
--- /dev/null
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ExchangeMessagesTest.java
@@ -0,0 +1,58 @@
+/*
+ *
+ * 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.messages;
+
+import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+
+import java.util.List;
+
+public class ExchangeMessagesTest extends AbstractTestMessages
+{
+ public void testMessage1001()
+ {
+ // Get the Default Exchange on the Test Vhost for testing
+ Exchange exchange = ApplicationRegistry.getInstance().
+ getVirtualHostRegistry().getVirtualHost("test").
+ getExchangeRegistry().getDefaultExchange();
+
+ String type = exchange.getType().toString();
+ String name = exchange.getName().toString();
+
+ _logMessage = ExchangeMessages.EXH_1001(type, name);
+ List<Object> log = performLog();
+
+ String[] expected = {"Create :", "Type:", type, "Name:", name};
+
+ validateLogMessage(log, "EXH-1001", expected);
+ }
+
+ public void testMessage1002()
+ {
+ _logMessage = ExchangeMessages.EXH_1002();
+ List<Object> log = performLog();
+
+ String[] expected = {"Deleted"};
+
+ validateLogMessage(log, "EXH-1002", expected);
+ }
+
+}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ManagementConsoleMessagesTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ManagementConsoleMessagesTest.java
new file mode 100644
index 0000000000..e9b40c5dad
--- /dev/null
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/ManagementConsoleMessagesTest.java
@@ -0,0 +1,95 @@
+/*
+ *
+ * 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.messages;
+
+import java.util.List;
+
+public class ManagementConsoleMessagesTest extends AbstractTestMessages
+{
+ public void testMessage1001()
+ {
+ _logMessage = ManagementConsoleMessages.MNG_1001();
+ List<Object> log = performLog();
+
+ String[] expected = {"Startup"};
+
+ validateLogMessage(log, "MNG-1001", expected);
+ }
+
+ public void testMessage1002()
+ {
+ String transport = "JMX";
+ Integer port = 8889;
+
+ _logMessage = ManagementConsoleMessages.MNG_1002(transport, port);
+ List<Object> log = performLog();
+
+ String[] expected = {"Starting :", transport, ": Listening on port", String.valueOf(port)};
+
+ validateLogMessage(log, "MNG-1002", expected);
+ }
+
+ public void testMessage1003()
+ {
+ String transport = "JMX";
+ Integer port = 8889;
+
+ _logMessage = ManagementConsoleMessages.MNG_1003(transport, port);
+ List<Object> log = performLog();
+
+ String[] expected = {"Shuting down :", transport, ": port", String.valueOf(port)};
+
+ validateLogMessage(log, "MNG-1003", expected);
+ }
+
+ public void testMessage1004()
+ {
+ _logMessage = ManagementConsoleMessages.MNG_1004();
+ List<Object> log = performLog();
+
+ String[] expected = {"Ready"};
+
+ validateLogMessage(log, "MNG-1004", expected);
+ }
+
+ public void testMessage1005()
+ {
+ _logMessage = ManagementConsoleMessages.MNG_1005();
+ List<Object> log = performLog();
+
+ String[] expected = {"Stopped"};
+
+ validateLogMessage(log, "MNG-1005", expected);
+ }
+
+ public void testMessage1006()
+ {
+ String path = "/path/to/the/keystore/files.jks";
+
+ _logMessage = ManagementConsoleMessages.MNG_1006(path);
+ List<Object> log = performLog();
+
+ String[] expected = {"Using SSL Keystore :", path};
+
+ validateLogMessage(log, "MNG-1006", expected);
+ }
+
+}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/MessageStoreMessagesTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/MessageStoreMessagesTest.java
new file mode 100644
index 0000000000..e1ae93b869
--- /dev/null
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/MessageStoreMessagesTest.java
@@ -0,0 +1,123 @@
+/*
+ *
+ * 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.messages;
+
+import java.text.MessageFormat;
+import java.util.List;
+
+public class MessageStoreMessagesTest extends AbstractTestMessages
+{
+ public void testMessage1001()
+ {
+ String name = "DerbyMessageStore";
+
+ _logMessage = MessageStoreMessages.MST_1001(name);
+ List<Object> log = performLog();
+
+ String[] expected = {"Created :", name};
+
+ validateLogMessage(log, "MST-1001", expected);
+ }
+
+ public void testMessage1002()
+ {
+ String location = "/path/to/the/message/store.files";
+
+ _logMessage = MessageStoreMessages.MST_1002(location);
+ List<Object> log = performLog();
+
+ String[] expected = {"Store location :", location};
+
+ validateLogMessage(log, "MST-1002", expected);
+ }
+
+ public void testMessage1003()
+ {
+ _logMessage = MessageStoreMessages.MST_1003();
+ List<Object> log = performLog();
+
+ String[] expected = {"Closed"};
+
+ validateLogMessage(log, "MST-1003", expected);
+ }
+
+ public void testMessage1004()
+ {
+ _logMessage = MessageStoreMessages.MST_1004();
+ List<Object> log = performLog();
+
+ String[] expected = {"Recovery Start"};
+
+ validateLogMessage(log, "MST-1004", expected);
+ }
+
+ public void testMessage1005()
+ {
+ String queueName = "testQueue";
+
+ _logMessage = MessageStoreMessages.MST_1005(queueName);
+ List<Object> log = performLog();
+
+ String[] expected = {"Recovery Start :", queueName};
+
+ validateLogMessage(log, "MST-1005", expected);
+ }
+
+ public void testMessage1006()
+ {
+ String queueName = "testQueue";
+ Integer messasgeCount = 2000;
+
+ _logMessage = MessageStoreMessages.MST_1006(messasgeCount, queueName);
+ List<Object> log = performLog();
+
+ // Here we use MessageFormat to ensure the messasgeCount of 2000 is
+ // reformated for display as '2,000'
+ String[] expected = {"Recovered ",
+ MessageFormat.format("{0,number}", messasgeCount),
+ "messages for queue", queueName};
+
+ validateLogMessage(log, "MST-1006", expected);
+ }
+
+ public void testMessage1007()
+ {
+ _logMessage = MessageStoreMessages.MST_1007();
+ List<Object> log = performLog();
+
+ String[] expected = {"Recovery Complete"};
+
+ validateLogMessage(log, "MST-1007", expected);
+ }
+
+ public void testMessage1008()
+ {
+ String queueName = "testQueue";
+
+ _logMessage = MessageStoreMessages.MST_1008(queueName);
+ List<Object> log = performLog();
+
+ String[] expected = {"Recovery Complete :", queueName};
+
+ validateLogMessage(log, "MST-1008", expected);
+ }
+
+}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/QueueMessagesTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/QueueMessagesTest.java
new file mode 100644
index 0000000000..4ba00ea6e4
--- /dev/null
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/QueueMessagesTest.java
@@ -0,0 +1,49 @@
+/*
+ *
+ * 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.messages;
+
+import java.util.List;
+
+public class QueueMessagesTest extends AbstractTestMessages
+{
+ public void testMessage1001()
+ {
+ String owner = "guest";
+
+ _logMessage = QueueMessages.QUE_1001(owner);
+ List<Object> log = performLog();
+
+ String[] expected = {"Create :", "Owner:", owner};
+
+ validateLogMessage(log, "QUE-1001", expected);
+ }
+
+ public void testMessage1002()
+ {
+ _logMessage = QueueMessages.QUE_1002();
+ List<Object> log = performLog();
+
+ String[] expected = {"Deleted"};
+
+ validateLogMessage(log, "QUE-1002", expected);
+ }
+
+}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/SubscriptionMessagesTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/SubscriptionMessagesTest.java
new file mode 100644
index 0000000000..1bb96e1e33
--- /dev/null
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/SubscriptionMessagesTest.java
@@ -0,0 +1,47 @@
+/*
+ *
+ * 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.messages;
+
+import java.util.List;
+
+public class SubscriptionMessagesTest extends AbstractTestMessages
+{
+ public void testMessage1001()
+ {
+
+ _logMessage = SubscriptionMessages.SUB_1001();
+ List<Object> log = performLog();
+
+ String[] expected = {"Create :"};
+
+ validateLogMessage(log, "SUB-1001", expected);
+ }
+
+ public void testMessage1002()
+ {
+ _logMessage = SubscriptionMessages.SUB_1002();
+ List<Object> log = performLog();
+
+ String[] expected = {"Close"};
+
+ validateLogMessage(log, "SUB-1002", expected);
+ }
+}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/VirtualHostMessagesTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/VirtualHostMessagesTest.java
new file mode 100644
index 0000000000..2158676115
--- /dev/null
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/messages/VirtualHostMessagesTest.java
@@ -0,0 +1,48 @@
+/*
+ *
+ * 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.messages;
+
+import java.util.List;
+
+public class VirtualHostMessagesTest extends AbstractTestMessages
+{
+ public void testMessage1001()
+ {
+ String name = "test";
+ _logMessage = VirtualHostMessages.VHT_1001(name);
+ List<Object> log = performLog();
+
+ String[] expected = {"Created :", name};
+
+ validateLogMessage(log, "VHT-1001", expected);
+ }
+
+ public void testMessage1002()
+ {
+ _logMessage = VirtualHostMessages.VHT_1002();
+ List<Object> log = performLog();
+
+ String[] expected = {"Closed"};
+
+ validateLogMessage(log, "VHT-1002", expected);
+ }
+
+}
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 04081db8e3..02cdbdbe6a 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
@@ -57,9 +57,9 @@ public abstract class AbstractTestLogSubject extends TestCase
RootMessageLogger rootLogger =
new RootMessageLoggerImpl(serverConfig, logger);
- LogActor actor_actor = new TestBlankActor(rootLogger);
+ LogActor actor = new TestBlankActor(rootLogger);
- actor_actor.message(_subject, new LogMessage()
+ actor.message(_subject, new LogMessage()
{
public String toString()
{
@@ -228,7 +228,7 @@ public abstract class AbstractTestLogSubject extends TestCase
{
List<Object> logs = performLog();
- assertEquals("Log has to many messagse", 1, logs.size());
+ assertEquals("Log has incorrect message count", 1, logs.size());
validateLogStatement(String.valueOf(logs.get(0)));
}
@@ -252,7 +252,7 @@ public abstract class AbstractTestLogSubject extends TestCase
List<Object> logs = performLog();
- assertEquals("Log has to many messagse", 0, logs.size());
+ assertEquals("Log has incorrect message count", 0, logs.size());
}
}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubjectTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubjectTest.java
index 35df4c5976..5bf00cc92f 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubjectTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubjectTest.java
@@ -20,12 +20,9 @@
*/
package org.apache.qpid.server.logging.subjects;
-import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.queue.MockAMQQueue;
import org.apache.qpid.server.exchange.Exchange;
-import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.server.virtualhost.VirtualHost;
public class ExchangeLogSubjectTest extends AbstractTestLogSubject
{
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/TestBlankSubject.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/TestBlankSubject.java
new file mode 100644
index 0000000000..9e3c6f9bcb
--- /dev/null
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/TestBlankSubject.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.subjects;
+
+public class TestBlankSubject extends AbstractLogSubject
+{
+ public TestBlankSubject()
+ {
+ logString = "[TestBlankSubject]";
+ }
+
+}
diff --git a/qpid/java/broker/src/velocity/java/org/apache/qpid/server/logging/GenerateLogMessages.java b/qpid/java/broker/src/velocity/java/org/apache/qpid/server/logging/GenerateLogMessages.java
new file mode 100644
index 0000000000..cc0565031f
--- /dev/null
+++ b/qpid/java/broker/src/velocity/java/org/apache/qpid/server/logging/GenerateLogMessages.java
@@ -0,0 +1,354 @@
+/*
+ * 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.velocity.VelocityContext;
+import org.apache.velocity.app.Velocity;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import java.util.ResourceBundle;
+
+public class GenerateLogMessages
+{
+ private static String _tmplDir;
+ private String _outputDir;
+
+ public static void main(String[] args)
+ {
+ GenerateLogMessages generator = null;
+ try
+ {
+ generator = new GenerateLogMessages(args);
+ }
+ catch (IllegalAccessException iae)
+ {
+ // This occurs when args does not contain Template and output dirs.
+ System.exit(-1);
+ }
+ catch (Exception e)
+ {
+ //This is thrown by the Velocity Engine initialisation
+ e.printStackTrace();
+ System.exit(-1);
+ }
+
+ try
+ {
+ generator.run();
+ }
+ catch (InvalidTypeException e)
+ {
+ // This occurs when a type other than 'number' appears in the
+ // paramater config {0, number...}
+ System.err.println(e.getMessage());
+ System.exit(-1);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ System.exit(-1);
+ }
+ }
+
+ GenerateLogMessages(String[] args) throws Exception
+ {
+ processArgs(args);
+
+ // We need the template and output dirs set to run.
+ if (_tmplDir == null || _outputDir == null)
+ {
+ showUsage();
+ throw new IllegalAccessException();
+ }
+
+ // Initialise the Velocity Engine, Telling it where our macro lives
+ Properties props = new Properties();
+ props.setProperty("file.resource.loader.path", _tmplDir);
+ Velocity.init(props);
+ }
+
+ private void showUsage()
+ {
+ System.out.println("Broker LogMessageGenerator v.0.0");
+ System.out.println("Usage: GenerateLogMessages: -t tmplDir");
+ System.out.println(" where -t tmplDir: Find templates in tmplDir.");
+ System.out.println(" -o outDir: Use outDir as the output dir.");
+ }
+
+ public void run() throws InvalidTypeException, Exception
+ {
+ /* lets make a Context and put data into it */
+ createMessageClass("Broker", "BRK");
+ createMessageClass("ManagementConsole", "MNG");
+ createMessageClass("VirtualHost", "VHT");
+ createMessageClass("MessageStore", "MST");
+ createMessageClass("Connection", "CON");
+ createMessageClass("Channel", "CHN");
+ createMessageClass("Queue", "QUE");
+ createMessageClass("Exchange", "EXH");
+ createMessageClass("Binding", "BND");
+ createMessageClass("Subscription", "SUB");
+ }
+
+ /**
+ * Process the args for:
+ * -t|T value for the template location
+ * -o|O value for the output directory
+ *
+ * @param args the commandline arguments
+ */
+ private void processArgs(String[] args)
+ {
+ // Crude but simple...
+ for (int i = 0; i < args.length; i++)
+ {
+ String arg = args[i];
+ if (arg.charAt(0) == '-')
+ {
+ switch (arg.charAt(1))
+ {
+ case 'o':
+ case 'O':
+ if (++i < args.length)
+ {
+ _outputDir = args[i];
+ }
+ break;
+ case 't':
+ case 'T':
+ if (++i < args.length)
+ {
+ _tmplDir = args[i];
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * This is the main method that generates the _Messages.java file.
+ * The class is generated by extracting the list of messges from the
+ * available LogMessages Resource.
+ *
+ * The extraction is done based on typeIdentifier which is a 3-digit prefix
+ * on the messages e.g. BRK for Broker.
+ *
+ * @param className The name for the file '_className_Messages.java'
+ * @param typeIdentifier The 3 digit identifier
+ * @throws InvalidTypeException when an unknown parameter type is used in the properties file
+ * @throws Exception thrown by velocity if there is an error
+ */
+ private void createMessageClass(String className, String typeIdentifier)
+ throws InvalidTypeException, Exception
+ {
+ VelocityContext context = new VelocityContext();
+
+ // Get the Data for this class and typeIdentifier
+ HashMap<String, Object> typeData = prepareType(className, typeIdentifier);
+
+ // Store this data in the context for the macro to access
+ context.put("type", typeData);
+
+ // Create the file writer to put the finished file in
+ FileWriter output = new FileWriter(_outputDir + File.separator + className + "Messages.java");
+
+ // Run Velocity to create the output file.
+ // Fix the default file encoding to 'ISO-8859-1' rather than let
+ // Velocity fix it. This is the encoding format for the macro.
+ Velocity.mergeTemplate("LogMessages.vm", "ISO-8859-1", context, output);
+
+ //Close our file.
+ output.flush();
+ output.close();
+ }
+
+ /**
+ * This method does the processing and preparation of the data to be added
+ * to the Velocity context so that the macro can access and process the data
+ *
+ * The given messageKey (e.g. 'BRK') uses a 3-digit code used to match
+ * the property key from the loaded 'LogMessages' ResourceBundle.
+ *
+ * This gives a list of messages which are to be associated with the given
+ * messageName (e.g. 'Broker')
+ *
+ * Each of the messages in the list are then processed to identify how many
+ * parameters the MessageFormat call is expecting. These parameters are
+ * identified by braces ('{}') so a quick count of these can then be used
+ * to create a defined parameter list.
+ *
+ * Rather than defaulting all parameters to String a check is performed to
+ * see if a 'number' value has been requested. e.g. {0. number}
+ * {@see MessageFormat}. If a parameter has a 'number' type then the
+ * parameter will be defined as an Number value. This allows for better
+ * type checking during compilation whilst allowing the log message to
+ * maintain formatting controls.
+ *
+ * The returned hashMap contains the following structured data:
+ *
+ * - name - ClassName ('Broker')
+ * list - methodName ('BRK_1001')
+ * - name ('BRK-1001')
+ * - format ('Startup : Version: {0} Build: {1}')
+ * - parameters (list)
+ * - type ('String'|'Number')
+ * - name ('param1')
+ *
+ * @param messsageName the name to give the Class e.g. 'Broker'
+ * @param messageKey the 3-digit key to extract the messages e.g. 'BRK'
+ * @return A HashMap with data for the macro
+ * @throws InvalidTypeException when an unknown parameter type is used in the properties file
+ */
+ private HashMap<String, Object> prepareType(String messsageName, String messageKey) throws InvalidTypeException
+ {
+ // Load the LogMessages Resource Bundle
+ ResourceBundle _messages = ResourceBundle.getBundle("org.apache.qpid.server.logging.messages.LogMessages");
+
+ Enumeration<String> messageKeys = _messages.getKeys();
+
+ //Create the return map
+ HashMap<String, Object> messageTypeData = new HashMap<String, Object>();
+ // Store the name to give to this Class <name>Messages.java
+ messageTypeData.put("name", messsageName);
+
+ // Prepare the list of log messages
+ List<HashMap> logMessageList = new LinkedList<HashMap>();
+ messageTypeData.put("list", logMessageList);
+
+ //Process each of the properties
+ while (messageKeys.hasMoreElements())
+ {
+ HashMap<String, Object> logEntryData = new HashMap<String, Object>();
+
+ //Add MessageName to amp
+ String message = messageKeys.nextElement();
+
+ // Process the log message if it matches the specified key e.g.'BRK'
+ if (message.startsWith(messageKey))
+ {
+ // Method names can't have a '-' in them so lets make it '_'
+ // e.g. BRK_1001
+ logEntryData.put("methodName", message.replace('-', '_'));
+ // Store the real name so we can use that in the actual log.
+ logEntryData.put("name", message);
+
+ //Retrieve the actual log message string.
+ String logMessage = _messages.getString(message);
+
+ // Store the value of the property so we can add it to the
+ // Javadoc of the method.
+ logEntryData.put("format", logMessage);
+
+ // Split the string on the start brace '{' this will give us the
+ // details for each parameter that this message contains.
+ String[] parametersString = logMessage.split("\\{");
+ // Taking an example of 'Text {n[,type]} text {m} more text {p}'
+ // This would give us:
+ // 0 - Text
+ // 1 - n[,type]} text
+ // 2 - m} more text
+ // 3 - p}
+
+ // Create the parameter list for this item
+ List<HashMap<String, String>> parameters = new LinkedList<HashMap<String, String>>();
+
+ // Add the parameter list to this log entry data
+ logEntryData.put("parameters", parameters);
+
+ // Add the data to the list of messages
+ logMessageList.add(logEntryData);
+
+ // Check that we have some parameters to process
+ // Skip 0 as that will not be the first entry
+ // Text {n[,type]} text {m} more text {p}
+ if (parametersString.length > 1)
+ {
+ for (int index = 1; index < parametersString.length; index++)
+ {
+ // Use a HashMap to store the type,name of the parameter
+ // for easy retrieval in the macro template
+ HashMap<String, String> parameter = new HashMap<String, String>();
+
+ // Check for any properties of the parameter :
+ // e.g. {0} vs {0,number} vs {0,number,xxxx}
+ int typeIndex = parametersString[index].indexOf(",");
+
+ // The parameter type
+ String type;
+
+ //Be default all types are Strings
+ if (typeIndex == -1)
+ {
+ type = "String";
+ }
+ else
+ {
+ //Check string ',....}' for existence of number
+ // to identify this parameter as an integer
+ // This allows for a style value to be present
+ // Only check the text inside the braces '{}'
+ int typeIndexEnd = parametersString[index].indexOf("}", typeIndex);
+ String typeString = parametersString[index].substring(typeIndex, typeIndexEnd);
+ if (typeString.contains("number"))
+ {
+ type = "Number";
+ }
+ else
+ {
+ throw new InvalidTypeException("Invalid type(" + typeString + ") index (" + parameter.size() + ") in message:" + logMessage);
+ }
+
+ }
+
+ //Store the data
+ parameter.put("type", type);
+ // Simply name the parameters by index.
+ parameter.put("name", "param" + index);
+
+ parameters.add(parameter);
+ }
+ }
+ }
+ }
+
+ return messageTypeData;
+ }
+
+ /**
+ * Just a inner exception to be able to identify when a type that is not
+ * 'number' occurs in the message parameter text.
+ */
+ private class InvalidTypeException extends Throwable
+ {
+ public InvalidTypeException(String message)
+ {
+ super(message);
+ }
+ }
+} \ No newline at end of file
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
new file mode 100644
index 0000000000..6656763ab9
--- /dev/null
+++ b/qpid/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm
@@ -0,0 +1,77 @@
+/*
+ * 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.messages;
+
+import org.apache.qpid.server.logging.LogMessage;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * Generated Using GeneratedLogMessages and LogMessages.vm
+ *
+ * This file is based on the content of LogMessages.properties
+ *
+ * It is generated so that we can provide compile time validation of the
+ * message parameters
+ */
+public class ${type.name}Messages
+{
+ static ResourceBundle _messages;
+ static MessageFormat _formatter;
+
+ static
+ {
+ Locale currentLocale = ApplicationRegistry.getInstance().getConfiguration().getLocale();
+
+ _messages = ResourceBundle.getBundle("org.apache.qpid.server.logging.messages.LogMessages",
+ currentLocale);
+
+ _formatter = new MessageFormat("");
+ _formatter.setLocale(currentLocale);
+ }
+
+#foreach( $message in ${type.list} )
+ /**
+ * Log a ${type.name} message of the Format:
+ * <pre>${message.format}</pre>
+ */
+ public static LogMessage ${message.methodName}(#foreach($parameter in ${message.parameters})${parameter.type} ${parameter.name}#if (${velocityCount} != ${message.parameters.size()} ), #end
+#end)
+ {
+ final Object[] messageArguments = {#foreach($parameter in ${message.parameters})${parameter.name}#if (${velocityCount} != ${message.parameters.size()} ), #end#end};
+
+ _formatter.applyPattern(_messages.getString("${message.name}"));
+ return new LogMessage()
+ {
+ public String toString()
+ {
+ return "${message.name} : " + _formatter.format(messageArguments);
+ }
+ };
+
+ }
+
+#end
+
+}
diff --git a/qpid/java/build.xml b/qpid/java/build.xml
index 155fef8656..ccca115c9d 100644
--- a/qpid/java/build.xml
+++ b/qpid/java/build.xml
@@ -206,8 +206,11 @@
datafile="${build.coveragereport}/cobertura.ser"
>
<fileset dir="${project.root}/common/src/main/java" includes="**/*.java" />
+ <fileset dir="${project.root}/build/scratch/common/src" includes="**/*.java" />
<fileset dir="${project.root}/broker/src/main/java" includes="**/*.java" />
+ <fileset dir="${project.root}/build/scratch/broker/src" includes="**/*.java" />
<fileset dir="${project.root}/client/src/main/java" includes="**/*.java" />
+ <fileset dir="${project.root}/build/scratch/client/src" includes="**/*.java" />
</cobertura-report>
</target>
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java
new file mode 100644
index 0000000000..c4803e121e
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java
@@ -0,0 +1,85 @@
+/*
+ *
+ * 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.configuration;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.qpid.test.utils.QpidTestCase;
+
+/**
+ * This system test ensures that when loading our default system-test
+ * configuration file the configuration is correctly loaded.
+ *
+ * All configuration values should be set in the systest config file so that
+ * the ability to load them can be validated.
+ */
+public class ServerConfigurationFileTest extends QpidTestCase
+{
+ ServerConfiguration _serverConfig;
+
+ public void setUp() throws ConfigurationException
+ {
+ if (!_configFile.exists())
+ {
+ fail("Unable to test without config file:" + _configFile);
+ }
+ _serverConfig = new ServerConfiguration(_configFile);
+ }
+
+ /**
+ * This helper method ensures that when we attempt to read a value that is
+ * set in the configuration file we do actualy read a value and not
+ * simply get a defaulted value from the ServerConfiguration.get*() methods.
+ *
+ * @param property the propert to test
+ */
+ private void validatePropertyDefinedInFile(String property)
+ {
+ //Verify that we are not just picking up the the default value from the getBoolean
+ assertNotNull("The value set in the configuration file is not being read for property:" + property,
+ _serverConfig.getConfig().getProperty(property));
+ }
+
+ public void testProtectIOEnabled() throws ConfigurationException
+ {
+ validatePropertyDefinedInFile(ServerConfiguration.CONNECTOR_PROTECTIO_ENABLED);
+ }
+
+ public void testProtectIOReadBufferLimitSize() throws ConfigurationException
+ {
+ validatePropertyDefinedInFile(ServerConfiguration.CONNECTOR_PROTECTIO_READ_BUFFER_LIMIT_SIZE);
+ }
+
+ public void testProtectIOWriteBufferLimitSize() throws ConfigurationException
+ {
+ validatePropertyDefinedInFile(ServerConfiguration.CONNECTOR_PROTECTIO_WRITE_BUFFER_LIMIT_SIZE);
+ }
+
+ public void testStatusUpdates() throws ConfigurationException
+ {
+ validatePropertyDefinedInFile(ServerConfiguration.STATUS_UPDATES);
+ }
+
+ public void testLocale() throws ConfigurationException
+ {
+ validatePropertyDefinedInFile(ServerConfiguration.ADVANCED_LOCALE);
+ }
+
+}