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 2020/11/24 20:18:27 UTC

[jena] branch windows-file updated (5f68697 -> 54be420)

This is an automated email from the ASF dual-hosted git repository.

andy pushed a change to branch windows-file
in repository https://gitbox.apache.org/repos/asf/jena.git.


 discard 5f68697  Investigation: Windows+file:
     new 54be420  Investigation: Windows+file:

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (5f68697)
            \
             N -- N -- N   refs/heads/windows-file (54be420)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../jena/riot/system/stream/LocatorFile.java       |  4 +-
 .../apache/jena/riot/stream/TestStreamManager.java | 71 ++++++++++++++--------
 pom.xml                                            |  7 +++
 3 files changed, 53 insertions(+), 29 deletions(-)


[jena] 01/01: Investigation: Windows+file:

Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

andy pushed a commit to branch windows-file
in repository https://gitbox.apache.org/repos/asf/jena.git

commit 54be4208385d9c51de72e6736e8ca2137415f340
Author: Andy Seaborne <an...@apache.org>
AuthorDate: Tue Nov 24 18:40:53 2020 +0000

    Investigation: Windows+file:
---
 .../jena/riot/system/stream/LocatorFile.java       |  55 ++++++----
 .../apache/jena/riot/stream/TestStreamManager.java | 111 ++++++++++++---------
 pom.xml                                            |   7 ++
 3 files changed, 108 insertions(+), 65 deletions(-)

diff --git a/jena-arq/src/main/java/org/apache/jena/riot/system/stream/LocatorFile.java b/jena-arq/src/main/java/org/apache/jena/riot/system/stream/LocatorFile.java
index 984846a..b919587 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/system/stream/LocatorFile.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/system/stream/LocatorFile.java
@@ -34,14 +34,16 @@ import org.slf4j.LoggerFactory ;
 
 /** Location files in the filing system.
  *  A FileLocator can have a "current directory" - this is separate from any
- *  location mapping (see @link{LocationMapping}) as it applies only to files.
+ *  location mapping (see {@link LocationMapper}) as it applies only to files.
  */
 
 public class LocatorFile implements Locator
 {
     // Implementation note:
-    // Java7: Path.resolve may provide an answer from the intricies of MS Windows
-    
+    // Java7: Path.resolve may provide an answer from the intricacies of MS Windows
+
+    public static boolean DEBUG = false;
+
     static Logger log = LoggerFactory.getLogger(LocatorFile.class) ;
     private final String thisDir ;
     private final String thisDirLogStr ;
@@ -50,7 +52,7 @@ public class LocatorFile implements Locator
      * Relative file names are relative to the working directory of the JVM.
      */
     public LocatorFile() { this(null) ; }
-    
+
     /** Create a LocatorFile that uses the argument as it's working directory.
      * <p>
      * The working directory should be a UNIX style file name,
@@ -58,7 +60,7 @@ public class LocatorFile implements Locator
      * <p>
      * For MS Window, if asked to {@link #open} a file name with a drive letter,
      * the code assumes it is not relative to the working directory
-     * of this {@code LocatorFile}.  
+     * of this {@code LocatorFile}.
      */
     public LocatorFile(String dir)
     {
@@ -71,27 +73,32 @@ public class LocatorFile implements Locator
         else
             thisDirLogStr = "" ;
         thisDir = dir ;
+
+        if ( DEBUG ) {
+            System.out.println("LocatorFile("+dir+") -> thisDir="+dir+"  thisDirLogStr="+thisDir);
+        }
+
     }
 
     /** Processing the filename for file: or relative filename
-     *  and return a filename suitable for file operations. 
+     *  and return a filename suitable for file operations.
      */
     public String toFileName(String filenameIRI)
     {
-        // Do not use directly : it will ignore the directory. 
+        // Do not use directly : it will ignore the directory.
         //IRILib.filenameToIRI
-        
+
         String scheme = FileUtils.getScheme(filenameIRI) ;
         String fn = filenameIRI ;
         // Windows : C:\\ is not a scheme name!
-        if ( scheme != null ) 
+        if ( scheme != null )
         {
             if ( scheme.length() == 1 )
             {
                 // Not perfect for MS Windows but if thisDir is set then
                 // the main use case is resolving relative (no drive)
                 // filenames against thisDir. Treat the presence of a
-                // drive letter as making this a JVM relative filename. 
+                // drive letter as making this a JVM relative filename.
                 return fn ;
             }
             else if ( scheme.length() > 1 )
@@ -101,14 +108,14 @@ public class LocatorFile implements Locator
                     return null ;
                 fn = IRILib.IRIToFilename(filenameIRI) ;
                 // fall through
-            } 
+            }
         }
         // fn is the file name to use.
         return absolute(fn) ;
     }
 
     /** Make a filename (no URI scheme, no windows drive) absolute if there is
-     * a setting for directory name thisDir  
+     * a setting for directory name thisDir
      */
     private String absolute(String fn)
     {
@@ -116,7 +123,7 @@ public class LocatorFile implements Locator
             fn = thisDir+File.separator+fn ;
         return fn ;
     }
