From: <mar...@us...> - 2010-10-12 13:11:55
|
Revision: 3771 http://bigdata.svn.sourceforge.net/bigdata/?rev=3771&view=rev Author: martyncutcher Date: 2010-10-12 13:11:49 +0000 (Tue, 12 Oct 2010) Log Message: ----------- Fix URI encode Modified Paths: -------------- branches/JOURNAL_HA_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/rules/TestDatabaseAtOnceClosure.java Modified: branches/JOURNAL_HA_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/rules/TestDatabaseAtOnceClosure.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/rules/TestDatabaseAtOnceClosure.java 2010-10-12 12:05:26 UTC (rev 3770) +++ branches/JOURNAL_HA_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/rules/TestDatabaseAtOnceClosure.java 2010-10-12 13:11:49 UTC (rev 3771) @@ -9,6 +9,7 @@ import java.io.FileNotFoundException; import java.io.FilenameFilter; import java.io.InputStream; +import java.net.URLEncoder; import java.util.Properties; import org.openrdf.model.Statement; @@ -620,18 +621,34 @@ try { - System.out.println("looking for " + resource); - is = new FileInputStream(new File(resource)); baseURI = new File(resource).toURI().toString(); } catch (FileNotFoundException ex) { + is = getClass().getResourceAsStream(resource); + java.net.URL resourceUrl = + getClass().getResource(resource); - System.out.println("no file, retrieving from resource"); - is = getClass().getResourceAsStream(resource); - baseURI = getClass().getResource(resource).toURI() + //if the resource couldn't be found in the file system + //and couldn't be found by searching from this class' + //package (com.bigdata.rdf.rules) as root, then use + //the class loader to try searching from the root of + //the JAR itself + if (resourceUrl == null) { + is = getClass().getClassLoader().getResourceAsStream(resource); + resourceUrl = + getClass().getClassLoader().getResource(resource); + } + + if (resourceUrl == null) { + log.warn("resource not found ["+resource+"]"); + throw new Exception("FAILURE: resource not found ["+resource+"]"); + } + + // must encode before new URI() + baseURI = new java.net.URI(URLEncoder.encode( + resourceUrl.toString(), "UTF-8")) .toString(); - } if (is == null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |