You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2017/11/28 07:38:33 UTC
[7/7] qpid-broker-j git commit: QPID-8055: [Performance Tests] Remove
hardcoded reference to legacy jms client context factory from perftests
runner
QPID-8055: [Performance Tests] Remove hardcoded reference to legacy jms client context factory from perftests runner
Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/0b7666eb
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/0b7666eb
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/0b7666eb
Branch: refs/heads/master
Commit: 0b7666ebe869de6cfdc34e13ff9d6c8e18c0cd5e
Parents: 9089861
Author: Alex Rudyy <or...@apache.org>
Authored: Fri Nov 24 14:21:04 2017 +0000
Committer: Alex Rudyy <or...@apache.org>
Committed: Tue Nov 28 07:37:08 2017 +0000
----------------------------------------------------------------------
.../apache/qpid/disttest/AbstractRunner.java | 38 +++++++++++++++-----
1 file changed, 29 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/0b7666eb/perftests/src/main/java/org/apache/qpid/disttest/AbstractRunner.java
----------------------------------------------------------------------
diff --git a/perftests/src/main/java/org/apache/qpid/disttest/AbstractRunner.java b/perftests/src/main/java/org/apache/qpid/disttest/AbstractRunner.java
index 1c9366a..48f1bc5 100644
--- a/perftests/src/main/java/org/apache/qpid/disttest/AbstractRunner.java
+++ b/perftests/src/main/java/org/apache/qpid/disttest/AbstractRunner.java
@@ -20,9 +20,16 @@
*/
package org.apache.qpid.disttest;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
+import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
@@ -41,19 +48,19 @@ public class AbstractRunner
protected Context getContext()
{
String jndiConfig = getJndiConfig();
- Hashtable env = new Hashtable();
- env.put(Context.PROVIDER_URL, jndiConfig);
- // Java allows this to be overridden with a system property of the same name
- if (!System.getProperties().containsKey(InitialContext.INITIAL_CONTEXT_FACTORY))
- {
- env.put(InitialContext.INITIAL_CONTEXT_FACTORY, "org.apache.qpid.jndi.PropertiesFileInitialContextFactory");
- }
try
{
- return new InitialContext(env);
+ Properties properties = new Properties();
+ properties.put(Context.PROVIDER_URL, jndiConfig);
+ try(InputStream is = getJndiConfigurationInputStream(jndiConfig))
+ {
+ properties.load(is);
+ }
+
+ return new InitialContext(properties);
}
- catch (NamingException e)
+ catch (IOException | NamingException e)
{
throw new DistributedTestException("Exception whilst creating InitialContext from URL '"
+ jndiConfig + "'", e);
@@ -75,4 +82,17 @@ public class AbstractRunner
{
return _cliOptions;
}
+
+ private InputStream getJndiConfigurationInputStream(final String providerUrl) throws IOException
+ {
+ try
+ {
+ URL url = new URL(providerUrl);
+ return url.openStream();
+ }
+ catch (MalformedURLException mue)
+ {
+ return new FileInputStream(new File(providerUrl));
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org