diff --git a/pom.xml b/pom.xml
index 5580def..e886ad5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,6 +13,7 @@
UTF-8
+ 5.14.1
@@ -36,15 +37,19 @@
-
- true
-
-
- true
-
- epi-public-repo
- Epimorphics Public Repository
- https://repository.epimorphics.com
+ epi-public-s3-release
+ Epimorphics S3 release repository
+ https://epi-repository.s3-eu-west-1.amazonaws.com/release
+ true
+ false
+
+
+
+ epi-public-s3-snapshot
+ Epimorphics S3 snapshot repository
+ https://epi-repository.s3-eu-west-1.amazonaws.com/snapshot
+ false
+ true
@@ -70,15 +75,26 @@
- junit
- junit
- 4.13.1
+ org.junit.jupiter
+ junit-jupiter-api
+ ${junit.jupiter.version}
test
-
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ ${junit.jupiter.version}
+ test
+
com.epimorphics
appbase
- 3.1.14
+ 4.0.0
+
+
+ org.apache.commons
+ commons-lang3
+ 3.20.0
org.apache.commons
@@ -88,31 +104,36 @@
joda-time
joda-time
- 2.3
+ 2.14.0
org.yaml
snakeyaml
- 2.4
+ 2.5
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.5.4
+
org.apache.maven.plugins
maven-compiler-plugin
- 3.3
+ 3.14.1
- 1.8
- 1.8
+ 21
+ 21
org.apache.maven.plugins
maven-scm-plugin
- 1.9.4
+ 2.2.1
developerConnection
@@ -121,13 +142,13 @@
org.apache.maven.plugins
maven-release-plugin
- 2.5.2
+ 3.3.0
org.apache.maven.plugins
maven-shade-plugin
- 2.4.1
+ 3.6.1
diff --git a/src/main/java/com/epimorphics/dclib/Main.java b/src/main/java/com/epimorphics/dclib/Main.java
index f6c97ef..75e15f0 100644
--- a/src/main/java/com/epimorphics/dclib/Main.java
+++ b/src/main/java/com/epimorphics/dclib/Main.java
@@ -213,7 +213,7 @@ public Boolean call() {
String filebasename = NameUtils.removeExtension(filename);
dc.getGlobalEnv().put(ConverterProcess.FILE_NAME, filename);
dc.getGlobalEnv().put(ConverterProcess.FILE_BASE_NAME, filebasename);
- InputStream is = new BOMInputStream( new FileInputStream(dataFileF) );
+ InputStream is = BOMInputStream.builder().setInputStream( new FileInputStream(dataFileF) ).get();
ConverterProcess process = new ConverterProcess(dc, is);
process.setDebug( args.isDebug() );
diff --git a/src/main/java/com/epimorphics/dclib/framework/ConverterProcess.java b/src/main/java/com/epimorphics/dclib/framework/ConverterProcess.java
index 564ca56..b190043 100644
--- a/src/main/java/com/epimorphics/dclib/framework/ConverterProcess.java
+++ b/src/main/java/com/epimorphics/dclib/framework/ConverterProcess.java
@@ -13,6 +13,7 @@
import java.io.InputStream;
import java.util.Map.Entry;
+import com.opencsv.exceptions.CsvValidationException;
import org.apache.commons.collections.map.LRUMap;
import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.riot.system.StreamRDF;
@@ -221,6 +222,8 @@ public boolean process() {
} catch (IOException e) {
messageReporter.reportError("Problem reading next line of source");
+ } catch (CsvValidationException csvve) {
+ messageReporter.reportError("The CSV content was invalid: " + csvve.getMessage());
} finally {
current.set(null);
}
@@ -291,7 +294,7 @@ public BindingEnv peekRow() {
}
}
- protected void preprocess() throws IOException {
+ protected void preprocess() throws IOException, CsvValidationException {
Node dataset = NodeFactory.createBlankNode();
Object baseURI = env.get(BASE_OBJECT_NAME);
@@ -332,7 +335,7 @@ protected void preprocess() throws IOException {
try {
Node prop = new Pattern(peekRow[1], dataContext).evaluateAsURINode(env, this, -1);
Node value = new Pattern(peekRow[2], dataContext).evaluateAsNode(env, this, -1);
- getOutputStream().triple( new Triple(dataset, prop, value) );
+ getOutputStream().triple(Triple.create(dataset, prop, value));
} catch (Exception e) {
messageReporter.report("Failed to process metadata row: " + e, dataSource.getLineNumber());
}
diff --git a/src/main/java/com/epimorphics/dclib/framework/ConverterService.java b/src/main/java/com/epimorphics/dclib/framework/ConverterService.java
index a7fe61d..c712824 100644
--- a/src/main/java/com/epimorphics/dclib/framework/ConverterService.java
+++ b/src/main/java/com/epimorphics/dclib/framework/ConverterService.java
@@ -15,6 +15,7 @@
import java.io.InputStream;
import org.apache.commons.io.input.BOMInputStream;
+import org.apache.jena.riot.RDFDataMgr;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -50,7 +51,7 @@ public class ConverterService extends ComponentBase {
public ConverterService(String defaultPrefixes) {
dc = new DataContext();
dc.getGlobalEnv().put(ConverterProcess.BASE_OBJECT_NAME, DEFAULT_BASE_URI);
- PrefixMapping prefixes = FileManager.get().loadModel(defaultPrefixes);
+ PrefixMapping prefixes = RDFDataMgr.loadModel(defaultPrefixes);
if (prefixes != null) {
dc.setPrefixes(prefixes);
} else {
@@ -64,7 +65,7 @@ public ConverterService(String defaultPrefixes) {
* all qnames in templates.
*/
public void setPrefixFile(String prefixes) {
- PrefixMapping pref = FileManager.get().loadModel(prefixes);
+ PrefixMapping pref = RDFDataMgr.loadModel(prefixes);
dc.setPrefixes(pref);
}
@@ -147,7 +148,7 @@ public Model simpleConvert(String templateFile, String dataFile, ProgressMonitor
String filebasename = NameUtils.removeExtension(filename);
put(ConverterProcess.FILE_NAME, filename);
put(ConverterProcess.FILE_BASE_NAME, filebasename);
- InputStream is = new BOMInputStream( new FileInputStream(dataFileF) );
+ InputStream is = BOMInputStream.builder().setInputStream( new FileInputStream(dataFileF) ).get();
ConverterProcess process = new ConverterProcess(dc, is);
process.setDebug(debug);
diff --git a/src/main/java/com/epimorphics/dclib/framework/LocatorHTTP.java b/src/main/java/com/epimorphics/dclib/framework/LocatorHTTP.java
index eb0dc4d..19075da 100644
--- a/src/main/java/com/epimorphics/dclib/framework/LocatorHTTP.java
+++ b/src/main/java/com/epimorphics/dclib/framework/LocatorHTTP.java
@@ -27,7 +27,7 @@
package com.epimorphics.dclib.framework ;
import org.apache.jena.atlas.web.TypedInputStream ;
-import org.apache.jena.riot.web.HttpOp ;
+import org.apache.jena.http.HttpOp;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
@@ -47,7 +47,7 @@ public LocatorHTTP() {
@Override
public TypedInputStream performOpen(String uri) {
if ( uri.startsWith("http://") || uri.startsWith("https://") )
- return HttpOp.execHttpGet(uri, acceptHeader) ;
+ return HttpOp.httpGet(uri, acceptHeader) ;
return null ;
}
diff --git a/src/main/java/com/epimorphics/dclib/framework/Pattern.java b/src/main/java/com/epimorphics/dclib/framework/Pattern.java
index 7099c2b..1966525 100644
--- a/src/main/java/com/epimorphics/dclib/framework/Pattern.java
+++ b/src/main/java/com/epimorphics/dclib/framework/Pattern.java
@@ -12,11 +12,13 @@
import java.util.ArrayList;
import java.util.List;
-import javax.ws.rs.NotSupportedException;
+import jakarta.ws.rs.NotSupportedException;
import org.apache.commons.jexl2.Expression;
import org.apache.commons.jexl2.JexlEngine;
import org.apache.commons.jexl2.Script;
+import org.apache.jena.datatypes.xsd.XSDDatatype;
+import org.apache.jena.vocabulary.XSD;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -225,11 +227,11 @@ public Node asNode(Object result) {
} else if (result instanceof RDFNodeWrapper) {
return ((RDFNodeWrapper)result).asRDFNode().asNode();
} else if (result instanceof String) {
- return NodeFactory.createLiteral( (String)result );
+ return NodeFactory.createLiteralString( (String)result );
} else if (result instanceof Number) {
return ValueNumber.nodeFromNumber( (Number)result );
} else if (result instanceof Boolean) {
- return NodeFactory.createLiteral( LiteralLabelFactory.createTypedLiteral(result) );
+ return NodeFactory.createLiteralDT(result.toString(), XSDDatatype.XSDboolean);
} else if (result instanceof Value) {
return ((Value)result).asNode();
} else {
diff --git a/src/main/java/com/epimorphics/dclib/sources/CSVInput.java b/src/main/java/com/epimorphics/dclib/sources/CSVInput.java
index a8414c9..8fbc39a 100644
--- a/src/main/java/com/epimorphics/dclib/sources/CSVInput.java
+++ b/src/main/java/com/epimorphics/dclib/sources/CSVInput.java
@@ -15,11 +15,13 @@
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
+import com.opencsv.CSVParser;
+import com.opencsv.CSVParserBuilder;
+import com.opencsv.CSVReader;
+import com.opencsv.CSVReaderBuilder;
+import com.opencsv.exceptions.CsvValidationException;
import org.apache.commons.io.input.BOMInputStream;
-import au.com.bytecode.opencsv.CSVParser;
-import au.com.bytecode.opencsv.CSVReader;
-
import com.epimorphics.dclib.framework.BindingEnv;
import com.epimorphics.util.EpiException;
import com.epimorphics.util.NameUtils;
@@ -35,12 +37,12 @@ public class CSVInput {
protected boolean hasPreamble = false;
protected String[] peekRow;
- public CSVInput(String filename) throws IOException {
- this( new BOMInputStream( new FileInputStream(filename) ) );
+ public CSVInput(String filename) throws IOException, CsvValidationException {
+ this(BOMInputStream.builder().setInputStream( new FileInputStream(filename) ).get());
}
- public CSVInput(InputStream ins) throws IOException {
- in = new CSVReader( new InputStreamReader(ins, StandardCharsets.UTF_8), CSVParser.DEFAULT_SEPARATOR, CSVParser.DEFAULT_QUOTE_CHARACTER, '\0' );
+ public CSVInput(InputStream ins) throws IOException, CsvValidationException {
+ in = new CSVReaderBuilder(new InputStreamReader(ins, StandardCharsets.UTF_8)).build();
String[] headerLine = in.readNext();
if (headerLine == null) {
@@ -72,7 +74,7 @@ private String safeColName(String col) {
* Return a look ahead to the next row.
* Repeat calls do not advance to further rows,
*/
- public String[] getPeekRow() throws IOException {
+ public String[] getPeekRow() throws IOException, CsvValidationException {
if (peekRow == null) {
peekRow = in.readNext();
}
@@ -83,7 +85,7 @@ public String[] getPeekRow() throws IOException {
* Advances to the next row after a prior peek.
* Returns true if a new peek was available.
*/
- public boolean advancePeek() throws IOException {
+ public boolean advancePeek() throws IOException, CsvValidationException {
peekRow = in.readNext();
lineNumber++;
return peekRow != null;
@@ -96,7 +98,7 @@ public boolean advancePeek() throws IOException {
* If there have been any peek rows then returns an env based
* on the last peeked row.
*/
- public BindingEnv nextRow() throws IOException {
+ public BindingEnv nextRow() throws IOException, CsvValidationException {
if (in != null) {
String[] rowValues = (peekRow != null) ? peekRow : in.readNext();
lineNumber++;
diff --git a/src/main/java/com/epimorphics/dclib/sources/CSVMapSource.java b/src/main/java/com/epimorphics/dclib/sources/CSVMapSource.java
index 732afeb..2f9476c 100644
--- a/src/main/java/com/epimorphics/dclib/sources/CSVMapSource.java
+++ b/src/main/java/com/epimorphics/dclib/sources/CSVMapSource.java
@@ -11,6 +11,7 @@
import java.io.IOException;
+import com.opencsv.exceptions.CsvValidationException;
import org.apache.jena.atlas.json.JsonObject;
import com.epimorphics.dclib.framework.BindingEnv;
@@ -39,7 +40,7 @@ public static boolean isSpec(JsonObject spec) {
return false;
}
- public CSVMapSource(JsonObject spec, ConverterProcess config) throws IOException {
+ public CSVMapSource(JsonObject spec, ConverterProcess config) throws IOException, CsvValidationException {
super(spec);
String keyCol = getField(JSONConstants.KEY, "key");
String valueCol = getField(JSONConstants.VALUE, "value");
@@ -76,7 +77,7 @@ private Node asNode(boolean isURI, String value) {
if (isURI) {
return NodeFactory.createURI(value);
} else {
- return NodeFactory.createLiteral(value);
+ return NodeFactory.createLiteralString(value);
}
}
}
diff --git a/src/main/java/com/epimorphics/dclib/sources/LexIndex.java b/src/main/java/com/epimorphics/dclib/sources/LexIndex.java
index deb2ca8..034acf4 100644
--- a/src/main/java/com/epimorphics/dclib/sources/LexIndex.java
+++ b/src/main/java/com/epimorphics/dclib/sources/LexIndex.java
@@ -16,6 +16,7 @@
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.text.similarity.LevenshteinDistance;
import org.apache.jena.util.OneToManyMap;
/**
@@ -25,6 +26,7 @@
* @author Dave Reynolds
*/
public class LexIndex {
+ private static final LevenshteinDistance levDist = LevenshteinDistance.getDefaultInstance();
protected OneToManyMap table = new OneToManyMap<>();
/**
@@ -48,11 +50,11 @@ public T lookup(String key) {
// There is a result but is there more than one
if (i.hasNext()) {
// Yes, so search for best
- int bestDist = StringUtils.getLevenshteinDistance(key, match.key);
+ int bestDist = levDist.apply(key, match.key);
Record best = match;
while (i.hasNext()) {
match = i.next();
- int dist = StringUtils.getLevenshteinDistance(key, match.key);
+ int dist = levDist.apply(key, match.key);
if (dist < bestDist) {
bestDist = dist;
best = match;
diff --git a/src/main/java/com/epimorphics/dclib/sources/MapSourceFactory.java b/src/main/java/com/epimorphics/dclib/sources/MapSourceFactory.java
index f1ada8c..6fd8cf2 100644
--- a/src/main/java/com/epimorphics/dclib/sources/MapSourceFactory.java
+++ b/src/main/java/com/epimorphics/dclib/sources/MapSourceFactory.java
@@ -11,6 +11,7 @@
import java.io.IOException;
+import com.opencsv.exceptions.CsvValidationException;
import org.apache.jena.atlas.json.JsonObject;
import com.epimorphics.dclib.framework.ConverterProcess;
@@ -18,7 +19,7 @@
public class MapSourceFactory {
- public static MapSource sourceFrom(JsonObject spec, ConverterProcess proc) throws IOException {
+ public static MapSource sourceFrom(JsonObject spec, ConverterProcess proc) throws IOException, CsvValidationException {
if (CSVMapSource.isSpec(spec)) {
return new CSVMapSource(spec, proc);
} else if (RDFMapSource.isSpec(spec)) {
diff --git a/src/main/java/com/epimorphics/dclib/sources/RDFMapSource.java b/src/main/java/com/epimorphics/dclib/sources/RDFMapSource.java
index 9113854..89ff9aa 100644
--- a/src/main/java/com/epimorphics/dclib/sources/RDFMapSource.java
+++ b/src/main/java/com/epimorphics/dclib/sources/RDFMapSource.java
@@ -16,6 +16,7 @@
import org.apache.jena.atlas.json.JsonObject;
import org.apache.jena.atlas.json.JsonValue;
+import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.riot.system.StreamRDF;
import com.epimorphics.dclib.framework.ConverterProcess;
@@ -68,7 +69,7 @@ public RDFMapSource(JsonObject spec, ConverterProcess proc) throws IOException {
List typeConstraints = getTypeConstraints(spec, proc);
String sourceFile = getRequiredField(JSONConstants.SOURCE);
- rdf = FileManager.get().loadModel( "file:" + findFile(sourceFile, proc) );
+ rdf = RDFDataMgr.loadModel( "file:" + findFile(sourceFile, proc) );
for (StmtIterator i = rdf.listStatements(null, keyProp, (RDFNode)null); i.hasNext();) {
Statement s = i.next();
diff --git a/src/main/java/com/epimorphics/dclib/sources/RDFSparqlMapSource.java b/src/main/java/com/epimorphics/dclib/sources/RDFSparqlMapSource.java
index adc259e..80fdef8 100644
--- a/src/main/java/com/epimorphics/dclib/sources/RDFSparqlMapSource.java
+++ b/src/main/java/com/epimorphics/dclib/sources/RDFSparqlMapSource.java
@@ -15,9 +15,10 @@
import java.util.Iterator;
import java.util.Map;
-import javax.ws.rs.NotSupportedException;
+import jakarta.ws.rs.NotSupportedException;
import org.apache.jena.atlas.json.JsonObject;
+import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.riot.system.StreamRDF;
import com.epimorphics.dclib.framework.ConverterProcess;
@@ -64,7 +65,7 @@ public static boolean isSpec(JsonObject spec) {
public RDFSparqlMapSource(JsonObject spec, ConverterProcess proc) throws IOException {
super(spec);
String sourceFile = getRequiredField(JSONConstants.SOURCE);
- Model rdf = FileManager.get().loadModel( "file:" + findFile(sourceFile, proc) );
+ Model rdf = RDFDataMgr.loadModel( "file:" + findFile(sourceFile, proc) );
String query = getRequiredField(JSONConstants.QUERY);
query = PrefixUtils.expandQuery(query, proc.getDataContext().getPrefixes());
diff --git a/src/main/java/com/epimorphics/dclib/templates/CompositeTemplate.java b/src/main/java/com/epimorphics/dclib/templates/CompositeTemplate.java
index da36f29..5125935 100644
--- a/src/main/java/com/epimorphics/dclib/templates/CompositeTemplate.java
+++ b/src/main/java/com/epimorphics/dclib/templates/CompositeTemplate.java
@@ -157,7 +157,7 @@ private void processRawColumns(Node resource, ConverterProcess proc, BindingEnv
} else {
proc.getMessageReporter().report("Warning: could not interpret raw column value: " + v, rowNumber);
}
- out.triple( new Triple(resource, predicate, obj) );
+ out.triple(Triple.create(resource, predicate, obj) );
}
}
}
diff --git a/src/main/java/com/epimorphics/dclib/templates/HierarchyTemplate.java b/src/main/java/com/epimorphics/dclib/templates/HierarchyTemplate.java
index 5ece125..9325939 100644
--- a/src/main/java/com/epimorphics/dclib/templates/HierarchyTemplate.java
+++ b/src/main/java/com/epimorphics/dclib/templates/HierarchyTemplate.java
@@ -110,7 +110,7 @@ protected void condLink(ConverterProcess proc, BindingEnv row, Pattern link,
Node resource, Node parent, int rowNumber) {
if (link != null) {
Node linkn = link.evaluateAsNode( row, proc, rowNumber );
- proc.getOutputStream().triple( new Triple(resource, linkn, parent) );
+ proc.getOutputStream().triple(Triple.create(resource, linkn, parent));
}
}
diff --git a/src/main/java/com/epimorphics/dclib/templates/TemplateBase.java b/src/main/java/com/epimorphics/dclib/templates/TemplateBase.java
index eaf0989..fb75164 100644
--- a/src/main/java/com/epimorphics/dclib/templates/TemplateBase.java
+++ b/src/main/java/com/epimorphics/dclib/templates/TemplateBase.java
@@ -17,6 +17,7 @@
import java.util.Set;
import java.util.regex.Matcher;
+import com.opencsv.exceptions.CsvValidationException;
import org.apache.jena.atlas.json.JsonObject;
import org.apache.jena.atlas.json.JsonValue;
@@ -192,7 +193,7 @@ private void processSourceSpec(JsonValue spec, ConverterProcess config) {
} else {
config.getDataContext().registerSource(source);
}
- } catch (IOException e) {
+ } catch (IOException | CsvValidationException e) {
throw new EpiException(e);
}
}
@@ -260,9 +261,9 @@ protected Triple asTriple(Pattern propPattern, Pattern valPattern, Node subject,
Node so = propPattern.isInverse() ? valPattern.asURINode(v) : valPattern.asNode(v);
validateNode(so);
if (propPattern.isInverse()) {
- return new Triple( so, prop, subject);
+ return Triple.create( so, prop, subject);
} else {
- return new Triple(subject, prop, so);
+ return Triple.create(subject, prop, so);
}
}
diff --git a/src/main/java/com/epimorphics/dclib/values/GlobalFunctions.java b/src/main/java/com/epimorphics/dclib/values/GlobalFunctions.java
index 79bbd26..b25936e 100644
--- a/src/main/java/com/epimorphics/dclib/values/GlobalFunctions.java
+++ b/src/main/java/com/epimorphics/dclib/values/GlobalFunctions.java
@@ -47,7 +47,7 @@ public static Node datatype(Object value, Object type) {
typeURI = typeURI.replace("xsd:", XSD.getURI());
}
RDFDatatype typeR = TypeMapper.getInstance().getSafeTypeByName( typeURI );
- return NodeFactory.createLiteral(value.toString(), typeR);
+ return NodeFactory.createLiteralDT(value.toString(), typeR);
}
public static Value nullValue() {
diff --git a/src/main/java/com/epimorphics/dclib/values/ValueArray.java b/src/main/java/com/epimorphics/dclib/values/ValueArray.java
index 809bb61..498a897 100644
--- a/src/main/java/com/epimorphics/dclib/values/ValueArray.java
+++ b/src/main/java/com/epimorphics/dclib/values/ValueArray.java
@@ -105,7 +105,7 @@ public Value get(int i) {
public Object datatype(final String typeURI) {
return applyFunction(new MapValue() {
public Value map(Value value) {
- return new ValueNode( NodeFactory.createLiteral(value.toString(), typeFor(typeURI)) );
+ return new ValueNode( NodeFactory.createLiteralDT(value.toString(), typeFor(typeURI)) );
}
});
}
diff --git a/src/main/java/com/epimorphics/dclib/values/ValueBase.java b/src/main/java/com/epimorphics/dclib/values/ValueBase.java
index 937c263..cc12da5 100644
--- a/src/main/java/com/epimorphics/dclib/values/ValueBase.java
+++ b/src/main/java/com/epimorphics/dclib/values/ValueBase.java
@@ -111,7 +111,7 @@ protected void reportError(String msg) {
// Value methods applicable to any type
public Object datatype(String typeURI) {
- return NodeFactory.createLiteral(toString(), typeFor(typeURI));
+ return NodeFactory.createLiteralDT(toString(), typeFor(typeURI));
}
protected RDFDatatype typeFor(String typeURI) {
@@ -306,7 +306,7 @@ public Value lastSegment() {
}
public Node lang(String lang) {
- return NodeFactory.createLiteral(toString(), lang, false);
+ return NodeFactory.createLiteralLang(toString(), lang);
}
/**
diff --git a/src/main/java/com/epimorphics/dclib/values/ValueDate.java b/src/main/java/com/epimorphics/dclib/values/ValueDate.java
index ebd0d2f..1e9154f 100644
--- a/src/main/java/com/epimorphics/dclib/values/ValueDate.java
+++ b/src/main/java/com/epimorphics/dclib/values/ValueDate.java
@@ -59,13 +59,13 @@ public ValueDate(Node node) {
private static Node stringToDate(String value) {
if (DATETIME_PATTERN.matcher(value).matches()) {
- return NodeFactory.createLiteral(value, XSDDatatype.XSDdateTime);
+ return NodeFactory.createLiteralDT(value, XSDDatatype.XSDdateTime);
} else if (DATE_PATTERN.matcher(value).matches()) {
- return NodeFactory.createLiteral(value, XSDDatatype.XSDdate);
+ return NodeFactory.createLiteralDT(value, XSDDatatype.XSDdate);
} else if (TIME_PATTERN.matcher(value).matches()) {
- return NodeFactory.createLiteral(value, XSDDatatype.XSDtime);
+ return NodeFactory.createLiteralDT(value, XSDDatatype.XSDtime);
} else if (GYEARMONTH_PATTERN.matcher(value).matches()) {
- return NodeFactory.createLiteral(value, XSDDatatype.XSDgYearMonth);
+ return NodeFactory.createLiteralDT(value, XSDDatatype.XSDgYearMonth);
} else {
return null;
}
@@ -156,7 +156,7 @@ protected static Value fromDateTime(DateTime time, String typeURI, boolean withT
if (formatted.endsWith("UTC")) {
formatted = formatted.replace("UTC", "Z");
}
- Node n = NodeFactory.createLiteral(formatted, TypeMapper.getInstance().getSafeTypeByName(typeURI));
+ Node n = NodeFactory.createLiteralDT(formatted, TypeMapper.getInstance().getSafeTypeByName(typeURI));
return new ValueDate(n);
}
@@ -184,7 +184,7 @@ protected static Value fromDateTime(LocalDateTime time, String typeURI) {
throw new EpiException("Unrecognized datetime type");
}
- Node n = NodeFactory.createLiteral(formatted, TypeMapper.getInstance().getSafeTypeByName(typeURI));
+ Node n = NodeFactory.createLiteralDT(formatted, TypeMapper.getInstance().getSafeTypeByName(typeURI));
return new ValueDate(n);
}
@@ -195,7 +195,7 @@ protected static Value fromDateTime(LocalDateTime time, String typeURI) {
* @return A ValueDate containing an RDF literal
*/
public static Value parse(String lex, String typeURI) {
- Node node = NodeFactory.createLiteral(lex, TypeMapper.getInstance().getSafeTypeByName(typeURI));
+ Node node = NodeFactory.createLiteralDT(lex, TypeMapper.getInstance().getSafeTypeByName(typeURI));
node.getLiteral().getValue(); // Checks well formed, throws exception if not
return new ValueDate( node);
}
diff --git a/src/main/java/com/epimorphics/dclib/values/ValueNode.java b/src/main/java/com/epimorphics/dclib/values/ValueNode.java
index b9c766b..32fcfe0 100644
--- a/src/main/java/com/epimorphics/dclib/values/ValueNode.java
+++ b/src/main/java/com/epimorphics/dclib/values/ValueNode.java
@@ -48,7 +48,7 @@ public String toString() {
} else if (value.isURI()) {
return value.getURI();
} else {
- return value.getBlankNodeId().toString();
+ return value.getBlankNodeLabel();
}
}
@@ -269,7 +269,7 @@ public ValueNode addPropertyValue(Value p, Node o) {
Resource prop = ResourceFactory.createResource(dc.expandURI(p.toString()) );
- out.triple(new Triple(this.asNode(), prop.asNode(), o));
+ out.triple(Triple.create(this.asNode(), prop.asNode(), o));
// model.getModel().add(this.asResource(), prop, (RDFNode) val);
return this;
@@ -300,7 +300,7 @@ public ValueNode addObjectPropertyValue(Value p, Value o) {
? o.asNode()
: ResourceFactory.createResource(dc.expandURI(o.toString())).asNode();
- out.triple(new Triple(this.asNode(), prop, res ));
+ out.triple(Triple.create(this.asNode(), prop, res ));
// model.getModel().add(this.asResource(), prop, (RDFNode) val);
return this;
diff --git a/src/main/java/com/epimorphics/dclib/values/ValueNumber.java b/src/main/java/com/epimorphics/dclib/values/ValueNumber.java
index 24b1dd5..a3196c5 100644
--- a/src/main/java/com/epimorphics/dclib/values/ValueNumber.java
+++ b/src/main/java/com/epimorphics/dclib/values/ValueNumber.java
@@ -106,7 +106,7 @@ public Node asNode() {
public static Node nodeFromNumber(Number result) {
if(result instanceof BigDecimal) {
- return NodeFactory.createLiteral( ((BigDecimal)result).toPlainString(), XSDDatatype.XSDdecimal) ;
+ return NodeFactory.createLiteralDT( ((BigDecimal)result).toPlainString(), XSDDatatype.XSDdecimal) ;
}
return NodeFactory.createLiteralByValue(result, typeFromNumber(result));
}
diff --git a/src/main/java/com/epimorphics/dclib/values/ValueString.java b/src/main/java/com/epimorphics/dclib/values/ValueString.java
index 3bb368f..2e3cfa8 100644
--- a/src/main/java/com/epimorphics/dclib/values/ValueString.java
+++ b/src/main/java/com/epimorphics/dclib/values/ValueString.java
@@ -58,11 +58,11 @@ public Node asNode() {
if (matcher.find()) {
String lang = matcher.group(1);
if (value.charAt(split-1) == '@') {
- return NodeFactory.createLiteral( value.substring(0, split) + lang );
+ return NodeFactory.createLiteralString( value.substring(0, split) + lang );
} else if (value.charAt(split-1) == '\\') {
- return NodeFactory.createLiteral( value.substring(0, split-1) + "@" + lang );
+ return NodeFactory.createLiteralString( value.substring(0, split-1) + "@" + lang );
} else {
- return NodeFactory.createLiteral(value.substring(0, split), lang, false);
+ return NodeFactory.createLiteralLang(value.substring(0, split), lang);
}
}
}
@@ -77,13 +77,13 @@ public Node asNode() {
dt = dt.substring(1, dt.length() - 1);
}
dt = ConverterProcess.getGlobalDataContext().expandURI(dt);
- return NodeFactory.createLiteral(lex, TypeMapper.getInstance().getSafeTypeByName(dt));
+ return NodeFactory.createLiteralDT(lex, TypeMapper.getInstance().getSafeTypeByName(dt));
} else {
- return NodeFactory.createLiteral(value.substring(0,split-1) + value.substring(split));
+ return NodeFactory.createLiteralString(value.substring(0,split-1) + value.substring(split));
}
}
- return NodeFactory.createLiteral( value );
+ return NodeFactory.createLiteralString( value );
}
@Override
diff --git a/src/test/java/com/epimorphics/dclib/Temp.java b/src/test/java/com/epimorphics/dclib/Temp.java
index 83dc3bd..6123700 100644
--- a/src/test/java/com/epimorphics/dclib/Temp.java
+++ b/src/test/java/com/epimorphics/dclib/Temp.java
@@ -18,9 +18,9 @@
import java.util.regex.Pattern;
import com.epimorphics.geo.GeoPoint;
-
-import au.com.bytecode.opencsv.CSVReader;
-import au.com.bytecode.opencsv.CSVWriter;
+import com.opencsv.CSVReader;
+import com.opencsv.CSVWriter;
+import com.opencsv.exceptions.CsvValidationException;
/**
* Used for experimentation or one off hacks
@@ -31,7 +31,7 @@ public class Temp {
public static final String dest = "/home/der/tmp/Data/postcodes.csv";
public static final Pattern PCMERGED = Pattern.compile( "([A-Z]{2}[0-9]{2})([0-9][A-Z]{2})" );
- public static void main(String[] args) throws IOException {
+ public static void main(String[] args) throws IOException, CsvValidationException {
Reader in = new FileReader( src );
CSVReader reader = new CSVReader(in);
Writer out = new FileWriter( dest );
diff --git a/src/test/java/com/epimorphics/dclib/framework/TestBasicConverters.java b/src/test/java/com/epimorphics/dclib/framework/TestBasicConverters.java
index 1911048..fa853cc 100644
--- a/src/test/java/com/epimorphics/dclib/framework/TestBasicConverters.java
+++ b/src/test/java/com/epimorphics/dclib/framework/TestBasicConverters.java
@@ -9,15 +9,12 @@
package com.epimorphics.dclib.framework;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
-import org.junit.Test;
+import org.apache.jena.riot.RDFDataMgr;
+import org.apache.jena.riot.RDFLanguages;
+import org.apache.jena.riot.RDFParserBuilder;
+import org.junit.jupiter.api.Test;
import com.epimorphics.rdfutil.RDFUtil;
import com.epimorphics.tasks.SimpleProgressMonitor;
@@ -35,6 +32,8 @@
import org.apache.jena.vocabulary.RDF;
import org.apache.jena.vocabulary.RDFS;
+import static org.junit.jupiter.api.Assertions.*;
+
public class TestBasicConverters {
@Test
@@ -295,7 +294,7 @@ public void testPerformanceProblem() throws IOException {
long duration = System.currentTimeMillis() - start;
if (duration > 30000) {
System.out.println("Took " + NameUtils.formatDuration(duration));
- assertTrue("Conversion exceed 30s, should be less than 1s", false);
+ fail("Conversion exceed 30s, should be less than 1s");
}
}
@@ -337,7 +336,7 @@ public static void checkAgainstExpected(String templateFile, String dataFile, St
Model m = convert(templateFile, dataFile, loadDirs);
assertNotNull(m);
String DUMMY = "http://example.com/DONOTUSE/";
- Model expected = FileManager.get().loadModel(resultFile, DUMMY, "Turtle");
+ Model expected = RDFParserBuilder.create().source(resultFile).lang(RDFLanguages.TTL).base(DUMMY).toModel();
expected = RDFUtil.mapNamespace(expected, DUMMY, "");
boolean same = m.isIsomorphicWith(expected);
// boolean rev = expected.isIsomorphicWith(m);
diff --git a/src/test/java/com/epimorphics/dclib/framework/TestBindingEnv.java b/src/test/java/com/epimorphics/dclib/framework/TestBindingEnv.java
index c12184d..2c9f95d 100644
--- a/src/test/java/com/epimorphics/dclib/framework/TestBindingEnv.java
+++ b/src/test/java/com/epimorphics/dclib/framework/TestBindingEnv.java
@@ -9,9 +9,10 @@
package com.epimorphics.dclib.framework;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
public class TestBindingEnv {
diff --git a/src/test/java/com/epimorphics/dclib/framework/TestConverterProcess.java b/src/test/java/com/epimorphics/dclib/framework/TestConverterProcess.java
index 2242334..432bbf3 100644
--- a/src/test/java/com/epimorphics/dclib/framework/TestConverterProcess.java
+++ b/src/test/java/com/epimorphics/dclib/framework/TestConverterProcess.java
@@ -9,15 +9,15 @@
package com.epimorphics.dclib.framework;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import com.epimorphics.dclib.values.ValueNumber;
import com.epimorphics.tasks.ProgressMessage;
@@ -109,8 +109,8 @@ public Node convertRow(ConverterProcess config, BindingEnv row, int rowNumber) {
throw new NullResult("Value exceeds test threshold of 20");
}
}
- Node vnode = NodeFactory.createLiteral( value.toString() );
- config.getOutputStream().triple( new Triple(root, property, vnode) );
+ Node vnode = NodeFactory.createLiteralString( value.toString() );
+ config.getOutputStream().triple( Triple.create(root, property, vnode) );
}
return root;
}
diff --git a/src/test/java/com/epimorphics/dclib/framework/TestDataContext.java b/src/test/java/com/epimorphics/dclib/framework/TestDataContext.java
index aeaa8d0..b0015f7 100644
--- a/src/test/java/com/epimorphics/dclib/framework/TestDataContext.java
+++ b/src/test/java/com/epimorphics/dclib/framework/TestDataContext.java
@@ -9,11 +9,11 @@
package com.epimorphics.dclib.framework;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.apache.jena.atlas.json.JsonObject;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import com.epimorphics.dclib.templates.TemplateBase;
diff --git a/src/test/java/com/epimorphics/dclib/framework/TestFunctions.java b/src/test/java/com/epimorphics/dclib/framework/TestFunctions.java
index d07b085..110347b 100644
--- a/src/test/java/com/epimorphics/dclib/framework/TestFunctions.java
+++ b/src/test/java/com/epimorphics/dclib/framework/TestFunctions.java
@@ -9,17 +9,17 @@
package com.epimorphics.dclib.framework;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import com.epimorphics.dclib.values.Row;
import com.epimorphics.dclib.values.Value;
diff --git a/src/test/java/com/epimorphics/dclib/framework/TestPattern.java b/src/test/java/com/epimorphics/dclib/framework/TestPattern.java
index 80d9e2e..223c943 100644
--- a/src/test/java/com/epimorphics/dclib/framework/TestPattern.java
+++ b/src/test/java/com/epimorphics/dclib/framework/TestPattern.java
@@ -9,12 +9,13 @@
package com.epimorphics.dclib.framework;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.jena.riot.RDFDataMgr;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import com.epimorphics.dclib.values.Value;
import com.epimorphics.dclib.values.ValueArray;
@@ -23,7 +24,6 @@
import org.apache.jena.datatypes.xsd.XSDDatatype;
import org.apache.jena.graph.Node;
import org.apache.jena.graph.NodeFactory;
-import org.apache.jena.util.FileManager;
import org.apache.jena.vocabulary.RDF;
public class TestPattern {
@@ -34,7 +34,7 @@ public class TestPattern {
public TestPattern() {
}
- @Before
+ @BeforeEach
public void setUp() {
proc = new ConverterProcess(dc, null);
@@ -62,7 +62,7 @@ public void setUp() {
env.set("d4", ValueFactory.asValue("0.1"));
env.set("str",ValueFactory.asValue("South Tees Hospitals NHS Foundation Trust"));
- dc.setPrefixes( FileManager.get().loadModel("prefixes.ttl") );
+ dc.setPrefixes( RDFDataMgr.loadModel("prefixes.ttl") );
}
@Test
@@ -185,36 +185,36 @@ private Object eval(String pattern) {
@Test
public void testNodeValues() {
- assertEquals(NodeFactory.createLiteral("foo\nbar", "en", false), evalNode("{ml}@en") );
+ assertEquals(NodeFactory.createLiteralLang("foo\nbar", "en"), evalNode("{ml}@en") );
assertEquals(NodeFactory.createURI("http://example.com/foo"), evalNode("<{u}>"));
- assertEquals(NodeFactory.createLiteral("42", XSDDatatype.XSDinteger), evalNode("{i}"));
- assertEquals(NodeFactory.createLiteral("true", XSDDatatype.XSDboolean), evalNode("{true}"));
- assertEquals(NodeFactory.createLiteral("false", XSDDatatype.XSDboolean), evalNode("{false}"));
- assertEquals(NodeFactory.createLiteral("true", XSDDatatype.XSDboolean), evalNode("{t.asBoolean()}"));
-
- assertEquals(NodeFactory.createLiteral("42", XSDDatatype.XSDshort), evalNode("{i.datatype('xsd:short')}"));
- assertEquals(NodeFactory.createLiteral("42", XSDDatatype.XSDstring), evalNode("{i.datatype('xsd:string')}"));
- assertEquals(NodeFactory.createLiteral("42"), evalNode("{i.asString()}"));
-
- assertEquals(NodeFactory.createLiteral("a string", "en", false), evalNode("{a.lang('en')}"));
-
- assertEquals(NodeFactory.createLiteral("b", "en", false), evalNode("b@en") );
- assertEquals(NodeFactory.createLiteral("foo bar", "en", false), evalNode("{b}@en") );
- assertEquals(NodeFactory.createLiteral("foo bar@en"), evalNode("{b}@@en") );
- assertEquals(NodeFactory.createLiteral("foo bar@en"), evalNode("{b}\\@en") );
-
- assertEquals(NodeFactory.createLiteral("foo bar", XSDDatatype.XSDstring), evalNode("{b}^^xsd:string"));
- assertEquals(NodeFactory.createLiteral("foo bar^^xsd:string"), evalNode("{b}\\^^xsd:string"));
- assertEquals(NodeFactory.createLiteral("foo bar", XSDDatatype.XSDstring), evalNode("{b}^^http://www.w3.org/2001/XMLSchema#string"));
- assertEquals(NodeFactory.createLiteral("foo bar", XSDDatatype.XSDstring), evalNode("{b}^^"));
-
- assertEquals(NodeFactory.createLiteral("42", XSDDatatype.XSDdecimal), evalNode("{i.asDecimal()}") );
- assertEquals(NodeFactory.createLiteral("0.1", XSDDatatype.XSDdecimal), evalNode("{d4.asDecimal()}") );
- assertEquals(NodeFactory.createLiteral("0.6", XSDDatatype.XSDdecimal), evalNode("{d1.asDecimal()}") );
- assertEquals(NodeFactory.createLiteral("460", XSDDatatype.XSDdecimal), evalNode("{d2.asDecimal()}") );
- assertEquals(NodeFactory.createLiteral("460000000000000000000", XSDDatatype.XSDdecimal), evalNode("{d3.asDecimal()}") );
- assertEquals(NodeFactory.createLiteral("5501000000000000000000000000000",XSDDatatype.XSDdecimal), evalNode("{big.asDecimal()}"));
+ assertEquals(NodeFactory.createLiteralDT("42", XSDDatatype.XSDinteger), evalNode("{i}"));
+ assertEquals(NodeFactory.createLiteralDT("true", XSDDatatype.XSDboolean), evalNode("{true}"));
+ assertEquals(NodeFactory.createLiteralDT("false", XSDDatatype.XSDboolean), evalNode("{false}"));
+ assertEquals(NodeFactory.createLiteralDT("true", XSDDatatype.XSDboolean), evalNode("{t.asBoolean()}"));
+
+ assertEquals(NodeFactory.createLiteralDT("42", XSDDatatype.XSDshort), evalNode("{i.datatype('xsd:short')}"));
+ assertEquals(NodeFactory.createLiteralDT("42", XSDDatatype.XSDstring), evalNode("{i.datatype('xsd:string')}"));
+ assertEquals(NodeFactory.createLiteralString("42"), evalNode("{i.asString()}"));
+
+ assertEquals(NodeFactory.createLiteralLang("a string", "en"), evalNode("{a.lang('en')}"));
+
+ assertEquals(NodeFactory.createLiteralLang("b", "en"), evalNode("b@en") );
+ assertEquals(NodeFactory.createLiteralLang("foo bar", "en"), evalNode("{b}@en") );
+ assertEquals(NodeFactory.createLiteralString("foo bar@en"), evalNode("{b}@@en") );
+ assertEquals(NodeFactory.createLiteralString("foo bar@en"), evalNode("{b}\\@en") );
+
+ assertEquals(NodeFactory.createLiteralDT("foo bar", XSDDatatype.XSDstring), evalNode("{b}^^xsd:string"));
+ assertEquals(NodeFactory.createLiteralString("foo bar^^xsd:string"), evalNode("{b}\\^^xsd:string"));
+ assertEquals(NodeFactory.createLiteralDT("foo bar", XSDDatatype.XSDstring), evalNode("{b}^^http://www.w3.org/2001/XMLSchema#string"));
+ assertEquals(NodeFactory.createLiteralDT("foo bar", XSDDatatype.XSDstring), evalNode("{b}^^"));
+
+ assertEquals(NodeFactory.createLiteralDT("42", XSDDatatype.XSDdecimal), evalNode("{i.asDecimal()}") );
+ assertEquals(NodeFactory.createLiteralDT("0.1", XSDDatatype.XSDdecimal), evalNode("{d4.asDecimal()}") );
+ assertEquals(NodeFactory.createLiteralDT("0.6", XSDDatatype.XSDdecimal), evalNode("{d1.asDecimal()}") );
+ assertEquals(NodeFactory.createLiteralDT("460", XSDDatatype.XSDdecimal), evalNode("{d2.asDecimal()}") );
+ assertEquals(NodeFactory.createLiteralDT("460000000000000000000", XSDDatatype.XSDdecimal), evalNode("{d3.asDecimal()}") );
+ assertEquals(NodeFactory.createLiteralDT("5501000000000000000000000000000",XSDDatatype.XSDdecimal), evalNode("{big.asDecimal()}"));
}
@Test
diff --git a/src/test/java/com/epimorphics/dclib/sources/TestLexIndex.java b/src/test/java/com/epimorphics/dclib/sources/TestLexIndex.java
index d4489f2..22f16d2 100644
--- a/src/test/java/com/epimorphics/dclib/sources/TestLexIndex.java
+++ b/src/test/java/com/epimorphics/dclib/sources/TestLexIndex.java
@@ -9,21 +9,20 @@
package com.epimorphics.dclib.sources;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Collection;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class TestLexIndex {
LexIndex table = new LexIndex<>();
- @Before
+ @BeforeEach
public void setUp() {
table.put("theFirstKey", "first");
table.put("first key", "second");
diff --git a/src/test/java/com/epimorphics/dclib/values/TestValueArray.java b/src/test/java/com/epimorphics/dclib/values/TestValueArray.java
index c7fb52a..03e3395 100644
--- a/src/test/java/com/epimorphics/dclib/values/TestValueArray.java
+++ b/src/test/java/com/epimorphics/dclib/values/TestValueArray.java
@@ -8,20 +8,20 @@
*****************************************************************/
package com.epimorphics.dclib.values;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
import java.util.Arrays;
+import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.util.FileManager;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import com.epimorphics.dclib.framework.BindingEnv;
import com.epimorphics.dclib.framework.ConverterProcess;
import com.epimorphics.dclib.framework.DataContext;
import com.epimorphics.dclib.framework.Pattern;
+import static org.junit.jupiter.api.Assertions.*;
+
/**
* @author skw
*
@@ -35,10 +35,10 @@ public class TestValueArray {
public TestValueArray() {
}
- @Before
+ @BeforeEach
public void setUp() {
// Need to set prefixes in DC *before* creating the converter process.
- dc.setPrefixes( FileManager.get().loadModel("prefixes.ttl") );
+ dc.setPrefixes( RDFDataMgr.loadModel("prefixes.ttl") );
proc = new ConverterProcess(dc, null);
env = new BindingEnv();
env.set("u", ValueFactory.asValue("http://example.com/foo"));
@@ -63,28 +63,31 @@ public void testCreateFromArrayAndCollection() {
String[] t_s = {"a", "b", "c", "d", "e"} ;
ValueArray t_= new ValueArray( t_s ) ;
-
- assertTrue("Failed to match array of strings", Arrays.equals( (Value[])t.getValue(), (Value [])t_.getValue() ) ) ;
- assertTrue("Failed to match integers",
+
+ assertArrayEquals((Value[]) t.getValue(), (Value[]) t_.getValue(), "Failed to match array of strings");
+ assertTrue(
((ValueArray)u).get(0).equals(value(6)) &&
((ValueArray)u).get(1).equals(value(7)) &&
((ValueArray)u).get(2).equals(value(8)) &&
((ValueArray)u).get(3).equals(value(9)) &&
- ((ValueArray)u).get(4).equals(value(10))
+ ((ValueArray)u).get(4).equals(value(10)),
+ "Failed to match integers"
) ;
- assertTrue("Failed to match values from split",
+ assertTrue(
((ValueArray)v).get(0).equals(value("one")) &&
((ValueArray)v).get(1).equals(value("two")) &&
((ValueArray)v).get(2).equals(value("three")) &&
((ValueArray)v).get(3).equals(value("4")) &&
- ((ValueArray)v).get(4).equals(value("rdfs:label"))
+ ((ValueArray)v).get(4).equals(value("rdfs:label")),
+ "Failed to match values from split"
);
- assertTrue("Failed to match values from collection" ,
+ assertTrue(
((ValueArray)w).get(0).equals(value(1)) &&
((ValueArray)w).get(1).equals(value(2)) &&
((ValueArray)w).get(2).equals(value(3)) &&
((ValueArray)w).get(3).equals(value(4)) &&
- ((ValueArray)w).get(4).equals(value(5))
+ ((ValueArray)w).get(4).equals(value(5)),
+ "Failed to match values from collection"
) ;
}
diff --git a/src/test/java/com/epimorphics/dclib/values/TestValueDate.java b/src/test/java/com/epimorphics/dclib/values/TestValueDate.java
index 52b2af7..6a6d181 100644
--- a/src/test/java/com/epimorphics/dclib/values/TestValueDate.java
+++ b/src/test/java/com/epimorphics/dclib/values/TestValueDate.java
@@ -9,15 +9,12 @@
package com.epimorphics.dclib.values;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
+import org.apache.jena.riot.RDFDataMgr;
import org.joda.time.DateTime;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import com.epimorphics.dclib.framework.BindingEnv;
import com.epimorphics.dclib.framework.ConverterProcess;
@@ -27,19 +24,20 @@
import com.epimorphics.rdfutil.RDFUtil;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.Resource;
-import org.apache.jena.util.FileManager;
import org.apache.jena.vocabulary.DCTerms;
import org.apache.jena.vocabulary.XSD;
+import static org.junit.jupiter.api.Assertions.*;
+
public class TestValueDate {
DataContext dc = new DataContext();
ConverterProcess proc;
BindingEnv env;
- @Before
+ @BeforeEach
public void setUp() {
proc = new ConverterProcess(dc, null);
- dc.setPrefixes( FileManager.get().loadModel("prefixes.ttl") );
+ dc.setPrefixes( RDFDataMgr.loadModel("prefixes.ttl") );
env = new BindingEnv();
env.put("date", ValueDate.parse("2014-09-11") );
env.put("datetime", ValueDate.parse("2014-09-11T12:42:21.23") );
@@ -118,7 +116,7 @@ public void testCoercions() {
try {
doTestCoercion("2014 03", XSD.gYearMonth.getURI(), "2014-03");
- assertTrue("Should have raised exception", false);
+ fail("Should have raised exception");
} catch (Exception e) { }
doTestCoercion("2014 03", "yyyy MM", XSD.gYearMonth.getURI(), "2014-03");
doTestCoercion("2014 03", "yyyy-MM|yyyy MM", XSD.gYearMonth.getURI(), "2014-03");
diff --git a/src/test/java/com/epimorphics/dclib/values/TestValueNode.java b/src/test/java/com/epimorphics/dclib/values/TestValueNode.java
index 79a466e..a8c61ea 100644
--- a/src/test/java/com/epimorphics/dclib/values/TestValueNode.java
+++ b/src/test/java/com/epimorphics/dclib/values/TestValueNode.java
@@ -8,25 +8,19 @@
*****************************************************************/
package com.epimorphics.dclib.values;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import java.io.IOException;
import java.math.BigDecimal;
import org.apache.jena.datatypes.xsd.XSDDatatype;
import org.apache.jena.graph.Node;
-import org.apache.jena.graph.NodeFactory;
import org.apache.jena.rdf.model.Resource;
-import org.apache.jena.util.FileManager;
+import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.vocabulary.DCTerms;
-import org.apache.jena.vocabulary.RDF;
import org.apache.jena.vocabulary.RDFS;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import com.epimorphics.dclib.framework.BindingEnv;
import com.epimorphics.dclib.framework.ConverterProcess;
@@ -46,10 +40,10 @@ public class TestValueNode {
public TestValueNode() {
}
- @Before
+ @BeforeEach
public void setUp() {
// Need to set prefixes in DC *before* creating the converter process.
- dc.setPrefixes( FileManager.get().loadModel("prefixes.ttl") );
+ dc.setPrefixes( RDFDataMgr.loadModel("prefixes.ttl") );
proc = new ConverterProcess(dc, null);
env = new BindingEnv();
env.set("u", ValueFactory.asValue("http://example.com/foo"));
@@ -72,12 +66,12 @@ public void testAddProperty() {
+ "}"
);
- assertTrue("Missing or unexpected rdfs:label value", proc.getModel().contains(r, RDFS.label,proc.getModel().createLiteral("This is a test","en")));
- assertTrue("Missing or unexpected dct:created value", proc.getModel().contains(r, DCTerms.created,proc.getModel().createTypedLiteral("2018-05-29T12:24:00Z",XSDDatatype.XSDdateTime)));
- assertTrue("Missing or unexpected dct:hasVersion (decimal) value", proc.getModel().contains(r, DCTerms.hasVersion,proc.getModel().createTypedLiteral(BigDecimal.valueOf(10.5))));
- assertTrue("Missing or unexpected dct:isVersionOf (resource) value", proc.getModel().contains(r, DCTerms.isVersionOf, proc.getModel().getResource("http://example.com/bar")));
- assertTrue("Missing or unexpected dct:isVersionOf (resource) value", proc.getModel().contains(r, DCTerms.isVersionOf, proc.getModel().getResource("http://example.com/bar2")));
- assertTrue("Missing or unexpected rdfs:label value", proc.getModel().contains(r, RDFS.label, proc.getModel().createLiteral("This is also a test","en")));
+ assertTrue(proc.getModel().contains(r, RDFS.label,proc.getModel().createLiteral("This is a test","en")), "Missing or unexpected rdfs:label value");
+ assertTrue(proc.getModel().contains(r, DCTerms.created,proc.getModel().createTypedLiteral("2018-05-29T12:24:00Z",XSDDatatype.XSDdateTime)), "Missing or unexpected dct:created value");
+ assertTrue(proc.getModel().contains(r, DCTerms.hasVersion,proc.getModel().createTypedLiteral(BigDecimal.valueOf(10.5))), "Missing or unexpected dct:hasVersion (decimal) value");
+ assertTrue(proc.getModel().contains(r, DCTerms.isVersionOf, proc.getModel().getResource("http://example.com/bar")), "Missing or unexpected dct:isVersionOf (resource) value");
+ assertTrue(proc.getModel().contains(r, DCTerms.isVersionOf, proc.getModel().getResource("http://example.com/bar2")), "Missing or unexpected dct:isVersionOf (resource) value");
+ assertTrue(proc.getModel().contains(r, RDFS.label, proc.getModel().createLiteral("This is also a test","en")), "Missing or unexpected rdfs:label value");
}
diff --git a/test/mapping/sampling-points.ttl b/test/mapping/sampling-points.ttl
index 40ff7e2..5a3059e 100644
--- a/test/mapping/sampling-points.ttl
+++ b/test/mapping/sampling-points.ttl
@@ -4,5 +4,4 @@
- .
-
\ No newline at end of file
+ .
\ No newline at end of file