jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1453497 - in /jena/branches/arq-riot-output/src: main/java/org/apache/jena/riot/stream/StreamManager.java test/java/org/apache/jena/riot/stream/TestStreamManager.java
Date Wed, 06 Mar 2013 19:22:19 GMT
Author: andy
Date: Wed Mar  6 19:22:19 2013
New Revision: 1453497

URL: http://svn.apache.org/r1453497
Log:
Fix tests

Modified:
    jena/branches/arq-riot-output/src/main/java/org/apache/jena/riot/stream/StreamManager.java
    jena/branches/arq-riot-output/src/test/java/org/apache/jena/riot/stream/TestStreamManager.java

Modified: jena/branches/arq-riot-output/src/main/java/org/apache/jena/riot/stream/StreamManager.java
URL: http://svn.apache.org/viewvc/jena/branches/arq-riot-output/src/main/java/org/apache/jena/riot/stream/StreamManager.java?rev=1453497&r1=1453496&r2=1453497&view=diff
==============================================================================
--- jena/branches/arq-riot-output/src/main/java/org/apache/jena/riot/stream/StreamManager.java
(original)
+++ jena/branches/arq-riot-output/src/main/java/org/apache/jena/riot/stream/StreamManager.java
Wed Mar  6 19:22:19 2013
@@ -45,6 +45,8 @@ public class StreamManager
     
     private static StreamManager globalStreamManager ;
     
+    public StreamManager() {}
+    
     /** Return a default configuration StreamManager 
      *  with a {@link LocatorFile}, 
      *  {@link LocatorURL},

Modified: jena/branches/arq-riot-output/src/test/java/org/apache/jena/riot/stream/TestStreamManager.java
URL: http://svn.apache.org/viewvc/jena/branches/arq-riot-output/src/test/java/org/apache/jena/riot/stream/TestStreamManager.java?rev=1453497&r1=1453496&r2=1453497&view=diff
==============================================================================
--- jena/branches/arq-riot-output/src/test/java/org/apache/jena/riot/stream/TestStreamManager.java
(original)
+++ jena/branches/arq-riot-output/src/test/java/org/apache/jena/riot/stream/TestStreamManager.java
Wed Mar  6 19:22:19 2013
@@ -38,75 +38,100 @@ public class TestStreamManager extends B
     private static final String directory = "testing/RIOT/StreamManager" ;
     private static final String absDirectory = new File(directory).getAbsolutePath() ;
 
-    private static Context context = new Context() ;
     
-    private static StreamManager streamMgr ;
+    
+    private static StreamManager streamMgrDir ;
+    private static StreamManager streamMgrHere ;
+    private static StreamManager streamMgrNull ;
     private static StreamManager streamMgrStd ;
-    private static Object streamManagerContextValue ;
     
     @BeforeClass static public void beforeClass()
     { 
         streamMgrStd = StreamManager.get() ;
-        streamMgr = new StreamManager() ;
-        streamMgr.addLocator(new LocatorFile()) ;
-        streamMgr.addLocator(new LocatorFile(directory)) ;
-        streamMgr.addLocator(new LocatorURL()) ;
+        streamMgrDir = new StreamManager() ;
+        // Not current directory.
+        streamMgrDir.addLocator(new LocatorFile(directory)) ;
+        streamMgrDir.addLocator(new LocatorURL()) ;
         
-        streamManagerContextValue = context.get(RDFDataMgr.streamManagerSymbol) ;
-        context.put(RDFDataMgr.streamManagerSymbol, streamMgr) ;
+        streamMgrHere = new StreamManager() ;
+        // Not current directory.
+        streamMgrHere.addLocator(new LocatorFile()) ;
+        streamMgrHere.addLocator(new LocatorURL()) ;
+        
+        streamMgrNull = new StreamManager() ;
     }
     
     @AfterClass static public void afterClass()
     { 
         StreamManager.setGlobal(streamMgrStd) ;
-        if ( streamManagerContextValue == null )
-            context.remove(RDFDataMgr.streamManagerSymbol) ;
-        else
-            context.put(RDFDataMgr.streamManagerSymbol, streamManagerContextValue) ;
     }
     
-    @Test public void fm_open_01() { open(directory+"/D.ttl", context) ; }
-    @Test public void fm_open_02() { open("D.ttl", context) ; }
+    private static Context context(StreamManager streamMgr)
+    {
+        Context context = new Context() ;
+        context.put(RDFDataMgr.streamManagerSymbol, 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_03() { open("file:"+directory+"/D.ttl", context) ; }
-    @Test public void fm_open_04() { open("file:D.ttl", context) ; }
+    @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_05() { open(absDirectory+"/D.ttl", context) ; }
-    @Test public void fm_open_06() { open("file://"+absDirectory+"/D.ttl", context) ; }
+    @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 (expected=RiotNotFoundException.class)
-    public void fm_open_10() { open("nosuchfile", null) ; }
+    public void fm_open_20()        { open(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.json") ; }
+    @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.json") ; }
 
-    @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.json") ; }
+    @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.json") ; }
     
     // TriG
     // NQuads
     
-    private static void open(String dataName, Context context)
+    private static void open(StreamManager streamMgr, String dataName, Context context)
     {
-        TypedInputStream in = 
-            ( context != null ) ?
-                 RDFDataMgr.open(dataName, context) :
-                 RDFDataMgr.open(dataName) ;
-        assertNotNull(in) ;
-        IO.close(in) ;
+        StreamManager.setGlobal(streamMgr) ;
+        try {
+            TypedInputStream in = ( context != null ) 
+                ? RDFDataMgr.open(dataName, context)
+                : RDFDataMgr.open(dataName) ;
+            assertNotNull(in) ;
+            IO.close(in) ;
+        } finally {
+            StreamManager.setGlobal(streamMgrStd) ;
+        }
     }
     
     private static void read(String dataName)
     {
-        StreamManager.setGlobal(streamMgr) ;
-        Model m = ModelFactory.createDefaultModel() ;
-        RDFDataMgr.read(m, dataName) ;
-        assertTrue(m.size() != 0 ) ;
-        StreamManager.setGlobal(streamMgrStd) ;
+        try {
+            StreamManager.setGlobal(streamMgrDir) ;
+            Model m = ModelFactory.createDefaultModel() ;
+            RDFDataMgr.read(m, dataName) ;
+            assertNotEquals("Read "+dataName, 0, m.size()) ;
+        } finally {
+            StreamManager.setGlobal(streamMgrStd) ;
+        }
     }
 }
 



Mime
View raw message