diff options
author | Martin Ritchie <ritchiem@apache.org> | 2006-10-03 06:42:50 +0000 |
---|---|---|
committer | Martin Ritchie <ritchiem@apache.org> | 2006-10-03 06:42:50 +0000 |
commit | f2bbab8d8360c524e19a126cf0c9320d2fa87525 (patch) | |
tree | f105a817f6a17138b1464135b06b7c227ea2ef85 | |
parent | 0fb1d150ed0489db09aca1b3653926356186ca7d (diff) | |
download | qpid-python-f2bbab8d8360c524e19a126cf0c9320d2fa87525.tar.gz |
Added vm://:1 and localhost as JNDI values setup by the IBM Scripts.
Changed exception handling in JNDIBindConnectionFactory.java
Added lookup(String) method to Lookup.java to allow use in other tests.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@452321 13f79535-47bb-0310-9956-ffa450edef68
4 files changed, 53 insertions, 30 deletions
diff --git a/java/client/test/bin/IBM-JNDI-Setup.bat b/java/client/test/bin/IBM-JNDI-Setup.bat index fdf2b1cef5..25f5b90d35 100644 --- a/java/client/test/bin/IBM-JNDI-Setup.bat +++ b/java/client/test/bin/IBM-JNDI-Setup.bat @@ -52,6 +52,7 @@ goto exit set CLIENT_TEST_CLASSES=%QPID_HOME%\lib\client-test-launch.jar
echo on
+"%JAVA_HOME%\bin\java" -server -Xmx1024m -DQPID_HOME="%QPID_HOME%" -cp "%CLIENT_TEST_CLASSES%" org.apache.qpid.IBMPerfTest.JNDIBindConnectionFactory amqp://guest:guest@clientid/testpath?brokerlist='localhost' amq.ConnectionFactory
"%JAVA_HOME%\bin\java" -server -Xmx1024m -DQPID_HOME="%QPID_HOME%" -cp "%CLIENT_TEST_CLASSES%" org.apache.qpid.IBMPerfTest.JNDIBindConnectionFactory amqp://guest:guest@clientid/testpath?brokerlist='vm://:1' amq.VMConnectionFactory
"%JAVA_HOME%\bin\java" -server -Xmx1024m -DQPID_HOME="%QPID_HOME%" -cp "%CLIENT_TEST_CLASSES%" org.apache.qpid.IBMPerfTest.JNDIBindQueue amq.Queue direct://amq.direct//IBMPerfQueue1
"%JAVA_HOME%\bin\java" -server -Xmx1024m -DQPID_HOME="%QPID_HOME%" -cp "%CLIENT_TEST_CLASSES%" org.apache.qpid.IBMPerfTest.JNDIBindTopic amq.Topic1 topic://amq.topic/IBMPerfTopic1/
diff --git a/java/client/test/bin/IBM-JNDI-Setup.sh b/java/client/test/bin/IBM-JNDI-Setup.sh index 36ad9db598..8ce4bf7e56 100755 --- a/java/client/test/bin/IBM-JNDI-Setup.sh +++ b/java/client/test/bin/IBM-JNDI-Setup.sh @@ -15,7 +15,7 @@ # limitations under the License. # -qpid-run org.apache.qpid.IBMPerfTest.JNDIBindConnectionFactory amqp://guest:guest@clientid/testpath?brokerlist=\'tcp://10.0.0.1\' amq.VMConnectionFactory +qpid-run org.apache.qpid.IBMPerfTest.JNDIBindConnectionFactory amqp://guest:guest@clientid/testpath?brokerlist=\'tcp://localhost\' amq.ConnectionFactory qpid-run org.apache.qpid.IBMPerfTest.JNDIBindConnectionFactory amqp://guest:guest@clientid/testpath?brokerlist=\'vm://:1\' amq.VMConnectionFactory qpid-run org.apache.qpid.IBMPerfTest.JNDIBindQueue amq.Queue direct://amq.direct//IBMPerfQueue1 qpid-run org.apache.qpid.IBMPerfTest.JNDIBindTopic amq.Topic1 topic://amq.topic/IBMPerfTopic1/ diff --git a/java/client/test/src/org/apache/qpid/IBMPerfTest/JNDIBindConnectionFactory.java b/java/client/test/src/org/apache/qpid/IBMPerfTest/JNDIBindConnectionFactory.java index ff276fb07c..038be976ad 100644 --- a/java/client/test/src/org/apache/qpid/IBMPerfTest/JNDIBindConnectionFactory.java +++ b/java/client/test/src/org/apache/qpid/IBMPerfTest/JNDIBindConnectionFactory.java @@ -20,6 +20,7 @@ package org.apache.qpid.IBMPerfTest; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.qpid.client.AMQConnectionFactory; +import org.apache.qpid.url.URLSyntaxException; import javax.jms.ConnectionFactory; import javax.naming.Context; @@ -163,7 +164,11 @@ public class JNDIBindConnectionFactory System.out.println("JNDI FS Context:" + provider); } - catch (Exception amqe) + catch (NamingException amqe) + { + + } + catch (URLSyntaxException e) { } diff --git a/java/client/test/src/org/apache/qpid/jndi/referenceable/Lookup.java b/java/client/test/src/org/apache/qpid/jndi/referenceable/Lookup.java index ed31539f8d..05098269c1 100644 --- a/java/client/test/src/org/apache/qpid/jndi/referenceable/Lookup.java +++ b/java/client/test/src/org/apache/qpid/jndi/referenceable/Lookup.java @@ -17,22 +17,25 @@ */ package org.apache.qpid.jndi.referenceable; -import javax.naming.*; import javax.jms.Connection; import javax.jms.JMSException; - -import java.util.Properties; -import java.io.InputStream; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; /** * Looksup a reference from a JNDI source. * Given a properties file with the JNDI information and a binding string. */ -class Lookup +public class Lookup { private static final String USAGE = "USAGE: java lookup <JNDI Properties file> -b <binding>"; + private Properties _properties; + private Object _object; public Lookup(String propertiesFile, String bindingValue) throws NamingException { @@ -56,28 +59,8 @@ class Lookup Properties properties = new Properties(); properties.load(inputStream); - // Create the initial context - Context ctx = new InitialContext(properties); - - // Perform the binds - Object obj = ctx.lookup(bindingValue); - - if (obj instanceof Connection) - { - try - { - ((Connection) obj).close(); - } - catch (JMSException jmse) - { - ; - } - } - - System.out.println(bindingValue + " bound to " + obj); - - // Close the context when we're done - ctx.close(); + _properties = properties; + lookup(bindingValue); } catch (IOException ioe) { @@ -85,6 +68,26 @@ class Lookup } } + public Object lookup(String bindingValue) throws NamingException + { + + // Create the initial context + Context ctx = new InitialContext(_properties); + + // Perform the binds + _object = ctx.lookup(bindingValue); + + // Close the context when we're done + ctx.close(); + + return getObject(); + } + + public Object getObject() + { + return _object; + } + private static String parse(String[] args, int index, String what) { try @@ -159,7 +162,21 @@ class Lookup System.out.print("Looking up:" + binding); try { - new Lookup(args[0], binding); + Lookup l = new Lookup(args[0], binding); + + Object object = l.getObject(); + + if (object instanceof Connection) + { + try + { + ((Connection) object).close(); + } + catch (JMSException jmse) + { + ; + } + } } catch (NamingException nabe) { |