diff options
author | Bhupendra Bhusman Bhardwaj <bhupendrab@apache.org> | 2007-02-02 14:26:32 +0000 |
---|---|---|
committer | Bhupendra Bhusman Bhardwaj <bhupendrab@apache.org> | 2007-02-02 14:26:32 +0000 |
commit | 6aef63d9078abd7f96b79e70ede242fa7056da37 (patch) | |
tree | 470ec5bb3e77ca6761750b7020d5990e4b4a3ee1 | |
parent | 93e7f636f8b4fb184362c145f9162afeb704d9bf (diff) | |
download | qpid-python-6aef63d9078abd7f96b79e70ede242fa7056da37.tar.gz |
QPID-84
tests for FSContextFactory deleted.fscontext.jar is not part of apache svn.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@502610 13f79535-47bb-0310-9956-ffa450edef68
5 files changed, 3 insertions, 695 deletions
diff --git a/java/client/src/old_test/java/org/apache/qpid/test/unit/jndi/PropertiesFileInitialContextFactoryTest.java b/java/client/src/old_test/java/org/apache/qpid/test/unit/jndi/PropertiesFileInitialContextFactoryTest.java index cdb00240b6..5ab5722146 100644 --- a/java/client/src/old_test/java/org/apache/qpid/test/unit/jndi/PropertiesFileInitialContextFactoryTest.java +++ b/java/client/src/old_test/java/org/apache/qpid/test/unit/jndi/PropertiesFileInitialContextFactoryTest.java @@ -123,7 +123,7 @@ public class PropertiesFileInitialContextFactoryTest extends TestCase try { AMQQueue queue = (AMQQueue) ctx.lookup("MyQueue"); - assertEquals("example.MyQueue", queue.getRoutingKey()); + assertEquals("example.MyQueue", queue.getRoutingKey().toString()); } catch (NamingException ne) { @@ -133,7 +133,7 @@ public class PropertiesFileInitialContextFactoryTest extends TestCase try { AMQTopic topic = (AMQTopic) ctx.lookup("ibmStocks"); - assertEquals("stocks.nyse.ibm", topic.getTopicName()); + assertEquals("stocks.nyse.ibm", topic.getTopicName().toString()); } catch (Exception ne) { @@ -143,7 +143,7 @@ public class PropertiesFileInitialContextFactoryTest extends TestCase try { AMQQueue direct = (AMQQueue) ctx.lookup("direct"); - assertEquals("directQueue", direct.getRoutingKey()); + assertEquals("directQueue", direct.getRoutingKey().toString()); } catch (NamingException ne) { diff --git a/java/client/src/old_test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Bind.java b/java/client/src/old_test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Bind.java deleted file mode 100644 index db871281bf..0000000000 --- a/java/client/src/old_test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Bind.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.test.unit.jndi.referenceabletest; - -import org.apache.qpid.client.AMQConnection; -import org.apache.qpid.client.AMQConnectionFactory; -import org.apache.qpid.client.AMQTopic; -import org.apache.qpid.url.URLSyntaxException; - -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; - -import junit.framework.TestCase; - -/** - * Usage: To run these you need to have the sun JNDI SPI for the FileSystem. - * This can be downloaded from sun here: - * http://java.sun.com/products/jndi/downloads/index.html - * Click : Download JNDI 1.2.1 & More button - * Download: File System Service Provider, 1.2 Beta 3 - * and add the two jars in the lib dir to your class path. - * <p/> - * Also you need to create the directory /temp/qpid-jndi-test - */ -class Bind extends TestCase -{ - public static final String DEFAULT_PROVIDER_FILE_PATH = System.getProperty("java.io.tmpdir") + "/JNDITest" + System.currentTimeMillis(); - public static final String DEFAULT_PROVIDER_URL = "file://" + DEFAULT_PROVIDER_FILE_PATH; - public String PROVIDER_URL = DEFAULT_PROVIDER_URL; - - String _connectionFactoryString = ""; - - String _connectionString = "amqp://guest:guest@clientid/testpath?brokerlist='vm://:1'"; - Topic _topic = null; - - boolean _bound = false; - - public Bind() throws NameAlreadyBoundException, NoInitialContextException - { - this(false, DEFAULT_PROVIDER_URL); - } - - public Bind(boolean output) throws NameAlreadyBoundException, NoInitialContextException - { - this(output, DEFAULT_PROVIDER_URL); - } - - public Bind(boolean output, String providerURL) throws NameAlreadyBoundException, NoInitialContextException - { - PROVIDER_URL = providerURL; - - // 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, 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; - } - } - } - - Connection connection = null; - try - { - // Create the initial context - Context ctx = new InitialContext(env); - - // Create the connection factory to be bound - ConnectionFactory connectionFactory = null; - // Create the Connection to be bound - - - try - { - connectionFactory = new AMQConnectionFactory(_connectionString); - connection = connectionFactory.createConnection(); - - _connectionFactoryString = ((AMQConnectionFactory) connectionFactory).getConnectionURL().getURL(); - } - catch (JMSException jmsqe) - { - fail("Unable to create Connection:" + jmsqe); - } - catch (URLSyntaxException urlse) - { - fail("Unable to create Connection:" + urlse); - } - - try - { - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - - _topic = session.createTopic("Fruity"); - } - catch (JMSException jmse) - { - - } - // Perform the binds - ctx.bind("ConnectionFactory", connectionFactory); - if (output) - { - System.out.println("Bound factory\n" + ((AMQConnectionFactory) connectionFactory).getConnectionURL()); - } - ctx.bind("Connection", connection); - if (output) - { - System.out.println("Bound Connection\n" + ((AMQConnection) connection).toURL()); - } - ctx.bind("Topic", _topic); - if (output) - { - System.out.println("Bound Topic:\n" + ((AMQTopic) _topic).toURL()); - } - _bound = true; - - // Check that it is bound - //Object obj = ctx.lookup("Connection"); - //System.out.println(((AMQConnection)obj).toURL()); - - // Close the context when we're done - ctx.close(); - } - catch (NamingException e) - { - System.out.println("Operation failed: " + e); - if (e instanceof NameAlreadyBoundException) - { - throw(NameAlreadyBoundException) e; - } - - if (e instanceof NoInitialContextException) - { - throw(NoInitialContextException) e; - } - } - finally - { - try - { - if (connection != null) - { - connection.close(); - } - } - catch (JMSException e) - { - //ignore just want it closed - } - } - } - - public String connectionFactoryValue() - { - if (_connectionFactoryString != null) - { - return _connectionFactoryString; - } - else - { - return ""; - } - } - - public String connectionValue() - { - if (_connectionString != null) - { - return _connectionString; - } - else - { - return ""; - } - } - - public String topicValue() - { - if (_topic != null) - { - return ((AMQTopic) _topic).toURL(); - } - else - { - return ""; - } - - } - - public boolean bound() - { - return _bound; - } - - public String getProviderURL() - { - return PROVIDER_URL; - } - - public static void main(String[] args) throws NameAlreadyBoundException, NoInitialContextException - { - new Bind(true); - } -} diff --git a/java/client/src/old_test/java/org/apache/qpid/test/unit/jndi/referenceabletest/JNDIReferenceableTest.java b/java/client/src/old_test/java/org/apache/qpid/test/unit/jndi/referenceabletest/JNDIReferenceableTest.java deleted file mode 100644 index 9fc186f19a..0000000000 --- a/java/client/src/old_test/java/org/apache/qpid/test/unit/jndi/referenceabletest/JNDIReferenceableTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.test.unit.jndi.referenceabletest; - -import junit.framework.TestCase; -//import org.apache.qpid.testutil.VMBrokerSetup; - -import javax.naming.NameAlreadyBoundException; -import javax.naming.NoInitialContextException; - -/** - * Usage: To run these you need to have the sun JNDI SPI for the FileSystem. - * This can be downloaded from sun here: - * http://java.sun.com/products/jndi/downloads/index.html - * Click : Download JNDI 1.2.1 & More button - * Download: File System Service Provider, 1.2 Beta 3 - * and add the two jars in the lib dir to your class path. - * <p/> - * Also you need to create the directory /temp/qpid-jndi-test - */ -public class JNDIReferenceableTest extends TestCase -{ -/* // FIXME FSContext has been removed from repository. This needs redone with the PropertiesFileInitialContextFactory. QPID-84 - public void testReferenceable() - { - Bind b = null; - try - { - try - { - b = new Bind(); - } - catch (NameAlreadyBoundException e) - { - if (new Unbind().unbound()) - { - try - { - b = new Bind(); - } - catch (NameAlreadyBoundException ee) - { - fail("Unable to clear bound objects for test."); - } - } - else - { - fail("Unable to clear bound objects for test."); - } - } - } - catch (NoInitialContextException e) - { - fail("You don't have the File System SPI on you class path.\n" + - "This can be downloaded from sun here:\n" + - "http://java.sun.com/products/jndi/downloads/index.html\n" + - "Click : Download JNDI 1.2.1 & More button\n" + - "Download: File System Service Provider, 1.2 Beta 3\n" + - "and add the two jars in the lib dir to your class path."); - } - - assertTrue(b.bound()); - - Lookup l = new Lookup(b.getProviderURL()); - - assertTrue(l.connectionFactoryValue().equals(b.connectionFactoryValue())); - - assertTrue(l.connectionValue().equals(b.connectionValue())); - - assertTrue(l.topicValue().equals(b.topicValue())); - - - Unbind u = new Unbind(); - - assertTrue(u.unbound()); - - } - - public static junit.framework.Test suite() - { - return new VMBrokerSetup(new junit.framework.TestSuite(JNDIReferenceableTest.class)); - } - */ -} diff --git a/java/client/src/old_test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Lookup.java b/java/client/src/old_test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Lookup.java deleted file mode 100644 index b804ccb30c..0000000000 --- a/java/client/src/old_test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Lookup.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.test.unit.jndi.referenceabletest; - -import org.apache.qpid.client.AMQConnection; -import org.apache.qpid.client.AMQConnectionFactory; -import org.apache.qpid.client.AMQTopic; - -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import javax.jms.JMSException; -import java.io.File; -import java.util.Hashtable; - - -/** - * Usage: To run these you need to have the sun JNDI SPI for the FileSystem. - * This can be downloaded from sun here: - * http://java.sun.com/products/jndi/downloads/index.html - * Click : Download JNDI 1.2.1 & More button - * Download: File System Service Provider, 1.2 Beta 3 - * and add the two jars in the lib dir to your class path. - * <p/> - * Also you need to create the directory /temp/qpid-jndi-test - */ -class Lookup -{ - public static final String DEFAULT_PROVIDER_FILE_PATH = System.getProperty("java.io.tmpdir") + "/JNDITest"; - public static final String DEFAULT_PROVIDER_URL = "file://" + DEFAULT_PROVIDER_FILE_PATH; - public String PROVIDER_URL = DEFAULT_PROVIDER_URL; - - AMQTopic _topic = null; - AMQConnection _connection = null; - AMQConnectionFactory _connectionFactory = null; - private String _connectionURL; - - - public Lookup() - { - this(DEFAULT_PROVIDER_URL); - } - - public Lookup(String providerURL) - { - - PROVIDER_URL = providerURL; - - // 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, 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 - { - // Create the initial context - Context ctx = new InitialContext(env); - - _topic = (AMQTopic) ctx.lookup("Topic"); - - _connection = (AMQConnection) ctx.lookup("Connection"); - - _connectionURL = _connection.toURL(); - - _connectionFactory = (AMQConnectionFactory) ctx.lookup("ConnectionFactory"); - //System.out.println(topic); - - // Close the context when we're done - ctx.close(); - } - catch (NamingException e) - { - System.out.println("Operation failed: " + e); - } - finally - { - try - { - if (_connection != null) - { - _connection.close(); - } - } - catch (JMSException e) - { - //ignore just need to close - } - } - } - - public String connectionFactoryValue() - { - if (_connectionFactory != null) - { - return _connectionFactory.getConnectionURL().toString(); - } - return ""; - } - - public String connectionValue() - { - if (_connectionURL != null) - { - return _connectionURL; - } - return ""; - } - - public String topicValue() - { - if (_topic != null) - { - return _topic.toURL(); - } - return ""; - } - - public String getProviderURL() - { - return PROVIDER_URL; - } - - public static void main(String[] args) - { - new Lookup(); - } -} - diff --git a/java/client/src/old_test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Unbind.java b/java/client/src/old_test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Unbind.java deleted file mode 100644 index 869bc55d8f..0000000000 --- a/java/client/src/old_test/java/org/apache/qpid/test/unit/jndi/referenceabletest/Unbind.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.test.unit.jndi.referenceabletest; - -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NameNotFoundException; -import javax.naming.NamingException; -import javax.jms.Connection; -import javax.jms.JMSException; -import java.io.File; -import java.util.Hashtable; - -/** - * Usage: To run these you need to have the sun JNDI SPI for the FileSystem. - * This can be downloaded from sun here: - * http://java.sun.com/products/jndi/downloads/index.html - * Click : Download JNDI 1.2.1 & More button - * Download: File System Service Provider, 1.2 Beta 3 - * and add the two jars in the lib dir to your class path. - * <p/> - * Also you need to create the directory /temp/qpid-jndi-test - */ -class Unbind -{ - public static final String DEFAULT_PROVIDER_FILE_PATH = System.getProperty("java.io.tmpdir") + "/JNDITest" + System.currentTimeMillis(); - public static final String DEFAULT_PROVIDER_URL = "file://" + DEFAULT_PROVIDER_FILE_PATH; - public String PROVIDER_URL = DEFAULT_PROVIDER_URL; - - boolean _unbound = false; - - public Unbind() - { - this(false, DEFAULT_PROVIDER_URL); - } - - public Unbind(Boolean output) - { - this(output, DEFAULT_PROVIDER_URL); - } - - public Unbind(String provider) - { - this(false, provider); - } - - public Unbind(boolean output, String providerURL) - { - PROVIDER_URL = providerURL; - // 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, 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 - { - // Create the initial context - Context ctx = new InitialContext(env); - - // Remove the binding - ctx.unbind("ConnectionFactory"); - ctx.unbind("Connection"); - ctx.unbind("Topic"); - - // Check that it is gone - Object obj = null; - try - { - obj = ctx.lookup("ConnectionFactory"); - } - catch (NameNotFoundException ne) - { - if (output) - { - System.out.println("unbind ConnectionFactory successful"); - } - try - { - obj = ctx.lookup("Connection"); - try - { - ((Connection) obj).close(); - } - catch (JMSException e) - { - //ignore just need to close - } - } - catch (NameNotFoundException ne2) - { - if (output) - { - System.out.println("unbind Connection successful"); - } - - try - { - obj = ctx.lookup("Topic"); - } - catch (NameNotFoundException ne3) - { - if (output) - { - System.out.println("unbind Topic successful"); - } - _unbound = true; - } - } - } - - //System.out.println("unbind failed; object still there: " + obj); - - // Close the context when we're done - - ctx.close(); - - } - catch (NamingException e) - { - System.out.println("Operation failed: " + e); - } - } - - public boolean unbound() - { - return _unbound; - } - - public static void main(String[] args) - { - - new Unbind(true); - } -} - |