You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by rv...@apache.org on 2015/03/31 15:45:52 UTC

jena git commit: Add test cases that demonstrate Turtle output bug (JENA-908)

Repository: jena
Updated Branches:
  refs/heads/master b348d9c08 -> 8ddef8a52


Add test cases that demonstrate Turtle output bug (JENA-908)

The failing test cases are currently disabled until JENA-908 is resolved


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/8ddef8a5
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/8ddef8a5
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/8ddef8a5

Branch: refs/heads/master
Commit: 8ddef8a52f1fc6f560669aee113e78d1020f17ee
Parents: b348d9c
Author: Rob Vesse <rv...@apache.org>
Authored: Tue Mar 31 14:45:20 2015 +0100
Committer: Rob Vesse <rv...@apache.org>
Committed: Tue Mar 31 14:45:20 2015 +0100

----------------------------------------------------------------------
 .../apache/jena/riot/lang/TestLangTurtle.java   | 85 +++++++++++++++++++-
 1 file changed, 82 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/8ddef8a5/jena-arq/src/test/java/org/apache/jena/riot/lang/TestLangTurtle.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/riot/lang/TestLangTurtle.java b/jena-arq/src/test/java/org/apache/jena/riot/lang/TestLangTurtle.java
index 64f6f52..926caec 100644
--- a/jena-arq/src/test/java/org/apache/jena/riot/lang/TestLangTurtle.java
+++ b/jena-arq/src/test/java/org/apache/jena/riot/lang/TestLangTurtle.java
@@ -22,14 +22,17 @@ import static org.apache.jena.riot.system.ErrorHandlerFactory.errorHandlerNoLogg
 import static org.apache.jena.riot.system.ErrorHandlerFactory.getDefaultErrorHandler ;
 import static org.apache.jena.riot.system.ErrorHandlerFactory.setDefaultErrorHandler ;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.Reader ;
 import java.io.StringReader ;
+import java.nio.charset.Charset;
 
 import org.apache.jena.atlas.junit.BaseTest ;
 import org.apache.jena.atlas.lib.StrUtils ;
-import org.apache.jena.riot.ErrorHandlerTestLib.ErrorHandlerEx ;
-import org.apache.jena.riot.ErrorHandlerTestLib.ExFatal ;
-import org.apache.jena.riot.ErrorHandlerTestLib.ExWarning ;
+import org.apache.jena.riot.ErrorHandlerTestLib.ErrorHandlerEx;
+import org.apache.jena.riot.ErrorHandlerTestLib.ExFatal;
+import org.apache.jena.riot.ErrorHandlerTestLib.ExWarning;
 import org.apache.jena.riot.* ;
 import org.apache.jena.riot.system.ErrorHandler ;
 import org.apache.jena.riot.system.StreamRDF ;
@@ -37,7 +40,9 @@ import org.apache.jena.riot.system.StreamRDFLib ;
 import org.apache.jena.riot.tokens.Tokenizer ;
 import org.apache.jena.riot.tokens.TokenizerFactory ;
 import org.junit.AfterClass ;
+import org.junit.Assert;
 import org.junit.BeforeClass ;
+import org.junit.Ignore;
 import org.junit.Test ;
 
 import com.hp.hpl.jena.graph.Graph ;
@@ -236,5 +241,79 @@ public class TestLangTurtle extends BaseTest
 
     @Test (expected=ExWarning.class)
     public void turtle_23()     { parse("@prefix xsd:  <http://www.w3.org/2001/XMLSchema#> . <x> <p> 'number'^^xsd:byte }") ; }
+    
+    @Test
+    @Ignore // Currently ignored due to JENA-908
+    public void bnode_cycles_01() {
+        // An example graph with a simple blank node cycle that fails to be output correctly using some Turtle variants
+        Model m = RDFDataMgr.loadModel("testing/DAWG-Final/construct/data-ident.ttl");
+        Assert.assertTrue(m.size() > 0);
+        
+        ByteArrayOutputStream output = new ByteArrayOutputStream();
+        RDFDataMgr.write(output, m, Lang.TURTLE);
+        
+        ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
+        System.out.println(new String(output.toByteArray(), Charset.forName("utf-8")));
+        Model m2 = ModelFactory.createDefaultModel();
+        RDFDataMgr.read(m2, input, Lang.TURTLE);
+        Assert.assertTrue(m2.size() > 0);
+        
+        Assert.assertTrue(m.isIsomorphicWith(m2));
+    }
+    
+    @Test
+    public void bnode_cycles_02() {
+        // An example graph with a simple blank node cycle that fails to be output correctly using some Turtle variants
+        Model m = RDFDataMgr.loadModel("testing/DAWG-Final/construct/data-ident.ttl");
+        Assert.assertTrue(m.size() > 0);
+        
+        ByteArrayOutputStream output = new ByteArrayOutputStream();
+        RDFDataMgr.write(output, m, RDFFormat.TURTLE_BLOCKS);
+        
+        ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
+        System.out.println(new String(output.toByteArray(), Charset.forName("utf-8")));
+        Model m2 = ModelFactory.createDefaultModel();
+        RDFDataMgr.read(m2, input, Lang.TURTLE);
+        Assert.assertTrue(m2.size() > 0);
+        
+        Assert.assertTrue(m.isIsomorphicWith(m2));
+    }
+    
+    @Test
+    public void bnode_cycles_03() {
+        // An example graph with a simple blank node cycle that fails to be output correctly using some Turtle variants
+        Model m = RDFDataMgr.loadModel("testing/DAWG-Final/construct/data-ident.ttl");
+        Assert.assertTrue(m.size() > 0);
+        
+        ByteArrayOutputStream output = new ByteArrayOutputStream();
+        RDFDataMgr.write(output, m, RDFFormat.TURTLE_FLAT);
+        
+        ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
+        System.out.println(new String(output.toByteArray(), Charset.forName("utf-8")));
+        Model m2 = ModelFactory.createDefaultModel();
+        RDFDataMgr.read(m2, input, Lang.TURTLE);
+        Assert.assertTrue(m2.size() > 0);
+        
+        Assert.assertTrue(m.isIsomorphicWith(m2));
+    }
+    
+    @Test
+    @Ignore // Currently ignored due to JENA-908
+    public void bnode_cycles_04() {
+        // An example graph with a simple blank node cycle that fails to be output correctly using some Turtle variants
+        Model m = RDFDataMgr.loadModel("testing/DAWG-Final/construct/data-ident.ttl");
+        Assert.assertTrue(m.size() > 0);
+        
+        ByteArrayOutputStream output = new ByteArrayOutputStream();
+        RDFDataMgr.write(output, m, RDFFormat.TURTLE_PRETTY);
+        
+        ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
+        System.out.println(new String(output.toByteArray(), Charset.forName("utf-8")));
+        Model m2 = ModelFactory.createDefaultModel();
+        RDFDataMgr.read(m2, input, Lang.TURTLE);
+        Assert.assertTrue(m2.size() > 0);
+        
+        Assert.assertTrue(m.isIsomorphicWith(m2));
+    }
 
 }