summaryrefslogtreecommitdiff
path: root/java/client/test/src
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2006-10-03 06:42:50 +0000
committerMartin Ritchie <ritchiem@apache.org>2006-10-03 06:42:50 +0000
commitf2bbab8d8360c524e19a126cf0c9320d2fa87525 (patch)
treef105a817f6a17138b1464135b06b7c227ea2ef85 /java/client/test/src
parent0fb1d150ed0489db09aca1b3653926356186ca7d (diff)
downloadqpid-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
Diffstat (limited to 'java/client/test/src')
-rw-r--r--java/client/test/src/org/apache/qpid/IBMPerfTest/JNDIBindConnectionFactory.java7
-rw-r--r--java/client/test/src/org/apache/qpid/jndi/referenceable/Lookup.java73
2 files changed, 51 insertions, 29 deletions
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)
{