Skip to content
Permalink
Browse files
[ANY23-461] Upgrade Any23 to JDK11
  • Loading branch information
lewismc committed Mar 23, 2021
1 parent 7615693 commit 6d0467fc061083ca5fe1e503876380371d881ede
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 29 deletions.
@@ -19,8 +19,9 @@

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonLocation;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.StreamReadFeature;
import com.fasterxml.jackson.core.json.JsonReadFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.jsonldjava.core.JsonLdOptions;
import com.github.jsonldjava.core.JsonLdProcessor;
@@ -43,24 +44,25 @@
* <a href="http://www.w3.org/TR/json-ld/">JSON-LD</a> format.
*
*/
@SuppressWarnings("static-access")
public class JSONLDExtractor extends BaseRDFExtractor {

private static final JsonFactory JSON_FACTORY = new JsonFactory(new ObjectMapper());

static {
JSON_FACTORY.enable(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER);
JSON_FACTORY.disable(JsonParser.Feature.ALLOW_COMMENTS); // handled by JsonCleaningInputStream
JSON_FACTORY.disable(JsonParser.Feature.ALLOW_MISSING_VALUES); // handled by JsonCleaningInputStream
JSON_FACTORY.enable(JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS);
JSON_FACTORY.enable(JsonParser.Feature.ALLOW_NUMERIC_LEADING_ZEROS);
JSON_FACTORY.disable(JsonParser.Feature.ALLOW_SINGLE_QUOTES); // handled by JsonCleaningInputStream
JSON_FACTORY.disable(JsonParser.Feature.ALLOW_TRAILING_COMMA); // handled by JsonCleaningInputStream
JSON_FACTORY.enable(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS);
JSON_FACTORY.enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES);
JSON_FACTORY.disable(JsonParser.Feature.ALLOW_YAML_COMMENTS); // handled by JsonCleaningInputStream
JSON_FACTORY.enable(JsonParser.Feature.IGNORE_UNDEFINED);
JSON_FACTORY.enable(JsonParser.Feature.INCLUDE_SOURCE_IN_LOCATION);
JSON_FACTORY.disable(JsonParser.Feature.STRICT_DUPLICATE_DETECTION);
JSON_FACTORY.builder().configure(JsonReadFeature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER, true)
.configure(JsonReadFeature.ALLOW_JAVA_COMMENTS, false)
.configure(JsonReadFeature.ALLOW_MISSING_VALUES, false)
.configure(JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS, true)
.configure(JsonReadFeature.ALLOW_LEADING_ZEROS_FOR_NUMBERS, true)
.configure(JsonReadFeature.ALLOW_SINGLE_QUOTES, false)
.configure(JsonReadFeature.ALLOW_TRAILING_COMMA, false)
.configure(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS, true)
.configure(JsonReadFeature.ALLOW_UNQUOTED_FIELD_NAMES, true)
.configure(JsonReadFeature.ALLOW_YAML_COMMENTS, false)
.configure(StreamReadFeature.IGNORE_UNDEFINED, true)
.configure(StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION, true)
.configure(StreamReadFeature.STRICT_DUPLICATE_DETECTION, false).build();
}

/**
@@ -198,18 +198,18 @@ public void testDemoCodeSnippet1() throws Exception {
public void testDemoCodeSnippet2() throws Exception {
assumeOnlineAllowed();

/* 1 */Any23 runner = new Any23();
/* 2 */runner.setHTTPUserAgent("apache-any23-test-user-agent");
/* 3 */HTTPClient httpClient = runner.getHTTPClient();
/* 4 */DocumentSource source = new HTTPDocumentSource(httpClient, "http://dbpedia.org/resource/Trento");
/* 5 */ByteArrayOutputStream out = new ByteArrayOutputStream();
/* 6 */TripleHandler handler = new NTriplesWriter(out);
Any23 runner = new Any23();
runner.setHTTPUserAgent("apache-any23-test-user-agent");
HTTPClient httpClient = runner.getHTTPClient();
DocumentSource source = new HTTPDocumentSource(httpClient, "http://dbpedia.org/resource/Trento");
ByteArrayOutputStream out = new ByteArrayOutputStream();
TripleHandler handler = new NTriplesWriter(out);
try {
/* 7 */runner.extract(source, handler);
runner.extract(source, handler);
} finally {
/* 8 */handler.close();
handler.close();
}
/* 9 */String n3 = out.toString("UTF-8");
String n3 = out.toString("UTF-8");

/*
* <http://dbpedia.org/resource/Trent> <http://dbpedia.org/ontology/wikiPageDisambiguates>
@@ -222,7 +222,7 @@ public void testDemoCodeSnippet2() throws Exception {
Assert.assertTrue(n3.length() > 0);

Assert.assertTrue(n3.contains(
"<http://dbpedia.org/resource/Trento> <http://dbpedia.org/property/mayor> \"Alessandro Andreatta\" ."));
"<http://dbpedia.org/resource/Trento> <http://dbpedia.org/property/mayor> \"Franco Ianeselli, elected 2020\"@en ."));
}

/**
@@ -274,7 +274,7 @@
<tika.version>1.24</tika.version>
<openie_2.11.version>4.2.6</openie_2.11.version>
<openregex.version>1.1.1</openregex.version>
<jackson.version>2.10.3</jackson.version>
<jackson.version>2.12.2</jackson.version>
<commons-io.version>2.6</commons-io.version>

<!-- Overridden in profiles to add JDK specific arguments to surefire -->
@@ -510,7 +510,7 @@
<dependency>
<groupId>com.github.jsonld-java</groupId>
<artifactId>jsonld-java</artifactId>
<version>0.13.1</version>
<version>0.13.2</version>
</dependency>
<dependency>
<groupId>org.semarglproject</groupId>
@@ -747,8 +747,7 @@
<bundledSignature>jdk-unsafe-${javac.src.version}</bundledSignature>
<bundledSignature>jdk-deprecated-${javac.src.version}</bundledSignature>
<bundledSignature>jdk-non-portable</bundledSignature>
<!-- comment out until we upgrade past Java 8 -->
<!--bundledSignature>jdk-reflection</bundledSignature-->
<bundledSignature>jdk-reflection</bundledSignature>
<bundledSignature>jdk-internal-${javac.src.version}</bundledSignature>
<bundledSignature>jdk-system-out</bundledSignature>
<bundledSignature>commons-io-unsafe-${commons-io.version}</bundledSignature>
@@ -758,7 +757,7 @@
<execution>
<goals>
<goal>check</goal>
<!--goal>testCheck</goal-->
<goal>testCheck</goal>
</goals>
</execution>
</executions>

0 comments on commit 6d0467f

Please sign in to comment.