This is an automated email from the ASF dual-hosted git repository. andy pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/jena.git
The following commit(s) were added to refs/heads/main by this push: new 23c4910a76 GH-2232: Handle drive letter in base 23c4910a76 is described below commit 23c4910a76890d55a2e46aa44ddeb7af5e360930 Author: Andy Seaborne <a...@apache.org> AuthorDate: Thu Feb 1 20:55:43 2024 +0000 GH-2232: Handle drive letter in base --- .../jena/sparql/core/assembler/DatasetAssembler.java | 4 ++++ .../test/java/org/apache/jena/riot/TestSysRIOT.java | 18 +++++++++++------- .../apache/jena/atlas/lib/TestFilenameProcessing.java | 3 ++- .../java/org/apache/jena/atlas/lib/TestIRILib.java | 3 +++ jena-core/src/main/java/org/apache/jena/irix/IRIs.java | 4 +++- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetAssembler.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetAssembler.java index db281ec028..6b35c3e0c1 100644 --- a/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetAssembler.java +++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetAssembler.java @@ -32,6 +32,10 @@ import org.apache.jena.sparql.core.DatasetGraph; public abstract class DatasetAssembler extends AssemblerBase implements Assembler { + /** @deprecated To be removed - use {@link #getGeneralType()} */ + @Deprecated + public static Resource getType() { return getGeneralType(); } + /** This is the superclass of all datasets assemblers */ public static Resource getGeneralType() { return DatasetAssemblerVocab.tDataset ; diff --git a/jena-arq/src/test/java/org/apache/jena/riot/TestSysRIOT.java b/jena-arq/src/test/java/org/apache/jena/riot/TestSysRIOT.java index 95118dc12b..69593c84ec 100644 --- a/jena-arq/src/test/java/org/apache/jena/riot/TestSysRIOT.java +++ b/jena-arq/src/test/java/org/apache/jena/riot/TestSysRIOT.java @@ -20,8 +20,6 @@ package org.apache.jena.riot; import static org.apache.jena.atlas.lib.Lib.lowercase; -import java.util.function.Predicate; - import org.apache.jena.atlas.io.IO; import org.apache.jena.base.Sys; import org.junit.Assert; @@ -43,7 +41,7 @@ public class TestSysRIOT { public void chooseBaseIRI_3() { if ( Sys.isWindows ) { if ( IO.exists("c:/") ) - testChooseBaseIRI("c:", s->lowercase(s).startsWith("file:///c:/")); + testChooseBaseIRI_windows("c:/", "file:///c:/"); } else testChooseBaseIRI("x:", "x:"); } @@ -52,14 +50,15 @@ public class TestSysRIOT { public void chooseBaseIRI_4() { if ( Sys.isWindows ) { if ( IO.exists("c:/") ) - testChooseBaseIRI("c:", s->lowercase(s).startsWith("file:///c:/")); + testChooseBaseIRI_windows("c:", "file:///c:"); } else testChooseBaseIRI("x:/", "x:/"); } @Test public void chooseBaseIRI_10() { - testChooseBaseIRI("foo", s->s.startsWith("file:///")); + String x = SysRIOT.chooseBaseIRI(null, "foo"); + Assert.assertTrue(x.startsWith("file:///")); } private void testChooseBaseIRI(String input, String expected) { @@ -67,8 +66,13 @@ public class TestSysRIOT { Assert.assertEquals(expected, x); } - private void testChooseBaseIRI(String input, Predicate<String> test) { + private void testChooseBaseIRI_windows(String input, String prefix) { String x = SysRIOT.chooseBaseIRI(null, input); - Assert.assertTrue(test.test(x)); + String x1 = lowercase(x); + boolean b = x1.startsWith(prefix); + if ( ! b ) + System.out.printf("Input: %s => (prefix(%s) A:%s)=\n", input, prefix, x1); + // drive letters can be uppercase. + Assert.assertTrue(x1.startsWith(prefix)); } } diff --git a/jena-base/src/test/java/org/apache/jena/atlas/lib/TestFilenameProcessing.java b/jena-base/src/test/java/org/apache/jena/atlas/lib/TestFilenameProcessing.java index b83846c63d..4476104ec1 100644 --- a/jena-base/src/test/java/org/apache/jena/atlas/lib/TestFilenameProcessing.java +++ b/jena-base/src/test/java/org/apache/jena/atlas/lib/TestFilenameProcessing.java @@ -26,6 +26,7 @@ import static org.junit.Assert.assertTrue; import java.io.File ; import java.nio.file.Path; +import org.apache.jena.base.Sys; import org.junit.Test ; public class TestFilenameProcessing @@ -37,7 +38,7 @@ public class TestFilenameProcessing // ---- Main tests. // Portablility - static boolean isWindows = File.separatorChar != '/' ; + static boolean isWindows = Sys.isWindows; private static String cwd = Path.of(".").toAbsolutePath().normalize().toString() ; // Sort out cwd, not using the IRILib code. diff --git a/jena-base/src/test/java/org/apache/jena/atlas/lib/TestIRILib.java b/jena-base/src/test/java/org/apache/jena/atlas/lib/TestIRILib.java index ee72e46e51..dc260cd9c6 100644 --- a/jena-base/src/test/java/org/apache/jena/atlas/lib/TestIRILib.java +++ b/jena-base/src/test/java/org/apache/jena/atlas/lib/TestIRILib.java @@ -22,6 +22,9 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; +/* + * @see TestFilenameProcessing + */ public class TestIRILib { @Test public void encodeDecode01() { encodeDecode("", ""); } diff --git a/jena-core/src/main/java/org/apache/jena/irix/IRIs.java b/jena-core/src/main/java/org/apache/jena/irix/IRIs.java index 38149142b3..b9890e41da 100644 --- a/jena-core/src/main/java/org/apache/jena/irix/IRIs.java +++ b/jena-core/src/main/java/org/apache/jena/irix/IRIs.java @@ -84,8 +84,10 @@ public class IRIs { String scheme = scheme(uriForBase); if ( Sys.isWindows ) { // Assume a scheme of one letter is a Windows drive letter. - if ( scheme != null && scheme.length() == 1 ) + if ( scheme != null && scheme.length() == 1 ) { scheme = "file"; + uriForBase = "file:/"+uriForBase; + } } if ( scheme == null ) { // Relative name: it the base is a file: URI, encode the relative