Jackson 2.11, update named modules, add pmd/checkstyle/spotbugs

This commit is contained in:
Jörg Prante 2020-06-04 23:41:01 +02:00
parent d46afa4c03
commit dd635c54b2
24 changed files with 169 additions and 463 deletions

View file

@ -2,6 +2,9 @@ plugins {
id "de.marcphilipp.nexus-publish" version "0.4.0" id "de.marcphilipp.nexus-publish" version "0.4.0"
id "io.codearte.nexus-staging" version "0.21.1" id "io.codearte.nexus-staging" version "0.21.1"
id "org.xbib.gradle.plugin.asciidoctor" version "1.5.6.0.1" id "org.xbib.gradle.plugin.asciidoctor" version "1.5.6.0.1"
id "com.github.spotbugs" version "4.2.4"
id "pmd"
id "checkstyle"
} }
wrapper { wrapper {
@ -29,6 +32,9 @@ subprojects {
apply from: rootProject.file('gradle/ide/idea.gradle') apply from: rootProject.file('gradle/ide/idea.gradle')
apply from: rootProject.file('gradle/compile/java.gradle') apply from: rootProject.file('gradle/compile/java.gradle')
apply from: rootProject.file('gradle/test/junit5.gradle') apply from: rootProject.file('gradle/test/junit5.gradle')
apply from: rootProject.file('gradle/quality/checkstyle.gradle')
apply from: rootProject.file('gradle/quality/pmd.gradle')
apply from: rootProject.file('gradle/quality/spotbugs.gradle')
apply from: rootProject.file('gradle/publishing/publication.gradle') apply from: rootProject.file('gradle/publishing/publication.gradle')
} }
apply from: rootProject.file('gradle/publishing/sonatype.gradle') apply from: rootProject.file('gradle/publishing/sonatype.gradle')

View file

@ -38,6 +38,22 @@ page at http://checkstyle.sourceforge.net/config.html -->
Only allows a package-info.java, not package.html. --> Only allows a package-info.java, not package.html. -->
</module> </module>
<module name="LineLength">
<!-- Checks if a line is too long. -->
<property name="max" value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.max}" default="128"/>
<property name="severity" value="error"/>
<!--
The default ignore pattern exempts the following elements:
- import statements
- long URLs inside comments
-->
<property name="ignorePattern"
value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}"
default="^(package .*;\s*)|(import .*;\s*)|( *(\*|//).*https?://.*)$"/>
</module>
<!-- All Java AST specific tests live under TreeWalker module. --> <!-- All Java AST specific tests live under TreeWalker module. -->
<module name="TreeWalker"> <module name="TreeWalker">
@ -75,9 +91,6 @@ page at http://checkstyle.sourceforge.net/config.html -->
<property name="severity" value="warning"/> <property name="severity" value="warning"/>
<property name="allowMissingParamTags" value="true"/> <property name="allowMissingParamTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/> <property name="allowMissingReturnTag" value="true"/>
<property name="allowMissingThrowsTags" value="true"/>
<property name="allowThrowsTagsForSubclasses" value="true"/>
<property name="allowUndeclaredRTE" value="true"/>
</module> </module>
<module name="JavadocType"> <module name="JavadocType">
@ -183,21 +196,6 @@ page at http://checkstyle.sourceforge.net/config.html -->
--> -->
<module name="LineLength">
<!-- Checks if a line is too long. -->
<property name="max" value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.max}" default="128"/>
<property name="severity" value="error"/>
<!--
The default ignore pattern exempts the following elements:
- import statements
- long URLs inside comments
-->
<property name="ignorePattern"
value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}"
default="^(package .*;\s*)|(import .*;\s*)|( *(\*|//).*https?://.*)$"/>
</module>
<module name="LeftCurly"> <module name="LeftCurly">
<!-- Checks for placement of the left curly brace ('{'). --> <!-- Checks for placement of the left curly brace ('{'). -->

View file

