Repository: jena Updated Branches: refs/heads/master 8ddef8a52 -> 6f70ddbce
JENA-908: Move cyclic print tests to new writer.TestTurtleWriter Project: http://git-wip-us.apache.org/repos/asf/jena/repo Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/6f70ddbc Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/6f70ddbc Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/6f70ddbc Branch: refs/heads/master Commit: 6f70ddbceb00dafa86aea3c54b5c518ece4e129c Parents: 8ddef8a Author: Andy Seaborne <[email protected]> Authored: Tue Mar 31 15:21:44 2015 +0100 Committer: Andy Seaborne <[email protected]> Committed: Tue Mar 31 15:21:44 2015 +0100 ---------------------------------------------------------------------- .../apache/jena/riot/lang/TestLangTurtle.java | 86 +------------------- .../apache/jena/riot/writer/TS_RiotWriter.java | 1 + .../jena/riot/writer/TestTurtleWriter.java | 79 ++++++++++++++++++ 3 files changed, 83 insertions(+), 83 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jena/blob/6f70ddbc/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 926caec..96fedef 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,17 +22,14 @@ 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 ; @@ -40,9 +37,7 @@ 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 ; @@ -241,79 +236,4 @@ 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)); - } - } http://git-wip-us.apache.org/repos/asf/jena/blob/6f70ddbc/jena-arq/src/test/java/org/apache/jena/riot/writer/TS_RiotWriter.java ---------------------------------------------------------------------- diff --git a/jena-arq/src/test/java/org/apache/jena/riot/writer/TS_RiotWriter.java b/jena-arq/src/test/java/org/apache/jena/riot/writer/TS_RiotWriter.java index 91c275f..8bbc242 100644 --- a/jena-arq/src/test/java/org/apache/jena/riot/writer/TS_RiotWriter.java +++ b/jena-arq/src/test/java/org/apache/jena/riot/writer/TS_RiotWriter.java @@ -32,6 +32,7 @@ import org.junit.runners.Suite.SuiteClasses ; , TestRiotWriterDataset.class , TestJenaWriters.class , TestRDFJSON.class + , TestTurtleWriter.class , TestTriXWriter.class }) http://git-wip-us.apache.org/repos/asf/jena/blob/6f70ddbc/jena-arq/src/test/java/org/apache/jena/riot/writer/TestTurtleWriter.java ---------------------------------------------------------------------- diff --git a/jena-arq/src/test/java/org/apache/jena/riot/writer/TestTurtleWriter.java b/jena-arq/src/test/java/org/apache/jena/riot/writer/TestTurtleWriter.java new file mode 100644 index 0000000..955d07a --- /dev/null +++ b/jena-arq/src/test/java/org/apache/jena/riot/writer/TestTurtleWriter.java @@ -0,0 +1,79 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.riot.writer; + +import java.io.ByteArrayInputStream ; +import java.io.ByteArrayOutputStream ; +import java.io.StringReader ; + +import org.apache.jena.riot.RDFDataMgr ; +import org.apache.jena.riot.RDFFormat ; +import org.apache.jena.riot.RDFLanguages ; +import org.junit.Assert ; +import org.junit.Ignore ; +import org.junit.Test ; + +import com.hp.hpl.jena.rdf.model.Model ; +import com.hp.hpl.jena.rdf.model.ModelFactory ; + +public class TestTurtleWriter { + // Tests data. + static String cycle = "_:a <urn:p> _:b . _:b <urn:q> _:a ." ; + + + /** Read in N-Triples data, which is not empty, + * then write-read-compare using the format given. + * + * @param testdata + * @param lang + */ + static void blankNodeLang(String testdata, RDFFormat lang) { + StringReader r = new StringReader(testdata) ; + Model m = ModelFactory.createDefaultModel() ; + RDFDataMgr.read(m, r, null, RDFLanguages.NTRIPLES) ; + Assert.assertTrue(m.size() > 0); + + ByteArrayOutputStream output = new ByteArrayOutputStream(); + RDFDataMgr.write(output, m, lang); + + ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray()); + Model m2 = ModelFactory.createDefaultModel(); + RDFDataMgr.read(m2, input, lang.getLang()); + + Assert.assertTrue(m2.size() > 0); + Assert.assertTrue(m.isIsomorphicWith(m2)); + } + + + @Test + @Ignore // Currently ignored due to JENA-908 + public void bnode_cycles_01() { blankNodeLang(cycle, RDFFormat.TURTLE) ; } + + @Test + public void bnode_cycles_02() { blankNodeLang(cycle, RDFFormat.TURTLE_BLOCKS) ; } + + @Test + public void bnode_cycles_03() { blankNodeLang(cycle, RDFFormat.TURTLE_FLAT) ; } + + @Test + @Ignore // Currently ignored due to JENA-908 + public void bnode_cycles_04() { blankNodeLang(cycle, RDFFormat.TURTLE_PRETTY) ; } + +} +
