FileManager, N3 and testing clean-up
diff --git a/jena-arq/src/main/java/org/apache/jena/query/DatasetFactory.java b/jena-arq/src/main/java/org/apache/jena/query/DatasetFactory.java
index de99b71..f78c960 100644
--- a/jena-arq/src/main/java/org/apache/jena/query/DatasetFactory.java
+++ b/jena-arq/src/main/java/org/apache/jena/query/DatasetFactory.java
@@ -24,6 +24,7 @@
import org.apache.jena.assembler.Assembler;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.sparql.ARQException;
import org.apache.jena.sparql.core.DatasetGraph;
import org.apache.jena.sparql.core.DatasetGraphFactory;
@@ -32,7 +33,6 @@
import org.apache.jena.sparql.core.assembler.DatasetAssembler;
import org.apache.jena.sparql.util.DatasetUtils;
import org.apache.jena.sparql.util.graph.GraphUtils;
-import org.apache.jena.util.FileManager;
/**
* Makes {@link Dataset}s in various ways.
@@ -46,23 +46,23 @@
* <p>
* This implementation copies models when {@link Dataset#addNamedModel(String, Model)} is called.
* <p>
- * This implementation does not support serialized transactions (it only provides MRSW locking).
- *
+ * This implementation does not support serialized transactions (it only provides MRSW locking).
+ *
* @see #createTxnMem
*/
public static Dataset create() {
return wrap(DatasetGraphFactory.create()) ;
}
-
+
/**
* Create an in-memory. transactional {@link Dataset}.
- * <p>
+ * <p>
* This fully supports transactions, including abort to roll-back changes.
* It provides "autocommit" if operations are performed
* outside a transaction but with a performance impact
* (the implementation adds a begin/commit around each add or delete
* so overheads can accumulate).
- *
+ *
* @return a transactional, in-memory, modifiable Dataset
*/
public static Dataset createTxnMem() {
@@ -75,26 +75,26 @@
* </p>
* This dataset type can contain graphs from any source when added via {@link Dataset#addNamedModel}.
* These are held as links to the supplied graph and not copied.
- * <p>
+ * <p>
* <em>This dataset does not support the graph indexing feature of jena-text.</em>
* <p>
- * This dataset does not support serialized transactions (it only provides MRSW locking).
+ * This dataset does not support serialized transactions (it only provides MRSW locking).
* <p>
- *
+ *
* @see #createTxnMem
* @return a general-purpose Dataset
*/
public static Dataset createGeneral() {
- return wrap(DatasetGraphFactory.createGeneral());
+ return wrap(DatasetGraphFactory.createGeneral());
}
/** Create an in-memory {@link Dataset}.
* <p>
* See also {@link #createTxnMem()} for a transactional dataset.
* <p>
- * Use {@link #createGeneral()} when needing to add graphs with mixed characteristics,
+ * Use {@link #createGeneral()} when needing to add graphs with mixed characteristics,
* e.g. inference graphs, or specific graphs from TDB.
- * <p>
+ * <p>
* <em>It does not support the graph indexing feature of jena-text.</em>
* <p>
* <em>This factory operation is marked "deprecated" because the general purpose "add named graph of any implementation"
@@ -110,11 +110,11 @@
/**
* Create a dataset, starting with the model argument as the default graph of the
- * dataset. Named graphs can be added.
- * <p>
+ * dataset. Named graphs can be added.
+ * <p>
* Use {@link #wrap(Model)} to put dataset functionality around a single
* model when named graphs will not be added.
- *
+ *
* @param model The model for the default graph
* @return a dataset with the given model as the default graph
*/
@@ -146,8 +146,8 @@
}
/**
- * Wrap a {@link Model} to make a dataset; the model is the default graph of the RDF Dataset.
- *
+ * Wrap a {@link Model} to make a dataset; the model is the default graph of the RDF Dataset.
+ *
* This dataset can not have additional models
* added to it, including indirectly through SPARQL Update
* adding new graphs.
@@ -165,7 +165,7 @@
*
* @param dataset DatasetGraph
* @return Dataset
- * @deprecated Use {@link #wrap}
+ * @deprecated Use {@link #wrap}
*/
@Deprecated
public static Dataset create(DatasetGraph dataset) {
@@ -271,7 +271,7 @@
*/
public static Dataset assemble(String filename) {
Objects.requireNonNull(filename, "file name can not be null") ;
- Model model = FileManager.get().loadModel(filename);
+ Model model = RDFDataMgr.loadModel(filename);
return assemble(model);
}
@@ -285,7 +285,7 @@
public static Dataset assemble(String filename, String resourceURI) {
Objects.requireNonNull(filename, "file name can not be null") ;
Objects.requireNonNull(resourceURI, "resourceURI can not be null") ;
- Model model = FileManager.get().loadModel(filename);
+ Model model = RDFDataMgr.loadModel(filename);
Resource r = model.createResource(resourceURI);
return assemble(r);
}
diff --git a/jena-arq/src/main/java/org/apache/jena/query/QueryFactory.java b/jena-arq/src/main/java/org/apache/jena/query/QueryFactory.java
index f5a8cd0..bb27203 100644
--- a/jena-arq/src/main/java/org/apache/jena/query/QueryFactory.java
+++ b/jena-arq/src/main/java/org/apache/jena/query/QueryFactory.java
@@ -18,13 +18,18 @@
package org.apache.jena.query;
+import java.io.IOException;
+
+import org.apache.jena.atlas.io.IO;
import org.apache.jena.riot.system.IRIResolver ;
+import org.apache.jena.riot.system.stream.StreamManager;
import org.apache.jena.sparql.lang.ParserARQ ;
import org.apache.jena.sparql.lang.SPARQLParser ;
import org.apache.jena.sparql.lang.SPARQLParserRegistry ;
import org.apache.jena.sparql.syntax.Element ;
import org.apache.jena.sparql.syntax.Template ;
-import org.apache.jena.util.FileManager ;
+//import org.apache.jena.util.FileManager ;
+import org.apache.jena.util.FileManager;
public class QueryFactory
@@ -34,19 +39,19 @@
* @param queryString The query string
* @throws QueryException Thrown when a parse error occurs
*/
-
+
static public Query create(String queryString)
{
return create(queryString, Syntax.defaultQuerySyntax) ;
}
- /** Create a query from the given string with the
+ /** Create a query from the given string with the
*
* @param queryString The query string
* @param syntax {@link Syntax}
* @throws QueryException Thrown when a parse error occurs
*/
-
+
static public Query create(String queryString, Syntax syntax)
{
return create(queryString, null, syntax) ;
@@ -58,13 +63,13 @@
* @param baseURI Base URI
* @throws QueryException Thrown when a parse error occurs
*/
-
+
static public Query create(String queryString, String baseURI)
{
Query query = new Query() ;
return parse(query, queryString, baseURI, Syntax.defaultQuerySyntax) ;
}
-
+
/** Create a query from the given string by calling the parser.
*
* @param queryString The query string
@@ -72,21 +77,21 @@
* @param syntax {@link Syntax}
* @throws QueryException Thrown when a parse error occurs
*/
-
+
static public Query create(String queryString, String baseURI, Syntax syntax)
{
Query query = new Query() ;
return parse(query, queryString, baseURI, syntax) ;
}
-
+
/**
- * Make a query - no parsing done
+ * Make a query - no parsing done
*/
static public Query create() { return new Query() ; }
-
+
/**
- * Make a query - no parsing done - old name: {@link #create()} preferred.
+ * Make a query - no parsing done - old name: {@link #create()} preferred.
*/
static public Query make() { return create() ; }
@@ -95,16 +100,16 @@
* The returned query will be .equals to the original.
* The returned query can be mutated without changing the
* original (at which point it will stop being .equals)
- *
+ *
* @param originalQuery The query to clone.
- *
+ *
*/
static public Query create(Query originalQuery)
{
return originalQuery.cloneQuery() ;
}
-
+
/** Parse a query from the given string by calling the parser.
*
* @param query Existing, uninitialized query
@@ -113,7 +118,7 @@
* @param syntaxURI URI for the syntax
* @throws QueryException Thrown when a parse error occurs
*/
-
+
static public Query parse(Query query, String queryString, String baseURI, Syntax syntaxURI)
{
if ( syntaxURI == null )
@@ -122,31 +127,31 @@
query.setSyntax(syntaxURI) ;
SPARQLParser parser = SPARQLParser.createParser(syntaxURI) ;
-
+
if ( parser == null )
throw new UnsupportedOperationException("Unrecognized syntax for parsing: "+syntaxURI) ;
-
+
if ( query.getResolver() == null )
{
IRIResolver resolver = null ;
- try {
- if ( baseURI != null ) {
+ try {
+ if ( baseURI != null ) {
// Sort out the baseURI - if that fails, dump in a dummy one and continue.
- resolver = IRIResolver.create(baseURI) ;
+ resolver = IRIResolver.create(baseURI) ;
}
- else {
+ else {
resolver = IRIResolver.create() ;
}
}
catch (Exception ex) {}
- if ( resolver == null )
+ if ( resolver == null )
resolver = IRIResolver.create("http://localhost/query/defaultBase#") ;
query.setResolver(resolver) ;
-
+
}
return parser.parse(query, queryString) ;
}
-
+
static boolean knownParserSyntax(Syntax syntaxURI)
{
return SPARQLParserRegistry.get().containsFactory(syntaxURI) ;
@@ -155,71 +160,95 @@
/**
* Read a SPARQL query from a file.
- *
+ *
* @param url
* URL (file: or http: or anything a FileManager can handle)
* @return A new query object
*/
static public Query read(String url)
{
- return read(url, null, null, null) ;
+ return read(url, (StreamManager)null, null, null) ;
}
/** Read a SPARQL query from a file.
- *
+ *
* @param url URL (file: or http: or anything a FileManager can handle)
* @param baseURI BaseURI for the query
- * @return A new query object
+ * @return A new query object
*/
static public Query read(String url, String baseURI)
{
- return read(url, null, baseURI, null) ;
+ return read(url, (StreamManager)null, baseURI, null) ;
}
/** Read a query from a file.
- *
+ *
* @param url URL (file: or http: or anything a FileManager can handle)
* @param langURI Query syntax
- * @return A new query object
+ * @return A new query object
*/
static public Query read(String url, Syntax langURI)
{
- return read(url, null, null, langURI) ;
+ return read(url, (StreamManager)null, null, langURI) ;
}
/** Read a query from a file.
- *
+ *
* @param url URL (file: or http: or anything a FileManager can handle)
* @param baseURI BaseURI for the query
* @param langURI Query syntax
- * @return A new query object
+ * @return A new query object
*/
static public Query read(String url, String baseURI, Syntax langURI)
{
- return read(url, null, baseURI, langURI) ;
+ return read(url, (StreamManager)null, baseURI, langURI) ;
}
/** Read a query from a file.
- *
+ *
* @param url URL (file: or http: or anything a FileManager can handle)
* @param filemanager Optional filemanager
* @param baseURI BaseURI for the query
* @param langURI Query syntax
- * @return A new query object
+ * @return A new query object
+ * @deprecated Use {@link #read(String, StreamManager, String, Syntax)}
*/
+ @Deprecated
static public Query read(String url, FileManager filemanager, String baseURI, Syntax langURI)
{
if ( filemanager == null )
- filemanager = FileManager.get() ;
+ filemanager = org.apache.jena.util.FileManager.get() ;
String qStr = filemanager.readWholeFileAsUTF8(url) ;
if ( baseURI == null )
baseURI = url ;
if ( langURI == null )
langURI = Syntax.guessFileSyntax(url) ;
-
+
return create(qStr, baseURI, langURI) ;
}
-
+
+ @Deprecated
+ static public Query read(String url, StreamManager filemanager, String baseURI, Syntax langURI)
+ {
+ if ( filemanager == null )
+ filemanager = StreamManager.get() ;
+
+ String qStr;
+ try {
+ qStr = IO.readWholeFileAsUTF8(filemanager.open(url));
+ } catch (IOException e) {
+ IO.exception(e);
+ qStr = null;
+ }
+ if ( baseURI == null )
+ baseURI = url ;
+ if ( langURI == null )
+ langURI = Syntax.guessFileSyntax(url) ;
+
+ return create(qStr, baseURI, langURI) ;
+ }
+
+
static public Element createElement(String elementString)
{
return ParserARQ.parseElement(elementString) ;
diff --git a/jena-arq/src/main/java/org/apache/jena/query/ResultSetFactory.java b/jena-arq/src/main/java/org/apache/jena/query/ResultSetFactory.java
index 20320a5..5e78289 100644
--- a/jena-arq/src/main/java/org/apache/jena/query/ResultSetFactory.java
+++ b/jena-arq/src/main/java/org/apache/jena/query/ResultSetFactory.java
@@ -26,6 +26,7 @@
import org.apache.jena.rdf.model.Model ;
import org.apache.jena.rdf.model.ModelFactory ;
import org.apache.jena.riot.Lang ;
+import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.riot.ResultSetMgr ;
import org.apache.jena.riot.resultset.ResultSetLang;
import org.apache.jena.riot.resultset.rw.ReadAnything;
@@ -36,7 +37,6 @@
import org.apache.jena.sparql.sse.Item ;
import org.apache.jena.sparql.sse.SSE ;
import org.apache.jena.sparql.sse.builders.BuilderTable ;
-import org.apache.jena.util.FileManager ;
/** ResultSetFactory - make result sets from places other than a query. */
@@ -44,10 +44,10 @@
// See also ResultSetMgr - which post-dates this code.
// Ideally, read operations here should call ResultSetMgr.
// The exception is XML from a string and the arcachic RDF to ResultSet forms.
-
+
/**
* Load a result set from file or URL into a result set (memory backed).
- *
+ *
* @param filenameOrURI
* @return ResultSet
*/
@@ -58,7 +58,7 @@
/**
* Load a result set from file or URL into a result set (memory backed).
- *
+ *
* @param filenameOrURI
* @param format
* @return ResultSet
@@ -73,7 +73,7 @@
/**
* Load a result set from input stream into a result set (memory backed).
- *
+ *
* @param input
* @param format
* @return ResultSet
@@ -84,7 +84,7 @@
Log.warn(ResultSet.class, "Null format - defaulting to XML");
format = ResultsFormat.FMT_RS_XML;
}
-
+
// Old World - new world
Lang lang = ResultsFormat.convert(format) ;
if ( lang != null )
@@ -126,7 +126,7 @@
/**
* Load a result set (or any other model) from file or URL
- *
+ *
* @param filenameOrURI
* @return Model
*/
@@ -137,7 +137,7 @@
/**
* Load a result set (or any other model) from file or URL
- *
+ *
* @param model
* Load into this model (returned)
* @param filenameOrURI
@@ -149,7 +149,7 @@
/**
* Load a result set (or any other model) from file or URL
- *
+ *
* @param filenameOrURI
* @param format
* @return Model
@@ -163,7 +163,7 @@
* Load a result set (or any other model) from file or URL. Does not have to
* be a result set (e.g. CONSTRUCt results) but it does interpret the
* ResultSetFormat possibilities.
- *
+ *
* @param model
* Load into this model (returned)
* @param filenameOrURI
@@ -194,13 +194,15 @@
RDFOutput.encodeAsRDF(model, x.getResultSet());
else if ( x.isBoolean() )
RDFOutput.encodeAsRDF(model, x.getBooleanResult());
- else
+ else
throw new ResultSetException("Not a result set");
return model;
}
- if (ResultsFormat.isRDFGraphSyntax(format))
- return FileManager.get().readModel(model, filenameOrURI);
+ if (ResultsFormat.isRDFGraphSyntax(format)) {
+ RDFDataMgr.read(model, filenameOrURI);
+ return model;
+ }
Log.error(ResultSet.class, "Unknown result set syntax: " + format);
return null;
@@ -240,7 +242,7 @@
}
if (ResultsFormat.isRDFGraphSyntax(format)) {
- Model model = FileManager.get().loadModel(filenameOrURI);
+ Model model = RDFDataMgr.loadModel(filenameOrURI);
return new SPARQLResult(model);
}
@@ -250,7 +252,7 @@
/**
* Read XML which is the format of the SPARQL result set format.
- *
+ *
* @param in
* InputStream
* @return ResultSet
@@ -261,7 +263,7 @@
/**
* Read XML which is the format of the SPARQL result set format.
- *
+ *
* @param str
* String to process
* @return ResultSet
@@ -275,7 +277,7 @@
/**
* Read from an input stream which is the format of the SPARQL result set
* format in JSON.
- *
+ *
* @param in
* InputStream
* @return ResultSet
@@ -287,7 +289,7 @@
/**
* Read from an input stream which is the format of the SPARQL result set
* format in TSV.
- *
+ *
* @param in
* InputStream
* @return ResultSet
@@ -299,7 +301,7 @@
/**
* Read from an input stream which is the format of the SPARQL result set
* format in SSE.
- *
+ *
* @param in
* InputStream
* @return ResultSet
@@ -319,7 +321,7 @@
* Turns an RDF model, with properties and classes from the result set
* vocabulary, into a SPARQL result set. The result set formed is a copy in
* memory.
- *
+ *
* @param model
* @return ResultSet
*/
@@ -331,7 +333,7 @@
* Turns an RDF model, with properties and classes from the result set
* vocabulary, into a SPARQL result set which is rewindable (has a
* .reset()operation). The result set formed is a copy in memory.
- *
+ *
* @param model
* @return ResultSetRewindable
*/
@@ -343,7 +345,7 @@
* Turn an existing result set into a rewindable one.
* May take a copy but this is not guaranteed
* Uses up the result set passed in which is no longer valid as a ResultSet.
- *
+ *
* @param resultSet
* @return ResultSetRewindable
*/
@@ -369,7 +371,7 @@
* </p> Note that rewindable results may typically also be peekable so may
* be more broadly applicable if you can afford the cost of loading all the
* results into memory. </p>
- *
+ *
* @param resultSet
* Result set to wrap
* @return Peekable results
@@ -377,7 +379,7 @@
static public ResultSetPeekable makePeekable(ResultSet resultSet) {
return new ResultSetPeeking(resultSet);
}
-
+
/** Return a closable resultset for a {@link QueryExecution}.
* The {@link QueryExecution} must be for a {@code SELECT} query.
* <p>
@@ -388,7 +390,7 @@
* ...
* }
* </pre>
- *
+ *
* @param queryExecution {@code QueryExecution} must be for a {@code SELECT} query.
* @return ResultSetCloseable
*/
@@ -400,7 +402,7 @@
* Take a copy of a result set - the result set returns is an in-memory
* copy. It is not attached to the original query execution object which can
* be closed.
- *
+ *
* @param results
* @return ResultSet
*/
@@ -410,7 +412,7 @@
/**
* Build a result set from one of ARQ's lower level query iterator.
- *
+ *
* @param queryIterator
* @param vars
* List of variables, by name, for the result set
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/system/IO_JenaReaders.java b/jena-arq/src/main/java/org/apache/jena/riot/system/IO_JenaReaders.java
index 5372539..9c32fa6 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/system/IO_JenaReaders.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/system/IO_JenaReaders.java
@@ -25,13 +25,13 @@
public class IO_JenaReaders
{
-// private static String riotBase = "http://jena.apache.org/riot/" ;
-// private static String streamManagerSymbolStr = riotBase+"streammanager" ;
-// public static Symbol streamManagerSymbol = Symbol.create(streamManagerSymbolStr) ;
+// private static String riotBase = "http://jena.apache.org/riot/" ;
+// private static String streamManagerSymbolStr = riotBase+"streammanager" ;
+// public static Symbol streamManagerSymbol = Symbol.create(streamManagerSymbolStr) ;
private static FileManager coreFileManager = null;
private static boolean isWiredIn = false;
-
+
public static void wireIntoJena() {
if ( isWiredIn )
return ;
@@ -51,7 +51,7 @@
FileManager.setGlobalFileManager(coreFileManager) ;
}
- /** Register for use with Model.read (old style compatibility) */
+ /** Register for use with Model.read (old style compatibility) */
@Deprecated
public static void registerForModelRead(String name, Class<? > cls) {
RDFReaderFImpl.setBaseReaderClassName(name, cls.getName());
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/sse/builders/BuilderGraph.java b/jena-arq/src/main/java/org/apache/jena/sparql/sse/builders/BuilderGraph.java
index 53cf358..3e3dc9c 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/sse/builders/BuilderGraph.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/sse/builders/BuilderGraph.java
@@ -21,8 +21,7 @@
import org.apache.jena.graph.Graph ;
import org.apache.jena.graph.Node ;
import org.apache.jena.graph.Triple ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.rdf.model.ModelFactory ;
+import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.sparql.core.DatasetGraph ;
import org.apache.jena.sparql.core.DatasetGraphFactory ;
import org.apache.jena.sparql.core.Quad ;
@@ -31,7 +30,6 @@
import org.apache.jena.sparql.sse.ItemList ;
import org.apache.jena.sparql.sse.Tags ;
import org.apache.jena.sparql.util.NodeUtils ;
-import org.apache.jena.util.FileManager ;
public class BuilderGraph
{
@@ -167,8 +165,7 @@
String s = NodeUtils.stringLiteral(item.getNode());
if ( s == null )
BuilderLib.broken(item, "Expected: ("+Tags.tagLoad+" 'filename')");
- Model model = ModelFactory.createModelForGraph(graph);
- FileManager.get().readModel(model, s);
+ RDFDataMgr.read(graph, s);
}
public static Triple buildTriple(ItemList list) {
diff --git a/jena-arq/src/test/java/org/apache/jena/riot/system/TestIO_JenaWriters.java b/jena-arq/src/test/java/org/apache/jena/riot/system/TestIO_JenaWriters.java
index f835b3b..fde180a 100644
--- a/jena-arq/src/test/java/org/apache/jena/riot/system/TestIO_JenaWriters.java
+++ b/jena-arq/src/test/java/org/apache/jena/riot/system/TestIO_JenaWriters.java
@@ -21,7 +21,6 @@
import static org.junit.Assert.assertNotEquals ;
import static org.junit.Assert.fail ;
-import org.apache.jena.n3.N3JenaWriter ;
import org.apache.jena.rdf.model.RDFWriterF ;
import org.apache.jena.rdf.model.impl.RDFWriterFImpl ;
import org.apache.jena.riot.IO_Jena ;
@@ -32,10 +31,10 @@
import org.junit.Test ;
public class TestIO_JenaWriters {
-
- @BeforeClass public static void beforeClass() { }
+
+ @BeforeClass public static void beforeClass() { }
@AfterClass public static void afterClass() { IO_Jena.wireIntoJena(); }
-
+
@Test
public void testWireIntoJena() {
IO_Jena.wireIntoJena();
@@ -49,25 +48,20 @@
assertEquals(RDFWriterRIOT.class, writerF.getWriter("NT").getClass());
assertEquals(RDFWriterRIOT.class, writerF.getWriter("N3").getClass());
- assertEquals(RDFWriterRIOT.class, writerF.getWriter(N3JenaWriter.n3WriterPrettyPrinter).getClass());
- assertEquals(RDFWriterRIOT.class, writerF.getWriter(N3JenaWriter.n3WriterPlain).getClass());
- assertEquals(RDFWriterRIOT.class, writerF.getWriter(N3JenaWriter.n3WriterTriples).getClass());
- assertEquals(RDFWriterRIOT.class, writerF.getWriter(N3JenaWriter.n3WriterTriplesAlt).getClass());
-
- assertEquals(RDFWriterRIOT.class, writerF.getWriter(N3JenaWriter.turtleWriter).getClass());
- assertEquals(RDFWriterRIOT.class, writerF.getWriter(N3JenaWriter.turtleWriterAlt1).getClass());
- assertEquals(RDFWriterRIOT.class, writerF.getWriter(N3JenaWriter.turtleWriterAlt2).getClass());
+ assertEquals(RDFWriterRIOT.class, writerF.getWriter("TURTLE").getClass());
+ assertEquals(RDFWriterRIOT.class, writerF.getWriter("Turtle").getClass());
+ assertEquals(RDFWriterRIOT.class, writerF.getWriter("TTL").getClass());
assertEquals(RDFWriterRIOT.class, writerF.getWriter("RDF/JSON").getClass());
assertEquals(RDFWriterRIOT.class, writerF.getWriter("RDFJSON").getClass());
}
-
+
@Test
public void testResetJena() {
IO_Jena.wireIntoJena();
IO_Jena.resetJena();
RDFWriterF writerF = new RDFWriterFImpl();
-
+
assertNotEquals(RDFWriterRIOT.class, writerF.getWriter().getClass());
assertNotEquals(RDFWriterRIOT.class, writerF.getWriter("RDF/XML").getClass());
assertNotEquals(RDFWriterRIOT.class, writerF.getWriter("RDF/XML-ABBREV").getClass());
@@ -76,14 +70,9 @@
assertNotEquals(RDFWriterRIOT.class, writerF.getWriter("N-TRIPLE").getClass());
assertNotEquals(RDFWriterRIOT.class, writerF.getWriter("N3").getClass());
- assertNotEquals(RDFWriterRIOT.class, writerF.getWriter(N3JenaWriter.n3WriterPrettyPrinter).getClass());
- assertNotEquals(RDFWriterRIOT.class, writerF.getWriter(N3JenaWriter.n3WriterPlain).getClass());
- assertNotEquals(RDFWriterRIOT.class, writerF.getWriter(N3JenaWriter.n3WriterTriples).getClass());
- assertNotEquals(RDFWriterRIOT.class, writerF.getWriter(N3JenaWriter.n3WriterTriplesAlt).getClass());
-
- assertNotEquals(RDFWriterRIOT.class, writerF.getWriter(N3JenaWriter.turtleWriter).getClass());
- assertNotEquals(RDFWriterRIOT.class, writerF.getWriter(N3JenaWriter.turtleWriterAlt1).getClass());
- assertNotEquals(RDFWriterRIOT.class, writerF.getWriter(N3JenaWriter.turtleWriterAlt2).getClass());
+ assertNotEquals(RDFWriterRIOT.class, writerF.getWriter("TURTLE").getClass());
+ assertNotEquals(RDFWriterRIOT.class, writerF.getWriter("Turtle").getClass());
+ assertNotEquals(RDFWriterRIOT.class, writerF.getWriter("TTL").getClass());
try { writerF.getWriter("NT"); fail("Exception expected") ; } catch (NoWriterForLangException ex) {}
try { writerF.getWriter("RDF/JSON") ; fail("Exception expected") ; } catch (NoWriterForLangException ex) {}
@@ -91,5 +80,5 @@
IO_Jena.wireIntoJena();
}
-
+
}
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/junit/ScriptTestSuiteFactory.java b/jena-arq/src/test/java/org/apache/jena/sparql/junit/ScriptTestSuiteFactory.java
index 065f16c..78b06d9 100644
--- a/jena-arq/src/test/java/org/apache/jena/sparql/junit/ScriptTestSuiteFactory.java
+++ b/jena-arq/src/test/java/org/apache/jena/sparql/junit/ScriptTestSuiteFactory.java
@@ -28,14 +28,11 @@
import org.apache.jena.sparql.vocabulary.TestManifestUpdate_11 ;
import org.apache.jena.sparql.vocabulary.TestManifestX ;
import org.apache.jena.sparql.vocabulary.TestManifest_11 ;
-import org.apache.jena.util.FileManager ;
import org.apache.jena.util.junit.TestFactoryManifest ;
import org.apache.jena.util.junit.TestUtils ;
-
public class ScriptTestSuiteFactory extends TestFactoryManifest
{
- private FileManager fileManager = FileManager.get() ;
// Set (and retrieve) externally.
public static EarlReport results = null ;
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/junit/TestItem.java b/jena-arq/src/test/java/org/apache/jena/sparql/junit/TestItem.java
index 3ff0632..3593e3d 100644
--- a/jena-arq/src/test/java/org/apache/jena/sparql/junit/TestItem.java
+++ b/jena-arq/src/test/java/org/apache/jena/sparql/junit/TestItem.java
@@ -33,7 +33,6 @@
import org.apache.jena.sparql.vocabulary.TestManifest;
import org.apache.jena.sparql.vocabulary.TestManifestX;
import org.apache.jena.sparql.vocabulary.VocabTestQuery;
-import org.apache.jena.util.FileManager;
import org.apache.jena.util.iterator.ClosableIterator;
import org.apache.jena.util.junit.TestException;
import org.apache.jena.util.junit.TestUtils;
@@ -150,7 +149,7 @@
ResultsFormat format = ResultsFormat.guessSyntax(resultFile) ;
if ( ResultsFormat.isRDFGraphSyntax(format) ) {
- Model m = FileManager.get().loadModel(resultFile) ;
+ Model m = RDFDataMgr.loadModel(resultFile) ;
return new SPARQLResult(m) ;
}
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/junit/UpdateTest.java b/jena-arq/src/test/java/org/apache/jena/sparql/junit/UpdateTest.java
index 1e7786a..739f7f1 100644
--- a/jena-arq/src/test/java/org/apache/jena/sparql/junit/UpdateTest.java
+++ b/jena-arq/src/test/java/org/apache/jena/sparql/junit/UpdateTest.java
@@ -29,6 +29,7 @@
import org.apache.jena.rdf.model.Property ;
import org.apache.jena.rdf.model.Resource ;
import org.apache.jena.rdf.model.Statement ;
+import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.riot.checker.CheckerLiterals ;
import org.apache.jena.sparql.core.DatasetGraph ;
import org.apache.jena.sparql.core.DatasetGraphFactory ;
@@ -188,14 +189,14 @@
System.err.println("No data for graphData") ;
String fn = gn.getProperty(TestManifestUpdate_11.graph).getResource().getURI() ;
+ Model m = RDFDataMgr.loadModel(fn);
String name = gn.getProperty(RDFS.label).getString() ;
- Model m = FileManager.get().loadModel(fn) ;
ds.addNamedModel(name, m) ;
}
else
{
String x = gn.getURI() ;
- Model m = FileManager.get().loadModel(x) ;
+ Model m = RDFDataMgr.loadModel(x) ;
ds.addNamedModel(x, m) ;
}
}
diff --git a/jena-core/src/main/java/org/apache/jena/n3/N3JenaWriter.java b/jena-core/src/main/java/org/apache/jena/n3/N3JenaWriter.java
index 21fa0cb..b61d4b8 100644
--- a/jena-core/src/main/java/org/apache/jena/n3/N3JenaWriter.java
+++ b/jena-core/src/main/java/org/apache/jena/n3/N3JenaWriter.java
@@ -63,34 +63,9 @@
*/
static public final String n3Writer = "N3" ;
-
- /**
- * Name of the N3 pretty writer. The pretty writer
- * uses a frame-like layout, with prefixing, clustering like properties
- * and embedding one-referenced bNodes.
- */
- static public final String n3WriterPrettyPrinter = "N3-PP" ;
-
- /**
- * Name of the N3 plain writer. The plain writer writes records
- * by subject.
- */
- static public final String n3WriterPlain = "N3-PLAIN" ;
-
- /**
- * Name of the N3 triples writer. This writer writes one line per statement,
- * like N-Triples, but does N3-style prefixing.
- */
- static public final String n3WriterTriples = "N3-TRIPLES" ;
-
- /**
- * Alternative name for the N3 triples writer.
- */
- static public final String n3WriterTriplesAlt = "N3-TRIPLE" ;
/**
* Turtle writer.
- * http://www.dajobe.org/2004/01/turtle/
*/
static public final String turtleWriter = "TURTLE" ;
static public final String turtleWriterAlt1 = "Turtle" ;
@@ -105,16 +80,20 @@
{
// Choose the writer
String writerName = JenaRuntime.getSystemProperty(propWriterName) ;
- if ( writerName == null ||
- writerName.equals("N3") || writerName.equals(n3WriterPrettyPrinter) )
+ if ( writerName == null )
+ return new N3JenaWriterPP() ;
+ if ( writerName.equals("N3") )
return new N3JenaWriterPP() ;
- if ( writerName.equalsIgnoreCase(n3WriterPlain) )
- return new N3JenaWriterCommon() ;
-
- if ( writerName.equalsIgnoreCase(n3WriterTriples) ||
- writerName.equalsIgnoreCase(n3WriterTriplesAlt) )
- return new N3JenaWriterTriples() ;
+// if ( writerName.equals(n3WriterPrettyPrinter) )
+// return new N3JenaWriterPP() ;
+//
+// if ( writerName.equalsIgnoreCase(n3WriterPlain) )
+// return new N3JenaWriterCommon() ;
+//
+// if ( writerName.equalsIgnoreCase(n3WriterTriples) ||
+// writerName.equalsIgnoreCase(n3WriterTriplesAlt) )
+// return new N3JenaWriterTriples() ;
if ( writerName.equalsIgnoreCase(turtleWriter) )
{
diff --git a/jena-core/src/main/java/org/apache/jena/rdf/model/impl/RDFWriterFImpl.java b/jena-core/src/main/java/org/apache/jena/rdf/model/impl/RDFWriterFImpl.java
index d6cad8d..d2847bd 100644
--- a/jena-core/src/main/java/org/apache/jena/rdf/model/impl/RDFWriterFImpl.java
+++ b/jena-core/src/main/java/org/apache/jena/rdf/model/impl/RDFWriterFImpl.java
@@ -130,15 +130,11 @@
custom.put("RDF/XML", rdfxmlWriter);
custom.put("RDF/XML-ABBREV", rdfxmlAbbrevWriter);
- custom.put("N-TRIPLE", ntWriter);
+ custom.put("N-TRIPLE", ntWriter);
custom.put("N-TRIPLES", ntWriter);
custom.put("N-Triples", ntWriter);
- custom.put("N3", org.apache.jena.n3.N3JenaWriter.class);
- custom.put(N3JenaWriter.n3WriterPrettyPrinter, org.apache.jena.n3.N3JenaWriterPP.class);
- custom.put(N3JenaWriter.n3WriterPlain, org.apache.jena.n3.N3JenaWriterPP.class);
- custom.put(N3JenaWriter.n3WriterTriples, ttlWriter);
- custom.put(N3JenaWriter.n3WriterTriplesAlt, org.apache.jena.n3.N3JenaWriterTriples.class);
+ custom.put("N3", org.apache.jena.n3.N3JenaWriter.class);
custom.put(N3JenaWriter.turtleWriter, ttlWriter);
custom.put(N3JenaWriter.turtleWriterAlt1, ttlWriter);
diff --git a/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
index 3b22dea..7c10308 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/GraphContractTest.java
@@ -114,7 +114,7 @@
/**
* Inference graphs can not be truly empty.
- *
+ *
* @param g
* @param b
*/
@@ -132,7 +132,7 @@
/**
* Inference graphs can not be truly empty
- *
+ *
* @param g
* @param b
*/
@@ -1422,7 +1422,7 @@
/**
* testIsomorphism from file data
- *
+ *
* @throws URISyntaxException
* @throws MalformedURLException
*/
@@ -1495,74 +1495,6 @@
return result;
}
- // @ContractTest
- // public void testTransactionCommit()
- // {
- // Graph g = producer.newInstance();
- // if (g.getTransactionHandler().transactionsSupported())
- // {
- // Graph initial = graphWithTxn( "initial hasValue 42; also hasURI hello" );
- // Graph extra = graphWithTxn( "extra hasValue 17; also hasURI world" );
- // //File foo = FileUtils.tempFileName( "fileGraph", ".nt" );
- //
- // //Graph g = new FileGraph( foo, true, true );
- //
- // GraphUtil.addInto( g, initial );
- // g.getTransactionHandler().begin();
- // GraphUtil.addInto( g, extra );
- // g.getTransactionHandler().commit();
- // Graph union = graphWithTxn( "" );
- // GraphUtil.addInto(union, initial );
- // GraphUtil.addInto(union, extra );
- // assertIsomorphic( union, g );
- // //Model inFile = ModelFactory.createDefaultModel();
- // //inFile.read( "file:///" + foo, "N-TRIPLES" );
- // //assertIsomorphic( union, inFile.getGraph() );
- // }
- // }
- //
- // @ContractTest
- // public void testTransactionAbort()
- // {
- // Graph g = producer.newInstance();
- // if (g.getTransactionHandler().transactionsSupported())
- // {
- // Graph initial = graphWithTxn( "initial hasValue 42; also hasURI hello" );
- // Graph extra = graphWithTxn( "extra hasValue 17; also hasURI world" );
- // File foo = FileUtils.tempFileName( "fileGraph", ".n3" );
- // //Graph g = new FileGraph( foo, true, true );
- // GraphUtil.addInto( g, initial );
- // g.getTransactionHandler().begin();
- // GraphUtil.addInto( g, extra );
- // g.getTransactionHandler().abort();
- // assertIsomorphic( initial, g );
- // }
- // }
- //
- // @ContractTest
- // public void testTransactionCommitThenAbort()
- // {
- // Graph g = producer.newInstance();
- // if (g.getTransactionHandler().transactionsSupported())
- // {
- // Graph initial = graphWithTxn( "Foo pings B; B pings C" );
- // Graph extra = graphWithTxn( "C pingedBy B; fileGraph rdf:type Graph" );
- // //Graph g = producer.newInstance();
- // //File foo = FileUtils.tempFileName( "fileGraph", ".nt" );
- // //Graph g = new FileGraph( foo, true, true );
- // g.getTransactionHandler().begin();
- // GraphUtil.addInto( g, initial );
- // g.getTransactionHandler().commit();
- // g.getTransactionHandler().begin();
- // GraphUtil.addInto( g, extra );
- // g.getTransactionHandler().abort();
- // assertIsomorphic( initial, g );
- // //Model inFile = ModelFactory.createDefaultModel();
- // // inFile.read( "file:///" + foo, "N-TRIPLES" );
- // //assertIsomorphic( initial, inFile.getGraph() );
- // }
- // }
-
/**
* This test exposed that the update-existing-graph functionality was broken
* if the target graph already contained any statements with a subject S
@@ -1590,7 +1522,6 @@
txnBegin(source);
assertIsomorphic(graphWith("a R b; b S e; b R d"), dest);
txnRollback(source);
-
}
/**
diff --git a/jena-core/src/test/java/org/apache/jena/graph/test/TestTypedLiterals.java b/jena-core/src/test/java/org/apache/jena/graph/test/TestTypedLiterals.java
index 4b66077..91350c3 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/test/TestTypedLiterals.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/test/TestTypedLiterals.java
@@ -45,17 +45,17 @@
import org.apache.jena.vocabulary.RDF ;
import org.apache.jena.vocabulary.XSD ;
import org.junit.Assert ;
-
+
/**
* Unit test for the typed literal machinery - including RDFDatatype,
* TypeMapper and LiteralLabel.
* See also TestLiteralLabelSameValueAs
*/
public class TestTypedLiterals extends TestCase {
-
+
/** dummy model used as a literal factory */
private Model m = ModelFactory.createDefaultModel();
-
+
// Temporary for debug
/*
static {
@@ -63,21 +63,21 @@
TimeZone.setDefault(TimeZone.getTimeZone("CEST"));
}
*/
-
+
/**
* Boilerplate for junit
- */
+ */
public TestTypedLiterals( String name ) {
- super( name );
+ super( name );
}
-
+
/**
* This is its own test suite
*/
public static TestSuite suite() {
- return new TestSuite( TestTypedLiterals.class );
- }
-
+ return new TestSuite( TestTypedLiterals.class );
+ }
+
/**
* Test the base functioning of unknown datatypes
*/
@@ -93,11 +93,11 @@
Literal l6 = m.createLiteral("foo", "lang1");
JenaParameters.enableSilentAcceptanceOfUnknownDatatypes = originalFlag;
// Check for successful creation
-
+
assertNotNull(l1);
assertNotNull(l3);
assertNotNull(l5);
-
+
// check equality function
assertDiffer("datatype sensitive", l1, l5);
assertDiffer("value sensitive", l1, l3);
@@ -110,7 +110,7 @@
} catch (DatatypeFormatException e) {}
assertEquals("Extract value", l1.getValue(), new BaseDatatype.TypedValue("foo", typeURI));
assertEquals("Extract xml tag", l1.isWellFormedXML(), false);
-
+
JenaParameters.enableSilentAcceptanceOfUnknownDatatypes = false;
boolean foundException = false;
try {
@@ -120,13 +120,13 @@
}
JenaParameters.enableSilentAcceptanceOfUnknownDatatypes = originalFlag;
assertTrue("Detected unknown datatype", foundException);
-
+
// Check we can create a literal of an unregistered java type without anything blowing up
Object foo = new java.sql.Date(123456l);
LiteralLabel ll = LiteralLabelFactory.createTypedLiteral(foo);
assertEquals(ll.getLexicalForm(), foo.toString());
}
-
+
/**
* Tests the base functioning of a user defined datatype
*/
@@ -138,11 +138,11 @@
Literal l1 = m.createTypedLiteral("3/5", rtype);
Literal l3 = m.createTypedLiteral("7/5", rtype);
-
+
// Check for successful creation
assertNotNull(l1);
assertNotNull(l3);
-
+
// check equality function
assertDiffer("values should be tested!", l1, l3);
@@ -160,79 +160,14 @@
assertEquals("Extract xml tag", l1.isWellFormedXML(), false);
}
- // Removal of Apach Xerces : JENA-1537.
- // No XSDDatatype.loadUserDefineds
-
-// /**
-// * Test user defined data types.
-// * This is based on a corrected, modified version of an early DAML+OIL example
-// * but is not specific to DAML+OIL.
-// */
-// public void testUserDefined() throws IOException {
-// String uri = "http://www.daml.org/2001/03/daml+oil-ex-dt";
-// String filename = "testing/xsd/daml+oil-ex-dt.xsd";
-// TypeMapper tm = TypeMapper.getInstance();
-// List<String> typenames = XSDDatatype.loadUserDefined(uri, new FileReader(filename), null, tm);
-// assertIteratorValues(typenames.iterator(), new Object[] {
-// uri + "#XSDEnumerationHeight",
-// uri + "#over12",
-// uri + "#over17",
-// uri + "#over59",
-// uri + "#clothingsize" });
-//
-// // Check the string restriction
-// RDFDatatype heightType = tm.getSafeTypeByName(uri + "#XSDEnumerationHeight");
-// checkLegalLiteral("short", heightType, String.class, "short");
-// checkLegalLiteral("tall", heightType, String.class, "tall");
-// checkIllegalLiteral("shortish", heightType);
-//
-// // Check the numeric restriction
-// RDFDatatype over12Type = tm.getSafeTypeByName(uri + "#over12");
-// checkLegalLiteral("15", over12Type, Integer.class, 15 );
-// checkIllegalLiteral("12", over12Type);
-//
-// // Check the union type
-// RDFDatatype clothingsize = tm.getSafeTypeByName(uri + "#clothingsize");
-// checkLegalLiteral("42", clothingsize, Integer.class, 42 );
-// checkLegalLiteral("short", clothingsize, String.class, "short");
-//
-// // Check use of isValidLiteral for base versus derived combinations
-// LiteralLabel iOver12 = m.createTypedLiteral("13", over12Type).asNode().getLiteral();
-// LiteralLabel iDecimal14 = m.createTypedLiteral("14", XSDDatatype.XSDdecimal).asNode().getLiteral();
-// LiteralLabel iDecimal10 = m.createTypedLiteral("10", XSDDatatype.XSDdecimal).asNode().getLiteral();
-// LiteralLabel iString = m.createTypedLiteral("15", XSDDatatype.XSDstring).asNode().getLiteral();
-// LiteralLabel iPlain = m.createLiteral("foo").asNode().getLiteral();
-//
-// assertTrue(over12Type.isValidLiteral(iOver12));
-// assertTrue(over12Type.isValidLiteral(iDecimal14));
-// assertTrue( ! over12Type.isValidLiteral(iDecimal10));
-// assertTrue( ! over12Type.isValidLiteral(iString));
-// assertTrue( ! over12Type.isValidLiteral(iPlain));
-//
-// assertTrue(XSDDatatype.XSDdecimal.isValidLiteral(iOver12));
-// assertTrue(XSDDatatype.XSDdecimal.isValidLiteral(iDecimal14));
-// assertTrue(XSDDatatype.XSDdecimal.isValidLiteral(iDecimal10));
-// assertTrue( ! XSDDatatype.XSDdecimal.isValidLiteral(iString));
-// assertTrue( ! XSDDatatype.XSDdecimal.isValidLiteral(iPlain));
-//
-// assertTrue(XSDDatatype.XSDstring.isValidLiteral(iString));
-// assertTrue(XSDDatatype.XSDstring.isValidLiteral(iPlain));
-// assertTrue( ! XSDDatatype.XSDstring.isValidLiteral(iOver12));
-// assertTrue( ! XSDDatatype.XSDstring.isValidLiteral(iDecimal10));
-// assertTrue( ! XSDDatatype.XSDstring.isValidLiteral(iDecimal14));
-// }
-
public void testXMLLiteral() {
- Literal ll;
-
- ll = m.createLiteral("<bad",true);
-
+ Literal ll = m.createLiteral("<bad",true);
+
assertTrue("Error checking must be off.",((EnhNode)ll).asNode().getLiteralIsXML());
ll = m.createTypedLiteral("<bad/>",XMLLiteralType.theXMLLiteralType);
assertFalse("Error checking must be on.",((EnhNode)ll).asNode().getLiteralIsXML());
ll = m.createTypedLiteral("<good></good>",XMLLiteralType.theXMLLiteralType);
assertTrue("Well-formed XMLLiteral.",((EnhNode)ll).asNode().getLiteralIsXML());
-
}
public void testRDFLangString_1() {
@@ -241,15 +176,15 @@
assertEquals(RDF.dtLangString, dt) ;
assertTrue(RDF.dtLangString == dt) ;
}
-
+
public void testRDFLangString_2() {
// "abc"^^rdf:langString (no language tag)
Literal ll1 = m.createTypedLiteral("abc", RDFLangString.rdfLangString) ;
assertEquals("", ll1.getLanguage()) ;
Literal ll2 = m.createLiteral("xyz", "en") ;
-
+
if ( JenaRuntime.isRDF11 )
- assertTrue(ll1.getDatatype() == ll2.getDatatype()) ;
+ assertTrue(ll1.getDatatype() == ll2.getDatatype()) ;
else
assertTrue(ll1.getDatatype() != ll2.getDatatype()) ;
}
@@ -259,12 +194,12 @@
*/
public void testXSDbasics() {
String xsdIntURI = "http://www.w3.org/2001/XMLSchema#int";
-
+
// Check int and basic equality processing
Literal l1 = m.createTypedLiteral(42); // default map
Literal l2 = m.createTypedLiteral("42", XSDDatatype.XSDint);
Literal l4 = m.createTypedLiteral("63"); // default map
-
+
assertSameValueAs("Default map failed", l1, l2);
assertEquals("Value wrong", l1.getValue(), new Integer(42));
assertEquals("class wrong", l1.getValue().getClass(), Integer.class);
@@ -274,15 +209,15 @@
assertDiffer("Not value sensitive", l1, l4);
checkIllegalLiteral("zap", XSDDatatype.XSDint);
checkIllegalLiteral("42.1", XSDDatatype.XSDint);
-
+
Literal l5 = m.createTypedLiteral("42", XSDDatatype.XSDnonNegativeInteger);
assertSameValueAs("type coercion", l2, l5);
-
+
// Check float/double
l1 = m.createTypedLiteral(42.42); // default map
l2 = m.createTypedLiteral("42.42", XSDDatatype.XSDfloat);
Literal l3 = m.createTypedLiteral("42.42", XSDDatatype.XSDdouble);
-
+
assertEquals("class wrong", l1.getValue().getClass(), Double.class);
assertFloatEquals("value wrong", ((Double)(l1.getValue())).floatValue(), 42.42);
assertEquals("class wrong", l2.getValue().getClass(), Float.class);
@@ -290,12 +225,12 @@
assertFloatEquals("Value accessor problem", l1.getFloat(), 42.42);
assertEquals("wrong type", l2.getDatatype(), XSDDatatype.XSDfloat);
assertSameValueAs("equality fn", l1, l3);
-
+
// Minimal check on long, short, byte
checkLegalLiteral("12345", XSDDatatype.XSDlong, Integer.class, 12345 );
checkLegalLiteral("-12345", XSDDatatype.XSDlong, Integer.class, -12345 );
checkIllegalLiteral("2.3", XSDDatatype.XSDlong);
-
+
checkLegalLiteral("1234", XSDDatatype.XSDshort, Integer.class, (int) (short) 1234 );
checkLegalLiteral("-1234", XSDDatatype.XSDshort, Integer.class, (int) (short) -1234 );
checkLegalLiteral("32767", XSDDatatype.XSDshort, Integer.class, (int) (short) 32767 );
@@ -310,71 +245,71 @@
checkIllegalLiteral("32769", XSDDatatype.XSDbyte);
checkIllegalLiteral("128", XSDDatatype.XSDbyte);
checkIllegalLiteral("2.3", XSDDatatype.XSDbyte);
-
+
// Minimal check on unsigned normal types
checkLegalLiteral("12345", XSDDatatype.XSDunsignedLong, Integer.class, 12345 );
checkLegalLiteral("+12345", XSDDatatype.XSDunsignedLong, Integer.class, 12345 );
checkLegalLiteral("9223372036854775808", XSDDatatype.XSDunsignedLong, BigInteger.class, new BigInteger("9223372036854775808"));
checkIllegalLiteral("-12345", XSDDatatype.XSDunsignedLong);
-
+
checkLegalLiteral("12345", XSDDatatype.XSDunsignedInt, Integer.class, 12345 );
checkLegalLiteral("2147483648", XSDDatatype.XSDunsignedInt, Long.class, 2147483648l );
checkIllegalLiteral("-12345", XSDDatatype.XSDunsignedInt);
-
+
checkLegalLiteral("1234", XSDDatatype.XSDunsignedShort, Integer.class, 1234 );
checkLegalLiteral("32679", XSDDatatype.XSDunsignedShort, Integer.class, 32679 );
checkIllegalLiteral("-12345", XSDDatatype.XSDunsignedShort);
-
+
checkLegalLiteral("123", XSDDatatype.XSDunsignedByte, Integer.class, (int) (short) 123 );
checkLegalLiteral("129", XSDDatatype.XSDunsignedByte, Integer.class, (int) (short) 129 );
checkIllegalLiteral("-123", XSDDatatype.XSDunsignedByte);
-
+
// Minimal check on the big num types
checkLegalLiteral("12345", XSDDatatype.XSDinteger, Integer.class, 12345 );
checkLegalLiteral("0", XSDDatatype.XSDinteger, Integer.class, 0 );
checkLegalLiteral("-12345", XSDDatatype.XSDinteger, Integer.class, -12345 );
checkLegalLiteral("9223372036854775808", XSDDatatype.XSDinteger, BigInteger.class, new BigInteger("9223372036854775808"));
-
+
checkLegalLiteral("12345", XSDDatatype.XSDpositiveInteger, Integer.class, 12345 );
checkIllegalLiteral("0", XSDDatatype.XSDpositiveInteger);
checkIllegalLiteral("-12345", XSDDatatype.XSDpositiveInteger);
checkLegalLiteral("9223372036854775808", XSDDatatype.XSDpositiveInteger, BigInteger.class, new BigInteger("9223372036854775808"));
-
+
checkLegalLiteral("12345", XSDDatatype.XSDnonNegativeInteger, Integer.class, 12345 );
checkLegalLiteral("0", XSDDatatype.XSDnonNegativeInteger, Integer.class, 0 );
checkIllegalLiteral("-12345", XSDDatatype.XSDnonNegativeInteger);
checkLegalLiteral("9223372036854775808", XSDDatatype.XSDnonNegativeInteger, BigInteger.class, new BigInteger("9223372036854775808"));
-
+
checkLegalLiteral("-12345", XSDDatatype.XSDnegativeInteger, Integer.class, -12345 );
checkIllegalLiteral("0", XSDDatatype.XSDnegativeInteger);
checkIllegalLiteral("12345", XSDDatatype.XSDnegativeInteger);
checkLegalLiteral("-9223372036854775808", XSDDatatype.XSDnegativeInteger, BigInteger.class, new BigInteger("-9223372036854775808"));
-
+
checkLegalLiteral("-12345", XSDDatatype.XSDnonPositiveInteger, Integer.class, -12345 );
checkLegalLiteral("0", XSDDatatype.XSDnonPositiveInteger, Integer.class, 0 );
checkIllegalLiteral("12345", XSDDatatype.XSDnonPositiveInteger);
checkLegalLiteral("-9223372036854775808", XSDDatatype.XSDnonPositiveInteger, BigInteger.class, new BigInteger("-9223372036854775808"));
-
+
checkLegalLiteral("12345", XSDDatatype.XSDdecimal, Integer.class, new Integer("12345"));
checkLegalLiteral("0.0", XSDDatatype.XSDdecimal, Integer.class, new Integer("0"));
checkLegalLiteral("42.45", XSDDatatype.XSDdecimal, BigDecimal.class, new BigDecimal("42.45"));
checkLegalLiteral("9223372036854775808.1234", XSDDatatype.XSDdecimal, BigDecimal.class, new BigDecimal("9223372036854775808.1234"));
checkLegalLiteral("123.4", XSDDatatype.XSDdecimal, BigDecimal.class, new BigDecimal("123.4"));
checkIllegalLiteral("123,4", XSDDatatype.XSDdecimal);
-
+
// Booleans
checkLegalLiteral("true", XSDDatatype.XSDboolean, Boolean.class, true );
checkLegalLiteral("false", XSDDatatype.XSDboolean, Boolean.class, false );
l1 = m.createTypedLiteral(true);
assertEquals("boolean mapping", XSDDatatype.XSDboolean, l1.getDatatype());
-
+
// String types
checkLegalLiteral("hello world", XSDDatatype.XSDstring, String.class, "hello world");
l1 = m.createTypedLiteral("foo bar");
assertEquals("string mapping", XSDDatatype.XSDstring, l1.getDatatype());
-
+
}
-
+
/**
* Some selected equality tests which caused problems in WG tests
*/
@@ -382,15 +317,15 @@
Literal l1 = m.createTypedLiteral("10", "http://www.w3.org/2001/XMLSchema#integer");
Literal l3 = m.createTypedLiteral("010", "http://www.w3.org/2001/XMLSchema#integer");
assertSameValueAs("Int lex form", l1, l3);
-
+
l1 = m.createTypedLiteral("1", XSDDatatype.XSDint);
l3 = m.createTypedLiteral("1", XSDDatatype.XSDnonNegativeInteger);
-
+
assertSameValueAs("numeric comparisons", l1, l3);
}
-
+
/**
- * Check that creating a typed literal from an object traps the interesting
+ * Check that creating a typed literal from an object traps the interesting
* special cases of String and Calendar.
*/
public void testOverloads() {
@@ -398,7 +333,7 @@
boolean old = JenaParameters.enableEagerLiteralValidation;
try {
JenaParameters.enableEagerLiteralValidation = true;
-
+
// String overloading cases
boolean test1 = false;
try {
@@ -407,7 +342,7 @@
test1 = true;
}
assertTrue("detected illegal string, direct", test1);
-
+
boolean test2 = false;
try {
Object foo = "foo";
@@ -416,19 +351,19 @@
test2 = true;
}
assertTrue("detected illegal string, overloaded", test2);
-
+
// Overloading of calendar convenience functions
Calendar testCal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
testCal.set(1999, 4, 30, 15, 9, 32);
testCal.set(Calendar.MILLISECOND, 0); // ms field can be undefined on Linux
Literal lc = m.createTypedLiteral((Object)testCal);
assertEquals("calendar overloading test", m.createTypedLiteral("1999-05-30T15:09:32Z", XSDDatatype.XSDdateTime), lc );
-
+
} finally {
JenaParameters.enableEagerLiteralValidation = old;
}
}
-
+
/**
* Test plain literal/xsd:string/xsd:int equality operations
*/
@@ -438,7 +373,7 @@
Literal lPlain3 = m.createTypedLiteral("10", (String)null );
Literal lPlain2 = m.createLiteral("10");
Literal lInt = m.createTypedLiteral("10", XSDDatatype.XSDint );
-
+
assertSameValueAs("Null type = plain literal", lPlain, lPlain2);
assertSameValueAs("Null type = plain literal", lPlain, lPlain3);
assertSameValueAs("Null type = plain literal", lPlain2, lPlain3);
@@ -446,7 +381,7 @@
assertDiffer("String != int", lString, lInt);
assertDiffer("Plain != int", lPlain, lInt);
assertDiffer("Plain != int", lPlain2, lInt);
-
+
// The correct answer to this is currently up to us
if (JenaParameters.enablePlainLiteralSameAsString) {
assertSameValueAs("String != plain??", lString, lPlain);
@@ -455,9 +390,9 @@
assertDiffer("String != plain??", lString, lPlain);
assertDiffer("String != plain??", lString, lPlain2);
}
-
+
}
-
+
/**
* Test cases of numeric comparison.
*/
@@ -470,12 +405,12 @@
Literal lint = m.createTypedLiteral("5", XSDDatatype.XSDint);
Literal linteger = m.createTypedLiteral("5", XSDDatatype.XSDinteger);
Literal lbyte = m.createTypedLiteral("5", XSDDatatype.XSDbyte);
-
+
assertSameValueAs("integer subclasses equal", lint, linteger);
assertSameValueAs("integer subclasses equal", lint, lbyte);
assertSameValueAs("integer subclasses equal", linteger, lbyte);
assertSameValueAs("double equality", lDouble2, lDouble3);
-
+
assertDiffer("float/double/int distinct", lDouble, lDouble2);
assertDiffer("float/double/int distinct", lDouble, lFloat);
assertDiffer("float/double/int distinct", lDouble, lint);
@@ -486,16 +421,16 @@
assertDiffer("float/double/int distinct", lbyte, lDouble);
assertDiffer("float/double/int distinct", lint, lDouble2);
assertDiffer("float/double/int distinct", lbyte, lDouble2);
-
+
assertDiffer("double inequality", lDouble3, lDouble4);
assertDiffer("double inequality", lDouble2, lDouble);
-
+
// Check decimals
Literal lDecimal = m.createTypedLiteral("5.5", XSDDatatype.XSDdecimal);
Literal lDecimal2 = m.createTypedLiteral("5.6", XSDDatatype.XSDdecimal);
assertDiffer("decimal inequality", lDecimal, lDecimal2);
}
-
+
/**
* Check basic handling of big integers and decimals
*/
@@ -503,11 +438,11 @@
Literal l1 = m.createTypedLiteral("12345678901234567890", XSDDatatype.XSDinteger);
Literal l2 = m.createTypedLiteral("12345678901234567891", XSDDatatype.XSDinteger);
assertDiffer("Big integer equality", l1, l2);
-
+
BigInteger bigint1 = new BigInteger("12345678901234567890");
Literal lb1 = m.createTypedLiteral(bigint1, XSDDatatype.XSDinteger);
assertSameValueAs("big integer creation equality", l1, lb1);
-
+
BigDecimal bigdec1 = new BigDecimal("12345678901234567890.00");
Literal ld1 = m.createTypedLiteral(bigdec1, XSDDatatype.XSDdecimal);
BigDecimal bigdec1b = new BigDecimal("12345678901234567890.0");
@@ -517,7 +452,7 @@
assertSameValueAs("big decimal equality check", ld1, ld1b);
assertSameValueAs("big decimal equality check", ld1, lb1);
assertDiffer("Decimal equality", ld1, ld2);
-
+
BigDecimal bigdecF = new BigDecimal("12345678901234567890.1");
Literal ldF = m.createTypedLiteral(bigdecF, XSDDatatype.XSDdecimal);
BigDecimal bigdecFb = new BigDecimal("12345678901234567890.10");
@@ -527,7 +462,7 @@
assertSameValueAs("big decimal equality check", ldF, ldFb);
assertDiffer("Decimal equality", ldF, ldF2);
}
-
+
/**
* Test case for a bug in retrieving a value like 3.00 from
* a probe like 3.0
@@ -540,9 +475,9 @@
Node nx2 = NodeFactory.createLiteral("0.500", dt) ;
Graph graph = Factory.createDefaultGraph() ;
graph.add(new Triple(ns, np, nx1)) ;
- assertTrue( graph.find(Node.ANY, Node.ANY, nx2).hasNext() );
+ assertTrue( graph.find(Node.ANY, Node.ANY, nx2).hasNext() );
}
-
+
/**
* Test the internal machinery of decimal normalization directly
*/
@@ -555,7 +490,7 @@
doTestDecimalCanonicalize("500.0", "500", Integer.class);
doTestDecimalCanonicalize("5.00100", "5.001", BigDecimal.class);
}
-
+
/**
* Helper for testDecimalCannonicalize. Run a single
* cannonicalization test on a value specified in string form.
@@ -565,7 +500,7 @@
assertEquals(expected, normalized.toString());
assertEquals(expectedClass, normalized.getClass());
}
-
+
/**
* Test data/time wrappers
*/
@@ -640,17 +575,17 @@
assertEquals("calendar value", cal, testCal);
assertEquals("equality test", l1, m.createTypedLiteral("1999-05-31T02:09:32Z", XSDDatatype.XSDdateTime));
assertTrue("inequality test", l1 != m.createTypedLiteral("1999-04-31T02:09:32Z", XSDDatatype.XSDdateTime));
-
+
Calendar testCal2 = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
testCal2.set(1999, 4, 30, 15, 9, 32);
testCal2.set(Calendar.MILLISECOND, 0); // ms field can be undefined on Linux
Literal lc = m.createTypedLiteral(testCal2);
assertEquals("calendar 24 hour test", m.createTypedLiteral("1999-05-30T15:09:32Z", XSDDatatype.XSDdateTime), lc );
-
+
assertEquals("calendar value", cal, testCal);
assertEquals("equality test", l1, m.createTypedLiteral("1999-05-31T02:09:32Z", XSDDatatype.XSDdateTime));
}
-
+
public void testDateTime_7() {
Calendar testCal3 = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
testCal3.clear();
@@ -662,7 +597,7 @@
String urip=urib+"prop";
String testN3 = "<"+uri1+"> <"+urip+"> \""+lc.getLexicalForm()+"\"^^<"+lc.getDatatypeURI()+"> .";
java.io.StringReader sr = new java.io.StringReader(testN3);
- m.read(sr, urib, "N3");
+ m.read(sr, urib, "N-TRIPLES");
assertTrue(m.contains(m.getResource(uri1),m.getProperty(urip)));
Resource r1 = m.getResource(uri1);
Property p = m.getProperty(urip);
@@ -691,7 +626,7 @@
assertTrue("Fraction time check", Math.abs(dt4.getSeconds() - time) < 0.0001);
assertEquals(dt4.asCalendar(), cal);
}
-
+
public void testDateTime_9() {
// Years before 1000 : xsd:dateTime requires at least a four digit year.
// GregorianCalendar does not handle negative years. (.get(YEAR) triggers
@@ -704,7 +639,7 @@
calM1.set(Calendar.DATE, 23);
XSDDateTime xdtM = new XSDDateTime(calM1);
LiteralLabel xdtM_ll = LiteralLabelFactory.createByValue(xdtM, "", XSDDatatype.XSDdateTime);
-
+
assertTrue("Pre-1000 calendar value", xdtM_ll.isWellFormed()) ;
assertTrue("Pre-1000 calendar value", xdtM_ll.getLexicalForm().matches("^[0-9]{4}-.*")) ;
}
@@ -721,7 +656,7 @@
}
assertTrue("Early detection of invalid literals", ok);
}
-
+
// date
public void testDateTime_10() {
Literal l1 = m.createTypedLiteral("1999-05-31", XSDDatatype.XSDdate);
@@ -751,7 +686,7 @@
assertTrue("Failed to prevent illegal access", false);
} catch (IllegalDateTimeFieldException e) {}
}
-
+
// gYearMonth
public void testDateTime_12() {
Literal l1 = m.createTypedLiteral("1999-05", XSDDatatype.XSDgYearMonth);
@@ -764,10 +699,10 @@
xdt.getDays();
assertTrue("Failed to prevent illegal access", false);
} catch (IllegalDateTimeFieldException e) {}
-
+
// gYear
}
-
+
public void testDateTime_13() {
Literal l1 = m.createTypedLiteral("1999", XSDDatatype.XSDgYear);
assertEquals("dateTime data type", XSDDatatype.XSDgYear, l1.getDatatype());
@@ -778,10 +713,10 @@
xdt.getMonths();
assertTrue("Failed to prevent illegal access", false);
} catch (IllegalDateTimeFieldException e) {}
-
+
// gMonth
}
-
+
public void testDateTime_14() {
Literal l1 = m.createTypedLiteral("--05--", XSDDatatype.XSDgMonth);
assertEquals("dateTime data type", XSDDatatype.XSDgMonth, l1.getDatatype());
@@ -792,9 +727,9 @@
xdt.getYears();
assertTrue("Failed to prevent illegal access", false);
} catch (IllegalDateTimeFieldException e) {}
-
+
}
-
+
// gMonthDay
public void testDateTime_15() {
Literal l1 = m.createTypedLiteral("--05-25", XSDDatatype.XSDgMonthDay);
@@ -807,9 +742,9 @@
xdt.getYears();
assertTrue("Failed to prevent illegal access", false);
} catch (IllegalDateTimeFieldException e) {}
-
+
}
-
+
// gDay
public void testDateTime_16() {
Literal l1 = m.createTypedLiteral("---25", XSDDatatype.XSDgDay);
@@ -821,9 +756,9 @@
xdt.getMonths();
assertTrue("Failed to prevent illegal access", false);
} catch (IllegalDateTimeFieldException e) {}
-
+
}
-
+
public void testDateTime_17() {
// Creation of datetime from a date object
Calendar ncal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
@@ -833,9 +768,9 @@
assertEquals("DateTime from date", XSDDatatype.XSDdateTime, l1.getDatatype());
assertEquals("DateTime from date", XSDDateTime.class, l1.getValue().getClass());
assertEquals("DateTime from date", "2003-12-08T10:50:42Z", l1.getValue().toString());
-
+
}
-
+
// Thanks to Greg Shueler for DST patch and test case
//////some of below code from java.util.GregorianCalendar javadoc///////
// create a Pacific Standard Time time zone
@@ -865,8 +800,8 @@
assertEquals("DateTime from date", "2004-04-21T19:50:42Z", l1.getValue().toString());
//System.err.println("date is: "+ncal.getTime());
- }
-
+ }
+
/**
* Test query applied to graphs containing typed values
*/
@@ -881,7 +816,7 @@
assertTrue( model.getGraph().contains( a.asNode(), p.asNode(), l1.asNode() ) );
assertTrue( model.getGraph().contains( a.asNode(), p.asNode(), l2.asNode() ) );
}
-
+
/**
* Test the isValidLiteral machinery
*/
@@ -899,7 +834,7 @@
assertTrue( ! XSDDatatype.XSDstring.isValidLiteral(ll));
assertTrue( ! XSDDatatype.XSDbyte.isValidLiteral(ll));
assertTrue( ! XSDDatatype.XSDnegativeInteger.isValidLiteral(ll));
-
+
l = m.createTypedLiteral("-2", XSDDatatype.XSDinteger);
ll = l.asNode().getLiteral();
assertTrue(XSDDatatype.XSDlong.isValidLiteral(ll));
@@ -918,28 +853,28 @@
ll = l.asNode().getLiteral();
assertTrue(! XSDDatatype.XSDdouble.isValidLiteral(ll));
assertTrue(! XSDDatatype.XSDdecimal.isValidLiteral(ll));
-
+
Literal l2 = m.createTypedLiteral("foo", XSDDatatype.XSDstring);
assertTrue(XSDDatatype.XSDstring.isValidLiteral(l2.asNode().getLiteral()));
assertTrue(XSDDatatype.XSDnormalizedString.isValidLiteral(l2.asNode().getLiteral()));
assertTrue( ! XSDDatatype.XSDint.isValidLiteral(l2.asNode().getLiteral()));
-
+
l = m.createTypedLiteral("foo bar");
ll = l.asNode().getLiteral();
assertTrue(XSDDatatype.XSDstring.isValidLiteral(ll));
assertTrue(! XSDDatatype.XSDint.isValidLiteral(ll));
-
+
l = m.createTypedLiteral("12");
ll = l.asNode().getLiteral();
assertTrue(XSDDatatype.XSDstring.isValidLiteral(ll));
assertTrue(! XSDDatatype.XSDint.isValidLiteral(ll));
-
+
// Test the isValidValue form which had a problem with numbers
assertTrue(XSDDatatype.XSDnonNegativeInteger.isValidValue(new Integer(10)));
assertTrue(XSDDatatype.XSDnonNegativeInteger.isValidValue(new Integer(10)));
assertTrue(!XSDDatatype.XSDnonNegativeInteger.isValidValue(new Integer(-10)));
assertTrue(!XSDDatatype.XSDnonNegativeInteger.isValidValue("10"));
-
+
// The correct behaviour on float/double is unclear but will be clarified
// by the SWBP working group task force on XML schema.
// For now we leave that float, double and the decimal tree are all distinct
@@ -960,10 +895,10 @@
Literal lit = m.createTypedLiteral("100", XSDDatatype.XSD+"#anySimpleType") ;
assertFalse(XSDDatatype.XSDinteger.isValidLiteral(lit.asNode().getLiteral()));
}
-
+
private static byte[] data = new byte[]{12, 42, 99};
-
+
/**
* Test binary types base64 and hexbinary
*/
@@ -972,15 +907,15 @@
byte[] data = new byte[]{12, 42, 99};
Literal l = m.createTypedLiteral(data);
LiteralLabel ll = l.asNode().getLiteral();
-
+
assertTrue("binary test 1", ll.getDatatype() instanceof XSDbinary);
-
- // base64 is registered for byte[]
- // hexBinary is not registered as a type for byte[]
+
+ // base64 is registered for byte[]
+ // hexBinary is not registered as a type for byte[]
assertTrue("binary test 1a", ll.getDatatype() instanceof XSDbase64Binary) ;
assertEquals("binary test 1b", "DCpj", ll.getLexicalForm());
}
-
+
public void testBinary2() {
// Check round tripping from value
LiteralLabel l2 = m.createTypedLiteral("DCpj", XSDDatatype.XSDbase64Binary).asNode().getLiteral();
@@ -991,14 +926,14 @@
assertEquals("binary test 5", data2b[1], data[1]);
assertEquals("binary test 6", data2b[2], data[2]);
}
-
+
public void testBinary3() {
// Check hexBinary
Literal l = m.createTypedLiteral(data, XSDDatatype.XSDhexBinary);
LiteralLabel ll = l.asNode().getLiteral();
assertEquals("binary test 1b", ll.getDatatype(), XSDDatatype.XSDhexBinary);
assertEquals("binary test 2b", Hex.encodeHexString(data, false), ll.getLexicalForm());
-
+
// Check round tripping from value
LiteralLabel l2 = m.createTypedLiteral(ll.getLexicalForm(), XSDDatatype.XSDhexBinary).asNode().getLiteral();
Object data2 = l2.getValue();
@@ -1009,18 +944,18 @@
assertEquals("binary test 6b", data2b[2], data[2]);
assertEquals(l2, ll);
}
-
- public void testBinary4() {
+
+ public void testBinary4() {
Literal la = m.createTypedLiteral("GpM7", XSDDatatype.XSDbase64Binary);
Literal lb = m.createTypedLiteral("GpM7", XSDDatatype.XSDbase64Binary);
assertTrue("equality test", la.sameValueAs(lb));
-
+
data = new byte[] {15, (byte)0xB7};
Literal l = m.createTypedLiteral(data, XSDDatatype.XSDhexBinary);
assertEquals("hexBinary encoding", "0FB7", l.getLexicalForm());
}
-
- /** Test that XSD anyURI is not sameValueAs XSD string (Xerces returns a string as the value for both) */
+
+ /** Test that XSD anyURI is not sameValueAs XSD string (Xerces returns a string as the value for both) */
public void testXSDanyURI() {
Node node1 = NodeFactory.createLiteral("http://example/", XSDDatatype.XSDanyURI) ;
Node node2 = NodeFactory.createLiteral("http://example/", XSDDatatype.XSDstring) ;
@@ -1041,19 +976,19 @@
*/
public void testDateTimeBug() {
// Bug in serialization
- String XSDDateURI = XSD.date.getURI();
- TypeMapper typeMapper=TypeMapper.getInstance();
- RDFDatatype dt = typeMapper.getSafeTypeByName(XSDDateURI);
- Object obj = dt.parse("2003-05-21");
- Literal literal = m.createTypedLiteral(obj, dt);
- literal.toString();
+ String XSDDateURI = XSD.date.getURI();
+ TypeMapper typeMapper=TypeMapper.getInstance();
+ RDFDatatype dt = typeMapper.getSafeTypeByName(XSDDateURI);
+ Object obj = dt.parse("2003-05-21");
+ Literal literal = m.createTypedLiteral(obj, dt);
+ literal.toString();
Object value2 = dt.parse(obj.toString());
assertEquals(obj, value2);
-
+
// Check alternative form doesn't provoke exceptions
RDFDatatype dateType = XSDDatatype.XSDdate;
m.createTypedLiteral("2003-05-21", dateType);
-
+
// Check alt time times
checkSerialization("2003-05-21", XSDDatatype.XSDdate);
checkSerialization("2003-05-21T12:56:10Z", XSDDatatype.XSDdateTime);
@@ -1063,7 +998,7 @@
checkSerialization("--05-12", XSDDatatype.XSDgMonthDay);
checkSerialization("---12", XSDDatatype.XSDgDay);
}
-
+
private static Date getDateFromPattern(String ts, String format, String timezoneid) throws Exception {
return getDateFromPattern(ts, new String[]{format}, TimeZone.getTimeZone(timezoneid));
}
@@ -1082,7 +1017,7 @@
}
return date;
}
-
+
public void testDateTimeBug2() throws Exception {
String[] timezonelist = {
"GMT",
@@ -1093,7 +1028,7 @@
for (String timezoneid : timezonelist) {
TimeZone tz = TimeZone.getTimeZone(timezoneid);
String[] sampletimelist = {
- "03/10/2012 01:29",
+ "03/10/2012 01:29",
// 03/11/2012 DST time change at 2 am
"03/11/2012 00:29",
"03/11/2012 01:29",
@@ -1124,7 +1059,7 @@
int dhr = cal.get(Calendar.HOUR_OF_DAY);
int dif = (xhr -dhr + offset) % 24;
Assert.assertEquals("Difference between cal and xdt", 0, dif) ;
-
+
// //System.out.println("xhr="+xhr+",dhr="+dhr+",dif="+dif);
// System.out.println(""
// +"tstr="+tstr
@@ -1136,8 +1071,8 @@
//System.out.println();
}
}
-
-
+
+
/**
* Test global parameter flags.
*/
@@ -1152,7 +1087,7 @@
}
JenaParameters.enableEagerLiteralValidation = originalFlag;
assertTrue("Early datatype format exception", foundException);
-
+
JenaParameters.enableEagerLiteralValidation = false;
foundException = false;
Literal l = null;
@@ -1169,16 +1104,16 @@
}
JenaParameters.enableEagerLiteralValidation = originalFlag;
assertTrue("Early datatype format exception", foundException);
-
+
if ( ! JenaRuntime.isRDF11 ) {
// RDF 1.1 - Simple Literals are identical terms to xsd:string hence same value always.
originalFlag = JenaParameters.enablePlainLiteralSameAsString;
Literal l1 = m.createLiteral("test string");
Literal l2 = m.createTypedLiteral("test string", XSDDatatype.XSDstring);
JenaParameters.enablePlainLiteralSameAsString = true;
- boolean ok1 = l1.sameValueAs(l2);
+ boolean ok1 = l1.sameValueAs(l2);
JenaParameters.enablePlainLiteralSameAsString = false;
- boolean ok2 = ! l1.sameValueAs(l2);
+ boolean ok2 = ! l1.sameValueAs(l2);
JenaParameters.enablePlainLiteralSameAsString = originalFlag;
assertTrue( ok1 );
assertTrue( ok2 );
@@ -1186,7 +1121,7 @@
}
/**
- * Test that equality function takes lexical distinction into account.
+ * Test that equality function takes lexical distinction into account.
*/
public void testLexicalDistinction() {
Literal l1 = m.createTypedLiteral("3.0", XSDDatatype.XSDdecimal);
@@ -1196,7 +1131,7 @@
assertSameValueAs("lexical form does not affect value", l3, l2);
assertTrue("lexical form affects equality", ! l1.equals(l2));
assertTrue("lexical form affects equality", l1.equals(l3));
-
+
// This version will become illegal in the future and will be removed then
l1 = m.createTypedLiteral("3", XSDDatatype.XSDint);
l2 = m.createTypedLiteral(" 3 ", XSDDatatype.XSDint);
@@ -1206,7 +1141,7 @@
assertTrue("lexical form affects equality", ! l1.equals(l2));
assertTrue("lexical form affects equality", l1.equals(l3));
}
-
+
/**
* Test parse/unparse pairing for problem datatypes
*/
@@ -1215,14 +1150,14 @@
doTestRoundTrip("13:20:00.000", XSDDatatype.XSDtime, false);
doTestRoundTrip("GpM7", XSDDatatype.XSDbase64Binary, true);
doTestRoundTrip("0FB7", XSDDatatype.XSDhexBinary, true);
-
+
// check value round tripping
doTestValueRoundTrip("2005-06-27", XSDDatatype.XSDdate, true);
doTestValueRoundTrip("2005", XSDDatatype.XSDgYear, true);
doTestValueRoundTrip("2005-06", XSDDatatype.XSDgYearMonth, true);
doTestValueRoundTrip("13:20:00.000", XSDDatatype.XSDtime, true);
}
-
+
/**
* Check parse/unparse loop.
*/
@@ -1235,7 +1170,7 @@
LiteralLabel ll2 = LiteralLabelFactory.create( lex2, dt );
assertTrue( ll2.isWellFormed() );
}
-
+
/**
* Check getValue/rewrap loop.
*/
@@ -1250,7 +1185,7 @@
assertEquals("Datatype round trip", dt, l2.getDatatype());
}
}
-
+
/**
* Test ability to override an apparent DateTime to be just a date
*/
@@ -1259,25 +1194,25 @@
date.setTimeZone( TimeZone.getTimeZone("GMT+0") );
XSDDateTime xsdDate = new XSDDateTime( date );
Literal l1 = m.createTypedLiteral(xsdDate, XSDDatatype.XSDdate);
-
+
assertEquals(XSDDatatype.XSDdate, l1.getDatatype());
assertEquals("2007-04-04Z", l1.getLexicalForm());
}
-
+
/**
* Test that two objects are not semantically the same
*/
private void assertDiffer( String title, Literal x, Literal y ) {
- assertTrue( title, !x.sameValueAs( y ) );
+ assertTrue( title, !x.sameValueAs( y ) );
}
-
+
/**
* Test that two objects are semantically the same
*/
private void assertSameValueAs( String title, Literal x, Literal y ) {
- assertTrue( title, x.sameValueAs( y ) );
+ assertTrue( title, x.sameValueAs( y ) );
}
-
+
/**
* Test two doubles are equal to within 0.001
*/
@@ -1298,7 +1233,7 @@
// OK this is what we expected
}
}
-
+
/**
* Check can legally construct a literal with given lex, value and dtype
*/
@@ -1308,7 +1243,7 @@
assertEquals(l.getValue(), value);
assertEquals(l.getDatatype(), dtype);
}
-
+
/**
* Chek the serialization of the parse of a value.
*/
@@ -1316,7 +1251,7 @@
Literal l = m.createTypedLiteral(lex, dtype);
assertEquals(l.getValue().toString(), lex);
}
-
+
/** Helper function test an iterator against a list of objects - order dependent */
public void assertIteratorValues( Iterator<String> it, Object[] vals ) {
boolean[] found = new boolean[vals.length];
@@ -1336,8 +1271,8 @@
assertTrue(found[i]);
}
}
-
-
+
+
}
/**
@@ -1348,11 +1283,11 @@
public static final String theTypeURI = "urn:x-hp-dt:rational";
public static final RDFDatatype theRationalType = new RationalType();
- /** private constructor - single global instance */
+ /** private constructor - single global instance */
private RationalType() {
super(theTypeURI);
}
-
+
/**
* Convert a value of this datatype out
* to lexical form.
@@ -1362,7 +1297,7 @@
Rational r = (Rational) value;
return Integer.toString(r.getNumerator()) + "/" + r.getDenominator();
}
-
+
/**
* Parse a lexical form of this datatype to a value
* @throws DatatypeFormatException if the lexical form is not legal
@@ -1381,7 +1316,7 @@
throw new DatatypeFormatException(lexicalForm, theRationalType, "");
}
}
-
+
/**
* Compares two instances of values of the given datatype.
* This does not allow rationals to be compared to other number
@@ -1392,7 +1327,7 @@
return value1.getDatatype() == value2.getDatatype()
&& value1.getValue().equals(value2.getValue());
}
-
+
}
/**
@@ -1402,7 +1337,7 @@
class Rational {
private int numerator;
private int denominator;
-
+
Rational(int numerator, int denominator) {
this.numerator = numerator;
this.denominator = denominator;
@@ -1438,7 +1373,7 @@
public void setNumerator(int numerator) {
this.numerator = numerator;
}
-
+
/**
* Printable form - not parsable
*/
@@ -1446,7 +1381,7 @@
public String toString() {
return "rational[" + numerator + "/" + denominator + "]";
}
-
+
/**
* Equality check
*/
diff --git a/jena-core/src/test/java/org/apache/jena/n3/N3JenaWriterTests.java b/jena-core/src/test/java/org/apache/jena/n3/N3JenaWriterTests.java
index 9006939..ba8e78b 100644
--- a/jena-core/src/test/java/org/apache/jena/n3/N3JenaWriterTests.java
+++ b/jena-core/src/test/java/org/apache/jena/n3/N3JenaWriterTests.java
@@ -55,15 +55,10 @@
resultsFile = basedir + "/" + resultsFile ;
// Run on each of the writers
- addTest(new Test(testName, inputFile, resultsFile,
- N3JenaWriter.n3WriterPrettyPrinter)) ;
- addTest(new Test(testName, inputFile, resultsFile,
- N3JenaWriter.n3WriterPlain)) ;
- addTest(new Test(testName, inputFile, resultsFile,
- N3JenaWriter.n3WriterTriples)) ;
+ addTest(new Test(testName, inputFile, resultsFile, N3JenaWriter.n3Writer));
+
}
-
static class Test extends TestCase
{
String writerName = null ;
diff --git a/jena-core/src/test/java/org/apache/jena/rdf/model/test/TestRDFWriterMap.java b/jena-core/src/test/java/org/apache/jena/rdf/model/test/TestRDFWriterMap.java
index 7a1f636..be08455 100644
--- a/jena-core/src/test/java/org/apache/jena/rdf/model/test/TestRDFWriterMap.java
+++ b/jena-core/src/test/java/org/apache/jena/rdf/model/test/TestRDFWriterMap.java
@@ -6,9 +6,9 @@
* 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.
@@ -22,7 +22,6 @@
import java.util.Map;
import org.apache.jena.Jena ;
-import org.apache.jena.n3.* ;
import org.apache.jena.rdf.model.RDFWriter ;
import org.apache.jena.rdf.model.RDFWriterF ;
import org.apache.jena.rdf.model.impl.NTripleWriter ;
@@ -73,30 +72,11 @@
private void loadDefaults()
{
- setWriterClassName(TestRDFWriterMap.TURTLE_WRITER, Jena.PATH
- + ".n3.N3TurtleJenaWriter");
- setWriterClassName(TestRDFWriterMap.TURTLE_WRITER_ALT1, Jena.PATH
- + ".n3.N3TurtleJenaWriter");
- setWriterClassName(TestRDFWriterMap.TURTLE_WRITER_ALT2, Jena.PATH
- + ".n3.N3TurtleJenaWriter");
- setWriterClassName(TestRDFWriterMap.RDF_XML, Jena.PATH
- + ".xmloutput.impl.Basic");
- setWriterClassName(TestRDFWriterMap.RDF_XML_ABBREV, Jena.PATH
- + ".xmloutput.impl.Abbreviated");
- setWriterClassName(TestRDFWriterMap.N3, Jena.PATH
- + ".n3.N3JenaWriter");
- setWriterClassName(TestRDFWriterMap.N3_PLAIN, Jena.PATH
- + ".n3.N3JenaWriterPlain");
- setWriterClassName(TestRDFWriterMap.N3_PP, Jena.PATH
- + ".n3.N3JenaWriterPP");
- setWriterClassName(TestRDFWriterMap.N3_TRIPLE, Jena.PATH
- + ".n3.N3JenaWriterTriples");
- setWriterClassName(TestRDFWriterMap.N3_TRIPLES, Jena.PATH
- + ".n3.N3JenaWriterTriples");
- setWriterClassName(TestRDFWriterMap.NTRIPLE, Jena.PATH
- + ".rdf.model.impl.NTripleWriter");
- setWriterClassName(TestRDFWriterMap.NTRIPLES, Jena.PATH
- + ".rdf.model.impl.NTripleWriter");
+ setWriterClassName(TestRDFWriterMap.RDF_XML, Jena.PATH + ".xmloutput.impl.Basic");
+ setWriterClassName(TestRDFWriterMap.RDF_XML_ABBREV, Jena.PATH + ".xmloutput.impl.Abbreviated");
+ setWriterClassName(TestRDFWriterMap.N3, Jena.PATH + ".n3.N3JenaWriter");
+ setWriterClassName(TestRDFWriterMap.NTRIPLE, Jena.PATH + ".rdf.model.impl.NTripleWriter");
+ setWriterClassName(TestRDFWriterMap.NTRIPLES, Jena.PATH + ".rdf.model.impl.NTripleWriter");
}
@Override
@@ -124,7 +104,7 @@
@Override
public void resetRDFWriterF() {
// TODO Auto-generated method stub
-
+
}
@Override
@@ -134,20 +114,11 @@
}
}
- public static final String TURTLE_WRITER_ALT2 = N3JenaWriter.turtleWriterAlt2;
- public static final String TURTLE_WRITER_ALT1 = N3JenaWriter.turtleWriterAlt1;
-
- public static final String TURTLE_WRITER = N3JenaWriter.turtleWriter;
public static final String RDF_XML = "RDF/XML";
public static final String RDF_XML_ABBREV = "RDF/XML-ABBREV";
public static final String NTRIPLE = "N-TRIPLE";
public static final String NTRIPLES = "N-TRIPLES";
public static final String N3 = "N3";
- public static final String N3_PLAIN = "N3-PLAIN";
- public static final String N3_PP = "N3-PP";
- public static final String N3_TRIPLE = "N3-TRIPLE";
-
- public static final String N3_TRIPLES = "N3-TRIPLES";
public TestRDFWriterMap( final String name )
{
@@ -183,29 +154,16 @@
public void testWritersAbsent()
{
- testWriterAbsent(TestRDFWriterMap.TURTLE_WRITER);
- testWriterAbsent(TestRDFWriterMap.TURTLE_WRITER_ALT1);
- testWriterAbsent(TestRDFWriterMap.TURTLE_WRITER_ALT2);
testWriterAbsent(TestRDFWriterMap.RDF_XML);
testWriterAbsent(TestRDFWriterMap.RDF_XML_ABBREV);
testWriterAbsent(TestRDFWriterMap.NTRIPLE);
testWriterAbsent(TestRDFWriterMap.NTRIPLES);
testWriterAbsent(TestRDFWriterMap.N3);
- testWriterAbsent(TestRDFWriterMap.N3_PP);
- testWriterAbsent(TestRDFWriterMap.N3_PLAIN);
- testWriterAbsent(TestRDFWriterMap.N3_TRIPLE);
- testWriterAbsent(TestRDFWriterMap.N3_TRIPLES);
}
public void testWritersPresent()
{
final RDFWriterF x = new RDFWriterMap(true);
- Assert.assertEquals(N3TurtleJenaWriter.class,
- x.getWriter(TestRDFWriterMap.TURTLE_WRITER).getClass());
- Assert.assertEquals(N3TurtleJenaWriter.class,
- x.getWriter(TestRDFWriterMap.TURTLE_WRITER_ALT1).getClass());
- Assert.assertEquals(N3TurtleJenaWriter.class,
- x.getWriter(TestRDFWriterMap.TURTLE_WRITER_ALT2).getClass());
Assert.assertEquals(Basic.class, x.getWriter(TestRDFWriterMap.RDF_XML)
.getClass());
Assert.assertEquals(Abbreviated.class,
@@ -214,15 +172,5 @@
x.getWriter(TestRDFWriterMap.NTRIPLE).getClass());
Assert.assertEquals(NTripleWriter.class,
x.getWriter(TestRDFWriterMap.NTRIPLES).getClass());
- Assert.assertEquals(N3JenaWriter.class, x
- .getWriter(TestRDFWriterMap.N3).getClass());
- Assert.assertEquals(N3JenaWriterPP.class,
- x.getWriter(TestRDFWriterMap.N3_PP).getClass());
- Assert.assertEquals(N3JenaWriterPlain.class,
- x.getWriter(TestRDFWriterMap.N3_PLAIN).getClass());
- Assert.assertEquals(N3JenaWriterTriples.class,
- x.getWriter(TestRDFWriterMap.N3_TRIPLE).getClass());
- Assert.assertEquals(N3JenaWriterTriples.class,
- x.getWriter(TestRDFWriterMap.N3_TRIPLES).getClass());
}
}
diff --git a/jena-core/src/test/java/org/apache/jena/rdf/model/test/TestReaderEvents.java b/jena-core/src/test/java/org/apache/jena/rdf/model/test/TestReaderEvents.java
index a988aa0..240ddb1 100644
--- a/jena-core/src/test/java/org/apache/jena/rdf/model/test/TestReaderEvents.java
+++ b/jena-core/src/test/java/org/apache/jena/rdf/model/test/TestReaderEvents.java
@@ -6,9 +6,9 @@
* 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.
@@ -35,15 +35,10 @@
{
super(modelFactory, name);
}
-
+
public TestReaderEvents()
{
- this( new TestPackage.PlainModelFactory(), "TestReaderEvents");
- }
-
- public void testN3ReaderEvents()
- {
- testReaderEvent("N3", "");
+ this( new TestPackage.PlainModelFactory(), "TestReaderEvents");
}
public void testNTriplesReaderEvents()
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/Manifest.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/Manifest.java
deleted file mode 100644
index 584e331..0000000
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/Manifest.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * 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.testing_framework.manifest;
-
-import java.util.ArrayList ;
-import java.util.Collection ;
-import java.util.Iterator ;
-import java.util.List ;
-
-import org.apache.jena.n3.N3IRIResolver ;
-import org.apache.jena.rdf.model.* ;
-import org.apache.jena.util.FileManager ;
-import org.apache.jena.vocabulary.RDF ;
-import org.apache.jena.vocabulary.RDFS ;
-import org.apache.jena.vocabulary.TestManifest ;
-import org.apache.jena.vocabulary.TestManifestX ;
-import org.slf4j.Logger ;
-import org.slf4j.LoggerFactory ;
-
-/**
- * A test manifest for a single manifest file.
- */
-
-@SuppressWarnings("deprecation")
-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<>();
- private Resource manifestRes = null;
-
- public Manifest(String fn) {
- log.debug("Manifest = " + fn);
- filename = N3IRIResolver.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<>();
- 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);
- }
-
-}
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestException.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestException.java
deleted file mode 100644
index 14a3d44..0000000
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestException.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.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);
- }
-}
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestFile.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestFile.java
deleted file mode 100644
index d7493bb..0000000
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestFile.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.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();
-
-}
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItem.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItem.java
deleted file mode 100644
index 9ba9028..0000000
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItem.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.testing_framework.manifest;
-
-import org.apache.jena.n3.turtle.TurtleTestVocab;
-import org.apache.jena.rdf.model.Resource;
-import org.apache.jena.vocabulary.RDF;
-import org.apache.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();
- }
-}
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItemHandler.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItemHandler.java
deleted file mode 100644
index f322867..0000000
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestItemHandler.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.testing_framework.manifest;
-
-import java.util.List ;
-
-import org.junit.runner.Runner ;
-
-public interface ManifestItemHandler {
- /**
- * Handle an item in a manifest
- */
- public void processManifestItem(ManifestItem item);
-
- public void setTestRunnerList(List<Runner> runners);
-}
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestSuite.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestSuite.java
deleted file mode 100644
index b84b683..0000000
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestSuite.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * 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.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 org.apache.jena.shared.JenaException;
-
-/**
- * Class that runs the Manifest annotated tests.
- *
- * Used with <code>@RunWith( ManifestSuite.class )</code> this class loads a
- * manifest test suite file and adds the tests.
- * <p>
- * Tests annotated with <code>@RunWith( ManifestSuite.class )</code> must
- * have a <code>ManifestFile</code> annotation specifying the path to the manifest file
- * </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<>();
-
- mf = cls.getAnnotation(ManifestFile.class);
- if (mf == null) {
- throw new IllegalStateException(
- "ManifestSuite requries ManifestFile annotation");
- }
- itemHandler = cls.getConstructor().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());
- }
-}
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTest.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTest.java
deleted file mode 100644
index f0d66b8..0000000
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.testing_framework.manifest;
-
-public abstract class ManifestTest {
-
- protected ManifestItem manifestItem;
-
- public final void setManifestItem(ManifestItem manifestItem) {
- this.manifestItem = manifestItem;
- }
-
- abstract public void runTest();
-
-}
diff --git a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTestRunner.java b/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTestRunner.java
deleted file mode 100644
index ef38c7b..0000000
--- a/jena-core/src/test/java/org/apache/jena/testing_framework/manifest/ManifestTestRunner.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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.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;
- }
-
-}