diff options
author | Keith Wall <kwall@apache.org> | 2015-02-18 11:56:07 +0000 |
---|---|---|
committer | Keith Wall <kwall@apache.org> | 2015-02-18 11:56:07 +0000 |
commit | 3f5cab26f9b4fdf299b8774a529948f0d25e25ad (patch) | |
tree | c1fbc635526f7e9ba44b8412b6faf6908525c1a2 | |
parent | 01cc230ddd9d630c99bd27140297e31213821ae6 (diff) | |
download | qpid-python-3f5cab26f9b4fdf299b8774a529948f0d25e25ad.tar.gz |
QPID-6390: [Java System Tests] Ensure that Broker's system properties are loaded before the test begins to use the Model to create test config
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1660604 13f79535-47bb-0310-9956-ffa450edef68
3 files changed, 22 insertions, 5 deletions
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/Broker.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/Broker.java index 0d291fb6ea..6dd6c58853 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/Broker.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/Broker.java @@ -320,12 +320,12 @@ public class Broker implements BrokerShutdownProvider } } - private void populateSystemPropertiesFromDefaults(final String initialProperties) throws IOException + public static void populateSystemPropertiesFromDefaults(final String initialProperties) throws IOException { URL initialPropertiesLocation; if(initialProperties == null) { - initialPropertiesLocation = getClass().getClassLoader().getResource("system.properties"); + initialPropertiesLocation = Broker.class.getClassLoader().getResource("system.properties"); } else { @@ -335,7 +335,11 @@ public class Broker implements BrokerShutdownProvider Properties props = new Properties(QpidProperties.asProperties()); if(initialPropertiesLocation != null) { - props.load(initialPropertiesLocation.openStream()); + + try(InputStream inStream = initialPropertiesLocation.openStream()) + { + props.load(inStream); + } } Set<String> propertyNames = new HashSet<>(props.stringPropertyNames()); @@ -344,7 +348,6 @@ public class Broker implements BrokerShutdownProvider { System.setProperty(propName, props.getProperty(propName)); } - } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryImpl.java index 27d914c639..5026df0e19 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryImpl.java @@ -156,7 +156,7 @@ public class ConfiguredObjectFactoryImpl implements ConfiguredObjectFactory factory = categoryFactories.get(_defaultTypes.get(category)); if(factory == null) { - throw new NoFactoryForTypeException(category, _defaultTypes.get(category)); + throw new NoFactoryForTypeException(category, type); } } return factory; diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java index 9a3308603b..9bcc2cb3ae 100755 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java @@ -59,6 +59,7 @@ import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.jms.BrokerDetails; import org.apache.qpid.jms.ConnectionURL; +import org.apache.qpid.server.Broker; import org.apache.qpid.server.BrokerOptions; import org.apache.qpid.server.configuration.BrokerProperties; import org.apache.qpid.server.configuration.updater.TaskExecutor; @@ -189,6 +190,19 @@ public class QpidBrokerTestCase extends QpidTestCase _brokerConfigurations = new HashMap<Integer, TestBrokerConfiguration>(); initialiseSpawnedBrokerLogConfigFile(); _brokerCommandTemplate = BROKER_COMMAND_TEMPLATE; + + + if (JAVA.equals(_brokerLanguage)) + { + try + { + Broker.populateSystemPropertiesFromDefaults(null); + } + catch (IOException ioe) + { + throw new RuntimeException("Failed to load Java broker system properties", ioe); + } + } } public TestBrokerConfiguration getBrokerConfiguration(int port) |