From fb4a1075356ab69a857afdcd4662bc5a0bae7b23 Mon Sep 17 00:00:00 2001 From: "Weston M. Price" Date: Sun, 13 May 2012 10:27:23 +0000 Subject: QPID-3994: add support for optionally retrieving FindBugs using Ivy git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1337829 13f79535-47bb-0310-9956-ffa450edef68 --- .../PropertiesFileInitialContextFactoryTest.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'java/client/src/test') diff --git a/java/client/src/test/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactoryTest.java b/java/client/src/test/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactoryTest.java index 2989970dcd..5f0fa9550f 100644 --- a/java/client/src/test/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactoryTest.java +++ b/java/client/src/test/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactoryTest.java @@ -21,6 +21,10 @@ package org.apache.qpid.jndi; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileWriter; import java.util.Properties; import javax.jms.Destination; @@ -51,7 +55,30 @@ public class PropertiesFileInitialContextFactoryTest extends TestCase ctx = new InitialContext(properties); } + public void testContextFromProviderURL() throws Exception + { + Properties properties = new Properties(); + properties.load(this.getClass().getResourceAsStream("hello.properties")); + File f = new File(System.getProperty("java.io.tmpdir") + FILE_NAME); + FileOutputStream fos = new FileOutputStream(f); + properties.store(fos, null); + + System.setProperty("java.naming.factory.initial", "org.apache.qpid.jndi.PropertiesFileInitialContextFactory"); + System.setProperty("java.naming.provider.url", "file://" + f.getCanonicalPath()); + + InitialContext context = new InitialContext(); + assertNotNull("Lookup from URI based context should not be null", context.lookup("topicExchange")); + context.close(); + + System.setProperty("java.naming.provider.url", f.getCanonicalPath()); + context = new InitialContext(); + assertNotNull("Lookup from fileName should not be null", context.lookup("qpidConnectionfactory")); + + context.close(); + f.delete(); + + } public void testQueueNamesWithTrailingSpaces() throws Exception { Queue queue = (Queue)ctx.lookup("QueueNameWithSpace"); -- cgit v1.2.1