You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2018/01/15 11:48:09 UTC
[04/10] jena git commit: N3IRIResolver for jena-core test support
only.
N3IRIResolver for jena-core test support only.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/35a5cc92
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/35a5cc92
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/35a5cc92
Branch: refs/heads/master
Commit: 35a5cc927222ea69d827633e13dd9065676558eb
Parents: a8c99ff
Author: Andy Seaborne <an...@apache.org>
Authored: Sat Jan 13 17:17:22 2018 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Jan 13 17:17:22 2018 +0000
----------------------------------------------------------------------
.../java/org/apache/jena/n3/N3IRIResolver.java | 34 +++++++++++++++++---
.../java/org/apache/jena/n3/TestResolver.java | 7 ++--
2 files changed, 34 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/35a5cc92/jena-core/src/main/java/org/apache/jena/n3/N3IRIResolver.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/n3/N3IRIResolver.java b/jena-core/src/main/java/org/apache/jena/n3/N3IRIResolver.java
index f8ba6de..2084604 100644
--- a/jena-core/src/main/java/org/apache/jena/n3/N3IRIResolver.java
+++ b/jena-core/src/main/java/org/apache/jena/n3/N3IRIResolver.java
@@ -19,19 +19,25 @@
package org.apache.jena.n3;
+import java.io.File;
+
import org.apache.jena.iri.IRI;
import org.apache.jena.iri.IRIException;
import org.apache.jena.iri.IRIFactory;
-import org.apache.jena.util.FileUtils ;
+import org.apache.jena.iri.ViolationCodes;
/** A simple class to access IRI resolution.
+ *
* Replaced by {@code org.apache.jena.riot.system.IRIResolver}
+ *
+ * Only exists for jena-core tests
*/
@Deprecated
public class N3IRIResolver {
/**
* The current working directory, as a string.
+ * Ends in "/".
*/
static private String globalBase = "http://localhost/LocalHostBase/" ;
@@ -39,9 +45,24 @@ public class N3IRIResolver {
// Security (e.g. Tomcat) may prevent this in which case we
// use a common default set above.
static {
- try { globalBase = FileUtils.toURL("."); }
- catch (Throwable th) { }
+ try { globalBase = cwdURL(); }
+ catch (Throwable th) {}
}
+
+ /** The current directory as a "file:" URL */
+ private static String cwdURL()
+ {
+ /**
+ * Convert a File, note java.net.URI does the right thing.
+ * viz:
+ * Convert to absolute path.
+ * Convert all % to %25.
+ * then convert all ' ' to %20.
+ * It quite probably does more e.g. ? #
+ * But has one /, not three, at beginning
+ */
+ return "file://" + new File("").toURI().toString().substring(5);
+ }
/**
* The current working directory, as an IRI.
@@ -51,9 +72,12 @@ public class N3IRIResolver {
/**
* An IRIFactory appropriately configuired.
*/
- static final IRIFactory factory = new IRIFactory(IRIFactory
- .jenaImplementation());
+ static final IRIFactory factory = new IRIFactory(IRIFactory.jenaImplementation());
static {
+ factory.shouldViolation(false,false);
+ factory.securityViolation(false,false);
+ factory.setIsWarning(ViolationCodes.UNREGISTERED_IANA_SCHEME, false);
+ factory.setIsError(ViolationCodes.UNREGISTERED_IANA_SCHEME, false);
factory.setSameSchemeRelativeReferences("file");
}
http://git-wip-us.apache.org/repos/asf/jena/blob/35a5cc92/jena-core/src/test/java/org/apache/jena/n3/TestResolver.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/n3/TestResolver.java b/jena-core/src/test/java/org/apache/jena/n3/TestResolver.java
index 832a4b7..1af8dc4 100644
--- a/jena-core/src/test/java/org/apache/jena/n3/TestResolver.java
+++ b/jena-core/src/test/java/org/apache/jena/n3/TestResolver.java
@@ -23,6 +23,7 @@ import junit.framework.TestSuite;
import org.apache.jena.n3.N3IRIResolver ;
import org.apache.jena.n3.JenaURIException ;
@SuppressWarnings("deprecation")
+// Tests the old N3IRIResolver which is now only used for tests.
public class TestResolver extends TestCase
{
public static TestSuite suite()
@@ -90,7 +91,8 @@ public class TestResolver extends TestCase
public void testURI_1() { execTest("", "http://example.org/", "http://example.org/"); }
public void testURI_2() { execTest("", "http://example.org/xyz_2007", "http://example.org/xyz_2007"); }
- public void testURI_3() { execTest("", "http://example.org/xyz 2007", "http://example.org/xyz 2007"); }
+ // RDF URI References - space in URI. Not IRIs.
+ //public void testURI_3() { execTest("", "http://example.org/xyz 2007", "http://example.org/xyz 2007"); }
public void testURI_4() { execTest("", "http://example.org/xyz__2007", "http://example.org/xyz__2007"); }
public void testURI_5() { execTest("", "http://example.org/xyz__abc", "http://example.org/xyz__abc"); }
@@ -222,7 +224,8 @@ public class TestResolver extends TestCase
public void testURI_file_7() { execTestMatch("file:foo", "file:xyz", "^file:///.*foo$") ; }
- public void testURI_file_8() { execTestMatch("file:foo", "file:a b", "^file:///.*foo$") ; }
+ // RDF URI References - space in URI. Not IRIs.
+ //public void testURI_file_8() { execTestMatch("file:foo", "file:a b", "^file:///.*foo$") ; }
// File URLs - test aren't exact as the depend where they are run.