You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ri...@apache.org on 2006/10/03 08:42:51 UTC

svn commit: r452321 - in /incubator/qpid/trunk/qpid/java/client/test: bin/IBM-JNDI-Setup.bat bin/IBM-JNDI-Setup.sh src/org/apache/qpid/IBMPerfTest/JNDIBindConnectionFactory.java src/org/apache/qpid/jndi/referenceable/Lookup.java

Author: ritchiem
Date: Mon Oct  2 23:42:50 2006
New Revision: 452321

URL: http://svn.apache.org/viewvc?view=rev&rev=452321
Log:
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.

Modified:
    incubator/qpid/trunk/qpid/java/client/test/bin/IBM-JNDI-Setup.bat
    incubator/qpid/trunk/qpid/java/client/test/bin/IBM-JNDI-Setup.sh
    incubator/qpid/trunk/qpid/java/client/test/src/org/apache/qpid/IBMPerfTest/JNDIBindConnectionFactory.java
    incubator/qpid/trunk/qpid/java/client/test/src/org/apache/qpid/jndi/referenceable/Lookup.java

Modified: incubator/qpid/trunk/qpid/java/client/test/bin/IBM-JNDI-Setup.bat
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/test/bin/IBM-JNDI-Setup.bat?view=diff&rev=452321&r1=452320&r2=452321
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/test/bin/IBM-JNDI-Setup.bat (original)
+++ incubator/qpid/trunk/qpid/java/client/test/bin/IBM-JNDI-Setup.bat Mon Oct  2 23:42:50 2006
@@ -52,6 +52,7 @@
 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/

Modified: incubator/qpid/trunk/qpid/java/client/test/bin/IBM-JNDI-Setup.sh
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/test/bin/IBM-JNDI-Setup.sh?view=diff&rev=452321&r1=452320&r2=452321
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/test/bin/IBM-JNDI-Setup.sh (original)
+++ incubator/qpid/trunk/qpid/java/client/test/bin/IBM-JNDI-Setup.sh Mon Oct  2 23:42:50 2006
@@ -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/

Modified: incubator/qpid/trunk/qpid/java/client/test/src/org/apache/qpid/IBMPerfTest/JNDIBindConnectionFactory.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/test/src/org/apache/qpid/IBMPerfTest/JNDIBindConnectionFactory.java?view=diff&rev=452321&r1=452320&r2=452321
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/test/src/org/apache/qpid/IBMPerfTest/JNDIBindConnectionFactory.java (original)
+++ incubator/qpid/trunk/qpid/java/client/test/src/org/apache/qpid/IBMPerfTest/JNDIBindConnectionFactory.java Mon Oct  2 23:42:50 2006
@@ -20,6 +20,7 @@
 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 @@
 
                 System.out.println("JNDI FS Context:" + provider);
             }
-            catch (Exception amqe)
+            catch (NamingException amqe)
+            {
+
+            }
+            catch (URLSyntaxException e)
             {
 
             }

Modified: incubator/qpid/trunk/qpid/java/client/test/src/org/apache/qpid/jndi/referenceable/Lookup.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/test/src/org/apache/qpid/jndi/referenceable/Lookup.java?view=diff&rev=452321&r1=452320&r2=452321
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/test/src/org/apache/qpid/jndi/referenceable/Lookup.java (original)
+++ incubator/qpid/trunk/qpid/java/client/test/src/org/apache/qpid/jndi/referenceable/Lookup.java Mon Oct  2 23:42:50 2006
@@ -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 @@
             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 @@
         }
     }
 
+    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 @@
                     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)
                     {