diff --git a/.travis.yml b/.travis.yml index 29a226e2..a311838b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,3 +6,10 @@ notifications: email: false after_success: - mvn clean test jacoco:report coveralls:report +arch: + - amd64 + - ppc64le + +cache: + directories: + - $HOME/.m2 diff --git a/README.md b/README.md index 2270d45c..f1102e69 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ From Maven com.github.jsonld-java jsonld-java - 0.13.0 + 0.13.5 Code example @@ -323,11 +323,11 @@ Here is the basic outline for what your module's pom.xml should look like com.github.jsonld-java jsonld-java-parent - 0.13.0 + 0.13.5 4.0.0 jsonld-java-{your module} - 0.13.0-SNAPSHOT + 0.13.5-SNAPSHOT JSONLD Java :: {your module name} JSON-LD Java integration module for {RDF Library your module integrates} jar @@ -449,6 +449,37 @@ Alternatively, we can also host your repository in the jsonld-java organisation CHANGELOG ========= +### 2023-11-06 +* Release 0.13.6 +* Bump Jackson-databind version to latest for security update + +### 2023-11-03 +* Release 0.13.5 +* Bump Jackson and Guava versions to latest for security updates + +### 2021-12-13 +* Release 0.13.4 +* Switch test logging from log4j to logback (Patch by @ansell) +* Improve Travis CI build Performance (Patch by @YunLemon) + +### 2021-03-06 +* Release 0.13.3 +* Fix @type when subject and object are the same (Reported by @barthanssens, Patch by @umbreak) +* Ignore @base if remote context is not relative (Reported by @whikloj, Patch by @dr0i) +* Fix throwing recursive context inclusion (Patch by @umbreak) + +### 2020-09-24 +* Release 0.13.2 +* Fix Guava dependency shading (Reported by @ggrasso) +* Fix @context issues when using a remote context (Patch by @umbreak) +* Deprecate Context.serialize (Patch by @umbreak) + +### 2020-09-09 +* Release 0.13.1 +* Fix java.net.URI resolution (Reported by @ebremer and @afs, Patch by @dr0i) +* Shade Guava failureaccess module (Patch by @peacekeeper) +* Don't minimize Guava class shading (Patch by @elahrvivaz) +* Follow link headers to @context files (Patch by @dr0i and @fsteeg) ### 2019-11-28 * Release 0.13.0 diff --git a/core/pom.xml b/core/pom.xml index c7ca4139..f14fb287 100755 --- a/core/pom.xml +++ b/core/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.13.1-SNAPSHOT + 0.13.6 4.0.0 jsonld-java @@ -53,8 +53,8 @@ test - org.slf4j - slf4j-log4j12 + ch.qos.logback + logback-classic test @@ -74,6 +74,7 @@ com.google.guava:guava + com.google.guava:failureaccess @@ -81,8 +82,11 @@ com.google.common com.github.jsonldjava.shaded.com.google.common + + com.google.thirdparty + com.github.jsonldjava.shaded.com.google.thirdparty + - true com.google.guava:guava @@ -90,6 +94,12 @@ META-INF/maven/** + + com.google.guava:failureaccess + + META-INF/maven/** + + diff --git a/core/src/main/java/com/github/jsonldjava/core/Context.java b/core/src/main/java/com/github/jsonldjava/core/Context.java index 8c149b08..4e563d78 100644 --- a/core/src/main/java/com/github/jsonldjava/core/Context.java +++ b/core/src/main/java/com/github/jsonldjava/core/Context.java @@ -9,6 +9,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.regex.Pattern; import com.github.jsonldjava.core.JsonLdError.Error; import com.github.jsonldjava.utils.JsonLdUrl; @@ -25,6 +26,7 @@ public class Context extends LinkedHashMap { private static final long serialVersionUID = 2894534897574805571L; + private static final Pattern URL_PATTERN = Pattern.compile("^https?://.*$", Pattern.CASE_INSENSITIVE); private JsonLdOptions options; private Map termDefinitions; public Map inverse = null; @@ -141,8 +143,10 @@ && getTermDefinition(activeProperty).containsKey(JsonLdConsts.LANGUAGE) * @throws JsonLdError * If there is an error parsing the contexts. */ - @SuppressWarnings("unchecked") public Context parse(Object localContext, List remoteContexts) throws JsonLdError { + if (remoteContexts == null) { + remoteContexts = new ArrayList(); + } return parse(localContext, remoteContexts, false); } @@ -163,11 +167,8 @@ public Context parse(Object localContext, List remoteContexts) throws Js * @throws JsonLdError * If there is an error parsing the contexts. */ - private Context parse(Object localContext, List remoteContexts, + private Context parse(Object localContext, final List remoteContexts, boolean parsingARemoteContext) throws JsonLdError { - if (remoteContexts == null) { - remoteContexts = new ArrayList(); - } // 1. Initialize result to the result of cloning active context. Context result = this.clone(); // TODO: clone? // 2) @@ -187,13 +188,18 @@ private Context parse(Object localContext, List remoteContexts, } // 3.2) else if (context instanceof String) { - String uri = (String) result.get(JsonLdConsts.BASE); + String uri = null; + // @base is ignored when processing remote contexts, https://github.com/jsonld-java/jsonld-java/issues/304 + if (!URL_PATTERN.matcher(context.toString()).matches()) { + uri = (String) result.get(JsonLdConsts.BASE); + } uri = JsonLdUrl.resolve(uri, (String) context); // 3.2.2 if (remoteContexts.contains(uri)) { throw new JsonLdError(Error.RECURSIVE_CONTEXT_INCLUSION, uri); } - remoteContexts.add(uri); + List nextRemoteContexts = new ArrayList<>(remoteContexts); + nextRemoteContexts.add(uri); // 3.2.3: Dereference context final RemoteDocument rd = this.options.getDocumentLoader().loadDocument(uri); @@ -208,7 +214,7 @@ else if (context instanceof String) { .get(JsonLdConsts.CONTEXT); // 3.2.4 - result = result.parse(tempContext, remoteContexts, true); + result = result.parse(tempContext, nextRemoteContexts, true); // 3.2.5 continue; } else if (!(context instanceof Map)) { @@ -304,9 +310,7 @@ public Context parse(Object localContext) throws JsonLdError { * * http://json-ld.org/spec/latest/json-ld-api/#create-term-definition * - * @param result * @param context - * @param key * @param defined * @throws JsonLdError */ @@ -572,7 +576,7 @@ else if (relative) { * the IRI to compact. * @param value * the value to check or null. - * @param relativeTo + * @param relativeToVocab * options for how to compact IRIs: vocab: true to split * after @vocab, false not to. * @param reverse @@ -1147,6 +1151,7 @@ else if (this.get(JsonLdConsts.LANGUAGE) != null) { return rval; } + @Deprecated public Map serialize() { final Map ctx = newMap(); if (this.get(JsonLdConsts.BASE) != null diff --git a/core/src/main/java/com/github/jsonldjava/core/JsonLdApi.java b/core/src/main/java/com/github/jsonldjava/core/JsonLdApi.java index 74cea926..2195d09a 100644 --- a/core/src/main/java/com/github/jsonldjava/core/JsonLdApi.java +++ b/core/src/main/java/com/github/jsonldjava/core/JsonLdApi.java @@ -2001,7 +2001,8 @@ public List fromRDF(final RDFDataset dataset, boolean noDuplicatesInData // 3.5.4) if (RDF_TYPE.equals(predicate) && (object.isIRI() || object.isBlankNode()) - && !opts.getUseRdfType() && !nodes.containsKey(object.getValue())) { + && !opts.getUseRdfType() && + (!nodes.containsKey(object.getValue()) || subject.equals(object.getValue()))) { JsonLdUtils.mergeValue(node, JsonLdConsts.TYPE, object.getValue()); continue; } diff --git a/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java b/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java index 00fd3e16..fedff3d2 100644 --- a/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java +++ b/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java @@ -70,19 +70,12 @@ public static Map compact(Object input, Object context, JsonLdOp compacted = tmp; } } - if (compacted != null && context != null) { - // TODO: figure out if we can make "@context" appear at the start of - // the keySet - if ((context instanceof Map && !((Map) context).isEmpty()) - || (context instanceof List && !((List) context).isEmpty())) { - - if (context instanceof List && ((List) context).size() == 1 - && opts.getCompactArrays()) { - ((Map) compacted).put(JsonLdConsts.CONTEXT, - ((List) context).get(0)); - } else { - ((Map) compacted).put(JsonLdConsts.CONTEXT, context); - } + if (compacted != null) { + final Object returnedContext = returnedContext(context, opts); + if(returnedContext != null) { + // TODO: figure out if we can make "@context" appear at the start of + // the keySet + ((Map) compacted).put(JsonLdConsts.CONTEXT, returnedContext); } } @@ -250,7 +243,11 @@ public static Object flatten(Object input, Object context, JsonLdOptions opts) compacted = tmp; } final String alias = activeCtx.compactIri(JsonLdConsts.GRAPH); - final Map rval = activeCtx.serialize(); + final Map rval = newMap(); + final Object returnedContext = returnedContext(context, opts); + if(returnedContext != null) { + rval.put(JsonLdConsts.CONTEXT, returnedContext); + } rval.put(alias, compacted); return rval; } @@ -319,14 +316,18 @@ public static Map frame(Object input, Object frame, JsonLdOption // to a new empty // context, otherwise. final JsonLdApi api = new JsonLdApi(expandedInput, opts); - final Context activeCtx = api.context - .parse(((Map) frame).get(JsonLdConsts.CONTEXT)); + final Object context = ((Map) frame).get(JsonLdConsts.CONTEXT); + final Context activeCtx = api.context.parse(context); final List framed = api.frame(expandedInput, expandedFrame); if (opts.getPruneBlankNodeIdentifiers()) { JsonLdUtils.pruneBlankNodes(framed); } Object compacted = api.compact(activeCtx, null, framed, opts.getCompactArrays()); - final Map rval = activeCtx.serialize(); + final Map rval = newMap(); + final Object returnedContext = returnedContext(context, opts); + if(returnedContext != null) { + rval.put(JsonLdConsts.CONTEXT, returnedContext); + } final boolean addGraph = ((!(compacted instanceof List)) && !opts.getOmitGraph()); if (addGraph && !(compacted instanceof List)) { final List tmp = new ArrayList(); @@ -343,6 +344,28 @@ public static Map frame(Object input, Object frame, JsonLdOption return rval; } + /** + * Builds the context to be returned in framing, flattening and compaction algorithms. + * In cases where the context is empty or from an unexpected type, it returns null. + * When JsonLdOptions compactArrays is set to true and the context contains a List with a single element, + * the element is returned instead of the list + */ + private static Object returnedContext(Object context, JsonLdOptions opts) { + if (context != null && + ((context instanceof Map && !((Map) context).isEmpty()) + || (context instanceof List && !((List) context).isEmpty()) + || (context instanceof String && !((String) context).isEmpty()))) { + + if (context instanceof List && ((List) context).size() == 1 + && opts.getCompactArrays()) { + return ((List) context).get(0); + } + return context; + } else { + return null; + } + } + /** * A registry for RDF Parsers (in this case, JSONLDSerializers) used by * fromRDF if no specific serializer is specified and options.format is set. diff --git a/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java b/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java index f7e0581b..c24c8467 100644 --- a/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java +++ b/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java @@ -9,14 +9,28 @@ import java.io.StringWriter; import java.io.Writer; import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.jsonldjava.core.DocumentLoader; +import com.github.jsonldjava.core.JsonLdApi; +import com.github.jsonldjava.core.JsonLdProcessor; + import org.apache.commons.io.ByteOrderMark; import org.apache.commons.io.IOUtils; import org.apache.commons.io.input.BOMInputStream; +import org.apache.http.Header; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpUriRequest; @@ -28,17 +42,8 @@ import org.apache.http.impl.client.cache.BasicHttpCacheStorage; import org.apache.http.impl.client.cache.CacheConfig; import org.apache.http.impl.client.cache.CachingHttpClientBuilder; - -import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.github.jsonldjava.core.DocumentLoader; -import com.github.jsonldjava.core.JsonLdApi; -import com.github.jsonldjava.core.JsonLdProcessor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Functions used to make loading, parsing, and serializing JSON easy using @@ -66,6 +71,8 @@ public class JsonUtils { private static final JsonFactory JSON_FACTORY = new JsonFactory(JSON_MAPPER); private static volatile CloseableHttpClient DEFAULT_HTTP_CLIENT; + // Avoid possible endless loop when following alternate locations + private static final int MAX_LINKS_FOLLOW = 20; static { // Disable default Jackson behaviour to close @@ -109,6 +116,10 @@ public static Object fromInputStream(InputStream input) throws IOException { } } return fromInputStream(bOMInputStream, charset); + } finally { + if (input != null) { + input.close(); + } } } @@ -335,40 +346,69 @@ public static Object fromURL(java.net.URL url, CloseableHttpClient httpClient) final String protocol = url.getProtocol(); // We can only use the Apache HTTPClient for HTTP/HTTPS, so use the // native java client for the others - CloseableHttpResponse response = null; - InputStream in = null; - try { - if (!protocol.equalsIgnoreCase("http") && !protocol.equalsIgnoreCase("https")) { - // Can't use the HTTP client for those! - // Fallback to Java's built-in JsonLdUrl handler. No need for - // Accept headers as it's likely to be file: or jar: - in = url.openStream(); - } else { - final HttpUriRequest request = new HttpGet(url.toExternalForm()); - // We prefer application/ld+json, but fallback to - // application/json - // or whatever is available - request.addHeader("Accept", ACCEPT_HEADER); - - response = httpClient.execute(request); - final int status = response.getStatusLine().getStatusCode(); - if (status != 200 && status != 203) { - throw new IOException("Can't retrieve " + url + ", status code: " + status); - } - in = response.getEntity().getContent(); + if (!protocol.equalsIgnoreCase("http") && !protocol.equalsIgnoreCase("https")) { + // Can't use the HTTP client for those! + // Fallback to Java's built-in JsonLdUrl handler. No need for + // Accept headers as it's likely to be file: or jar: + return fromInputStream(url.openStream()); + } else { + return fromJsonLdViaHttpUri(url, httpClient, 0); + } + } + + private static Object fromJsonLdViaHttpUri(final URL url, final CloseableHttpClient httpClient, int linksFollowed) + throws IOException { + final HttpUriRequest request = new HttpGet(url.toExternalForm()); + // We prefer application/ld+json, but fallback to application/json + // or whatever is available + request.addHeader("Accept", ACCEPT_HEADER); + try (CloseableHttpResponse response = httpClient.execute(request)) { + final int status = response.getStatusLine().getStatusCode(); + if (status != 200 && status != 203) { + throw new IOException("Can't retrieve " + url + ", status code: " + status); } - return fromInputStream(in); - } finally { - try { - if (in != null) { - in.close(); + // follow alternate document location + // https://www.w3.org/TR/json-ld11/#alternate-document-location + URL alternateLink = alternateLink(url, response); + if (alternateLink != null) { + linksFollowed++; + if (linksFollowed > MAX_LINKS_FOLLOW) { + throw new IOException("Too many alternate links followed. This may indicate a cycle. Aborting."); } - } finally { - if (response != null) { - response.close(); + return fromJsonLdViaHttpUri(alternateLink, httpClient, linksFollowed); + } + return fromInputStream(response.getEntity().getContent()); + } + } + + private static URL alternateLink(URL url, CloseableHttpResponse response) + throws MalformedURLException { + if (response.getEntity().getContentType() != null + && !response.getEntity().getContentType().getValue().equals("application/ld+json")) { + for (Header header : response.getAllHeaders()) { + if (header.getName().equalsIgnoreCase("link")) { + String alternateLink = ""; + boolean relAlternate = false; + boolean jsonld = false; + for (String value : header.getValue().split(";")) { + value=value.trim(); + if (value.startsWith("<") && value.endsWith(">")) { + alternateLink = value.substring(1, value.length() - 1); + } + if (value.startsWith("type=\"application/ld+json\"")) { + jsonld = true; + } + if (value.startsWith("rel=\"alternate\"")) { + relAlternate = true; + } + } + if (jsonld && relAlternate && !alternateLink.isEmpty()) { + return new URL(url.getProtocol() + "://" + url.getAuthority() + alternateLink); + } } } } + return null; } /** @@ -384,7 +424,7 @@ public static Object fromURL(java.net.URL url, CloseableHttpClient httpClient) * @throws IOException * If there was an IO error during parsing. */ - public static Object fromURLJavaNet(java.net.URL url) throws JsonParseException, IOException { + public static Object fromURLJavaNet(URL url) throws JsonParseException, IOException { final HttpURLConnection urlConn = (HttpURLConnection) url.openConnection(); urlConn.addRequestProperty("Accept", ACCEPT_HEADER); diff --git a/core/src/test/java/com/github/jsonldjava/core/ContextCompactionTest.java b/core/src/test/java/com/github/jsonldjava/core/ContextCompactionTest.java index 252621e1..31bfc3ef 100644 --- a/core/src/test/java/com/github/jsonldjava/core/ContextCompactionTest.java +++ b/core/src/test/java/com/github/jsonldjava/core/ContextCompactionTest.java @@ -1,20 +1,21 @@ package com.github.jsonldjava.core; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; - import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +import com.github.jsonldjava.utils.JsonUtils; import org.junit.Test; + public class ContextCompactionTest { - // @Ignore("Disable until schema.org is fixed") @Test - public void testCompaction() throws Exception { + public void testCompaction() { final Map contextAbbrevs = new HashMap(); contextAbbrevs.put("so", "http://schema.org/"); @@ -34,19 +35,30 @@ public void testCompaction() throws Exception { options.setBase("http://schema.org/"); options.setCompactArrays(true); - // System.out.println("Before compact"); - // System.out.println(JsonUtils.toPrettyString(json)); - final List newContexts = new LinkedList(); newContexts.add("http://schema.org/"); final Map compacted = JsonLdProcessor.compact(json, newContexts, options); - // System.out.println("\n\nAfter compact:"); - // System.out.println(JsonUtils.toPrettyString(compacted)); - assertTrue("Compaction removed the context", compacted.containsKey("@context")); assertFalse("Compaction of context should be a string, not a list", compacted.get("@context") instanceof List); } + @Test + public void testCompactionSingleRemoteContext() throws Exception { + final String jsonString = "[{\"@type\": [\"http://schema.org/Person\"] } ]"; + final String ctxStr = "{\"@context\": \"http://schema.org/\"}"; + + final Object json = JsonUtils.fromString(jsonString); + final Object ctx = JsonUtils.fromString(ctxStr); + + final JsonLdOptions options = new JsonLdOptions(); + + final Map compacted = JsonLdProcessor.compact(json, ctx, options); + + assertEquals("Wrong returned context", "http://schema.org/", compacted.get("@context")); + assertEquals("Wrong type", "Person", compacted.get("type")); + assertEquals("Wrong number of Json entries",2, compacted.size()); + } + } diff --git a/core/src/test/java/com/github/jsonldjava/core/ContextFlatteningTest.java b/core/src/test/java/com/github/jsonldjava/core/ContextFlatteningTest.java new file mode 100644 index 00000000..8e3a1710 --- /dev/null +++ b/core/src/test/java/com/github/jsonldjava/core/ContextFlatteningTest.java @@ -0,0 +1,66 @@ +package com.github.jsonldjava.core; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import com.github.jsonldjava.utils.JsonUtils; +import org.junit.Test; + +public class ContextFlatteningTest { + + @Test + public void testFlatenning() throws Exception { + + final Map contextAbbrevs = new HashMap<>(); + contextAbbrevs.put("so", "http://schema.org/"); + + final Map json = new HashMap<>(); + json.put("@context", contextAbbrevs); + json.put("@id", "http://example.org/my_work"); + + final List types = new LinkedList<>(); + types.add("so:CreativeWork"); + + json.put("@type", types); + json.put("so:name", "My Work"); + json.put("so:url", "http://example.org/my_work"); + + final JsonLdOptions options = new JsonLdOptions(); + options.setBase("http://schema.org/"); + options.setCompactArrays(true); + options.setOmitGraph(true); + + final String flattenStr = "{\"@id\": \"http://schema.org/myid\", \"@context\": \"http://schema.org/\"}"; + final Object flatten = JsonUtils.fromString(flattenStr); + + final Map flattened = ((Map)JsonLdProcessor.flatten(json, flatten, options)); + + assertTrue("Flattening removed the context", flattened.containsKey("@context")); + assertFalse("Flattening of context should be a string, not a list", + flattened.get("@context") instanceof List); + } + + @Test + public void testFlatteningRemoteContext() throws Exception { + final String jsonString = + "{\"@context\": {\"@vocab\": \"http://schema.org/\"}, \"knows\": [{\"name\": \"a\"}, {\"name\": \"b\"}] }"; + final String flattenStr = "{\"@context\": \"http://schema.org/\"}"; + + final Object json = JsonUtils.fromString(jsonString); + final Object flatten = JsonUtils.fromString(flattenStr); + + final JsonLdOptions options = new JsonLdOptions(); + options.setOmitGraph(true); + + final Map flattened = ((Map)JsonLdProcessor.flatten(json, flatten, options)); + + assertEquals("Wrong returned context", "http://schema.org/", flattened.get("@context")); + assertEquals("Wrong number of Json entries",2, flattened.size()); + } + +} diff --git a/core/src/test/java/com/github/jsonldjava/core/ContextFramingTest.java b/core/src/test/java/com/github/jsonldjava/core/ContextFramingTest.java new file mode 100644 index 00000000..73116205 --- /dev/null +++ b/core/src/test/java/com/github/jsonldjava/core/ContextFramingTest.java @@ -0,0 +1,67 @@ +package com.github.jsonldjava.core; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import com.github.jsonldjava.utils.JsonUtils; +import org.junit.Test; + +public class ContextFramingTest { + + @Test + public void testFraming() throws Exception { + + final Map contextAbbrevs = new HashMap<>(); + contextAbbrevs.put("so", "http://schema.org/"); + + final Map json = new HashMap<>(); + json.put("@context", contextAbbrevs); + json.put("@id", "http://example.org/my_work"); + + final List types = new LinkedList<>(); + types.add("so:CreativeWork"); + + json.put("@type", types); + json.put("so:name", "My Work"); + json.put("so:url", "http://example.org/my_work"); + + final JsonLdOptions options = new JsonLdOptions(); + options.setBase("http://schema.org/"); + options.setCompactArrays(true); + options.setOmitGraph(true); + + final String frameStr = "{\"@id\": \"http://schema.org/myid\", \"@context\": \"http://schema.org/\"}"; + final Object frame = JsonUtils.fromString(frameStr); + + final Map framed = JsonLdProcessor.frame(json, frame, options); + + assertTrue("Framing removed the context", framed.containsKey("@context")); + assertFalse("Framing of context should be a string, not a list", + framed.get("@context") instanceof List); + } + + @Test + public void testFramingRemoteContext() throws Exception { + final String jsonString = "{\"@id\": \"http://schema.org/myid\", \"@type\": [\"http://schema.org/Person\"]}"; + final String frameStr = "{\"@id\": \"http://schema.org/myid\", \"@context\": \"http://schema.org/\"}"; + + final Object json = JsonUtils.fromString(jsonString); + final Object frame = JsonUtils.fromString(frameStr); + + final JsonLdOptions options = new JsonLdOptions(); + options.setOmitGraph(true); + + final Map framed = JsonLdProcessor.frame(json, frame, options); + + assertEquals("Wrong returned context", "http://schema.org/", framed.get("@context")); + assertEquals("Wrong id", "schema:myid", framed.get("id")); + assertEquals("Wrong type", "Person", framed.get("type")); + assertEquals("Wrong number of Json entries",3, framed.size()); + } + +} diff --git a/core/src/test/java/com/github/jsonldjava/core/ContextRecursionTest.java b/core/src/test/java/com/github/jsonldjava/core/ContextRecursionTest.java new file mode 100644 index 00000000..d6610121 --- /dev/null +++ b/core/src/test/java/com/github/jsonldjava/core/ContextRecursionTest.java @@ -0,0 +1,75 @@ +package com.github.jsonldjava.core; + +import com.github.jsonldjava.utils.JsonUtils; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.io.IOException; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + + +public class ContextRecursionTest { + + @BeforeClass + public static void setup() { + System.setProperty(DocumentLoader.DISALLOW_REMOTE_CONTEXT_LOADING, "true"); + } + + @AfterClass + public static void tearDown() { + System.setProperty(DocumentLoader.DISALLOW_REMOTE_CONTEXT_LOADING, "false"); + } + + @Test + public void testIssue302_allowedRecursion() throws IOException { + + final String contextB = "{\"@context\": [\"http://localhost/d\", {\"b\": \"http://localhost/b\"} ] }"; + final String contextC = "{\"@context\": [\"http://localhost/d\", {\"c\": \"http://localhost/c\"} ] }"; + final String contextD = "{\"@context\": [\"http://localhost/e\", {\"d\": \"http://localhost/d\"} ] }"; + final String contextE = "{\"@context\": {\"e\": \"http://localhost/e\"} }"; + + final DocumentLoader dl = new DocumentLoader(); + dl.addInjectedDoc("http://localhost/b", contextB); + dl.addInjectedDoc("http://localhost/c", contextC); + dl.addInjectedDoc("http://localhost/d", contextD); + dl.addInjectedDoc("http://localhost/e", contextE); + final JsonLdOptions options = new JsonLdOptions(); + options.setDocumentLoader(dl); + + final String jsonString = "{\"@context\": [\"http://localhost/d\", \"http://localhost/b\", \"http://localhost/c\", {\"a\": \"http://localhost/a\"} ], \"a\": \"A\", \"b\": \"B\", \"c\": \"C\", \"d\": \"D\"}"; + final Object json = JsonUtils.fromString(jsonString); + final Object expanded = JsonLdProcessor.expand(json, options); + assertEquals( + "[{http://localhost/a=[{@value=A}], http://localhost/b=[{@value=B}], http://localhost/c=[{@value=C}], http://localhost/d=[{@value=D}]}]", + expanded.toString()); + } + + @Test + public void testCyclicRecursion() throws IOException { + + final String contextC = "{\"@context\": [\"http://localhost/d\", {\"c\": \"http://localhost/c\"} ] }"; + final String contextD = "{\"@context\": [\"http://localhost/e\", {\"d\": \"http://localhost/d\"} ] }"; + final String contextE = "{\"@context\": [\"http://localhost/c\", {\"e\": \"http://localhost/e\"} ] }"; + + final DocumentLoader dl = new DocumentLoader(); + dl.addInjectedDoc("http://localhost/c", contextC); + dl.addInjectedDoc("http://localhost/d", contextD); + dl.addInjectedDoc("http://localhost/e", contextE); + final JsonLdOptions options = new JsonLdOptions(); + options.setDocumentLoader(dl); + + final String jsonString = "{\"@context\": [\"http://localhost/c\", {\"a\": \"http://localhost/a\"} ]}"; + final Object json = JsonUtils.fromString(jsonString); + try { + JsonLdProcessor.expand(json, options); + fail("it should throw"); + } catch(JsonLdError err) { + assertEquals(JsonLdError.Error.RECURSIVE_CONTEXT_INCLUSION, err.getType()); + assertEquals("recursive context inclusion: http://localhost/c", err.getMessage()); + } + } + +} diff --git a/core/src/test/java/com/github/jsonldjava/core/ContextSerializationTest.java b/core/src/test/java/com/github/jsonldjava/core/ContextSerializationTest.java new file mode 100644 index 00000000..7077f228 --- /dev/null +++ b/core/src/test/java/com/github/jsonldjava/core/ContextSerializationTest.java @@ -0,0 +1,24 @@ +package com.github.jsonldjava.core; + +import com.github.jsonldjava.utils.JsonUtils; +import org.junit.Test; + +import java.io.IOException; +import java.util.Map; + +import static org.junit.Assert.assertEquals; + +public class ContextSerializationTest { + + @Test + // Added in order to have some coverage on the serialize method since is not used anywhere. + public void serializeTest() throws IOException { + final Map json = (Map)JsonUtils + .fromInputStream(getClass().getResourceAsStream("/custom/contexttest-0005.jsonld")); + + final Map contextValue = (Map)json.get(JsonLdConsts.CONTEXT); + final Map serializedContext = new Context().parse(contextValue).serialize(); + + assertEquals("Wrong serialized context", json, serializedContext); + } +} diff --git a/core/src/test/java/com/github/jsonldjava/core/DocumentLoaderTest.java b/core/src/test/java/com/github/jsonldjava/core/DocumentLoaderTest.java index c16d40b5..57b8f5ce 100644 --- a/core/src/test/java/com/github/jsonldjava/core/DocumentLoaderTest.java +++ b/core/src/test/java/com/github/jsonldjava/core/DocumentLoaderTest.java @@ -381,11 +381,19 @@ public void testDisallowRemoteContexts() throws Exception { } @Test - public void injectContext() throws Exception { + public void testInjectContext() throws Exception { + injectContext(new JsonLdOptions()); + } + + @Test + public void testIssue304_remoteContextAndBaseIri() throws Exception { + injectContext(new JsonLdOptions("testing:baseIri")); + } + + private void injectContext(final JsonLdOptions options) throws Exception { final Object jsonObject = JsonUtils.fromString( "{ \"@context\":\"http://nonexisting.example.com/thing\", \"pony\":5 }"); - final JsonLdOptions options = new JsonLdOptions(); // Verify fails to find context by default try { diff --git a/core/src/test/java/com/github/jsonldjava/core/JsonLdToRdfTest.java b/core/src/test/java/com/github/jsonldjava/core/JsonLdToRdfTest.java new file mode 100644 index 00000000..7586c1c6 --- /dev/null +++ b/core/src/test/java/com/github/jsonldjava/core/JsonLdToRdfTest.java @@ -0,0 +1,31 @@ +package com.github.jsonldjava.core; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class JsonLdToRdfTest { + + @Test + public void testIssue301() throws JsonLdError { + final RDFDataset rdf = new RDFDataset(); + rdf.addTriple( + "http://www.w3.org/2002/07/owl#Class", + "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", + "http://www.w3.org/2002/07/owl#Class"); + final JsonLdOptions opts = new JsonLdOptions(); + opts.setUseRdfType(Boolean.FALSE); + opts.setProcessingMode(JsonLdOptions.JSON_LD_1_0); + + final Object out = new JsonLdApi(opts).fromRDF(rdf, true); + assertEquals("[{@id=http://www.w3.org/2002/07/owl#Class, @type=[http://www.w3.org/2002/07/owl#Class]}]", + out.toString()); + + opts.setUseRdfType(Boolean.TRUE); + + final Object out2 = new JsonLdApi(opts).fromRDF(rdf, true); + assertEquals("[{@id=http://www.w3.org/2002/07/owl#Class, http://www.w3.org/1999/02/22-rdf-syntax-ns#type=[{@id=http://www.w3.org/2002/07/owl#Class}]}]", + out2.toString()); + } + +} diff --git a/core/src/test/java/com/github/jsonldjava/core/MinimalSchemaOrgRegressionTest.java b/core/src/test/java/com/github/jsonldjava/core/MinimalSchemaOrgRegressionTest.java index f4c1b88d..4694f897 100644 --- a/core/src/test/java/com/github/jsonldjava/core/MinimalSchemaOrgRegressionTest.java +++ b/core/src/test/java/com/github/jsonldjava/core/MinimalSchemaOrgRegressionTest.java @@ -1,20 +1,13 @@ package com.github.jsonldjava.core; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import java.io.IOException; -import java.io.InputStream; -import java.io.StringWriter; -import java.net.HttpURLConnection; import java.net.URL; -import java.nio.charset.StandardCharsets; -import org.apache.commons.io.IOUtils; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpUriRequest; +import com.github.jsonldjava.utils.JarCacheStorage; +import com.github.jsonldjava.utils.JsonUtils; + import org.apache.http.client.protocol.RequestAcceptEncoding; import org.apache.http.client.protocol.ResponseContentEncoding; import org.apache.http.impl.client.CloseableHttpClient; @@ -22,98 +15,47 @@ import org.apache.http.impl.client.cache.BasicHttpCacheStorage; import org.apache.http.impl.client.cache.CacheConfig; import org.apache.http.impl.client.cache.CachingHttpClientBuilder; -import org.junit.Ignore; import org.junit.Test; -import com.github.jsonldjava.utils.JarCacheStorage; - public class MinimalSchemaOrgRegressionTest { - private static final String ACCEPT_HEADER = "application/ld+json, application/json;q=0.9, application/javascript;q=0.5, text/javascript;q=0.5, text/plain;q=0.2, */*;q=0.1"; - - @Ignore("Java API does not have any way of redirecting automatically from HTTP to HTTPS, which breaks schema.org usage with it") + /** + * Tests getting JSON from schema.org with the HTTP Accept header set to + * {@value com.github.jsonldjava.utils.JsonUtils#ACCEPT_HEADER}? . + */ @Test - public void testHttpURLConnection() throws Exception { + public void testApacheHttpClient() throws Exception { final URL url = new URL("http://schema.org/"); - final boolean followRedirectsSetting = HttpURLConnection.getFollowRedirects(); - try { - HttpURLConnection.setFollowRedirects(true); - final HttpURLConnection urlConn = (HttpURLConnection) url.openConnection(); - urlConn.setInstanceFollowRedirects(true); - urlConn.addRequestProperty("Accept", ACCEPT_HEADER); - - final InputStream directStream = urlConn.getInputStream(); - verifyInputStream(directStream); - } finally { - HttpURLConnection.setFollowRedirects(followRedirectsSetting); - } + // Common CacheConfig for both the JarCacheStorage and the underlying + // BasicHttpCacheStorage + final CacheConfig cacheConfig = CacheConfig.custom().setMaxCacheEntries(1000) + .setMaxObjectSize(1024 * 128).build(); + + final CloseableHttpClient httpClient = CachingHttpClientBuilder.create() + // allow caching + .setCacheConfig(cacheConfig) + // Wrap the local JarCacheStorage around a BasicHttpCacheStorage + .setHttpCacheStorage(new JarCacheStorage(null, cacheConfig, + new BasicHttpCacheStorage(cacheConfig))) + // Support compressed data + // http://hc.apache.org/httpcomponents-client-ga/tutorial/html/httpagent.html#d5e1238 + .addInterceptorFirst(new RequestAcceptEncoding()) + .addInterceptorFirst(new ResponseContentEncoding()) + .setRedirectStrategy(DefaultRedirectStrategy.INSTANCE) + // use system defaults for proxy etc. + .useSystemProperties().build(); + + Object content = JsonUtils.fromURL(url, httpClient); + checkBasicConditions(content.toString()); } - private void verifyInputStream(InputStream directStream) throws IOException { - assertNotNull("InputStream was null", directStream); - final StringWriter output = new StringWriter(); - try { - IOUtils.copy(directStream, output, StandardCharsets.UTF_8); - } finally { - directStream.close(); - output.flush(); - } - final String outputString = output.toString(); - // System.out.println(outputString); + private void checkBasicConditions(final String outputString) { // Test for some basic conditions without including the JSON/JSON-LD // parsing code here - // assertTrue(outputString, outputString.endsWith("}")); + assertTrue(outputString, outputString.endsWith("}")); assertFalse("Output string should not be empty: " + outputString.length(), outputString.isEmpty()); assertTrue("Unexpected length: " + outputString.length(), outputString.length() > 100000); } - - @Test - public void testApacheHttpClient() throws Exception { - final URL url = new URL("http://schema.org/"); - // Common CacheConfig for both the JarCacheStorage and the underlying - // BasicHttpCacheStorage - final CacheConfig cacheConfig = CacheConfig.custom().setMaxCacheEntries(1000) - .setMaxObjectSize(1024 * 128).build(); - - final CloseableHttpClient httpClient = CachingHttpClientBuilder.create() - // allow caching - .setCacheConfig(cacheConfig) - // Wrap the local JarCacheStorage around a BasicHttpCacheStorage - .setHttpCacheStorage(new JarCacheStorage(null, cacheConfig, - new BasicHttpCacheStorage(cacheConfig))) - // Support compressed data - // http://hc.apache.org/httpcomponents-client-ga/tutorial/html/httpagent.html#d5e1238 - .addInterceptorFirst(new RequestAcceptEncoding()) - .addInterceptorFirst(new ResponseContentEncoding()) - .setRedirectStrategy(DefaultRedirectStrategy.INSTANCE) - // use system defaults for proxy etc. - .useSystemProperties().build(); - - try { - final HttpUriRequest request = new HttpGet(url.toExternalForm()); - // We prefer application/ld+json, but fallback to application/json - // or whatever is available - request.addHeader("Accept", ACCEPT_HEADER); - - final CloseableHttpResponse response = httpClient.execute(request); - try { - final int status = response.getStatusLine().getStatusCode(); - if (status != 200 && status != 203) { - throw new IOException("Can't retrieve " + url + ", status code: " + status); - } - final InputStream content = response.getEntity().getContent(); - verifyInputStream(content); - } finally { - if (response != null) { - response.close(); - } - } - } finally { - if (httpClient != null) { - httpClient.close(); - } - } - } - + } diff --git a/core/src/test/resources/custom/base-0001-in.jsonld b/core/src/test/resources/custom/base-0001-in.jsonld index f9bd58fd..12a082af 100644 --- a/core/src/test/resources/custom/base-0001-in.jsonld +++ b/core/src/test/resources/custom/base-0001-in.jsonld @@ -1,6 +1,6 @@ { - "@context": [ -"https://raw.githubusercontent.com/monarch-initiative/monarch-app/master/conf/monarch-context.jsonld", + "@context": [ + "https://raw.githubusercontent.com/jsonld-java/jsonld-java/master/core/src/test/resources/custom/monarch-context.jsonld", { "@base": "http://example.org/base/", "ex": "http://example.org/", @@ -13,4 +13,5 @@ "ex:name": "Jim", "ex:friendOf": "1234", "@type": "Person" -} \ No newline at end of file +} + diff --git a/core/src/test/resources/custom/base-0002-in.jsonld b/core/src/test/resources/custom/base-0002-in.jsonld index 4b2e3848..d533f432 100644 --- a/core/src/test/resources/custom/base-0002-in.jsonld +++ b/core/src/test/resources/custom/base-0002-in.jsonld @@ -1,5 +1,5 @@ { - "@context": [ + "@context": [ { "@base": "http://example.org/base/", "ex": "http://example.org/", @@ -7,10 +7,11 @@ "@type": "@id" } }, - "https://raw.githubusercontent.com/monarch-initiative/monarch-app/master/conf/monarch-context.jsonld" + "https://raw.githubusercontent.com/jsonld-java/jsonld-java/master/core/src/test/resources/custom/monarch-context.jsonld" ], "@id": "3456", "ex:name": "Jim", "ex:friendOf": "1234", "@type": "Person" -} \ No newline at end of file +} + diff --git a/core/src/test/resources/custom/contexttest-0005.jsonld b/core/src/test/resources/custom/contexttest-0005.jsonld new file mode 100644 index 00000000..f4baa06e --- /dev/null +++ b/core/src/test/resources/custom/contexttest-0005.jsonld @@ -0,0 +1,12 @@ +{ + "@context": { + "@base": "http://ex.com/base/", + "@vocab": "http://ex.com/vocab/", + "xsd": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", + "integer": { + "@id": "http://example.com/vocab/integer", + "@type": "xsd:integer" + }, + "@language": "en" + } +} \ No newline at end of file diff --git a/core/src/test/resources/custom/monarch-context.jsonld b/core/src/test/resources/custom/monarch-context.jsonld new file mode 100644 index 00000000..472f4153 --- /dev/null +++ b/core/src/test/resources/custom/monarch-context.jsonld @@ -0,0 +1,149 @@ +{ + "@context" : { + "EFO" : "http://purl.obolibrary.org/obo/EFO_", + "obo" : "http://purl.obolibrary.org/obo/", + "inheritance" : "monarch:mode_of_inheritance", + "@base" : "http://monarch-initiative.org/", + "email" : "foaf:mbox", + "BIND" : "http://identifiers.org/bind/bind:", + "morpholino" : "GENO:0000417", + "GENO" : "http://purl.obolibrary.org/obo/GENO_", + "UMLS" : "http://purl.obolibrary.org/obo/UMLS_", + "dcat" : "http://www.w3.org/ns/dcat#", + "PMID" : "http://www.ncbi.nlm.nih.gov/pubmed/", + "MP" : "http://purl.obolibrary.org/obo/MP_", + "ISBN-10" : "http://monarch-initiative.org/publications/ISBN:", + "rdf" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#", + "title" : "dc:title", + "Class" : "owl:Class", + "FBbt" : "http://purl.obolibrary.org/obo/FBbt_", + "pathway_associations" : "rdfs:seeAlso", + "FBInternalGT" : "http://monarchinitiative.org/genotype/", + "has_genotype" : "GENO:0000222", + "genotype" : "GENO:0000000", + "void" : "http://rdfs.org/ns/void#", + "has_phenotype" : "RO:0002200", + "reference_locus" : "GENO:0000036", + "dbVar" : "http://identifiers.org/dbVar_", + "AQTLTrait" : "http://purl.obolibrary.org/obo/AQTLTrait_", + "phenotype_associations" : "rdfs:seeAlso", + "ECO" : "http://purl.obolibrary.org/obo/ECO_", + "WB" : "http://identifiers.org/WormBase:", + "rdfs" : "http://www.w3.org/2000/01/rdf-schema#", + "variant_loci" : "GENO:0000027", + "MedGen" : "http://purl.obolibrary.org/obo/MedGen_", + "creator" : { + "@id" : "dc:creator", + "@type" : "@id" + }, + "SIO" : "http://semanticscience.org/resource/SIO_", + "DOID" : "http://purl.obolibrary.org/obo/DOID_", + "Ensembl" : "http://identifiers.org/ensembl:", + "id" : "@id", + "publisher" : "dc:publisher", + "depiction" : { + "@id" : "foaf:depiction", + "@type" : "@id" + }, + "ENSEMBL" : "http://identifiers.org/ensembl:", + "monarch" : "http://monarchinitiative.org/", + "ORPHANET" : "http://purl.obolibrary.org/obo/ORPHANET_", + "owl" : "http://www.w3.org/2002/07/owl#", + "GeneReviews" : "http://www.ncbi.nlm.nih.gov/books/", + "SNOMED_CT" : "http://purl.obolibrary.org/obo/SNOMED_", + "chromosomal_region" : "GENO:0000390", + "EOM" : "http://purl.obolibrary.org/obo/EOM_", + "type" : { + "@id" : "rdf:type", + "@type" : "@id" + }, + "FlyBase" : "http://identifiers.org/flybase:", + "DECIPHER" : "http://purl.obolibrary.org/obo/DECIPHER_", + "faldo" : "http://biohackathon.org/resource/faldo#", + "prov" : "http://www.w3.org/ns/prov#", + "MIM" : "http://purl.obolibrary.org/obo/OMIM_", + "genomic_variation_complement" : "GENO:0000009", + "evidence" : "monarch:evidence", + "BioGRID" : "http://purl.obolibrary.org/BioGRID_", + "dcterms" : "http://purl.org/dc/terms/", + "sequence_alteration" : "SO:0001059", + "RO" : "http://purl.obolibrary.org/obo/RO_", + "created" : { + "@id" : "dc:created", + "@type" : "xsd:dateTime" + }, + "Orphanet" : "http://purl.obolibrary.org/obo/ORPHANET_", + "oa" : "http://www.w3.org/ns/oa#", + "SGD" : "http://identifiers.org/mgd/sgd:", + "Gene" : "http://purl.obolibrary.org/obo/NCBIGene_", + "PomBase" : "http://identifiers.org/PomBase:", + "genotype_associations" : "rdfs:seeAlso", + "xsd" : "http://www.w3.org/2001/XMLSchema#", + "OMIABreed" : "http://purl.obolibrary.org/obo/OMIA_", + "TAIR" : "http://identifiers.org/mgd/tair:", + "oboInOwl" : "http://www.geneontology.org/formats/oboInOwl#", + "description" : "dc:description", + "disease" : "monarch:disease", + "OMIAPub" : "http://purl.obolibrary.org/obo/OMIAPub_", + "foaf" : "http://xmlns.com/foaf/0.1/", + "idot" : "http://identifiers.org/", + "subClassOf" : "owl:subClassOf", + "source" : "dc:source", + "keyword" : "dcat:keyword", + "onset" : "monarch:age_of_onset", + "genomic_background" : "GENO:0000010", + "dictyBase" : "http://identifiers.org/dictyBase:", + "OMIA" : "http://purl.obolibrary.org/obo/OMIA_", + "has_part" : "BFO:0000051", + "ClinVarVariant" : "http://identifiers.org/ClinVarVariant_", + "gene_locus" : "GENO:0000014", + "effective_genotype" : "GENO:0000525", + "VT" : "http://purl.obolibrary.org/obo/VT_", + "Association" : "SIO:000897", + "resource" : "monarch:nif-resource", + "KEGG" : "http://identifiers.org/kegg:", + "Annotation" : "oa:Annotation", + "FBdv" : "http://purl.obolibrary.org/obo/FBdv_", + "GeneID" : "http://purl.obolibrary.org/obo/NCBIGene_", + "has_background" : "GENO:0000010", + "BFO" : "http://purl.obolibrary.org/obo/BFO_", + "FB" : "http://identifiers.org/flybase:", + "frequency" : "monarch:frequency", + "ZP" : "http://purl.obolibrary.org/obo/ZP_", + "OMIM" : "http://purl.obolibrary.org/obo/OMIM_", + "MGI" : "http://identifiers.org/mgd/MGI:", + "dc" : "http://purl.org/dc/terms/", + "MONARCH" : "http://monarchinitiative.org/MONARCH_", + "ClinVarHaplotype" : "http://identifiers.org/ClinVarHaplotype_", + "homepage" : { + "@id" : "foaf:homepage", + "@type" : "@id" + }, + "RGD" : "http://identifiers.org/mgd/rgd:", + "CORIELL" : "http://purl.obolibrary.org/obo/CORIELL_", + "label" : "rdfs:label", + "NCBIGene" : "http://purl.obolibrary.org/obo/NCBIGene_", + "intrinsic_genotype" : "GENO:0000000", + "FBcv" : "http://purl.obolibrary.org/obo/FBcv_", + "WBStrain" : "http://identifiers.org/WormBase:", + "sequence_alteration_collection" : "GENO:0000025", + "reference" : "dc:publication", + "zygosity" : "GENO:0000133", + "chromosome" : "GENO:0000323", + "WormBase" : "http://identifiers.org/WormBase:", + "HPRD" : "http://identifiers.org/hprd/hprd:", + "ClinVar" : "http://purl.obolibrary.org/obo/ClinVar_", + "ISBN-13" : "http://monarch-initiative.org/publications/ISBN:", + "extrinsic_genotype" : "GENO:0000524", + "NCBITaxon" : "http://purl.obolibrary.org/obo/NCBITaxon_", + "environment" : "GENO:0000099", + "variant_locus" : "GENO:0000481", + "comment" : "rdfs:comment", + "SO" : "http://purl.obolibrary.org/obo/SO_", + "phenotype" : "monarch:phenotype", + "ZFIN" : "http://identifiers.org/zfin:", + "HP" : "http://purl.obolibrary.org/obo/HP_", + "MESH" : "http://purl.obolibrary.org/obo/MESH_", + "dbSNP" : "http://identifiers.org/dbSNP_" + } +} diff --git a/core/src/test/resources/log4j.properties b/core/src/test/resources/log4j.properties deleted file mode 100644 index 6cebabb1..00000000 --- a/core/src/test/resources/log4j.properties +++ /dev/null @@ -1,5 +0,0 @@ -log4j.rootLogger=INFO, R - -log4j.appender.R=org.apache.log4j.ConsoleAppender -log4j.appender.R.layout=org.apache.log4j.PatternLayout -log4j.appender.R.layout.ConversionPattern=[%d] %-5p (%c:%L) %m%n diff --git a/pom.xml b/pom.xml index a1bd056b..de5316fa 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.jsonld-java jsonld-java-parent - 0.13.1-SNAPSHOT + 0.13.6 JSONLD Java :: Parent Json-LD Java Parent POM pom @@ -39,11 +39,13 @@ UTF-8 UTF-8 - 4.5.10 - 4.4.12 - 2.10.1 - 4.12 - 1.7.29 + 4.5.13 + 4.4.14 + 2.12.7 + 2.12.7.1 + 4.13.2 + 1.7.32 + 1.2.7 0.11.0 @@ -65,7 +67,7 @@ com.fasterxml.jackson.core jackson-databind - ${jackson.version} + ${jackson-databind.version} com.fasterxml.jackson.core @@ -96,9 +98,9 @@ runtime - org.slf4j - slf4j-log4j12 - ${slf4j.version} + ch.qos.logback + logback-classic + ${logback.version} test @@ -192,24 +194,25 @@ commons-codec commons-codec - 1.13 + 1.15 org.mockito mockito-core 2.28.2 + test commons-io commons-io - 2.6 + 2.8.0 com.google.guava guava - 28.1-jre + 32.1.3-jre @@ -267,7 +270,7 @@ org.codehaus.mojo extra-enforcer-rules - 1.2 + 1.3 @@ -350,7 +353,7 @@ org.apache.maven.plugins maven-source-plugin - 3.2.0 + 3.2.1 attach-source @@ -400,7 +403,7 @@ com.github.siom79.japicmp japicmp-maven-plugin - 0.14.2 + 0.14.4 @@ -447,7 +450,7 @@ org.jacoco jacoco-maven-plugin - 0.8.5 + 0.8.6 prepare-agent