diff --git a/build.gradle b/build.gradle
index 9d3b235..0702dd2 100644
--- a/build.gradle
+++ b/build.gradle
@@ -2,6 +2,9 @@ plugins {
id "de.marcphilipp.nexus-publish" version "0.4.0"
id "io.codearte.nexus-staging" version "0.21.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 {
@@ -29,6 +32,9 @@ subprojects {
apply from: rootProject.file('gradle/ide/idea.gradle')
apply from: rootProject.file('gradle/compile/java.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/sonatype.gradle')
diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
index 773fc1a..2321bcb 100644
--- a/config/checkstyle/checkstyle.xml
+++ b/config/checkstyle/checkstyle.xml
@@ -38,6 +38,22 @@ page at http://checkstyle.sourceforge.net/config.html -->
Only allows a package-info.java, not package.html. -->
+
+
+
+
+
+
+
+
+
+
@@ -75,9 +91,6 @@ page at http://checkstyle.sourceforge.net/config.html -->
-
-
-
@@ -183,21 +196,6 @@ page at http://checkstyle.sourceforge.net/config.html -->
-->
-
-
-
-
-
-
-
-
-
diff --git a/content-core/src/main/java/module-info.java b/content-core/src/main/java/module-info.java
index c29c994..9a040d4 100644
--- a/content-core/src/main/java/module-info.java
+++ b/content-core/src/main/java/module-info.java
@@ -5,7 +5,7 @@ module org.xbib.content.core {
exports org.xbib.content.settings;
exports org.xbib.content.util.geo;
exports org.xbib.content.util.unit;
- requires com.fasterxml.jackson.core;
+ requires transitive com.fasterxml.jackson.core;
provides org.xbib.content.XContent with
org.xbib.content.json.JsonXContent;
provides org.xbib.content.settings.SettingsLoader with
diff --git a/content-core/src/main/java/org/xbib/content/json/JsonXContent.java b/content-core/src/main/java/org/xbib/content/json/JsonXContent.java
index 34c5478..7a0d5e9 100644
--- a/content-core/src/main/java/org/xbib/content/json/JsonXContent.java
+++ b/content-core/src/main/java/org/xbib/content/json/JsonXContent.java
@@ -2,7 +2,6 @@ package org.xbib.content.json;
import com.fasterxml.jackson.core.JsonEncoding;
import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import org.xbib.content.XContent;
import org.xbib.content.XContentBuilder;
@@ -29,7 +28,6 @@ public class JsonXContent implements XContent {
static {
jsonFactory = new JsonFactory();
jsonFactory.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
- jsonFactory.configure(JsonGenerator.Feature.QUOTE_FIELD_NAMES, true);
jsonXContent = new JsonXContent();
}
@@ -97,7 +95,7 @@ public class JsonXContent implements XContent {
@Override
public boolean isXContent(BytesReference bytes) {
- int length = bytes.length() < 20 ? bytes.length() : 20;
+ int length = Math.min(bytes.length(), 20);
if (length == 0) {
return false;
}
diff --git a/content-json/build.gradle b/content-json/build.gradle
index 0b1fcf4..2708c43 100644
--- a/content-json/build.gradle
+++ b/content-json/build.gradle
@@ -1,8 +1,5 @@
dependencies {
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')}") {
exclude group: 'org.hamcrest'
}
diff --git a/content-json/src/main/java/module-info.java b/content-json/src/main/java/module-info.java
index 0611013..0452788 100644
--- a/content-json/src/main/java/module-info.java
+++ b/content-json/src/main/java/module-info.java
@@ -4,5 +4,6 @@ module org.xbib.content.json {
exports org.xbib.content.json.mergepatch;
exports org.xbib.content.json.patch;
exports org.xbib.content.json.pointer;
- requires com.fasterxml.jackson.databind;
+ requires transitive com.fasterxml.jackson.core;
+ requires transitive com.fasterxml.jackson.databind;
}
diff --git a/content-json/src/test/java/org/xbib/content/json/jackson/JsonNodeReaderTest.java b/content-json/src/test/java/org/xbib/content/json/jackson/JsonNodeReaderTest.java
index dbdd531..6a0a4c7 100644
--- a/content-json/src/test/java/org/xbib/content/json/jackson/JsonNodeReaderTest.java
+++ b/content-json/src/test/java/org/xbib/content/json/jackson/JsonNodeReaderTest.java
@@ -1,29 +1,29 @@
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.verify;
-
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.Assert;
-import org.junit.Test;
-
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
+import java.nio.charset.StandardCharsets;
/**
*
*/
-public final class JsonNodeReaderTest extends Assert {
+public final class JsonNodeReaderTest {
@Test
public void streamIsClosedOnRead()
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);
verify(in).close();
assertEquals(node, new ObjectMapper().readTree(new ByteArrayInputStream("[]".getBytes("UTF-8"))));
@@ -39,21 +39,14 @@ public final class JsonNodeReaderTest extends Assert {
}
@Test
- public void malformedDataThrowsExpectedException()
- throws IOException {
-
+ public void malformedDataThrowsExpectedException() {
String[] inputs = new String[]{
"", "[]{}", "[]]"
};
final JsonNodeReader reader = new JsonNodeReader();
for (String input : inputs) {
- try {
- reader.fromInputStream(new ByteArrayInputStream(input.getBytes()));
- fail("No exception thrown!!");
- } catch (JsonParseException e) {
- //
- }
+ Assertions.assertThrows(JsonParseException.class, () ->
+ reader.fromInputStream(new ByteArrayInputStream(input.getBytes())));
}
}
-
}
diff --git a/content-json/src/test/java/org/xbib/content/json/jackson/JsonNumEqualsTest.java b/content-json/src/test/java/org/xbib/content/json/jackson/JsonNumEqualsTest.java
index 57217fe..bd25316 100644
--- a/content-json/src/test/java/org/xbib/content/json/jackson/JsonNumEqualsTest.java
+++ b/content-json/src/test/java/org/xbib/content/json/jackson/JsonNumEqualsTest.java
@@ -1,12 +1,11 @@
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.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.junit.Assert;
-import org.junit.Test;
-
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.ArrayList;
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;
diff --git a/content-json/src/test/java/org/xbib/content/json/pointer/JsonNodeResolverTest.java b/content-json/src/test/java/org/xbib/content/json/pointer/JsonNodeResolverTest.java
index 557ac77..9a35772 100644
--- a/content-json/src/test/java/org/xbib/content/json/pointer/JsonNodeResolverTest.java
+++ b/content-json/src/test/java/org/xbib/content/json/pointer/JsonNodeResolverTest.java
@@ -1,29 +1,29 @@
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.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.xbib.content.json.jackson.JacksonUtils;
import org.xbib.content.json.jackson.NodeType;
import org.xbib.content.json.jackson.SampleNodeProvider;
-
import java.util.ArrayList;
import java.util.List;
/**
*
*/
-public final class JsonNodeResolverTest extends Assert {
+public final class JsonNodeResolverTest {
+
private static final JsonNodeFactory FACTORY = JacksonUtils.nodeFactory();
@Test
public void resolvingNullReturnsNull() {
final JsonNodeResolver resolver
= new JsonNodeResolver(ReferenceToken.fromRaw("whatever"));
-
assertNull(resolver.get(null));
}
@@ -33,7 +33,6 @@ public final class JsonNodeResolverTest extends Assert {
NodeType.OBJECT).next()[0];
final JsonNodeResolver resolver
= new JsonNodeResolver(ReferenceToken.fromRaw("whatever"));
-
assertNull(resolver.get(node));
}
@@ -42,18 +41,13 @@ public final class JsonNodeResolverTest extends Assert {
final JsonNodeResolver resolver
= new JsonNodeResolver(ReferenceToken.fromRaw("a"));
final JsonNode target = FACTORY.textNode("b");
-
ObjectNode node;
-
node = FACTORY.objectNode();
node.set("a", target);
-
final JsonNode resolved = resolver.get(node);
assertEquals(resolved, target);
-
node = FACTORY.objectNode();
node.set("b", target);
-
assertNull(resolver.get(node));
}
@@ -61,13 +55,10 @@ public final class JsonNodeResolverTest extends Assert {
public void resolvingArrayIndicesWorks() {
final JsonNodeResolver resolver
= new JsonNodeResolver(ReferenceToken.fromInt(1));
-
final JsonNode target = FACTORY.textNode("b");
final ArrayNode node = FACTORY.arrayNode();
-
node.add(target);
assertNull(resolver.get(node));
-
node.add(target);
assertEquals(target, resolver.get(node));
}
@@ -77,7 +68,6 @@ public final class JsonNodeResolverTest extends Assert {
final JsonNode target = FACTORY.textNode("b");
final ArrayNode node = FACTORY.arrayNode();
node.add(target);
-
List