You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by cl...@apache.org on 2013/12/19 00:56:45 UTC
svn commit: r1552171 [10/10] - in /jena/Experimental/new-test: .settings/
Testing/ Testing/Turtle/ Testing/Turtle/N3/ Testing/Turtle/NTriples/
Testing/Turtle/RaptorTurtle/ src/test/java/com/hp/hpl/jena/n3/
src/test/java/com/hp/hpl/jena/n3/turtle/ src/t...
Added: jena/Experimental/new-test/Testing/Turtle/TurtleTestVocab.ttl
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/Testing/Turtle/TurtleTestVocab.ttl?rev=1552171&view=auto
==============================================================================
--- jena/Experimental/new-test/Testing/Turtle/TurtleTestVocab.ttl (added)
+++ jena/Experimental/new-test/Testing/Turtle/TurtleTestVocab.ttl Wed Dec 18 23:56:42 2013
@@ -0,0 +1,54 @@
+## Vocabulary specific to Turtle tests
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix dc: <http://purl.org/dc/elements/1.1/> .
+
+@prefix : <http://jena.hpl.hp.com/2005/12/test-turtle#> .
+
+<> rdfs:comment "Vocabulary for Turtle testing" ;
+ dc:creator "Andy Seaborne" ;
+ dc:subject "" ;
+ dc:publisher "Hewlett-Packard" ;
+ dc:title "Test case vocabulary for Turtle" ;
+ dc:description "Test case vocabulary for Turtle" ;
+ dc:date "2005-12" ;
+ dc:format "RDF" ;
+ dc:identifier : ;
+ rdfs:seeAlso <http://www.dajobe.org/2004/01/turtle/>
+ .
+
+## ----------------
+## Test types
+
+:Test rdf:type rdfs:Class .
+
+# Parse the file.
+:TestSyntax rdf:type rdfs:Class ;
+ rdfs:subClassOf :Test .
+
+# Bad file.
+:TestBadSyntax rdf:type rdfs:Class ;
+ rdfs:subClassOf :Test .
+
+# Parse and check triples
+:TestInOut rdf:type rdfs:Class ;
+ rdfs:subClassOf :Test .
+
+## ----------------
+## Properties
+
+
+:input rdf:type rdf:Property ;
+ rdfs:comment "Input to a test" ;
+ rdfs:domain :Test ;
+ .
+
+:output rdf:type rdf:Property ;
+ rdfs:comment "Output of a test" ;
+ rdfs:domain :Test ;
+ .
+
+
+:inputIRI rdf:type rdf:Property ;
+ rdfs:comment "Declare a IRI for the test input" ;
+ .
Added: jena/Experimental/new-test/Testing/Turtle/build
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/Testing/Turtle/build?rev=1552171&view=auto
==============================================================================
--- jena/Experimental/new-test/Testing/Turtle/build (added)
+++ jena/Experimental/new-test/Testing/Turtle/build Wed Dec 18 23:56:42 2013
@@ -0,0 +1,31 @@
+#!/bin/bash
+# Build vocabulary
+
+function syntaxCheck
+{
+ FILE="$1"
+ echo "Syntax check: $FILE"
+ n3 -n -rdf "$FILE"
+}
+
+function proc
+{
+ TMP=TT
+ FILE="$1"
+ CLASS="$2"
+ NS="$3"
+ echo "Schemagen: $FILE"
+ schemagen --rdfs -i "$FILE" -n "$CLASS" -a "$NS" -o "$CLASS".java -e N3
+ # Add imports
+ echo "package dev.turtle.test ;" >> "$TMP"
+ echo >>"$TMP"
+ cat "$CLASS".java >> "$TMP"
+ mv "$TMP" "$CLASS".java
+}
+
+syntaxCheck TurtleTestVocab.ttl
+
+proc TurtleTestVocab.ttl TurtleTestVocab \
+ "http://jena.hpl.hp.com/2005/12/test-turtle#"
+
+echo "mv TurtleTestVocab.java ../../src-dev/dev/turtle/test/"
\ No newline at end of file
Added: jena/Experimental/new-test/Testing/Turtle/i18n.ttl
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/Testing/Turtle/i18n.ttl?rev=1552171&view=auto
==============================================================================
--- jena/Experimental/new-test/Testing/Turtle/i18n.ttl (added)
+++ jena/Experimental/new-test/Testing/Turtle/i18n.ttl Wed Dec 18 23:56:42 2013
@@ -0,0 +1,20 @@
+# $Id: kanji.ttl,v 1.5 2005/11/06 08:27:50 eric Exp $
+# See DOCUMENT INFO below.
+
+# NAMESPACES
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix owl: <http://www.w3.org/2002/07/owl#> .
+@prefix foaf: <http://xmlns.com/foaf/0.1/> .
+@prefix é£: <http://www.w3.org/2001/sw/DataAccess/tests/data/i18n/kanji.ttl#> .
+
+# DOCUMENT INFO
+<> rdfs:comment "test kanji IRIs (composed from QNames)" ;
+ owl:versionInfo "$Id: kanji.ttl,v 1.5 2005/11/06 08:27:50 eric Exp $".
+
+# DOCUMENT
+[ foaf:name "Alice" ;
+ é£:é£ã¹ã é£:ç´è± ] .
+
+[ foaf:name "Bob" ;
+ é£:é£ã¹ã é£:æµ·è ] .
+
Added: jena/Experimental/new-test/Testing/Turtle/manifest.ttl
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/Testing/Turtle/manifest.ttl?rev=1552171&view=auto
==============================================================================
--- jena/Experimental/new-test/Testing/Turtle/manifest.ttl (added)
+++ jena/Experimental/new-test/Testing/Turtle/manifest.ttl Wed Dec 18 23:56:42 2013
@@ -0,0 +1,30 @@
+# 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.
+
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> .
+@prefix mfx: <http://jena.hpl.hp.com/2005/05/test-manifest-extra#> .
+@prefix qt: <http://www.w3.org/2001/sw/DataAccess/tests/test-query#> .
+
+<> rdf:type mf:Manifest ;
+ rdfs:label "Turtle tests" ;
+ mfx:include (
+ # The RDF core tests for N-triples
+ <NTriples/manifest.ttl>
+ # The tests from dajobe
+ <RaptorTurtle/manifest-good.ttl>
+ <RaptorTurtle/manifest-bad.ttl>
+ ).
Added: jena/Experimental/new-test/Testing/Turtle/simple.ttl
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/Testing/Turtle/simple.ttl?rev=1552171&view=auto
==============================================================================
--- jena/Experimental/new-test/Testing/Turtle/simple.ttl (added)
+++ jena/Experimental/new-test/Testing/Turtle/simple.ttl Wed Dec 18 23:56:42 2013
@@ -0,0 +1,3 @@
+@prefix : <http://example/> .
+
+:s :p :o .
Added: jena/Experimental/new-test/Testing/Turtle/turtle-tests.zip
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/Testing/Turtle/turtle-tests.zip?rev=1552171&view=auto
==============================================================================
Binary file - no diff available.
Propchange: jena/Experimental/new-test/Testing/Turtle/turtle-tests.zip
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/IRIResolverTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/IRIResolverTest.java?rev=1552171&r1=1552170&r2=1552171&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/IRIResolverTest.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/IRIResolverTest.java Wed Dec 18 23:56:42 2013
@@ -20,12 +20,8 @@ package com.hp.hpl.jena.n3;
import static org.junit.Assert.*;
-import org.junit.Before;
import org.junit.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import com.hp.hpl.jena.n3.IRIResolver;
import com.hp.hpl.jena.n3.JenaURIException;
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterCommonTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterCommonTest.java?rev=1552171&r1=1552170&r2=1552171&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterCommonTest.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterCommonTest.java Wed Dec 18 23:56:42 2013
@@ -2,28 +2,8 @@ package com.hp.hpl.jena.n3;
import static org.junit.Assert.*;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.Reader;
-import java.io.StringWriter;
-import java.util.List;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
import com.hp.hpl.jena.rdf.model.AbstractRDFWriterTest;
-import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.RDFWriter;
-import com.hp.hpl.jena.shared.JenaException;
-import com.hp.hpl.jena.testing_framework.ModelHelper;
-import com.hp.hpl.jena.util.FileUtils;
public class N3JenaWriterCommonTest extends AbstractRDFWriterTest {
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterPPTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterPPTest.java?rev=1552171&r1=1552170&r2=1552171&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterPPTest.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterPPTest.java Wed Dec 18 23:56:42 2013
@@ -1,13 +1,5 @@
package com.hp.hpl.jena.n3;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.xenei.junit.contract.ContractImpl;
-import org.xenei.junit.contract.ContractSuite;
-
-import com.hp.hpl.jena.rdf.model.AbstractRDFWriterTest;
import com.hp.hpl.jena.rdf.model.RDFWriter;
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterParameterizedTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterParameterizedTest.java?rev=1552171&r1=1552170&r2=1552171&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterParameterizedTest.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterParameterizedTest.java Wed Dec 18 23:56:42 2013
@@ -2,16 +2,9 @@ package com.hp.hpl.jena.n3;
import static org.junit.Assert.*;
-import java.io.BufferedReader;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.PrintWriter;
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
@@ -25,15 +18,12 @@ import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
-import com.hp.hpl.jena.rdf.model.AbstractRDFWriterTest;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.RDFWriter;
import com.hp.hpl.jena.shared.JenaException;
-import com.hp.hpl.jena.testing_framework.ModelHelper;
-import com.hp.hpl.jena.testing_framework.TupleItem;
-import com.hp.hpl.jena.testing_framework.TupleSet;
-import com.hp.hpl.jena.util.FileUtils;
+import com.hp.hpl.jena.testing_framework.tuples.TupleItem;
+import com.hp.hpl.jena.testing_framework.tuples.TupleSet;
@RunWith( value= Parameterized.class )
public class N3JenaWriterParameterizedTest {
@@ -78,9 +68,6 @@ public class N3JenaWriterParameterizedTe
public static Collection<Object[]> data() throws Exception {
List<Object[]> retval = new ArrayList<Object[]>();
InputStream is = N3JenaWriterParameterizedTest.class.getResourceAsStream("n3-writer-tests");
- //String name = N3JenaWriterParameterizedTest.class.getCanonicalName().replaceAll("\\.", "/");
- //File baseDir = new File(name).getParentFile();
- //File testFile = findFile(baseDir, "n3-reader-tests");
TupleSet tests = null ;
Reader r = new InputStreamReader(is) ;
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterPlainTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterPlainTest.java?rev=1552171&r1=1552170&r2=1552171&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterPlainTest.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterPlainTest.java Wed Dec 18 23:56:42 2013
@@ -1,13 +1,5 @@
package com.hp.hpl.jena.n3;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.xenei.junit.contract.ContractImpl;
-import org.xenei.junit.contract.ContractSuite;
-
-import com.hp.hpl.jena.rdf.model.AbstractRDFWriterTest;
import com.hp.hpl.jena.rdf.model.RDFWriter;
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterTest.java?rev=1552171&r1=1552170&r2=1552171&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterTest.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterTest.java Wed Dec 18 23:56:42 2013
@@ -1,13 +1,5 @@
package com.hp.hpl.jena.n3;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.xenei.junit.contract.ContractImpl;
-import org.xenei.junit.contract.ContractSuite;
-
-import com.hp.hpl.jena.rdf.model.AbstractRDFWriterTest;
import com.hp.hpl.jena.rdf.model.RDFWriter;
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterTriplesTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterTriplesTest.java?rev=1552171&r1=1552170&r2=1552171&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterTriplesTest.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3JenaWriterTriplesTest.java Wed Dec 18 23:56:42 2013
@@ -2,12 +2,6 @@ package com.hp.hpl.jena.n3;
import static org.junit.Assert.assertTrue;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.xenei.junit.contract.ContractImpl;
-import org.xenei.junit.contract.ContractSuite;
-
-import com.hp.hpl.jena.rdf.model.AbstractRDFWriterTest;
import com.hp.hpl.jena.rdf.model.RDFWriter;
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3TurtleJenaWriterTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3TurtleJenaWriterTest.java?rev=1552171&r1=1552170&r2=1552171&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3TurtleJenaWriterTest.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/N3TurtleJenaWriterTest.java Wed Dec 18 23:56:42 2013
@@ -1,13 +1,5 @@
package com.hp.hpl.jena.n3;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.xenei.junit.contract.ContractImpl;
-import org.xenei.junit.contract.ContractSuite;
-
-import com.hp.hpl.jena.rdf.model.AbstractRDFWriterTest;
import com.hp.hpl.jena.rdf.model.RDFWriter;
Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleParserTests.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleParserTests.java?rev=1552171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleParserTests.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleParserTests.java Wed Dec 18 23:56:42 2013
@@ -0,0 +1,336 @@
+/*
+ * 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 com.hp.hpl.jena.n3.turtle;
+
+import static org.junit.Assert.*;
+
+import java.io.StringReader;
+
+import org.junit.Test;
+
+import com.hp.hpl.jena.n3.turtle.TurtleEventNull;
+import com.hp.hpl.jena.n3.turtle.parser.ParseException;
+import com.hp.hpl.jena.n3.turtle.parser.TurtleParser;
+
+public class TurtleParserTests
+{
+
+ static public final String QUOTE3 = "\"\"\"" ;
+ static public boolean VERBOSE = false ;
+
+ public TurtleParserTests()
+ {
+ }
+
+
+ // ---- Debug testing
+ //runTest( "<thing> b:px.b:py [] . " ) ;
+ // if ( true ) return ;
+ // ---- Debug testing
+
+ // Make sure basic things, at least, parse.
+
+ // URIs, qnames, statements, prefixes
+
+ // End of statement (and whitespace)
+
+
+ @Test
+ public void testPrefix() {
+ runTest( "@prefix start: <somewhere>." ) ;
+ }
+
+ @Test
+ public void testXML() {
+ runTest( "<http://here/subj> <http://here/prep> <http://here/obj>." ) ;
+ }
+
+ @Test
+ public void testWhiteSpace()
+ {
+ runTest( "a:subj a:prop a:d ." ) ;
+ runTest( "a:subj a:prop a:d . " ) ;
+ runTest( "a:subj a:prop a:d." ) ;
+ runTest( "a:subj a:prop a:d. " ) ;
+ // Whitespace, comments
+ runTest( "a:subj\ta:prop\ta:d.\t" ) ;
+ runTest( " a:subj\ta:prop\ta:d. " ) ;
+ runTest( "a:subj a:prop a:d. " ) ;
+ }
+
+ @Test
+ public void testEmpty()
+ {
+ runTest("") ;
+ }
+
+ @Test
+ public void testComment()
+ {
+ runTest( " #Comment" ) ;
+ runTest( "a:subj a:prop a:d. # Comment" ) ;
+ runTest( "a:subj a:prop a:d.# Comment" ) ;
+ }
+
+ @Test
+ public void testLiteralStrings()
+ {
+ // Literal: strings
+ runTest( "a:subj a:prop 'string1'." ) ;
+ runTest( "a:subj a:prop \"string2\"." ) ;
+ runTest( "a:subj a:prop '''string3'''." ) ;
+ runTest( "a:subj a:prop "+QUOTE3+"string3"+QUOTE3+"." ) ;
+
+ // Language tags
+ runTest( "a:subj a:prop 'text'@en ." ) ;
+ }
+
+ @Test
+ public void testLiteralDatatypes()
+ {
+ // Literals: datatypes
+ runTest( "a:subj a:prop 'string1'^^x:dt." ) ;
+ runTest( "a:subj a:prop 'string1'^^<uriref>." ) ;
+
+ runTest( "a:subj a:prop '123'^^xsd:integer ." ) ;
+ runTest( "a:subj a:prop '123'^^<uri> ." ) ;
+ runTest( "a:subj a:prop '<tag>text</tag>'^^rdf:XMLLiteral ." ) ;
+ }
+
+ @Test
+ public void testLiteralNumbers()
+ {
+
+ // Literals: numbers.
+ runTest( "a: :p 2. ." ) ;
+ runTest( "a: :p +2. ." ) ;
+ runTest( "a: :p -2 ." ) ;
+ runTest( "a: :p 2e6." ) ;
+ runTest( "a: :p 2e-6." ) ;
+ runTest( "a: :p -2e-6." ) ;
+ runTest( "a: :p 2.0e-6." ) ;
+ runTest( "a: :p 2.0 ." ) ;
+
+ runTest( "a:subj a:prop 123 ." ) ;
+ // runTest( "a:subj a:prop 123." ) ; Illegal N3
+ runTest( "a:subj a:prop 123.1 ." ) ;
+ runTest( "a:subj a:prop -123.1 ." ) ;
+ runTest( "a:subj a:prop 123.1e3 ." ) ;
+ runTest( "a:subj a:prop 123.1e-3 ." ) ;
+ runTest( "a:subj a:prop 123.1E3 ." ) ;
+ runTest( "a:subj a:prop 123.1E-3 ." ) ;
+ }
+// // The "unusual" cases
+// runTest( "a:subj 'prop'^^<uriref> 'string'." ) ;
+// runTest( "a:subj a:prop 'string1'^^'stringDT'." ) ;
+//
+// runTest( "a:subj a:prop1 ?x ^^ x:dt." ) ;
+// runTest( "a:subj a:prop2 ?x ^^ ?x." ) ;
+
+ @Test
+ public void testQuotesInStrings()
+ {
+
+ // Quotes in string
+ runTest( "a:subj a:prop \"\\'string2\\'\"." ) ;
+ runTest( "a:subj a:prop \"\\\"string2\\\"\"." ) ;
+ runTest( "a:subj a:prop '\\'string1\\'\'." ) ;
+ runTest( "a:subj a:prop '\\\"string1\\\"\'." ) ;
+
+ runTest( "a:q21 a:prop "+QUOTE3+"start\"finish"+QUOTE3+"." ) ;
+ runTest( "a:q22 a:prop "+QUOTE3+"start\"\"finish"+QUOTE3+"." ) ;
+ runTest( "a:q2e3 a:prop "+QUOTE3+"start\\\"\\\"\\\"finish"+QUOTE3+"." ) ;
+ runTest( "a:q13 a:prop "+QUOTE3+"start'''finish"+QUOTE3+"." ) ;
+
+ runTest( "a:q11 a:prop '''start'finish'''." ) ;
+ runTest( "a:q12 a:prop '''start''finish'''." ) ;
+ runTest( "a:q12 a:prop '''start\\'\\'\\'finish'''." ) ;
+ runTest( "a:q23 a:prop '''start\"\"\"finish'''." ) ;
+ }
+ // Keywords and syntactic sugar
+// runTest( "this a:prop x:y ." ) ;
+// runTest( "a:subj a x:y ." ) ;
+// runTest( "a:subj = x:y ." ) ;
+// runTest( "a:subj => x:y ." ) ;
+// runTest( "a:subj <= x:y ." ) ;
+// // <=> is not legal : it would mean "implies and is implied by"
+// // runTest( "a:subj <=> x:y ." ) ;
+// runTest( "a:subj >- x:y -> 'value' ." ) ;
+// runTest( "a:subj >- x:y -> 'value1', 'value2' ." ) ;
+
+ @Test
+ public void testKeywordsInNonKeywordPosition()
+ {
+ // Not keywords
+ runTest( "a:subj <a> x:y ." ) ;
+ runTest( "<this> a x:y ." ) ;
+ runTest( "@prefix has: <uri>." ) ;
+
+ runTest( "<> a:prop x:y ." ) ;
+ runTest( "<#> a:prop x:y ." ) ;
+ }
+
+ @Test
+ public void testObjectLists()
+ {
+ // Object lists
+ runTest( "a:subj a:prop a:d, a:e." ) ;
+ runTest( "a:subj a:prop a:d, '123'." ) ;
+ runTest( "a:subj a:prop '123', a:e." ) ;
+ //runTest( "a:subj a:prop '123', ." ) ; // Null object list
+ //runTest( "a:subj a:prop '123', '456', ." ) ; // Null object list
+ }
+
+
+ @Test
+ public void testPropertyLists()
+ {
+ // Property lists
+ runTest( "a:subj a:p1 a:v1 ; a:p2 a:v2 ." ) ;
+ runTest( "a:subj a:p1 a:v1, a:v2 ; a:p2 a:v2 ; a:p3 'v4' ,'v5' ." ) ;
+ runTest( "a:subj a:p1 a:v1; ." ) ; // Null property list
+ runTest( "a:subj a:p1 a:v1; a:p2 a:v2; ." ) ; // Null property list
+ }
+ @Test
+ public void testAnonymousNodes()
+ {
+ runTest( "rdf: rdf:type :_." ) ;
+
+ // anon nodes
+ runTest( "[a:prop a:val]." ) ;
+ runTest( "[] a:prop a:val." ) ;
+ runTest( "[] a:prop []." ) ;
+ }
+ // formulae
+ // The final dot (statement terminator of outer statement) is necessary
+ // Inside formulae, it is not.
+// runTest( "{:x :y :z} => {:x :y :z}." ) ;
+// runTest( "{:x :y :z} => {:x :y :z . }." ) ;
+// runTest( "{:x :y :z. } => {:x :y :z}." ) ;
+
+ // Variables
+// runTest( "?who ?knows ?what ." ) ;
+// runTest(("{?who ?knows ?what} => {'somesort' 'of' 'logic'}." )) ;
+
+ // Formulae do not need the trailing '.'
+// runTest( "{ this a \"string2\". } => { this a 'string1'} ." ) ;
+
+ // And they can have directives in.
+// runTest( "{ @prefix : <a> } => { this a 'string1'} ." ) ;
+// runTest( "{ @prefix : <a> . a:x <b> 'c'} => { this a 'string1'} ." ) ;
+
+ @Test
+ public void testRDFCollections()
+ {
+ // RDF collections
+ //runTest( "() ." ) ;
+ runTest( "<here> <list> ()." ) ;
+ runTest( " ( a:i1 a:i2 a:i3 ) a rdf:List." ) ;
+ }
+ // Paths
+// runTest( ":x!:y <prop> []." ) ;
+// runTest( ":x!:y!:z <prop> []." ) ;
+// runTest( ":x^:y <prop> []." ) ;
+// runTest( ":x^:y^:z <prop> []." ) ;
+// runTest( "[] <prop> :x!:y^:z." ) ;
+// runTest( "[] :x^:y!:z []." ) ;
+
+ // Paths - using . (dot)
+// runTest( ":x.:y <prop> []." ) ;
+// runTest( ":x.:y.:z <prop> []." ) ;
+// runTest( "[] <prop> :a.:c." ) ;
+// runTest( "<thing>.:y <prop> []." ) ;
+// runTest( "x:x.<thing>.:y <prop> []." ) ;
+// runTest( "<thing>.:y^:z <prop> []." ) ;
+// runTest( ":y.<thing>.:z <prop> []." ) ;
+// runTest( "<thing> :px.:py.:pz [] . " ) ;
+// runTest( "<thing> :px!:py!:pz [] . " ) ;
+
+ // Paths and formulae
+// runTest( "{ :a.:b.:c . }." ) ;
+// runTest( "{ :a.:b.<c>.}." ) ;
+
+ // Named things
+// runTest( "_:anon :- [a:p a:v] ." ) ;
+// runTest( "<uri> :- [a:p [ a:p a:v] ] ." ) ;
+// // Named list: Not supported by cwm (as of 2001, 2002, 2003/09) but needed for printing shared
+// runTest( "_:anon :- (\"1\") ." ) ;
+// // Named formulae: Not supported by cwm (as of 2001, 2002, 2003/09)
+// runTest( "_:anon :- { ?a ?b ?c } ." ) ;
+
+ // Datatypes
+
+
+ // Numbers
+
+
+
+ // Illegal in N-Triples
+ //runTest( "a:subj a:prop 'text'^^a:lang@en ." ) ;
+ //runTest( "a:subj a:prop 'text'@en^^a:lang ." ) ; // Can't have both
+
+ @Test
+ public void testXMLLiteral()
+ {
+ // XML Literal
+ runTest( "a:subj a:prop '<tag>text</tag>'^^rdf:XMLLiteral ." ) ; // Can't have both
+// runTest( "a:subj a:prop '<tag>text</tag>'^^rdf:XMLLiteral@fr ." ) ;
+ }
+ //runTest( "a:subj a:prop ?x^^xsd:integer ." ) ; // No varibales
+ //runTest( "a:subj a:prop '123'^^?x ." ) ;
+ //runTest( "a:subj a:prop ?x^^?y ." ) ;
+
+ @Test
+ public void testUnicode()
+ {
+ // Unicode 00E9 is e-acute
+ // Unicode 03B1 is alpha
+ runTest( "a:subj a:prop '\u00E9'." ) ;
+ runTest( "a:subj a:prop '\u003B1'." ) ;
+
+ runTest( "\u00E9:subj a:prop '\u00E9'." ) ;
+ runTest( "a:subj-\u00E9 a:prop '\u00E9'." ) ;
+
+ runTest( "\u03B1:subj a:prop '\u03B1'." ) ;
+ runTest("a:subj-\u03B1 a:prop '\u03B1'.") ;
+ }
+
+
+ protected void runTest( String testString )
+ {
+ TurtleParser parser = new TurtleParser(new StringReader(testString)) ;
+ parser.setEventHandler(new TurtleEventNull()) ;
+ parser.getPrefixMapping().setNsPrefix("a", "http://host/a#") ;
+ parser.getPrefixMapping().setNsPrefix("x", "http://host/a#") ;
+ // Unicode 00E9 is e-acute
+ // Unicode 03B1 is alpha
+ parser.getPrefixMapping().setNsPrefix("\u00E9", "http://host/e-acute/") ;
+ parser.getPrefixMapping().setNsPrefix("\u03B1", "http://host/alpha/") ;
+ parser.getPrefixMapping().setNsPrefix("", "http://host/") ;
+ parser.getPrefixMapping().setNsPrefix("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#") ;
+ parser.getPrefixMapping().setNsPrefix("xsd", "http://www.w3.org/2001/XMLSchema#") ;
+ parser.setBaseURI("http://base/") ;
+ try {
+ parser.parse() ;
+ } catch (ParseException e) {
+ fail( String.format( "Error parsing: `%s` [%s]", testString, e.getMessage()));
+ }
+ }
+
+}
Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleParserTests.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleReaderTests.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleReaderTests.java?rev=1552171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleReaderTests.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleReaderTests.java Wed Dec 18 23:56:42 2013
@@ -0,0 +1,70 @@
+/*
+ * 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 com.hp.hpl.jena.n3.turtle;
+
+import static org.junit.Assert.*;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URL;
+
+import org.junit.Test;
+
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.rdf.model.RDFReader;
+
+
+public class TurtleReaderTests
+{
+ private URL getURL( String name ) throws FileNotFoundException
+ {
+ URL url = TurtleReaderTests.class.getResource(name );
+ if (url == null)
+ {
+ throw new FileNotFoundException( name );
+ }
+ return url;
+ }
+
+ @Test
+ public void test0()
+ {
+ RDFReader r = ModelFactory.createDefaultModel().getReader("Turtle") ;
+ assertNotNull(r) ;
+ }
+
+ @Test
+ public void test1() throws IOException
+ {
+ Model m = ModelFactory.createDefaultModel() ;
+ URL url = getURL("simple.ttl");
+ m.read(url.openStream(), url.toExternalForm(), "TTL") ;
+ assertFalse(m.isEmpty()) ;
+ }
+
+ @Test
+ public void test2() throws IOException
+ {
+ Model m = ModelFactory.createDefaultModel() ;
+ URL url = getURL("i18n.ttl");
+ m.read(url.openStream(), url.toExternalForm(), "TTL") ;
+ assertFalse(m.isEmpty()) ;
+ }
+}
Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleReaderTests.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleTestSuite.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleTestSuite.java?rev=1552171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleTestSuite.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleTestSuite.java Wed Dec 18 23:56:42 2013
@@ -0,0 +1,147 @@
+/*
+ * 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 com.hp.hpl.jena.n3.turtle;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.List;
+
+import org.junit.internal.runners.ErrorReportingRunner;
+import org.junit.runner.RunWith;
+import org.junit.runner.Runner;
+import org.junit.runners.model.InitializationError;
+
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.rdf.model.RDFReader;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.util.FileManager;
+import com.hp.hpl.jena.util.FileUtils;
+import com.hp.hpl.jena.vocabulary.RDF;
+import com.hp.hpl.jena.testing_framework.manifest.Manifest;
+import com.hp.hpl.jena.testing_framework.manifest.ManifestException;
+import com.hp.hpl.jena.testing_framework.manifest.ManifestItem;
+import com.hp.hpl.jena.testing_framework.manifest.ManifestSuite;
+import com.hp.hpl.jena.testing_framework.manifest.ManifestItemHandler;
+import com.hp.hpl.jena.testing_framework.manifest.ManifestFile;
+import com.hp.hpl.jena.testing_framework.manifest.ManifestTestRunner;
+import com.hp.hpl.jena.testing_framework.manifest.ManifestTest;
+
+@RunWith(ManifestSuite.class)
+@ManifestFile(value = "Testing/Turtle/manifest.ttl")
+public class TurtleTestSuite implements ManifestItemHandler {
+ private List<Runner> runners;
+
+ @Override
+ public void processManifestItem(ManifestItem manifestItem) {
+
+ Resource r = manifestItem.getType();
+ ManifestTestRunner mt = null;
+ Class<? extends ManifestTest> cls = null;
+
+ if (r.equals(TurtleTestVocab.TestInOut)) {
+ cls = TestTurtle.class;
+ }
+ if (r.equals(TurtleTestVocab.TestSyntax)) {
+ cls = TestSyntax.class;
+ }
+ if (r.equals(TurtleTestVocab.TestBadSyntax)) {
+ cls = TestBadSyntax.class;
+ }
+
+ if (cls != null) {
+ try {
+ runners.add(new ManifestTestRunner(manifestItem, cls));
+ } catch (InitializationError e) {
+ runners.add( new ErrorReportingRunner( cls, e ) );
+ }
+ } else {
+ runners.add( new ErrorReportingRunner( this.getClass(),
+ new ManifestException( "Unrecognized test : "
+ + manifestItem.getTestName())) );
+ }
+
+
+ }
+
+ @Override
+ public void setTestRunnerList(List<Runner> runners) {
+ this.runners = runners;
+ }
+
+ public static class TestTurtle extends ManifestTest
+ {
+ @Override
+ public void runTest()
+ {
+ Model model = ModelFactory.createDefaultModel() ;
+ RDFReader t = new TurtleReader() ;
+ try {
+ if ( manifestItem.getUriString() != null )
+ t.read(model, FileManager.get().open(manifestItem.getInput().getURI()), manifestItem.getUriString()) ;
+ else
+ t.read(model, manifestItem.getInput().getURI()) ;
+ // "http://www.w3.org/2001/sw/DataAccess/df1/tests/rdfq-results.ttl"
+
+ String syntax = FileUtils.guessLang(manifestItem.getOutput().getURI(), FileUtils.langNTriple) ;
+
+ Model results = FileManager.get().loadModel(manifestItem.getOutput().getURI(), syntax);
+ boolean b = model.isIsomorphicWith(results) ;
+ if ( !b )
+ assertTrue("Models not isomorphic", b) ;
+ } catch (TurtleParseException ex)
+ {
+ throw ex ;
+ }
+ }
+
+ }
+
+ public static class TestSyntax extends ManifestTest
+ {
+ @Override
+ public void runTest()
+ {
+ Model model = ModelFactory.createDefaultModel() ;
+ RDFReader t = new TurtleReader() ;
+ t.read(model, manifestItem.getInput().getURI()) ;
+ }
+ }
+
+ public static class TestBadSyntax extends ManifestTest
+ {
+ @Override
+ public void runTest()
+ {
+ Model model = ModelFactory.createDefaultModel() ;
+ RDFReader t = new TurtleReader() ;
+ try {
+ t.read(model, manifestItem.getInput().getURI()) ;
+ fail("Bad syntax test succeed in parsing the file") ;
+ } catch (TurtleParseException ex)
+ {
+ return ;
+ }
+
+ }
+
+ }
+
+}
Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleTestSuite.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleTestVocab.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleTestVocab.java?rev=1552171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleTestVocab.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleTestVocab.java Wed Dec 18 23:56:42 2013
@@ -0,0 +1,57 @@
+/*
+ * 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 com.hp.hpl.jena.n3.turtle ;
+
+import com.hp.hpl.jena.rdf.model.*;
+
+/**
+ * Vocabulary definitions from TurtleTestVocab.ttl
+ */
+public class TurtleTestVocab {
+ /** <p>The RDF model that holds the vocabulary terms</p> */
+ private static Model m_model = ModelFactory.createDefaultModel();
+
+ /** <p>The namespace of the vocabulary as a string</p> */
+ public static final String NS = "http://jena.hpl.hp.com/2005/12/test-turtle#";
+
+ /** <p>The namespace of the vocabulary as a string</p>
+ * @see #NS */
+ public static String getURI() {return NS;}
+
+ /** <p>The namespace of the vocabulary as a resource</p> */
+ public static final Resource NAMESPACE = m_model.createResource( NS );
+
+ /** <p>Declare a IRI for the test input</p> */
+ public static final Property inputIRI = m_model.createProperty( "http://jena.hpl.hp.com/2005/12/test-turtle#inputIRI" );
+
+ /** <p>Output of a test</p> */
+ public static final Property output = m_model.createProperty( "http://jena.hpl.hp.com/2005/12/test-turtle#output" );
+
+ /** <p>Input to a test</p> */
+ public static final Property input = m_model.createProperty( "http://jena.hpl.hp.com/2005/12/test-turtle#input" );
+
+ public static final Resource TestInOut = m_model.createResource( "http://jena.hpl.hp.com/2005/12/test-turtle#TestInOut" );
+
+ public static final Resource TestBadSyntax = m_model.createResource( "http://jena.hpl.hp.com/2005/12/test-turtle#TestBadSyntax" );
+
+ public static final Resource TestSyntax = m_model.createResource( "http://jena.hpl.hp.com/2005/12/test-turtle#TestSyntax" );
+
+ public static final Resource Test = m_model.createResource( "http://jena.hpl.hp.com/2005/12/test-turtle#Test" );
+
+}
Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/n3/turtle/TurtleTestVocab.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/TestUtils.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/TestUtils.java?rev=1552171&r1=1552170&r2=1552171&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/TestUtils.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/TestUtils.java Wed Dec 18 23:56:42 2013
@@ -25,6 +25,7 @@ import java.lang.reflect.Constructor;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -34,10 +35,16 @@ import org.slf4j.LoggerFactory;
import static org.junit.Assert.*;
+import com.hp.hpl.jena.rdf.model.Literal;
+import com.hp.hpl.jena.rdf.model.Property;
+import com.hp.hpl.jena.rdf.model.RDFNode;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.rdf.model.StmtIterator;
import com.hp.hpl.jena.util.CollectionFactory;
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
import com.hp.hpl.jena.util.iterator.WrappedIterator;
+
/**
* Foo basis for Jena test cases which provides assertFalse and assertDiffer.
* Often the logic of the names is clearer than using a negation.
@@ -309,5 +316,13 @@ public class TestUtils {
.println(String.format("[%s WARNING] %s expected: %s got: %s",
clazz, msg, obj1, obj2));
}
+
+ public static String safeName(String s)
+ {
+ // Safe from Eclipse
+ s = s.replace('(','[') ;
+ s = s.replace(')',']') ;
+ return s ;
+ }
}
Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/Manifest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/Manifest.java?rev=1552171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/Manifest.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/Manifest.java Wed Dec 18 23:56:42 2013
@@ -0,0 +1,228 @@
+/*
+ * 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 com.hp.hpl.jena.testing_framework.manifest;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.hp.hpl.jena.n3.IRIResolver;
+import com.hp.hpl.jena.rdf.model.*;
+import com.hp.hpl.jena.util.FileManager;
+import com.hp.hpl.jena.vocabulary.RDF;
+import com.hp.hpl.jena.vocabulary.RDFS;
+import com.hp.hpl.jena.vocabulary.TestManifest;
+import com.hp.hpl.jena.vocabulary.TestManifestX;
+
+/**
+ * A test manifest for a single manifest file.
+ */
+
+public class Manifest {
+ // This class does not know about JUnit.
+ private static Logger log = LoggerFactory.getLogger(Manifest.class);
+ private Model manifest;
+ private String manifestName;
+ private String filename;
+ private List<String> includedFiles = new ArrayList<String>();
+ private Resource manifestRes = null;
+
+ public Manifest(String fn) {
+ log.debug("Manifest = " + fn);
+ filename = IRIResolver.resolveGlobal(fn);
+ log.debug(" = " + filename);
+ manifest = FileManager.get().loadModel(filename);
+ parseIncludes();
+ parseManifest();
+ }
+
+ public String getName() {
+ return manifestName;
+ }
+
+ public Iterator<String> includedManifests() {
+ return includedFiles.iterator();
+ }
+
+ private void parseManifest() {
+ StmtIterator manifestStmts = manifest.listStatements(null, RDF.type,
+ TestManifest.Manifest);
+ if (!manifestStmts.hasNext()) {
+ log.warn("No manifest in manifest file: " + filename);
+ return;
+ }
+
+ Statement manifestItemStmt = manifestStmts.nextStatement();
+ if (manifestStmts.hasNext()) {
+ log.warn("Multiple manifests in manifest file: " + filename);
+ return;
+ }
+
+ manifestRes = manifestItemStmt.getSubject();
+ manifestName = getLiteral(manifestRes, RDFS.label);
+ if (manifestName == null)
+ manifestName = getLiteral(manifestRes, RDFS.comment);
+ manifestStmts.close();
+ }
+
+ // For every test item (does not recurse)
+ public void apply(ManifestItemHandler gen) {
+
+ StmtIterator manifestStmts = manifest.listStatements(null, RDF.type,
+ TestManifest.Manifest);
+
+ for (; manifestStmts.hasNext();) {
+ Statement manifestItemStmt = manifestStmts.nextStatement();
+ Resource manifestRes = manifestItemStmt.getSubject();
+
+ // For each item in this manifest
+ StmtIterator listIter = manifestRes
+ .listProperties(TestManifest.entries);
+ for (; listIter.hasNext();) {
+ // List head
+ Resource listItem = listIter.nextStatement().getResource();
+ for (; !listItem.equals(RDF.nil);) {
+ ManifestItem item = new ManifestItem(listItem
+ .getRequiredProperty(RDF.first).getResource());
+ gen.processManifestItem(item);
+ // Move to next list item
+ listItem = listItem.getRequiredProperty(RDF.rest)
+ .getResource();
+ }
+ }
+ listIter.close();
+ }
+ manifestStmts.close();
+ }
+
+ // -------- included manifests
+ private void parseIncludes() {
+ parseIncludes(TestManifest.include);
+ parseIncludes(TestManifestX.include);
+ }
+
+ private void parseIncludes(Property property) {
+ StmtIterator includeStmts = manifest.listStatements(null, property,
+ (RDFNode) null);
+
+ for (; includeStmts.hasNext();) {
+ Statement s = includeStmts.nextStatement();
+ if (!(s.getObject() instanceof Resource)) {
+ log.warn("Include: not a Resource" + s);
+ continue;
+ }
+ Resource r = s.getResource();
+ parseOneIncludesList(r);
+ }
+ includeStmts.close();
+ }
+
+ private void parseOneIncludesList(Resource r) {
+ if (r == null)
+ return;
+
+ if (r.equals(RDF.nil))
+ return;
+
+ if (!r.isAnon()) {
+ String uri = r.getURI();
+ if (includedFiles.contains(uri))
+ return;
+ includedFiles.add(r.getURI());
+ return;
+ }
+
+ // BNnode => list
+ Resource listItem = r;
+ while (!listItem.equals(RDF.nil)) {
+ r = listItem.getRequiredProperty(RDF.first).getResource();
+ parseOneIncludesList(r);
+ // Move on
+ listItem = listItem.getRequiredProperty(RDF.rest).getResource();
+ }
+ }
+
+ public static Resource getResource(Resource r, Property p) {
+ if (r == null)
+ return null;
+ if (!r.hasProperty(p))
+ return null;
+
+ RDFNode n = r.getProperty(p).getObject();
+ if (n instanceof Resource)
+ return (Resource) n;
+
+ throw new ManifestException("Manifest problem (not a Resource): " + n
+ + " => " + p);
+ }
+
+ public static Collection<Resource> listResources(Resource r, Property p) {
+ if (r == null)
+ return null;
+ List<Resource> x = new ArrayList<Resource>();
+ StmtIterator sIter = r.listProperties(p);
+ for (; sIter.hasNext();) {
+ RDFNode n = sIter.next().getObject();
+ if (!(n instanceof Resource))
+ throw new ManifestException(
+ "Manifest problem (not a Resource): " + n + " => " + p);
+ x.add((Resource) n);
+ }
+ return x;
+ }
+
+ public static String getLiteral(Resource r, Property p) {
+ if (r == null)
+ return null;
+ if (!r.hasProperty(p))
+ return null;
+
+ RDFNode n = r.getProperty(p).getObject();
+ if (n instanceof Literal)
+ return ((Literal) n).getLexicalForm();
+
+ throw new ManifestException("Manifest problem (not a Literal): " + n
+ + " => " + p);
+ }
+
+ public static String getLiteralOrURI(Resource r, Property p) {
+ if (r == null)
+ return null;
+
+ if (!r.hasProperty(p))
+ return null;
+
+ RDFNode n = r.getProperty(p).getObject();
+ if (n instanceof Literal)
+ return ((Literal) n).getLexicalForm();
+
+ if (n instanceof Resource) {
+ Resource r2 = (Resource) n;
+ if (!r2.isAnon())
+ return r2.getURI();
+ }
+
+ throw new ManifestException("Manifest problem: " + n + " => " + p);
+ }
+
+}
Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/Manifest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestException.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestException.java?rev=1552171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestException.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestException.java Wed Dec 18 23:56:42 2013
@@ -0,0 +1,48 @@
+/*
+ * 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 com.hp.hpl.jena.testing_framework.manifest;
+
+/**
+ * TestException a root exception for all (intentional) exceptions in tests
+ * setup, not a failure of the test itself (e.g. manifest problems)
+ */
+
+public class ManifestException extends RuntimeException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5601201233175898449L;
+
+ public ManifestException() {
+ super();
+ }
+
+ public ManifestException(Throwable cause) {
+ super(cause);
+ }
+
+ public ManifestException(String msg) {
+ super(msg);
+ }
+
+ public ManifestException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+}
Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestFile.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestFile.java?rev=1552171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestFile.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestFile.java Wed Dec 18 23:56:42 2013
@@ -0,0 +1,38 @@
+/*
+ * 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 com.hp.hpl.jena.testing_framework.manifest;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to declare the manifest file for the test.
+ *
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ManifestFile {
+ /**
+ * The file that the annotated class should read
+ */
+ String value();
+
+}
Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestFile.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestItem.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestItem.java?rev=1552171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestItem.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestItem.java Wed Dec 18 23:56:42 2013
@@ -0,0 +1,53 @@
+package com.hp.hpl.jena.testing_framework.manifest;
+
+import com.hp.hpl.jena.n3.turtle.TurtleTestVocab;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.vocabulary.RDF;
+import com.hp.hpl.jena.vocabulary.TestManifest;
+
+public class ManifestItem {
+ private Resource entry;
+
+ public ManifestItem(Resource entry) {
+ this.entry = entry;
+ }
+
+ public Resource getEntry() {
+ return entry;
+ }
+
+ public String getTestName() {
+ return Manifest.getLiteral(entry, TestManifest.name);
+ }
+
+ public Resource getAction() {
+ return Manifest.getResource(entry, TestManifest.action);
+ }
+
+ public Resource getResult() {
+ return Manifest.getResource(entry, TestManifest.result);
+ }
+
+ public Resource getType() {
+ return Manifest.getResource(entry, RDF.type);
+ }
+
+ public Resource getOutput() {
+ Resource result = getResult();
+ return result == null ? null : Manifest.getResource(result,
+ TurtleTestVocab.output);
+ }
+
+ public Resource getInput() {
+ Resource action = getAction();
+ return action == null ? null : Manifest.getResource(action,
+ TurtleTestVocab.input);
+ }
+
+ public String getUriString() {
+ Resource action = getAction();
+ Resource inputIRIr = action == null ? null : Manifest.getResource(
+ action, TurtleTestVocab.inputIRI);
+ return (inputIRIr == null) ? null : inputIRIr.getURI();
+ }
+}
Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestItem.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestItemHandler.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestItemHandler.java?rev=1552171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestItemHandler.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestItemHandler.java Wed Dec 18 23:56:42 2013
@@ -0,0 +1,35 @@
+/*
+ * 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 com.hp.hpl.jena.testing_framework.manifest;
+
+import java.util.List;
+
+import org.junit.runner.Runner;
+import org.junit.runners.model.InitializationError;
+
+public interface ManifestItemHandler {
+ /**
+ * Handle an item in a manifest
+ *
+ * @throws InitializationError
+ */
+ public void processManifestItem(ManifestItem item);
+
+ public void setTestRunnerList(List<Runner> runners);
+}
Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestItemHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestSuite.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestSuite.java?rev=1552171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestSuite.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestSuite.java Wed Dec 18 23:56:42 2013
@@ -0,0 +1,163 @@
+/*
+ * 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 com.hp.hpl.jena.testing_framework.manifest;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import org.junit.internal.runners.ErrorReportingRunner;
+import org.junit.runner.Description;
+import org.junit.runner.Runner;
+import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.ParentRunner;
+import org.junit.runners.Suite;
+import org.junit.runners.model.InitializationError;
+import org.junit.runners.model.RunnerBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.hp.hpl.jena.shared.JenaException;
+
+/**
+ * Class that runs the Contract annotated tests.
+ *
+ * Used with <code>@RunWith( ContractSuite.class )</code> this class scans the
+ * classes on the class path to find all the test implementations that should be
+ * run by this test suite.
+ * <p>
+ * Tests annotated with <code>@RunWith( ContractSuite.class )</code> must:
+ * <ol>
+ * <li>Have a <code>ContractImpl</code> annotation specifying the implementation
+ * being tested</li>
+ * <li>Include a <code>@Contract.Injeect</code> annotated getter that returns an
+ * IProducer<x> where "x" is the class specified in the ContractImpl</li>
+ * </ol>
+ * <p>
+ * The ContractSuite will:
+ * <ol>
+ * <li>Instantiate the class annotated with
+ * <code>@RunWith( ContractSuite.class )</code></li>
+ * <li>Find all the Contract tests for the class specified by ContractImpl and
+ * add them to the test suite</li>
+ * <li>execute all of the tests</li>
+ * </ol>
+ * </p>
+ * <p>
+ * <b>NOTE:</b>If the class annotated with
+ * <code>@RunWith( ContractSuite.class )</code> implements Dynamic the above
+ * requirements change. See Dynamic for more information.
+ * </p>
+ */
+public class ManifestSuite extends ParentRunner<Runner> {
+ private static final Logger LOG = LoggerFactory
+ .getLogger(ManifestSuite.class);
+ private final List<Runner> fRunners;
+ private final ManifestItemHandler itemHandler;
+ private final ManifestFile mf;
+
+ /**
+ * Called reflectively on classes annotated with
+ * <code>@RunWith(Suite.class)</code>
+ *
+ * @param cls
+ * the root class
+ * @param builder
+ * builds runners for classes in the suite
+ * @throws Throwable
+ */
+ public ManifestSuite(Class<? extends ManifestItemHandler> cls,
+ RunnerBuilder builder) throws Throwable {
+ super(cls);
+
+ List<Throwable> errors = new ArrayList<Throwable>();
+
+ mf = cls.getAnnotation(ManifestFile.class);
+ if (mf == null) {
+ throw new IllegalStateException(
+ "ManifestSuite reqruies ManifestFile annotation");
+ }
+ itemHandler = cls.newInstance();
+
+ Runner[] runner = new Runner[1];
+ try {
+ runner[0] = oneManifest(new Manifest(mf.value()),
+ new ArrayList<Runner>());
+ } catch (JenaException ex) {
+ runner[0] = new ErrorReportingRunner(null, ex);
+ }
+
+ if (!errors.isEmpty()) {
+ throw new InitializationError(errors);
+ }
+ fRunners = Collections.unmodifiableList(Arrays.asList(runner));
+ }
+
+ private Runner oneManifest(final Manifest manifest, List<Runner> r) {
+
+ // Recurse
+ for (Iterator<String> iter = manifest.includedManifests(); iter
+ .hasNext();) {
+ try {
+ r.add(oneManifest(new Manifest(iter.next()),
+ new ArrayList<Runner>()));
+ } catch (JenaException ex) {
+ r.add(new ErrorReportingRunner(null, ex));
+ }
+ }
+ itemHandler.setTestRunnerList(r);
+ manifest.apply(itemHandler);
+ try {
+ return new Suite((Class<?>) null, r) {
+
+ @Override
+ protected String getName() {
+ return manifest.getName();
+ }
+
+ };
+ } catch (InitializationError e) {
+ return new ErrorReportingRunner(null, e);
+ }
+ }
+
+ @Override
+ protected List<Runner> getChildren() {
+ return fRunners;
+ }
+
+ @Override
+ protected Description describeChild(Runner child) {
+ return child.getDescription();
+ }
+
+ @Override
+ protected void runChild(Runner child, RunNotifier notifier) {
+ child.run(notifier);
+ }
+
+ /**
+ * Returns a name used to describe this Runner
+ */
+ @Override
+ protected String getName() {
+ return String.format("%s - %s", super.getName(), mf.value());
+ }
+}
Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestSuite.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestTest.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestTest.java?rev=1552171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestTest.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestTest.java Wed Dec 18 23:56:42 2013
@@ -0,0 +1,13 @@
+package com.hp.hpl.jena.testing_framework.manifest;
+
+public abstract class ManifestTest {
+
+ protected ManifestItem manifestItem;
+
+ public final void setManifestItem(ManifestItem manifestItem) {
+ this.manifestItem = manifestItem;
+ }
+
+ abstract public void runTest();
+
+}
Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestTestRunner.java
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestTestRunner.java?rev=1552171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestTestRunner.java (added)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestTestRunner.java Wed Dec 18 23:56:42 2013
@@ -0,0 +1,75 @@
+package com.hp.hpl.jena.testing_framework.manifest;
+
+import java.lang.annotation.Annotation;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.runner.Description;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.InitializationError;
+
+public class ManifestTestRunner extends BlockJUnit4ClassRunner {
+
+ private ManifestItem manifestItem;
+
+ public ManifestTestRunner(ManifestItem manifestItem,
+ Class<? extends ManifestTest> cls) throws InitializationError {
+ super(cls);
+ this.manifestItem = manifestItem;
+ }
+
+ /**
+ * Returns the name that describes {@code method} for {@link Description}s.
+ * Default implementation is the method's name
+ */
+ @Override
+ protected String testName(FrameworkMethod method) {
+ return manifestItem.getTestName();
+ }
+
+ /**
+ * Returns the methods that run tests. Default implementation returns all
+ * methods annotated with {@code @Test} on this class and superclasses that
+ * are not overridden.
+ */
+ @Override
+ protected List<FrameworkMethod> computeTestMethods() {
+ FrameworkMethod[] lst = new FrameworkMethod[1];
+
+ try {
+ lst[0] = new FrameworkMethod(getTestClass().getJavaClass()
+ .getMethod("runTest")) {
+
+ @Override
+ public String getName() {
+ return manifestItem.getTestName();
+ }
+ };
+ } catch (NoSuchMethodException e) {
+ throw new IllegalStateException(e);
+ } catch (SecurityException e) {
+ throw new IllegalStateException(e);
+ }
+ return Arrays.asList(lst);
+ }
+
+ @Override
+ public Description getDescription() {
+ return Description.createTestDescription(this.getTestClass()
+ .getJavaClass(), manifestItem.getTestName(), new Annotation[0]);
+ }
+
+ /**
+ * Returns a new fixture for running a test. Default implementation executes
+ * the test class's no-argument constructor (validation should have ensured
+ * one exists).
+ */
+ @Override
+ protected Object createTest() throws Exception {
+ ManifestTest instance = (ManifestTest) super.createTest();
+ instance.setManifestItem(manifestItem);
+ return instance;
+ }
+
+}
Propchange: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/manifest/ManifestTestRunner.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/tuples/TupleItem.java (from r1551016, jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/TupleItem.java)
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/tuples/TupleItem.java?p2=jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/tuples/TupleItem.java&p1=jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/TupleItem.java&r1=1551016&r2=1552171&rev=1552171&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/TupleItem.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/tuples/TupleItem.java Wed Dec 18 23:56:42 2013
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package com.hp.hpl.jena.testing_framework;
+package com.hp.hpl.jena.testing_framework.tuples;
/**
* The unit found in a line of a tuple.
Copied: jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/tuples/TupleSet.java (from r1551016, jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/TupleSet.java)
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/tuples/TupleSet.java?p2=jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/tuples/TupleSet.java&p1=jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/TupleSet.java&r1=1551016&r2=1552171&rev=1552171&view=diff
==============================================================================
--- jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/TupleSet.java (original)
+++ jena/Experimental/new-test/src/test/java/com/hp/hpl/jena/testing_framework/tuples/TupleSet.java Wed Dec 18 23:56:42 2013
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package com.hp.hpl.jena.testing_framework ;
+package com.hp.hpl.jena.testing_framework.tuples ;
import java.io.* ;
import java.util.* ;
Added: jena/Experimental/new-test/src/test/resources/com/hp/hpl/jena/n3/turtle/i18n.ttl
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/resources/com/hp/hpl/jena/n3/turtle/i18n.ttl?rev=1552171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/resources/com/hp/hpl/jena/n3/turtle/i18n.ttl (added)
+++ jena/Experimental/new-test/src/test/resources/com/hp/hpl/jena/n3/turtle/i18n.ttl Wed Dec 18 23:56:42 2013
@@ -0,0 +1,20 @@
+# $Id: kanji.ttl,v 1.5 2005/11/06 08:27:50 eric Exp $
+# See DOCUMENT INFO below.
+
+# NAMESPACES
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix owl: <http://www.w3.org/2002/07/owl#> .
+@prefix foaf: <http://xmlns.com/foaf/0.1/> .
+@prefix é£: <http://www.w3.org/2001/sw/DataAccess/tests/data/i18n/kanji.ttl#> .
+
+# DOCUMENT INFO
+<> rdfs:comment "test kanji IRIs (composed from QNames)" ;
+ owl:versionInfo "$Id: kanji.ttl,v 1.5 2005/11/06 08:27:50 eric Exp $".
+
+# DOCUMENT
+[ foaf:name "Alice" ;
+ é£:é£ã¹ã é£:ç´è± ] .
+
+[ foaf:name "Bob" ;
+ é£:é£ã¹ã é£:æµ·è ] .
+
Added: jena/Experimental/new-test/src/test/resources/com/hp/hpl/jena/n3/turtle/simple.ttl
URL: http://svn.apache.org/viewvc/jena/Experimental/new-test/src/test/resources/com/hp/hpl/jena/n3/turtle/simple.ttl?rev=1552171&view=auto
==============================================================================
--- jena/Experimental/new-test/src/test/resources/com/hp/hpl/jena/n3/turtle/simple.ttl (added)
+++ jena/Experimental/new-test/src/test/resources/com/hp/hpl/jena/n3/turtle/simple.ttl Wed Dec 18 23:56:42 2013
@@ -0,0 +1,3 @@
+@prefix : <http://example/> .
+
+:s :p :o .