summaryrefslogtreecommitdiff
path: root/qpid/java/broker-core/src
diff options
context:
space:
mode:
authorRobert Gemmell <robbie@apache.org>2013-09-23 23:37:32 +0000
committerRobert Gemmell <robbie@apache.org>2013-09-23 23:37:32 +0000
commit59710ea96cf37dc3859ada1dc5fb095b0b2bc6b4 (patch)
tree9057f14c822133a506620251cd253a899b186564 /qpid/java/broker-core/src
parentefb5fc9fef693085e1eab22d84bd250f2bc241d6 (diff)
downloadqpid-python-59710ea96cf37dc3859ada1dc5fb095b0b2bc6b4.tar.gz
QPID-5159: fixups after previous directory rename of broker to broker-core
- Add new broker module build.xml - Updates the other modules to rely on broker-core, make it all compile. - 'Un-move' the bin, etc, scripts dirs and other non-core files to 'leave' them in the broker module. - 'Un-move' the Main and MainTest classes to 'leave' them in the broker module. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1525736 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-core/src')
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/Main.java381
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/MainTest.java284
2 files changed, 0 insertions, 665 deletions
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/Main.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/Main.java
deleted file mode 100644
index 20b73e965c..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/Main.java
+++ /dev/null
@@ -1,381 +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;
-
-import java.io.File;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.commons.cli.PosixParser;
-import org.apache.log4j.Logger;
-import org.apache.qpid.common.QpidProperties;
-import org.apache.qpid.framing.ProtocolVersion;
-import org.apache.qpid.server.configuration.store.ConfigurationEntryStoreUtil;
-
-/**
- * Main entry point for AMQPD.
- *
- */
-public class Main
-{
- private static final Option OPTION_HELP = new Option("h", "help", false, "print this message");
-
- private static final Option OPTION_VERSION = new Option("v", "version", false, "print the version information and exit");
-
- private static final Option OPTION_CONFIGURATION_STORE_PATH = OptionBuilder.withArgName("path").hasArg()
- .withDescription("use given configuration store location").withLongOpt("store-path").create("sp");
-
- private static final Option OPTION_CONFIGURATION_STORE_TYPE = OptionBuilder.withArgName("type").hasArg()
- .withDescription("use given broker configuration store type").withLongOpt("store-type").create("st");
-
- private static final Option OPTION_INITIAL_CONFIGURATION_PATH = OptionBuilder.withArgName("path").hasArg()
- .withDescription("set the location of initial JSON config to use when creating/overwriting a broker configuration store").withLongOpt("initial-config-path").create("icp");
-
- private static final Option OPTION_OVERWRITE_CONFIGURATION_STORE = OptionBuilder.withDescription("overwrite the broker configuration store with the current initial configuration")
- .withLongOpt("overwrite-store").create("os");
-
- private static final Option OPTION_CREATE_INITIAL_CONFIG = OptionBuilder.withArgName("path").hasOptionalArg().withDescription("create a copy of the initial config file, either to an" +
- " optionally specified file path, or as " + BrokerOptions.DEFAULT_INITIAL_CONFIG_NAME + " in the current directory")
- .withLongOpt("create-initial-config").create("cic");
-
- private static final Option OPTION_CONFIGURATION_PROPERTY = OptionBuilder.withArgName("name=value").hasArg()
- .withDescription("set a configuration property to use when resolving variables in the broker configuration store, with format \"name=value\"")
- .withLongOpt("config-property").create("prop");
-
- private static final Option OPTION_LOG_CONFIG_FILE =
- OptionBuilder.withArgName("file").hasArg()
- .withDescription("use the specified log4j xml configuration file. By "
- + "default looks for a file named " + BrokerOptions.DEFAULT_LOG_CONFIG_FILE
- + " in the same directory as the configuration file").withLongOpt("logconfig").create("l");
-
- private static final Option OPTION_LOG_WATCH =
- OptionBuilder.withArgName("period").hasArg()
- .withDescription("monitor the log file configuration file for changes. Units are seconds. "
- + "Zero means do not check for changes.").withLongOpt("logwatch").create("w");
-
- private static final Option OPTION_MANAGEMENT_MODE = OptionBuilder.withDescription("start broker in management mode, disabling the AMQP ports")
- .withLongOpt("management-mode").create("mm");
- private static final Option OPTION_MM_QUIESCE_VHOST = OptionBuilder.withDescription("make virtualhosts stay in the quiesced state during management mode.")
- .withLongOpt("management-mode-quiesce-virtualhosts").create("mmqv");
- private static final Option OPTION_MM_RMI_PORT = OptionBuilder.withArgName("port").hasArg()
- .withDescription("override jmx rmi registry port in management mode").withLongOpt("management-mode-rmi-registry-port").create("mmrmi");
- private static final Option OPTION_MM_CONNECTOR_PORT = OptionBuilder.withArgName("port").hasArg()
- .withDescription("override jmx connector port in management mode").withLongOpt("management-mode-jmx-connector-port").create("mmjmx");
- private static final Option OPTION_MM_HTTP_PORT = OptionBuilder.withArgName("port").hasArg()
- .withDescription("override http management port in management mode").withLongOpt("management-mode-http-port").create("mmhttp");
- private static final Option OPTION_MM_PASSWORD = OptionBuilder.withArgName("password").hasArg()
- .withDescription("Set the password for the management mode user " + BrokerOptions.MANAGEMENT_MODE_USER_NAME).withLongOpt("management-mode-password").create("mmpass");
-
- private static final Options OPTIONS = new Options();
-
- static
- {
- OPTIONS.addOption(OPTION_HELP);
- OPTIONS.addOption(OPTION_VERSION);
- OPTIONS.addOption(OPTION_CONFIGURATION_STORE_PATH);
- OPTIONS.addOption(OPTION_CONFIGURATION_STORE_TYPE);
- OPTIONS.addOption(OPTION_OVERWRITE_CONFIGURATION_STORE);
- OPTIONS.addOption(OPTION_CREATE_INITIAL_CONFIG);
- OPTIONS.addOption(OPTION_LOG_CONFIG_FILE);
- OPTIONS.addOption(OPTION_LOG_WATCH);
- OPTIONS.addOption(OPTION_INITIAL_CONFIGURATION_PATH);
- OPTIONS.addOption(OPTION_MANAGEMENT_MODE);
- OPTIONS.addOption(OPTION_MM_QUIESCE_VHOST);
- OPTIONS.addOption(OPTION_MM_RMI_PORT);
- OPTIONS.addOption(OPTION_MM_CONNECTOR_PORT);
- OPTIONS.addOption(OPTION_MM_HTTP_PORT);
- OPTIONS.addOption(OPTION_MM_PASSWORD);
- OPTIONS.addOption(OPTION_CONFIGURATION_PROPERTY);
- }
-
- protected CommandLine _commandLine;
-
- public static void main(String[] args)
- {
- //if the -Dlog4j.configuration property has not been set, enable the init override
- //to stop Log4J wondering off and picking up the first log4j.xml/properties file it
- //finds from the classpath when we get the first Loggers
- if(System.getProperty("log4j.configuration") == null)
- {
- System.setProperty("log4j.defaultInitOverride", "true");
- }
-
- new Main(args);
- }
-
- public Main(final String[] args)
- {
- if (parseCommandline(args))
- {
- try
- {
- execute();
- }
- catch(Throwable e)
- {
- System.err.println("Exception during startup: " + e);
- e.printStackTrace();
- shutdown(1);
- }
- }
- }
-
- protected boolean parseCommandline(final String[] args)
- {
- try
- {
- _commandLine = new PosixParser().parse(OPTIONS, args);
-
- return true;
- }
- catch (ParseException e)
- {
- System.err.println("Error: " + e.getMessage());
- HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp("Qpid", OPTIONS, true);
-
- return false;
- }
- }
-
- protected void execute() throws Exception
- {
- BrokerOptions options = new BrokerOptions();
- String initialConfigLocation = _commandLine.getOptionValue(OPTION_INITIAL_CONFIGURATION_PATH.getOpt());
- if (initialConfigLocation != null)
- {
- options.setInitialConfigurationLocation(initialConfigLocation);
- }
-
- //process the remaining options
- if (_commandLine.hasOption(OPTION_HELP.getOpt()))
- {
- final HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp("Qpid", OPTIONS, true);
- }
- else if (_commandLine.hasOption(OPTION_CREATE_INITIAL_CONFIG.getOpt()))
- {
- File destinationFile = null;
-
- String destinationOption = _commandLine.getOptionValue(OPTION_CREATE_INITIAL_CONFIG.getOpt());
- if (destinationOption != null)
- {
- destinationFile = new File(destinationOption);
- }
- else
- {
- destinationFile = new File(System.getProperty("user.dir"), BrokerOptions.DEFAULT_INITIAL_CONFIG_NAME);
- }
-
- ConfigurationEntryStoreUtil util = new ConfigurationEntryStoreUtil();
- util.copyInitialConfigFile(options.getInitialConfigurationLocation(), destinationFile);
-
- System.out.println("Initial config written to: " + destinationFile.getAbsolutePath());
- }
- else if (_commandLine.hasOption(OPTION_VERSION.getOpt()))
- {
- final StringBuilder protocol = new StringBuilder("AMQP version(s) [major.minor]: ");
- boolean first = true;
- for (final ProtocolVersion pv : ProtocolVersion.getSupportedProtocolVersions())
- {
- if (first)
- {
- first = false;
- }
- else
- {
- protocol.append(", ");
- }
-
- protocol.append(pv.getMajorVersion()).append('-').append(pv.getMinorVersion());
- }
- System.out.println(QpidProperties.getVersionString() + " (" + protocol + ")");
- }
- else
- {
- String[] configPropPairs = _commandLine.getOptionValues(OPTION_CONFIGURATION_PROPERTY.getOpt());
- if(configPropPairs != null && configPropPairs.length > 0)
- {
- for(String s : configPropPairs)
- {
- int firstEquals = s.indexOf("=");
- if(firstEquals == -1)
- {
- throw new IllegalArgumentException("Configuration property argument is not of the format name=value: " + s);
- }
- String name = s.substring(0, firstEquals);
- String value = s.substring(firstEquals + 1);
-
- if(name.equals(""))
- {
- throw new IllegalArgumentException("Configuration property argument is not of the format name=value: " + s);
- }
-
- options.setConfigProperty(name, value);
- }
- }
-
- String configurationStore = _commandLine.getOptionValue(OPTION_CONFIGURATION_STORE_PATH.getOpt());
- if (configurationStore != null)
- {
- options.setConfigurationStoreLocation(configurationStore);
- }
-
- String configurationStoreType = _commandLine.getOptionValue(OPTION_CONFIGURATION_STORE_TYPE.getOpt());
- if (configurationStoreType != null)
- {
- options.setConfigurationStoreType(configurationStoreType);
- }
-
- String logWatchConfig = _commandLine.getOptionValue(OPTION_LOG_WATCH.getOpt());
- if(logWatchConfig != null)
- {
- options.setLogWatchFrequency(Integer.parseInt(logWatchConfig));
- }
-
- String logConfig = _commandLine.getOptionValue(OPTION_LOG_CONFIG_FILE.getOpt());
- if(logConfig != null)
- {
- options.setLogConfigFileLocation(logConfig);
- }
-
- boolean overwriteConfigurationStore = _commandLine.hasOption(OPTION_OVERWRITE_CONFIGURATION_STORE.getOpt());
- options.setOverwriteConfigurationStore(overwriteConfigurationStore);
-
- boolean managementMode = _commandLine.hasOption(OPTION_MANAGEMENT_MODE.getOpt());
- if (managementMode)
- {
- options.setManagementMode(true);
- String rmiPort = _commandLine.getOptionValue(OPTION_MM_RMI_PORT.getOpt());
- if (rmiPort != null)
- {
- options.setManagementModeRmiPortOverride(Integer.parseInt(rmiPort));
- }
- String connectorPort = _commandLine.getOptionValue(OPTION_MM_CONNECTOR_PORT.getOpt());
- if (connectorPort != null)
- {
- options.setManagementModeJmxPortOverride(Integer.parseInt(connectorPort));
- }
- String httpPort = _commandLine.getOptionValue(OPTION_MM_HTTP_PORT.getOpt());
- if (httpPort != null)
- {
- options.setManagementModeHttpPortOverride(Integer.parseInt(httpPort));
- }
-
- boolean quiesceVhosts = _commandLine.hasOption(OPTION_MM_QUIESCE_VHOST.getOpt());
- options.setManagementModeQuiesceVirtualHosts(quiesceVhosts);
-
- String password = _commandLine.getOptionValue(OPTION_MM_PASSWORD.getOpt());
- if (password != null)
- {
- options.setManagementModePassword(password);
- }
- }
- setExceptionHandler();
-
- startBroker(options);
- }
- }
-
- protected void setExceptionHandler()
- {
- Thread.UncaughtExceptionHandler handler = null;
- String handlerClass = System.getProperty("qpid.broker.exceptionHandler");
- if(handlerClass != null)
- {
- try
- {
- handler = (Thread.UncaughtExceptionHandler) Class.forName(handlerClass).newInstance();
- }
- catch (ClassNotFoundException e)
- {
-
- }
- catch (InstantiationException e)
- {
-
- }
- catch (IllegalAccessException e)
- {
-
- }
- catch (ClassCastException e)
- {
-
- }
- }
-
- if(handler == null)
- {
- handler =
- new Thread.UncaughtExceptionHandler()
- {
- public void uncaughtException(final Thread t, final Throwable e)
- {
- boolean continueOnError = Boolean.getBoolean("qpid.broker.exceptionHandler.continue");
- try
- {
- System.err.println("########################################################################");
- System.err.println("#");
- System.err.print("# Unhandled Exception ");
- System.err.print(e.toString());
- System.err.print(" in Thread ");
- System.err.println(t.getName());
- System.err.println("#");
- System.err.println(continueOnError ? "# Forced to continue by JVM setting 'qpid.broker.exceptionHandler.continue'" : "# Exiting");
- System.err.println("#");
- System.err.println("########################################################################");
- e.printStackTrace(System.err);
-
- Logger logger = Logger.getLogger("org.apache.qpid.server.Main");
- logger.error("Uncaught exception, " + (continueOnError ? "continuing." : "shutting down."), e);
- }
- finally
- {
- if (!continueOnError)
- {
- Runtime.getRuntime().halt(1);
- }
- }
-
- }
- };
-
- Thread.setDefaultUncaughtExceptionHandler(handler);
- }
- }
-
- protected void startBroker(final BrokerOptions options) throws Exception
- {
- Broker broker = new Broker();
- broker.startup(options);
- }
-
- protected void shutdown(final int status)
- {
- System.exit(status);
- }
-
-}
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/MainTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/MainTest.java
deleted file mode 100644
index f3b1749808..0000000000
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/MainTest.java
+++ /dev/null
@@ -1,284 +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;
-
-import java.io.File;
-import java.util.Map;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.qpid.server.configuration.BrokerProperties;
-import org.apache.qpid.test.utils.QpidTestCase;
-
-/**
- * Test to verify the command line parsing within the Main class, by
- * providing it a series of command line arguments and verifying the
- * BrokerOptions emerging for use in starting the Broker instance.
- */
-public class MainTest extends QpidTestCase
-{
- private Exception _startupException;
-
- public void testNoOptionsSpecified()
- {
- String qpidWork = "/qpid/work";
- setTestSystemProperty(BrokerProperties.PROPERTY_QPID_WORK, qpidWork);
- String qpidHome = "/qpid/home";
- setTestSystemProperty(BrokerProperties.PROPERTY_QPID_HOME, qpidHome);
-
- String expectedStorePath = new File(qpidWork, BrokerOptions.DEFAULT_CONFIG_NAME_PREFIX + ".json").getAbsolutePath();
- String expectedLogConfigPath = new File(qpidHome, BrokerOptions.DEFAULT_LOG_CONFIG_FILE).getAbsolutePath();
-
- BrokerOptions options = startDummyMain("");
-
- assertEquals("json", options.getConfigurationStoreType());
- assertEquals(expectedStorePath, options.getConfigurationStoreLocation());
- assertEquals(expectedLogConfigPath, options.getLogConfigFileLocation());
- assertEquals(0, options.getLogWatchFrequency());
- assertEquals(BrokerOptions.DEFAULT_INITIAL_CONFIG_LOCATION, options.getInitialConfigurationLocation());
- assertFalse(options.isOverwriteConfigurationStore());
- assertFalse(options.isManagementMode());
- assertEquals(0, options.getManagementModeJmxPortOverride());
- assertEquals(0, options.getManagementModeRmiPortOverride());
- assertEquals(0, options.getManagementModeHttpPortOverride());
- }
-
- public void testConfigurationStoreLocation()
- {
- BrokerOptions options = startDummyMain("-sp abcd/config.xml");
- assertEquals("abcd/config.xml", options.getConfigurationStoreLocation());
-
- options = startDummyMain("-store-path abcd/config2.xml");
- assertEquals("abcd/config2.xml", options.getConfigurationStoreLocation());
- }
-
- public void testConfigurationStoreType()
- {
- BrokerOptions options = startDummyMain("-st dby");
- assertEquals("dby", options.getConfigurationStoreType());
-
- options = startDummyMain("-store-type bdb");
- assertEquals("bdb", options.getConfigurationStoreType());
- }
-
- public void testOverwriteConfigurationStore()
- {
- BrokerOptions options = startDummyMain("-os");
- assertTrue(options.isOverwriteConfigurationStore());
-
- options = startDummyMain("-overwrite-store");
- assertTrue(options.isOverwriteConfigurationStore());
- }
-
- public void testLogConfig()
- {
- BrokerOptions options = startDummyMain("-l wxyz/log4j.xml");
-
- assertEquals("wxyz/log4j.xml", options.getLogConfigFileLocation());
- }
-
- public void testLogWatch()
- {
- BrokerOptions options = startDummyMain("-w 9");
-
- assertEquals(9, options.getLogWatchFrequency());
- }
-
- public void testVersion()
- {
- final TestMain main = new TestMain("-v".split("\\s"));
-
- assertNotNull("Command line not parsed correctly", main.getCommandLine());
- assertTrue("Parsed command line didnt pick up version option", main.getCommandLine().hasOption("v"));
- }
-
- public void testHelp()
- {
- final TestMain main = new TestMain("-h".split("\\s"));
-
- assertNotNull("Command line not parsed correctly", main.getCommandLine());
- assertTrue("Parsed command line didnt pick up help option", main.getCommandLine().hasOption("h"));
- }
-
- public void testInitailConfigurationLocation()
- {
- BrokerOptions options = startDummyMain("-icp abcd/initial-config.json");
- assertEquals("abcd/initial-config.json", options.getInitialConfigurationLocation());
-
- options = startDummyMain("-initial-config-path abcd/initial-config.json");
- assertEquals("abcd/initial-config.json", options.getInitialConfigurationLocation());
- }
-
- public void testManagementMode()
- {
- BrokerOptions options = startDummyMain("-mm");
- assertTrue(options.isManagementMode());
-
- options = startDummyMain("--management-mode");
- assertTrue(options.isManagementMode());
- }
-
- public void testManagementModeRmiPortOverride()
- {
- BrokerOptions options = startDummyMain("-mm -mmrmi 7777");
- assertTrue(options.isManagementMode());
- assertEquals(7777, options.getManagementModeRmiPortOverride());
-
- options = startDummyMain("-mm --management-mode-rmi-registry-port 7777");
- assertTrue(options.isManagementMode());
- assertEquals(7777, options.getManagementModeRmiPortOverride());
-
- options = startDummyMain("-mmrmi 7777");
- assertEquals(0, options.getManagementModeRmiPortOverride());
- }
-
- public void testManagementModeJmxPortOverride()
- {
- BrokerOptions options = startDummyMain("-mm -mmjmx 8888");
- assertTrue(options.isManagementMode());
- assertEquals(8888, options.getManagementModeJmxPortOverride());
-
- options = startDummyMain("-mm --management-mode-jmx-connector-port 8888");
- assertTrue(options.isManagementMode());
- assertEquals(8888, options.getManagementModeJmxPortOverride());
-
- options = startDummyMain("-mmjmx 8888");
- assertEquals(0, options.getManagementModeJmxPortOverride());
- }
-
- public void testManagementModeHttpPortOverride()
- {
- BrokerOptions options = startDummyMain("-mm -mmhttp 9999");
- assertTrue(options.isManagementMode());
- assertEquals(9999, options.getManagementModeHttpPortOverride());
-
- options = startDummyMain("-mm --management-mode-http-port 9999");
- assertTrue(options.isManagementMode());
- assertEquals(9999, options.getManagementModeHttpPortOverride());
-
- options = startDummyMain("-mmhttp 9999");
- assertEquals(0, options.getManagementModeHttpPortOverride());
- }
-
- public void testManagementModePassword()
- {
- String password = getTestName();
- BrokerOptions options = startDummyMain("-mm -mmpass " + password);
- assertTrue(options.isManagementMode());
- assertEquals(password, options.getManagementModePassword());
-
- options = startDummyMain("-mm --management-mode-password " + password);
- assertTrue(options.isManagementMode());
- assertEquals(password, options.getManagementModePassword());
-
- options = startDummyMain("-mmpass " + password);
- assertNotNull(options.getManagementModePassword());
- }
-
- public void testDefaultManagementModePassword()
- {
- BrokerOptions options = startDummyMain("-mm");
- assertTrue(options.isManagementMode());
- assertNotNull(options.getManagementModePassword());
- }
-
- public void testSetConfigProperties()
- {
- //short name
- String newPort = "12345";
- BrokerOptions options = startDummyMain("-prop name=value -prop " + BrokerOptions.QPID_AMQP_PORT + "=" + newPort);
-
- Map<String, String> props = options.getConfigProperties();
-
- assertEquals(newPort, props.get(BrokerOptions.QPID_AMQP_PORT));
- assertEquals("value", props.get("name"));
-
- //long name
- newPort = "678910";
- options = startDummyMain("--config-property name2=value2 --config-property " + BrokerOptions.QPID_AMQP_PORT + "=" + newPort);
-
- props = options.getConfigProperties();
-
- assertEquals(newPort, props.get(BrokerOptions.QPID_AMQP_PORT));
- assertEquals("value2", props.get("name2"));
- }
-
- public void testSetConfigPropertiesInvalidFormat()
- {
- //missing equals
- startDummyMain("-prop namevalue");
- assertTrue("expected exception did not occur",
- _startupException instanceof IllegalArgumentException);
-
- //no name specified
- startDummyMain("-prop =value");
- assertTrue("expected exception did not occur",
- _startupException instanceof IllegalArgumentException);
- }
-
- private BrokerOptions startDummyMain(String commandLine)
- {
- return (new TestMain(commandLine.split("\\s"))).getOptions();
- }
-
- private class TestMain extends Main
- {
- private BrokerOptions _options;
-
- public TestMain(String[] args)
- {
- super(args);
- }
-
- @Override
- protected void execute()
- {
- try
- {
- super.execute();
- }
- catch(Exception re)
- {
- MainTest.this._startupException = re;
- }
- }
-
- @Override
- protected void startBroker(BrokerOptions options)
- {
- _options = options;
- }
-
- @Override
- protected void setExceptionHandler()
- {
- }
-
- public BrokerOptions getOptions()
- {
- return _options;
- }
-
- public CommandLine getCommandLine()
- {
- return _commandLine;
- }
- }
-}