-    
+
     public String getThisDir()
     {
         return thisDir ;
@@ -133,10 +140,10 @@ public class LocatorFile implements Locator
         String fn = toFileName(fileIRI) ;
         if ( fn == null )
             return false ;
-        
+
         return exists$(fn) ;
     }
-    
+
     private boolean exists$(String fn)
     {
         if ( fn.equals("-") )
@@ -144,14 +151,22 @@ public class LocatorFile implements Locator
         return new File(fn).exists() ;
     }
 
-    /** Open anything that looks a bit like a file name */ 
+    /** Open anything that looks a bit like a file name */
     @Override
     public TypedInputStream open(String filenameIRI)
     {
+        if ( LocatorFile.DEBUG ) {
+            System.out.println("> LocatiorFile.open: "+filenameIRI);
+            System.out.println("  thisDir = "+thisDir);
+            System.out.println("  thisDirLogStr = "+thisDirLogStr);
+        }
+
         String fn = toFileName(filenameIRI) ;
+        if ( LocatorFile.DEBUG )
+            System.out.println("  LocatiorFile.open#toFileName: "+fn);
         if ( fn == null )
             return null ;
-        
+
         try {
             if ( ! exists$(fn) )
             {
@@ -163,13 +178,13 @@ public class LocatorFile implements Locator
             log.warn("Security problem testing for file", e);
             return null;
         }
-        
+
         try {
             InputStream in = IO.openFileEx(fn) ;
 
             if ( StreamManager.logAllLookups && log.isTraceEnabled() )
                 log.trace("Found: "+filenameIRI+thisDirLogStr) ;
-            
+
             ContentType ct = RDFLanguages.guessContentType(filenameIRI) ;
             return new TypedInputStream(in, ct, filenameIRI) ;
         } catch (IOException ioEx)
@@ -180,7 +195,7 @@ public class LocatorFile implements Locator
             return null ;
         }
     }