@ -5,7 +5,7 @@ module org.xbib.content.core {
exports org.xbib.content.settings; exports org.xbib.content.settings;
exports org.xbib.content.util.geo; exports org.xbib.content.util.geo;
exports org.xbib.content.util.unit; exports org.xbib.content.util.unit;
requires com.fasterxml.jackson.core; requires transitive com.fasterxml.jackson.core;
provides org.xbib.content.XContent with provides org.xbib.content.XContent with
org.xbib.content.json.JsonXContent; org.xbib.content.json.JsonXContent;
provides org.xbib.content.settings.SettingsLoader with provides org.xbib.content.settings.SettingsLoader with

View file

@ -2,7 +2,6 @@ package org.xbib.content.json;
import com.fasterxml.jackson.core.JsonEncoding; import com.fasterxml.jackson.core.JsonEncoding;
import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonParser;
import org.xbib.content.XContent; import org.xbib.content.XContent;
import org.xbib.content.XContentBuilder; import org.xbib.content.XContentBuilder;
@ -29,7 +28,6 @@ public class JsonXContent implements XContent {
static { static {
jsonFactory = new JsonFactory(); jsonFactory = new JsonFactory();
jsonFactory.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); jsonFactory.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
jsonFactory.configure(JsonGenerator.Feature.QUOTE_FIELD_NAMES, true);
jsonXContent = new JsonXContent(); jsonXContent = new JsonXContent();
} }
@ -97,7 +95,7 @@ public class JsonXContent implements XContent {
@Override @Override
public boolean isXContent(BytesReference bytes) { public boolean isXContent(BytesReference bytes) {
int length = bytes.length() < 20 ? bytes.length() : 20; int length = Math.min(bytes.length(), 20);
if (length == 0) { if (length == 0) {
return false; return false;
} }

View file

@ -1,8 +1,5 @@
dependencies { dependencies {
api "com.fasterxml.jackson.core:jackson-databind:${project.property('jackson.version')}" api "com.fasterxml.jackson.core:jackson-databind:${project.property('jackson.version')}"
testImplementation("junit:junit:${project.property('junit4.version')}") {
exclude group: 'org.hamcrest'
}
testImplementation("org.mockito:mockito-core:${project.property('mockito.version')}") { testImplementation("org.mockito:mockito-core:${project.property('mockito.version')}") {
exclude group: 'org.hamcrest' exclude group: 'org.hamcrest'
} }

View file

@ -4,5 +4,6 @@ module org.xbib.content.json {
exports org.xbib.content.json.mergepatch; exports org.xbib.content.json.mergepatch;
exports org.xbib.content.json.patch; exports org.xbib.content.json.patch;
exports org.xbib.content.json.pointer; exports org.xbib.content.json.pointer;
requires com.fasterxml.jackson.databind; requires transitive com.fasterxml.jackson.core;
requires transitive com.fasterxml.jackson.databind;
} }

View file

@ -1,29 +1,29 @@
package org.xbib.content.json.jackson; package org.xbib.content.json.jackson;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Assert; import org.junit.jupiter.api.Assertions;
import org.junit.Test; import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.Reader; import java.io.Reader;
import java.io.StringReader; import java.io.StringReader;
import java.nio.charset.StandardCharsets;
/** /**
* *
*/ */
public final class JsonNodeReaderTest extends Assert { public final class JsonNodeReaderTest {
@Test @Test
public void streamIsClosedOnRead() public void streamIsClosedOnRead()
throws IOException { throws IOException {
final InputStream in = spy(new ByteArrayInputStream("[]".getBytes("UTF-8"))); final InputStream in = spy(new ByteArrayInputStream("[]".getBytes(StandardCharsets.UTF_8)));
final JsonNode node = new JsonNodeReader().fromInputStream(in); final JsonNode node = new JsonNodeReader().fromInputStream(in);
verify(in).close(); verify(in).close();
assertEquals(node, new ObjectMapper().readTree(new ByteArrayInputStream("[]".getBytes("UTF-8")))); assertEquals(node, new ObjectMapper().readTree(new ByteArrayInputStream("[]".getBytes("UTF-8"))));
@ -39,21 +39,14 @@ public final class JsonNodeReaderTest extends Assert {
} }
@Test @Test
public void malformedDataThrowsExpectedException() public void malformedDataThrowsExpectedException() {
throws IOException {
String[] inputs = new String[]{ String[] inputs = new String[]{
"", "[]{}", "[]]" "", "[]{}", "[]]"
}; };
final JsonNodeReader reader = new JsonNodeReader(); final JsonNodeReader reader = new JsonNodeReader();
for (String input : inputs) { for (String input : inputs) {
try { Assertions.assertThrows(JsonParseException.class, () ->
reader.fromInputStream(new ByteArrayInputStream(input.getBytes())); reader.fromInputStream(new ByteArrayInputStream(input.getBytes())));
fail("No exception thrown!!");
} catch (JsonParseException e) {
//
} }
} }
}
} }

View file

@ -1,12 +1,11 @@
package org.xbib.content.json.jackson; package org.xbib.content.json.jackson;
import static org.junit.jupiter.api.Assertions.assertTrue;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import org.junit.Assert; import org.junit.jupiter.api.Test;
import org.junit.Test;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
@ -15,7 +14,7 @@ import java.util.List;
/** /**
* *
*/ */
public final class JsonNumEqualsTest extends Assert { public final class JsonNumEqualsTest {
private static final JsonNodeFactory FACTORY = JsonNodeFactory.instance; private static final JsonNodeFactory FACTORY = JsonNodeFactory.instance;

View file

@ -1,29 +1,29 @@
package org.xbib.content.json.pointer; package org.xbib.content.json.pointer;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import org.junit.Assert; import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.xbib.content.json.jackson.JacksonUtils; import org.xbib.content.json.jackson.JacksonUtils;
import org.xbib.content.json.jackson.NodeType; import org.xbib.content.json.jackson.NodeType;
import org.xbib.content.json.jackson.SampleNodeProvider; import org.xbib.content.json.jackson.SampleNodeProvider;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* *
*/ */
public final class JsonNodeResolverTest extends Assert { public final class JsonNodeResolverTest {
private static final JsonNodeFactory FACTORY = JacksonUtils.nodeFactory(); private static final JsonNodeFactory FACTORY = JacksonUtils.nodeFactory();
@Test @Test
public void resolvingNullReturnsNull() { public void resolvingNullReturnsNull() {
final JsonNodeResolver resolver final JsonNodeResolver resolver
= new JsonNodeResolver(ReferenceToken.fromRaw("whatever")); = new JsonNodeResolver(ReferenceToken.fromRaw("whatever"));
assertNull(resolver.get(null)); assertNull(resolver.get(null));
} }
@ -33,7 +33,6 @@ public final class JsonNodeResolverTest extends Assert {
NodeType.OBJECT).next()[0]; NodeType.OBJECT).next()[0];
final JsonNodeResolver resolver final JsonNodeResolver resolver
= new JsonNodeResolver(ReferenceToken.fromRaw("whatever")); = new JsonNodeResolver(ReferenceToken.fromRaw("whatever"));
assertNull(resolver.get(node)); assertNull(resolver.get(node));
} }
@ -42,18 +41,13 @@ public final class JsonNodeResolverTest extends Assert {
final JsonNodeResolver resolver final JsonNodeResolver resolver
= new JsonNodeResolver(ReferenceToken.fromRaw("a")); = new JsonNodeResolver(ReferenceToken.fromRaw("a"));
final JsonNode target = FACTORY.textNode("b"); final JsonNode target = FACTORY.textNode("b");
ObjectNode node; ObjectNode node;
node = FACTORY.objectNode(); node = FACTORY.objectNode();
node.set("a", target); node.set("a", target);
final JsonNode resolved = resolver.get(node); final JsonNode resolved = resolver.get(node);
assertEquals(resolved, target); assertEquals(resolved, target);
node = FACTORY.objectNode(); node = FACTORY.objectNode();
node.set("b", target); node.set("b", target);
assertNull(resolver.get(node)); assertNull(resolver.get(node));
} }
@ -61,13 +55,10 @@ public final class JsonNodeResolverTest extends Assert {
public void resolvingArrayIndicesWorks() { public void resolvingArrayIndicesWorks() {
final JsonNodeResolver resolver final JsonNodeResolver resolver
= new JsonNodeResolver(ReferenceToken.fromInt(1)); = new JsonNodeResolver(ReferenceToken.fromInt(1));
final JsonNode target = FACTORY.textNode("b"); final JsonNode target = FACTORY.textNode("b");
final ArrayNode node = FACTORY.arrayNode(); final ArrayNode node = FACTORY.arrayNode();
node.add(target); node.add(target);
assertNull(resolver.get(node)); assertNull(resolver.get(node));
node.add(target); node.add(target);
assertEquals(target, resolver.get(node)); assertEquals(target, resolver.get(node));
} }
@ -77,7 +68,6 @@ public final class JsonNodeResolverTest extends Assert {
final JsonNode target = FACTORY.textNode("b"); final JsonNode target = FACTORY.textNode("b");
final ArrayNode node = FACTORY.arrayNode(); final ArrayNode node = FACTORY.arrayNode();
node.add(target); node.add(target);
List<Object[]> list = new ArrayList<>(); List<Object[]> list = new ArrayList<>();
list.add(new Object[]{"-1"}); list.add(new Object[]{"-1"});
list.add(new Object[]{"232398087298731987987232"}); list.add(new Object[]{"232398087298731987987232"});

View file

@ -1,13 +1,13 @@
package org.xbib.content.json.pointer; package org.xbib.content.json.pointer;
import static org.junit.jupiter.api.Assertions.assertEquals;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import org.junit.Assert; import org.junit.jupiter.api.Assertions;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.xbib.content.json.jackson.JacksonUtils; import org.xbib.content.json.jackson.JacksonUtils;
import org.xbib.content.json.jackson.JsonLoader; import org.xbib.content.json.jackson.JsonLoader;
import org.xbib.content.json.jackson.NodeType; import org.xbib.content.json.jackson.NodeType;
import org.xbib.content.json.jackson.SampleNodeProvider; import org.xbib.content.json.jackson.SampleNodeProvider;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
@ -20,7 +20,7 @@ import java.util.Map;
/** /**
* *
*/ */
public final class JsonPointerTest extends Assert { public final class JsonPointerTest {
private static final String PACKAGE = JsonPointerTest.class.getPackage().getName().replace('.', '/'); private static final String PACKAGE = JsonPointerTest.class.getPackage().getName().replace('.', '/');
private final JsonNode testData; private final JsonNode testData;
@ -33,11 +33,12 @@ public final class JsonPointerTest extends Assert {
document = testData.get("document"); document = testData.get("document");
} }
@Test(expected = NullPointerException.class) @Test
public void cannotAppendNullPointer() { public void cannotAppendNullPointer() {
Assertions.assertThrows(NullPointerException.class, () -> {
final JsonPointer foo = null; final JsonPointer foo = null;
JsonPointer.empty().append(foo); JsonPointer.empty().append(foo);
fail("No exception thrown!!"); });
} }
@Test @Test

View file

@ -1,55 +1,39 @@
package org.xbib.content.json.pointer; package org.xbib.content.json.pointer;
import org.junit.Assert; import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.Test; import static org.junit.jupiter.api.Assertions.assertNotEquals;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
* *
*/ */
public final class ReferenceTokenTest extends Assert { public final class ReferenceTokenTest {
@Test @Test
public void nullCookedRaisesError() public void nullCookedRaisesError() {
throws JsonPointerException { Assertions.assertThrows(NullPointerException.class, () ->
try { ReferenceToken.fromCooked(null));
ReferenceToken.fromCooked(null);
fail("No exception thrown!!");
} catch (NullPointerException e) {
//assertEquals(e.getMessage(), BUNDLE.getMessage("nullInput"));
}
} }
@Test @Test
public void nullRawRaisesError() { public void nullRawRaisesError() {
try { Assertions.assertThrows(NullPointerException.class, () ->
ReferenceToken.fromRaw(null); ReferenceToken.fromRaw(null));
fail("No exception thrown!!");
} catch (NullPointerException e) {
//assertEquals(e.getMessage(), BUNDLE.getMessage("nullInput"));
}
} }
@Test @Test
public void emptyEscapeRaisesTheAppropriateException() { public void emptyEscapeRaisesTheAppropriateException() {
try { Assertions.assertThrows(JsonPointerException.class, () ->
ReferenceToken.fromCooked("whatever~"); ReferenceToken.fromCooked("whatever~"));
fail("No exception thrown!!");
} catch (JsonPointerException e) {
//assertEquals(e.getMessage(), BUNDLE.getMessage("emptyEscape"));
}
} }
@Test @Test
public void illegalEscapeRaisesTheAppropriateException() { public void illegalEscapeRaisesTheAppropriateException() {
try { Assertions.assertThrows(JsonPointerException.class, () ->
ReferenceToken.fromCooked("~a"); ReferenceToken.fromCooked("~a"));
fail("No exception thrown!!");
} catch (JsonPointerException e) {
//assertEquals(e.getMessage(), BUNDLE.getMessage("illegalEscape"));
}
} }
@Test @Test
@ -68,8 +52,7 @@ public final class ReferenceTokenTest extends Assert {
String raw = (String) o[1]; String raw = (String) o[1];
final ReferenceToken token1 = ReferenceToken.fromCooked(cooked); final ReferenceToken token1 = ReferenceToken.fromCooked(cooked);
final ReferenceToken token2 = ReferenceToken.fromRaw(raw); final ReferenceToken token2 = ReferenceToken.fromRaw(raw);
assertEquals(token1, token2);
assertTrue(token1.equals(token2));
assertEquals(token2.toString(), cooked); assertEquals(token2.toString(), cooked);
} }
} }
@ -88,9 +71,9 @@ public final class ReferenceTokenTest extends Assert {
final ReferenceToken fromInt = ReferenceToken.fromInt(index); final ReferenceToken fromInt = ReferenceToken.fromInt(index);
final ReferenceToken cooked = ReferenceToken.fromCooked(asString); final ReferenceToken cooked = ReferenceToken.fromCooked(asString);
final ReferenceToken raw = ReferenceToken.fromRaw(asString); final ReferenceToken raw = ReferenceToken.fromRaw(asString);
assertTrue(fromInt.equals(cooked)); assertEquals(fromInt, cooked);
assertTrue(cooked.equals(raw)); assertEquals(cooked, raw);
assertTrue(raw.equals(fromInt)); assertEquals(raw, fromInt);
assertEquals(fromInt.toString(), asString); assertEquals(fromInt.toString(), asString);
} }
} }
@ -100,7 +83,6 @@ public final class ReferenceTokenTest extends Assert {
throws JsonPointerException { throws JsonPointerException {
final ReferenceToken zero = ReferenceToken.fromCooked("0"); final ReferenceToken zero = ReferenceToken.fromCooked("0");
final ReferenceToken zerozero = ReferenceToken.fromCooked("00"); final ReferenceToken zerozero = ReferenceToken.fromCooked("00");
assertNotEquals(zero, zerozero);
assertFalse(zero.equals(zerozero));
} }
} }

View file

@ -1,16 +1,19 @@
package org.xbib.content.json.pointer; package org.xbib.content.json.pointer;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.only; import static org.mockito.Mockito.only;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import com.fasterxml.jackson.core.TreeNode; import com.fasterxml.jackson.core.TreeNode;
import org.junit.Assert; import org.junit.jupiter.api.Assertions;
import org.junit.Test; import org.junit.jupiter.api.Test;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
@ -19,24 +22,24 @@ import java.util.List;
/** /**
* *
*/ */
public final class TreePointerTest extends Assert { public final class TreePointerTest {
@Test(expected = NullPointerException.class)
public void attemptToBuildTokensFromNullRaisesAnError() throws JsonPointerException { @Test
TreePointer.tokensFromInput(null); public void attemptToBuildTokensFromNullRaisesAnError() {
fail("No exception thrown!!"); Assertions.assertThrows(NullPointerException.class, () ->
TreePointer.tokensFromInput(null));
} }
@Test(expected = JsonPointerException.class) @Test
public void buildingTokenListYellsIfIllegalPointer() throws JsonPointerException { public void buildingTokenListYellsIfIllegalPointer() {
TreePointer.tokensFromInput("a/b"); Assertions.assertThrows(JsonPointerException.class, () ->
fail("No exception thrown!!"); TreePointer.tokensFromInput("a/b"));
} }
@Test @Test
public void buildingTokenListIsUnfazedByAnEmptyInput() public void buildingTokenListIsUnfazedByAnEmptyInput()
throws JsonPointerException { throws JsonPointerException {
assertEquals(TreePointer.tokensFromInput(""), assertEquals(TreePointer.tokensFromInput(""), new ArrayList<>());
new ArrayList<>());
} }
@Test @Test

View file

@ -10,8 +10,7 @@ module org.xbib.content.rdf {
exports org.xbib.content.rdf.io.turtle; exports org.xbib.content.rdf.io.turtle;
exports org.xbib.content.rdf.io.xml; exports org.xbib.content.rdf.io.xml;
exports org.xbib.content.rdf.util; exports org.xbib.content.rdf.util;
requires org.xbib.content.core; requires transitive org.xbib.content.core;
requires org.xbib.content.resource; requires transitive org.xbib.content.resource;
requires org.xbib.content.xml; requires transitive org.xbib.content.xml;
requires java.xml;
} }

View file

@ -1,323 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<!-- This is a checkstyle configuration file. For descriptions of
what the following rules do, please see the checkstyle configuration
page at http://checkstyle.sourceforge.net/config.html -->
<module name="Checker">
<module name="FileTabCharacter">
<!-- Checks that there are no tab characters in the file.
-->
</module>
<module name="NewlineAtEndOfFile">
<property name="lineSeparator" value="lf"/>
</module>
<module name="RegexpSingleline">
<!-- Checks that FIXME is not used in comments. TODO is preferred.
-->
<property name="format" value="((//.*)|(\*.*))FIXME" />
<property name="message" value='TODO is preferred to FIXME. e.g. "TODO(johndoe): Refactor when v2 is released."' />
</module>
<module name="RegexpSingleline">
<!-- Checks that TODOs are named. (Actually, just that they are followed
by an open paren.)
-->
<property name="format" value="((//.*)|(\*.*))TODO[^(]" />
<property name="message" value='All TODOs should be named. e.g. "TODO(johndoe): Refactor when v2 is released."' />
</module>
<module name="JavadocPackage">
<!-- Checks that each Java package has a Javadoc file used for commenting.
Only allows a package-info.java, not package.html. -->
</module>
<!-- All Java AST specific tests live under TreeWalker module. -->
<module name="TreeWalker">
<!--
IMPORT CHECKS
-->
<module name="RedundantImport">
<!-- Checks for redundant import statements. -->
<property name="severity" value="error"/>
</module>
<module name="ImportOrder">
<!-- Checks for out of order import statements. -->
<property name="severity" value="warning"/>
<property name="groups" value="com,junit,net,org,java,javax"/>
<!-- This ensures that static imports go first. -->
<property name="option" value="top"/>
<property name="tokens" value="STATIC_IMPORT, IMPORT"/>
</module>
<!--
JAVADOC CHECKS
-->
<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
<module name="JavadocMethod">
<property name="scope" value="protected"/>
<property name="severity" value="warning"/>
<property name="allowMissingJavadoc" value="true"/>
<property name="allowMissingParamTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
<property name="allowMissingThrowsTags" value="true"/>
<property name="allowThrowsTagsForSubclasses" value="true"/>
<property name="allowUndeclaredRTE" value="true"/>
</module>
<module name="JavadocType">
<property name="scope" value="protected"/>
<property name="severity" value="error"/>
</module>
<module name="JavadocStyle">
<property name="severity" value="warning"/>
</module>
<!--
NAMING CHECKS
-->
<!-- Item 38 - Adhere to generally accepted naming conventions -->
<module name="PackageName">
<!-- Validates identifiers for package names against the
supplied expression. -->
<!-- Here the default checkstyle rule restricts package name parts to
seven characters, this is not in line with common practice at Google.
-->
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]{1,})*$"/>
<property name="severity" value="warning"/>
</module>
<module name="TypeNameCheck">
<!-- Validates static, final fields against the
expression "^[A-Z][a-zA-Z0-9]*$". -->
<metadata name="altname" value="TypeName"/>
<property name="severity" value="warning"/>
</module>
<module name="ConstantNameCheck">
<!-- Validates non-private, static, final fields against the supplied
public/package final fields "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$". -->
<metadata name="altname" value="ConstantName"/>
<property name="applyToPublic" value="true"/>
<property name="applyToProtected" value="true"/>
<property name="applyToPackage" value="true"/>
<property name="applyToPrivate" value="false"/>
<property name="format" value="^([A-Z][A-Z0-9]*(_[A-Z0-9]+)*|FLAG_.*)$"/>
<message key="name.invalidPattern"
value="Variable ''{0}'' should be in ALL_CAPS (if it is a constant) or be private (otherwise)."/>
<property name="severity" value="warning"/>
</module>
<module name="StaticVariableNameCheck">
<!-- Validates static, non-final fields against the supplied
expression "^[a-z][a-zA-Z0-9]*_?$". -->
<metadata name="altname" value="StaticVariableName"/>
<property name="applyToPublic" value="true"/>
<property name="applyToProtected" value="true"/>
<property name="applyToPackage" value="true"/>
<property name="applyToPrivate" value="true"/>
<property name="format" value="^[a-z][a-zA-Z0-9]*_?$"/>
<property name="severity" value="warning"/>
</module>
<module name="MemberNameCheck">
<!-- Validates non-static members against the supplied expression. -->
<metadata name="altname" value="MemberName"/>
<property name="applyToPublic" value="true"/>
<property name="applyToProtected" value="true"/>
<property name="applyToPackage" value="true"/>
<property name="applyToPrivate" value="true"/>
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
<property name="severity" value="warning"/>
</module>
<module name="MethodNameCheck">
<!-- Validates identifiers for method names. -->
<metadata name="altname" value="MethodName"/>
<property name="format" value="^[a-z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*$"/>
<property name="severity" value="warning"/>
</module>
<module name="ParameterName">
<!-- Validates identifiers for method parameters against the
expression "^[a-z][a-zA-Z0-9]*$". -->
<property name="severity" value="warning"/>
</module>
<module name="LocalFinalVariableName">
<!-- Validates identifiers for local final variables against the
expression "^[a-z][a-zA-Z0-9]*$". -->
<property name="severity" value="warning"/>
</module>
<module name="LocalVariableName">
<!-- Validates identifiers for local variables against the
expression "^[a-z][a-zA-Z0-9]*$". -->
<property name="severity" value="warning"/>
</module>
<!--
LENGTH and CODING CHECKS
-->
<module name="LineLength">
<!-- Checks if a line is too long. -->
<property name="max" value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.max}" default="128"/>
<property name="severity" value="error"/>
<!--
The default ignore pattern exempts the following elements:
- import statements
- long URLs inside comments
-->
<property name="ignorePattern"
value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}"
default="^(package .*;\s*)|(import .*;\s*)|( *(\*|//).*https?://.*)$"/>
</module>
<module name="LeftCurly">
<!-- Checks for placement of the left curly brace ('{'). -->
<property name="severity" value="warning"/>
</module>
<module name="RightCurly">
<!-- Checks right curlies on CATCH, ELSE, and TRY blocks are on
the same line. e.g., the following example is fine:
<pre>
if {
...
} else
</pre>
-->
<!-- This next example is not fine:
<pre>
if {
...
}
else
</pre>
-->
<property name="option" value="same"/>
<property name="severity" value="warning"/>
</module>
<!-- Checks for braces around if and else blocks -->
<module name="NeedBraces">
<property name="severity" value="warning"/>
<property name="tokens" value="LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO"/>
</module>
<module name="UpperEll">
<!-- Checks that long constants are defined with an upper ell.-->
<property name="severity" value="error"/>
</module>
<module name="FallThrough">
<!-- Warn about falling through to the next case statement. Similar to
javac -Xlint:fallthrough, but the check is suppressed if a single-line comment
on the last non-blank line preceding the fallen-into case contains 'fall through' (or
some other variants which we don't publicized to promote consistency).
-->
<property name="reliefPattern"
value="fall through|Fall through|fallthru|Fallthru|falls through|Falls through|fallthrough|Fallthrough|No break|NO break|no break|continue on"/>
<property name="severity" value="error"/>
</module>
<!--
MODIFIERS CHECKS
-->
<module name="ModifierOrder">
<!-- Warn if modifier order is inconsistent with JLS3 8.1.1, 8.3.1, and
8.4.3. The prescribed order is:
public, protected, private, abstract, static, final, transient, volatile,
synchronized, native, strictfp
-->
</module>
<!--
WHITESPACE CHECKS
-->
<module name="WhitespaceAround">
<!-- Checks that various tokens are surrounded by whitespace.
This includes most binary operators and keywords followed
by regular or curly braces.
-->
<property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR,
BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN,
EQUAL, GE, GT, LAND, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS,
MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION,
SL, SL_ASSIGN, SR_ASSIGN, STAR, STAR_ASSIGN"/>
<property name="severity" value="error"/>
</module>
<module name="WhitespaceAfter">
<!-- Checks that commas, semicolons and typecasts are followed by
whitespace.
-->
<property name="tokens" value="COMMA, SEMI, TYPECAST"/>
</module>
<module name="NoWhitespaceAfter">
<!-- Checks that there is no whitespace after various unary operators.
Linebreaks are allowed.
-->
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS,
UNARY_PLUS"/>
<property name="allowLineBreaks" value="true"/>
<property name="severity" value="error"/>
</module>
<module name="NoWhitespaceBefore">
<!-- Checks that there is no whitespace before various unary operators.
Linebreaks are allowed.
-->
<property name="tokens" value="SEMI, DOT, POST_DEC, POST_INC"/>
<property name="allowLineBreaks" value="true"/>
<property name="severity" value="error"/>
</module>
<module name="ParenPad">
<!-- Checks that there is no whitespace before close parens or after
open parens.
-->
<property name="severity" value="warning"/>
</module>
</module>
</module>

View file

@ -1,7 +1,7 @@
module org.xbib.content.smile { module org.xbib.content.smile {
exports org.xbib.content.smile; exports org.xbib.content.smile;
requires org.xbib.content.core; requires transitive org.xbib.content.core;
requires com.fasterxml.jackson.dataformat.smile; requires transitive com.fasterxml.jackson.dataformat.smile;
provides org.xbib.content.XContent with provides org.xbib.content.XContent with
org.xbib.content.smile.SmileXContent; org.xbib.content.smile.SmileXContent;
} }

View file

@ -5,11 +5,10 @@ module org.xbib.content.xml {
exports org.xbib.content.xml.stream; exports org.xbib.content.xml.stream;
exports org.xbib.content.xml.transform; exports org.xbib.content.xml.transform;
exports org.xbib.content.xml.util; exports org.xbib.content.xml.util;
requires java.xml; requires transitive java.xml;
requires org.xbib.content.core; requires transitive org.xbib.content.core;
requires org.xbib.content.resource; requires transitive org.xbib.content.resource;
requires com.fasterxml.jackson.core; requires transitive com.fasterxml.jackson.dataformat.xml;
requires com.fasterxml.jackson.dataformat.xml;
provides org.xbib.content.XContent with provides org.xbib.content.XContent with
org.xbib.content.xml.XmlXContent; org.xbib.content.xml.XmlXContent;
} }

View file

@ -22,7 +22,7 @@ public class XmlXContent implements XContent {
private static XmlXContent xmlXContent; private static XmlXContent xmlXContent;
private XmlFactory xmlFactory; private final XmlFactory xmlFactory;
/** /**
* Public constructor, used by {@link java.util.ServiceLoader}. * Public constructor, used by {@link java.util.ServiceLoader}.

View file

@ -1,4 +1,5 @@
dependencies { dependencies {
api project(':content-core') api project(':content-core')
api "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${project.property('jackson.version')}" api "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${project.property('jackson.version')}"
api "org.yaml:snakeyaml:${project.property('snakeyaml.version')}"
} }

View file

@ -1,7 +1,7 @@
module org.xbib.content.yaml { module org.xbib.content.yaml {
exports org.xbib.content.yaml; exports org.xbib.content.yaml;
requires org.xbib.content.core; requires transitive org.xbib.content.core;
requires com.fasterxml.jackson.dataformat.yaml; requires transitive com.fasterxml.jackson.dataformat.yaml;
provides org.xbib.content.XContent with provides org.xbib.content.XContent with
org.xbib.content.yaml.YamlXContent; org.xbib.content.yaml.YamlXContent;
provides org.xbib.content.settings.SettingsLoader with provides org.xbib.content.settings.SettingsLoader with

View file

@ -1,12 +1,12 @@
group = org.xbib group = org.xbib
name = content name = content
version = 2.2.0 version = 2.3.0
gradle.wrapper.version = 6.4.1 gradle.wrapper.version = 6.4.1
xbib.net.version = 2.0.4 xbib.net.version = 2.0.4
jackson.version = 2.9.10 jackson.version = 2.11.0
jackson.databind.version = 2.9.10.1 jackson.databind.version = 2.11.0
woodstox.version = 6.2.1 woodstox.version = 6.2.1
mockito.version = 3.1.0 snakeyaml.version = 1.26
junit4.version = 4.13 mockito.version = 3.3.3
asciidoclet.version = 1.5.6 asciidoclet.version = 1.5.6

View file

@ -33,3 +33,11 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
artifacts { artifacts {
archives sourcesJar, javadocJar archives sourcesJar, javadocJar
} }
tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:all'
}
javadoc {
options.addStringOption('Xdoclint:none', '-quiet')
}

View file

@ -0,0 +1,27 @@
apply plugin: 'checkstyle'
checkstyle {
toolVersion '8.33'
showViolations = true
ignoreFailures = true
configFile rootProject.file("config/checkstyle/checkstyle.xml")
}
checkstyleMain {
exclude "**/module-info.java"
logging.setLevel(LogLevel.LIFECYCLE)
source ='src/main/java'
}
checkstyleTest {
exclude "**/module-info.java"
logging.setLevel(LogLevel.LIFECYCLE)
source ='src/test/java'
}
tasks.withType(Checkstyle) {
reports {
xml.enabled false
html.enabled true
}
}

View file

@ -0,0 +1,9 @@
apply plugin: 'pmd'
pmd {
ignoreFailures = true
consoleOutput = false
toolVersion = "6.24.0"
rulePriority = 5
ruleSets = ["category/java/errorprone.xml", "category/java/bestpractices.xml"]
}

View file

@ -0,0 +1,18 @@
apply plugin: "com.github.spotbugs"
spotbugs {
ignoreFailures = true
}
spotbugsMain {
reports {
html {
enabled = true
destination = file("$buildDir/reports/spotbugs/main/spotbugs.html")
}
}
}
spotbugsTest {
enabled = false
}