diff options
author | Martin Ritchie <ritchiem@apache.org> | 2006-10-13 13:02:54 +0000 |
---|---|---|
committer | Martin Ritchie <ritchiem@apache.org> | 2006-10-13 13:02:54 +0000 |
commit | 44c234332e01c90d9538a8fd1eee568217a2f054 (patch) | |
tree | 6e2e5ab59b46976d92627fa61a89e06304ae850d | |
parent | 37b4b5fcc618cbe534098fcab347503c8441d379 (diff) | |
download | qpid-python-44c234332e01c90d9538a8fd1eee568217a2f054.tar.gz |
Added Sun FSContext to client-test lib
Updated referenceabletest files to use the temporary directory reported by the System.properties.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@463671 13f79535-47bb-0310-9956-ffa450edef68
8 files changed, 100 insertions, 32 deletions
diff --git a/java/client/test/lib/fscontext-1_2-beta3/fscontext.jar b/java/client/test/lib/fscontext-1_2-beta3/fscontext.jar Binary files differnew file mode 100644 index 0000000000..0efc25071a --- /dev/null +++ b/java/client/test/lib/fscontext-1_2-beta3/fscontext.jar diff --git a/java/client/test/lib/fscontext-1_2-beta3/providerutil.jar b/java/client/test/lib/fscontext-1_2-beta3/providerutil.jar Binary files differnew file mode 100644 index 0000000000..0d6e48f388 --- /dev/null +++ b/java/client/test/lib/fscontext-1_2-beta3/providerutil.jar diff --git a/java/client/test/src/org/apache/qpid/jndi/referenceable/Bind.java b/java/client/test/src/org/apache/qpid/jndi/referenceable/Bind.java index 0829de0e82..3715ef7cc4 100644 --- a/java/client/test/src/org/apache/qpid/jndi/referenceable/Bind.java +++ b/java/client/test/src/org/apache/qpid/jndi/referenceable/Bind.java @@ -33,7 +33,7 @@ import java.io.IOException; * Binds a reference from a JNDI source. * Given a properties file with the JNDI information and a binding string. */ -class Bind +public class Bind { private static final String USAGE="USAGE: java bind <JNDI Properties file> -cf <url> <binding> | -c <url> <binding> [-t <topic Name> <binding>] [-q <queue Name> <binding>]"; public Bind(String propertiesFile, String bindingURL, Referenceable reference) throws NameAlreadyBoundException, NoInitialContextException diff --git a/java/client/test/src/org/apache/qpid/jndi/referenceable/Unbind.java b/java/client/test/src/org/apache/qpid/jndi/referenceable/Unbind.java index 90e5918e5c..1e9f57c07f 100644 --- a/java/client/test/src/org/apache/qpid/jndi/referenceable/Unbind.java +++ b/java/client/test/src/org/apache/qpid/jndi/referenceable/Unbind.java @@ -28,11 +28,11 @@ import java.io.IOException; * Unbinds a reference from a JNDI source. * Given a properties file with the JNDI information and a binding string. */ -class UnBind +public class Unbind { private static final String USAGE = "USAGE: java unbind <JNDI Properties file> -b <binding>"; - public UnBind(String propertiesFile, String bindingValue) throws NamingException + public Unbind(String propertiesFile, String bindingValue) throws NamingException { // Set up the environment for creating the initial context String qpid_home = System.getProperty("QPID_HOME"); @@ -143,7 +143,7 @@ class UnBind System.out.print("UnBinding:" + binding); try { - new UnBind(args[0], binding); + new Unbind(args[0], binding); System.out.println(" ..Successful"); } catch (NamingException nabe) diff --git a/java/client/test/src/org/apache/qpid/jndi/referenceabletest/Bind.java b/java/client/test/src/org/apache/qpid/jndi/referenceabletest/Bind.java index d5840d9600..221237a37c 100644 --- a/java/client/test/src/org/apache/qpid/jndi/referenceabletest/Bind.java +++ b/java/client/test/src/org/apache/qpid/jndi/referenceabletest/Bind.java @@ -18,15 +18,22 @@ package org.apache.qpid.jndi.referenceabletest; import org.apache.qpid.client.AMQConnection; -import org.apache.qpid.client.AMQTopic; import org.apache.qpid.client.AMQConnectionFactory; -import org.apache.qpid.AMQException; +import org.apache.qpid.client.AMQTopic; import org.apache.qpid.url.URLSyntaxException; import org.junit.Assert; -import javax.jms.*; -import javax.naming.*; - +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.JMSException; +import javax.jms.Session; +import javax.jms.Topic; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NameAlreadyBoundException; +import javax.naming.NamingException; +import javax.naming.NoInitialContextException; +import java.io.File; import java.util.Hashtable; /** @@ -41,11 +48,12 @@ import java.util.Hashtable; */ class Bind { + public static final String DEFAULT_PROVIDER_FILE_PATH = System.getProperty("java.io.tmpdir") + "/JNDITest"; + public static final String PROVIDER_URL = "file://" + DEFAULT_PROVIDER_FILE_PATH; String _connectionFactoryString = ""; - String _connectionString = "amqp://guest:guest@clientid/testpath?brokerlist='tcp://localhost:5672'"; - + String _connectionString = "amqp://guest:guest@clientid/testpath?brokerlist='vm://:1'"; Topic _topic = null; boolean _bound = false; @@ -54,13 +62,35 @@ class Bind { this(false); } + public Bind(boolean output) throws NameAlreadyBoundException, NoInitialContextException { // Set up the environment for creating the initial context Hashtable env = new Hashtable(11); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory"); - env.put(Context.PROVIDER_URL, "file:/temp/qpid-jndi-test"); + env.put(Context.PROVIDER_URL, PROVIDER_URL); + + + File file = new File(PROVIDER_URL.substring(PROVIDER_URL.indexOf("://") + 3)); + + if (file.exists() && !file.isDirectory()) + { + System.out.println("Couldn't make directory file already exists"); + return; + } + else + { + if (!file.exists()) + { + if (!file.mkdirs()) + { + System.out.println("Couldn't make directory"); + return; + } + } + } + try { @@ -93,7 +123,6 @@ class Bind Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); _topic = session.createTopic("Fruity"); - } catch (JMSException jmse) { @@ -129,15 +158,14 @@ class Bind System.out.println("Operation failed: " + e); if (e instanceof NameAlreadyBoundException) { - throw (NameAlreadyBoundException) e; + throw(NameAlreadyBoundException) e; } if (e instanceof NoInitialContextException) { - throw (NoInitialContextException) e; + throw(NoInitialContextException) e; } } - } public String connectionFactoryValue() diff --git a/java/client/test/src/org/apache/qpid/jndi/referenceabletest/JNDIReferenceableTest.java b/java/client/test/src/org/apache/qpid/jndi/referenceabletest/JNDIReferenceableTest.java index c167442783..7c7d32991f 100644 --- a/java/client/test/src/org/apache/qpid/jndi/referenceabletest/JNDIReferenceableTest.java +++ b/java/client/test/src/org/apache/qpid/jndi/referenceabletest/JNDIReferenceableTest.java @@ -45,12 +45,9 @@ public class JNDIReferenceableTest Bind b = null; try { - - try { b = new Bind(); - } catch (NameAlreadyBoundException e) { @@ -69,7 +66,6 @@ public class JNDIReferenceableTest { Assert.fail("Unable to clear bound objects for test."); } - } } catch (NoInitialContextException e) @@ -99,10 +95,8 @@ public class JNDIReferenceableTest } - public static junit.framework.Test suite - () + public static junit.framework.Test suite() { return new JUnit4TestAdapter(JNDIReferenceableTest.class); } - } diff --git a/java/client/test/src/org/apache/qpid/jndi/referenceabletest/Lookup.java b/java/client/test/src/org/apache/qpid/jndi/referenceabletest/Lookup.java index f5bebeec6b..481500b8f0 100644 --- a/java/client/test/src/org/apache/qpid/jndi/referenceabletest/Lookup.java +++ b/java/client/test/src/org/apache/qpid/jndi/referenceabletest/Lookup.java @@ -17,11 +17,14 @@ */ package org.apache.qpid.jndi.referenceabletest; -import org.apache.qpid.client.AMQTopic; import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.AMQConnectionFactory; +import org.apache.qpid.client.AMQTopic; -import javax.naming.*; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import java.io.File; import java.util.Hashtable; @@ -37,6 +40,9 @@ import java.util.Hashtable; */ class Lookup { + public static final String DEFAULT_PROVIDER_FILE_PATH = System.getProperty("java.io.tmpdir") + "/JNDITest"; + public static final String PROVIDER_URL = "file://" + DEFAULT_PROVIDER_FILE_PATH; + AMQTopic _topic = null; AMQConnection _connection = null; AMQConnectionFactory _connectionFactory = null; @@ -47,7 +53,26 @@ class Lookup Hashtable env = new Hashtable(11); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory"); - env.put(Context.PROVIDER_URL, "file:/temp/qpid-jndi-test"); + env.put(Context.PROVIDER_URL, PROVIDER_URL); + + File file = new File(PROVIDER_URL.substring(PROVIDER_URL.indexOf("://") + 3)); + + if (file.exists() && !file.isDirectory()) + { + System.out.println("Couldn't make directory file already exists"); + return; + } + else + { + if (!file.exists()) + { + if (!file.mkdirs()) + { + System.out.println("Couldn't make directory"); + return; + } + } + } try { @@ -70,10 +95,9 @@ class Lookup } } - public String connectionFactoryValue() { - return ((AMQConnection) _connectionFactory.getConnectionURL()).toURL(); + return _connectionFactory.getConnectionURL().toString(); } public String connectionValue() @@ -86,7 +110,6 @@ class Lookup return _topic.toURL(); } - public static void main(String[] args) { new Lookup(); diff --git a/java/client/test/src/org/apache/qpid/jndi/referenceabletest/Unbind.java b/java/client/test/src/org/apache/qpid/jndi/referenceabletest/Unbind.java index d2787f6dd0..767f7c5737 100644 --- a/java/client/test/src/org/apache/qpid/jndi/referenceabletest/Unbind.java +++ b/java/client/test/src/org/apache/qpid/jndi/referenceabletest/Unbind.java @@ -17,7 +17,10 @@ */ package org.apache.qpid.jndi.referenceabletest; -import javax.naming.*; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NameNotFoundException; +import javax.naming.NamingException; import java.io.File; import java.util.Hashtable; @@ -33,7 +36,8 @@ import java.util.Hashtable; */ class Unbind { - + public static final String DEFAULT_PROVIDER_FILE_PATH = System.getProperty("java.io.tmpdir") + "/JNDITest"; + public static final String PROVIDER_URL = "file://" + DEFAULT_PROVIDER_FILE_PATH; boolean _unbound = false; @@ -49,7 +53,26 @@ class Unbind Hashtable env = new Hashtable(11); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory"); - env.put(Context.PROVIDER_URL, "file:/temp/qpid-jndi-test"); + env.put(Context.PROVIDER_URL, PROVIDER_URL); + + File file = new File(PROVIDER_URL.substring(PROVIDER_URL.indexOf("://") + 3)); + + if (file.exists() && !file.isDirectory()) + { + System.out.println("Couldn't make directory file already exists"); + return; + } + else + { + if (!file.exists()) + { + if (!file.mkdirs()) + { + System.out.println("Couldn't make directory"); + return; + } + } + } try { |