-    
+
     @Override
     public String getName()
     {
diff --git a/jena-arq/src/test/java/org/apache/jena/riot/stream/TestStreamManager.java b/jena-arq/src/test/java/org/apache/jena/riot/stream/TestStreamManager.java
index e8d84a3..90e6417 100644
--- a/jena-arq/src/test/java/org/apache/jena/riot/stream/TestStreamManager.java
+++ b/jena-arq/src/test/java/org/apache/jena/riot/stream/TestStreamManager.java
@@ -36,97 +36,118 @@ import org.apache.jena.riot.system.stream.StreamManager ;
 import org.apache.jena.sparql.util.Context ;
 import org.junit.AfterClass ;
 import org.junit.BeforeClass ;
+import org.junit.FixMethodOrder;
 import org.junit.Test ;
+import org.junit.runners.MethodSorters;
 
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
 public class TestStreamManager
 {
     private static final String directory = "testing/RIOT/StreamManager" ;
     private static final String absDirectory = new File(directory).getAbsolutePath() ;
-    
+
     private static StreamManager streamMgrDir ;
     private static StreamManager streamMgrHere ;
     private static StreamManager streamMgrNull ;
     private static StreamManager streamMgrStd ;
-    
+
     @BeforeClass static public void beforeClass()
-    { 
+    {
+        boolean bool = LocatorFile.DEBUG;
+        LocatorFile.DEBUG = true;
+
         streamMgrStd = StreamManager.get() ;
         streamMgrDir = new StreamManager() ;
         // Not current directory.
         streamMgrDir.addLocator(new LocatorFile(directory)) ;
         streamMgrDir.addLocator(new LocatorHTTP()) ;
-        
+
         streamMgrHere = new StreamManager() ;
         // Not current directory.
         streamMgrHere.addLocator(new LocatorFile()) ;
         streamMgrHere.addLocator(new LocatorHTTP()) ;
-        
+
         streamMgrNull = new StreamManager() ;
+        LocatorFile.DEBUG = false;
     }
-    
+
     @AfterClass static public void afterClass()
-    { 
+    {
         StreamManager.setGlobal(streamMgrStd) ;
+        LocatorFile.DEBUG = false;
     }
-    
+
     private static Context context(StreamManager streamMgr)
     {
         Context context = new Context() ;
         context.put(SysRIOT.sysStreamManager, streamMgr) ;
         return context ;
     }
-    
-    @Test public void fm_open_01()  { open(streamMgrNull, directory+"/D.ttl", context(streamMgrHere)) ; }
-    @Test public void fm_open_02()  { open(streamMgrHere, directory+"/D.ttl", null) ; }
-    
-    @Test public void fm_open_03()  { open(streamMgrNull,  "D.ttl", context(streamMgrDir)) ; }
-    @Test public void fm_open_04()  { open(streamMgrDir, "D.ttl", null) ; }
-
-    @Test public void fm_open_05()  { open(streamMgrHere, "file:"+directory+"/D.ttl", context(streamMgrHere)) ; }
-    @Test public void fm_open_06()  { open(streamMgrHere, "file:"+directory+"/D.ttl", null) ; }
-
-    @Test public void fm_open_07()  { open(streamMgrHere, "file:D.ttl", context(streamMgrDir)) ; }
-    @Test public void fm_open_08()  { open(streamMgrDir, "file:D.ttl", null) ; }
-    
-    @Test public void fm_open_09()  { open(streamMgrHere, absDirectory+"/D.ttl", null) ; }
-    @Test public void fm_open_10()  { open(streamMgrDir,  absDirectory+"/D.ttl", null) ; }
-    @Test public void fm_open_11()  { open(streamMgrDir,  "file://"+absDirectory+"/D.ttl", null) ; }
-    @Test public void fm_open_12()  { open(streamMgrHere, "file://"+absDirectory+"/D.ttl", null) ; }
-    
+
+    @Test public void fm_open_01()  { open("fm_open_01", streamMgrNull, directory+"/D.ttl", context(streamMgrHere)) ; }
+    @Test public void fm_open_02()  { open("fm_open_02", streamMgrHere, directory+"/D.ttl", null) ; }
+
+    @Test public void fm_open_03()  { open("fm_open_03", streamMgrNull,  "D.ttl", context(streamMgrDir)) ; }
+    @Test public void fm_open_04()  { open("fm_open_04", streamMgrDir, "D.ttl", null) ; }
+
+    @Test public void fm_open_05()  { open("fm_open_05", streamMgrHere, "file:"+directory+"/D.ttl", context(streamMgrHere)) ; }
+    @Test public void fm_open_06()  { open("fm_open_06", streamMgrHere, "file:"+directory+"/D.ttl", null) ; }
+
+    @Test public void fm_open_07()  { open("fm_open_07", streamMgrHere, "file:D.ttl", context(streamMgrDir)) ; }
+    @Test public void fm_open_08()  { open("fm_open_08", streamMgrDir, "file:D.ttl", null) ; }
+
+    @Test public void fm_open_09()  { open("fm_open_09", streamMgrHere, absDirectory+"/D.ttl", null) ; }
+    @Test public void fm_open_10()  { open("fm_open_10", streamMgrDir,  absDirectory+"/D.ttl", null) ; }
+    @Test public void fm_open_11()  { open("fm_open_11", streamMgrDir,  "file://"+absDirectory+"/D.ttl", null) ; }
+    @Test public void fm_open_12()  { open("fm_open_12", streamMgrHere, "file://"+absDirectory+"/D.ttl", null) ; }
+
     @Test (expected=RiotNotFoundException.class)
-    public void fm_open_20()        { open(null, "nosuchfile", context(streamMgrDir)) ; }
+    public void fm_open_20()        { open("fm_open_20", null, "nosuchfile", context(streamMgrDir)) ; }
     @Test (expected=RiotNotFoundException.class)
-    public void fm_open_21()        { open(streamMgrHere, "nosuchfile", null) ; }
-    
-    @Test public void fm_read_01()  { read("D.nt") ; }
-    @Test public void fm_read_02()  { read("D.ttl") ; }
-    @Test public void fm_read_03()  { read("D.rdf") ; }
-    @Test public void fm_read_04()  { read("D.rj") ; }
-    @Test public void fm_read_05()  { read("D.jsonld") ; }
-
-    @Test public void fm_read_11()  { read("file:D.nt") ; }
-    @Test public void fm_read_12()  { read("file:D.ttl") ; }
-    @Test public void fm_read_13()  { read("file:D.rdf") ; }
-    @Test public void fm_read_14()  { read("file:D.rj") ; }
-    @Test public void fm_read_15()  { read("file:D.jsonld") ; }
-    
+    public void fm_open_21()        { open("fm_open_21", streamMgrHere, "nosuchfile", null) ; }
+
+//    @Test public void fm_read_01()  { read("D.nt") ; }
+//    @Test public void fm_read_02()  { read("D.ttl") ; }
+//    @Test public void fm_read_03()  { read("D.rdf") ; }
+//    @Test public void fm_read_04()  { read("D.rj") ; }
+//    @Test public void fm_read_05()  { read("D.jsonld") ; }
+//
+//    @Test public void fm_read_11()  { read("file:D.nt") ; }
+//    @Test public void fm_read_12()  { read("file:D.ttl") ; }
+//    @Test public void fm_read_13()  { read("file:D.rdf") ; }
+//    @Test public void fm_read_14()  { read("file:D.rj") ; }
+//    @Test public void fm_read_15()  { read("file:D.jsonld") ; }
+
     // TriG
     // NQuads
-    
-    private static void open(StreamManager streamMgr, String dataName, Context context)
+
+    private static void open(String testName, StreamManager streamMgr, String dataName, Context context)
     {
+
+        boolean bool = LocatorFile.DEBUG;
+        LocatorFile.DEBUG = true;
+        if ( LocatorFile.DEBUG )
+            System.out.println("Test: "+testName);
+
         StreamManager.setGlobal(streamMgr) ;
         try {
-            TypedInputStream in = ( context != null ) 
+            TypedInputStream in = ( context != null )
                 ? RDFDataMgr.open(dataName, context)
                 : RDFDataMgr.open(dataName) ;
             assertNotNull(in) ;
             IO.close(in) ;
+        } catch (Throwable th) {
+            if ( LocatorFile.DEBUG )
+                System.out.println("Test: (stack): "+testName);
+            th.printStackTrace();
         } finally {
             StreamManager.setGlobal(streamMgrStd) ;
+            if ( LocatorFile.DEBUG )
+                System.out.println();
+            LocatorFile.DEBUG = bool;
         }
     }
-    
+
     private static void read(String dataName)
     {
         try {
diff --git a/pom.xml b/pom.xml
index afd01d1..e6d3f7f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -156,6 +156,13 @@
 
   <profiles>
     <profile>
+      <id>afs</id>
+      <modules>
+        <module>jena-arq</module>
+      </modules>
+    </profile>
+
+    <profile>
       <!--
           This is the dev profile, typically used locally with 
           "mvn clean install -Pdev".