diff --git a/demos/customprovider-jdk9/pom.xml b/demos/customprovider-jdk9/pom.xml
index 0fd489b7..4787c4a7 100644
--- a/demos/customprovider-jdk9/pom.xml
+++ b/demos/customprovider-jdk9/pom.xml
@@ -74,8 +74,8 @@
jakarta.json-api
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter
test
diff --git a/demos/customprovider-jdk9/src/test/java/customprovider/test/TestProviderTest.java b/demos/customprovider-jdk9/src/test/java/customprovider/test/TestProviderTest.java
index 1d5b35b5..32dff212 100644
--- a/demos/customprovider-jdk9/src/test/java/customprovider/test/TestProviderTest.java
+++ b/demos/customprovider-jdk9/src/test/java/customprovider/test/TestProviderTest.java
@@ -10,11 +10,13 @@
package customprovider.test;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+
import jakarta.json.Json;
import jakarta.json.stream.JsonGenerator;
+
import org.eclipse.parsson.demos.customprovider.TestGenerator;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
@@ -23,9 +25,9 @@
public class TestProviderTest {
@Test
- public void hello() {
+ void hello() {
try (JsonGenerator generator = Json.createGenerator(System.out)) {
- Assert.assertTrue("TestGenerator is not picked up", generator instanceof TestGenerator);
+ assertInstanceOf(TestGenerator.class, generator, "TestGenerator is not picked up");
generator.writeStartArray().writeEnd();
}
System.out.println();
diff --git a/impl/pom.xml b/impl/pom.xml
index 013eec7a..ddc698bd 100644
--- a/impl/pom.xml
+++ b/impl/pom.xml
@@ -97,8 +97,14 @@
jakarta.json-api
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter
+ 5.10.1
+ test
+
+
+ org.hamcrest
+ hamcrest-core
test
diff --git a/impl/src/main/java/org/eclipse/parsson/JsonParserImpl.java b/impl/src/main/java/org/eclipse/parsson/JsonParserImpl.java
index 459d1fb3..b60c7fb8 100644
--- a/impl/src/main/java/org/eclipse/parsson/JsonParserImpl.java
+++ b/impl/src/main/java/org/eclipse/parsson/JsonParserImpl.java
@@ -44,6 +44,15 @@
import org.eclipse.parsson.JsonTokenizer.JsonToken;
+import static org.eclipse.parsson.JsonTokenizer.JsonToken.COLON;
+import static org.eclipse.parsson.JsonTokenizer.JsonToken.COMMA;
+import static org.eclipse.parsson.JsonTokenizer.JsonToken.CURLYCLOSE;
+import static org.eclipse.parsson.JsonTokenizer.JsonToken.CURLYOPEN;
+import static org.eclipse.parsson.JsonTokenizer.JsonToken.EOF;
+import static org.eclipse.parsson.JsonTokenizer.JsonToken.SQUARECLOSE;
+import static org.eclipse.parsson.JsonTokenizer.JsonToken.SQUAREOPEN;
+import static org.eclipse.parsson.JsonTokenizer.JsonToken.STRING;
+
/**
* JSON parser implementation. NoneContext, ArrayContext, ObjectContext is used
* to go to next parser state.
@@ -310,7 +319,7 @@ private JsonArray getArray(JsonArrayBuilder builder) {
}
builder.add(getValue());
}
- throw parsingException(JsonToken.EOF, "[CURLYOPEN, SQUAREOPEN, STRING, NUMBER, TRUE, FALSE, NULL, SQUARECLOSE]");
+ throw parsingException(EOF, "[CURLYOPEN, SQUAREOPEN, STRING, NUMBER, TRUE, FALSE, NULL, SQUARECLOSE]");
}
private CharSequence getCharSequence() {
@@ -331,7 +340,7 @@ private JsonObject getObject(JsonObjectBuilder builder) {
next();
builder.add(key, getValue());
}
- throw parsingException(JsonToken.EOF, "[STRING, CURLYCLOSE]");
+ throw parsingException(EOF, "[STRING, CURLYCLOSE]");
}
@Override
@@ -347,7 +356,7 @@ public JsonLocation getLastCharLocation() {
public boolean hasNext() {
if (stack.isEmpty() && (currentEvent != null && currentEvent.compareTo(Event.KEY_NAME) > 0)) {
JsonToken token = tokenizer.nextToken();
- if (token != JsonToken.EOF) {
+ if (token != EOF) {
throw new JsonParsingException(JsonMessages.PARSER_EXPECTED_EOF(token),
getLastCharLocation());
}
@@ -434,7 +443,7 @@ protected Event nextEventIfValueOrObjectOrArrayStart(JsonToken token) {
stack.push(currentContext);
currentContext = new ObjectContext();
return Event.START_OBJECT;
- } else if (token == JsonToken.SQUAREOPEN) {
+ } else if (token == SQUAREOPEN) {
stack.push(currentContext);
currentContext = new ArrayContext();
return Event.START_ARRAY;
@@ -510,7 +519,7 @@ private ObjectContext() {
public Event getNextEvent() {
// Handle 1. } 2. name:value 3. ,name:value
JsonToken token = tokenizer.nextToken();
- if (token == JsonToken.EOF) {
+ if (token == EOF) {
switch (currentEvent) {
case START_OBJECT:
throw parsingException(token, "[STRING, CURLYCLOSE]");
@@ -521,7 +530,7 @@ public Event getNextEvent() {
}
} else if (currentEvent == Event.KEY_NAME) {
// Handle 1. :value
- if (token != JsonToken.COLON) {
+ if (token != COLON) {
throw parsingException(token, "[COLON]");
}
token = tokenizer.nextToken();
@@ -532,19 +541,19 @@ public Event getNextEvent() {
throw parsingException(token, "[CURLYOPEN, SQUAREOPEN, STRING, NUMBER, TRUE, FALSE, NULL]");
} else {
// Handle 1. } 2. name 3. ,name
- if (token == JsonToken.CURLYCLOSE) {
+ if (token == CURLYCLOSE) {
currentContext = stack.pop();
return Event.END_OBJECT;
}
if (firstValue) {
firstValue = false;
} else {
- if (token != JsonToken.COMMA) {
+ if (token != COMMA) {
throw parsingException(token, "[COMMA]");
}
token = tokenizer.nextToken();
}
- if (token == JsonToken.STRING) {
+ if (token == STRING) {
return Event.KEY_NAME;
}
throw parsingException(token, "[STRING]");
@@ -563,7 +572,7 @@ private ArrayContext() {
@Override
public Event getNextEvent() {
JsonToken token = tokenizer.nextToken();
- if (token == JsonToken.EOF) {
+ if (token == EOF) {
switch (currentEvent) {
case START_ARRAY:
throw parsingException(token, "[CURLYOPEN, SQUAREOPEN, STRING, NUMBER, TRUE, FALSE, NULL]");
@@ -571,14 +580,14 @@ public Event getNextEvent() {
throw parsingException(token, "[COMMA, CURLYCLOSE]");
}
}
- if (token == JsonToken.SQUARECLOSE) {
+ if (token == SQUARECLOSE) {
currentContext = stack.pop();
return Event.END_ARRAY;
}
if (firstValue) {
firstValue = false;
} else {
- if (token != JsonToken.COMMA) {
+ if (token != COMMA) {
throw parsingException(token, "[COMMA]");
}
token = tokenizer.nextToken();
diff --git a/impl/src/test/java/org/eclipse/parsson/tests/Issue25Test.java b/impl/src/test/java/org/eclipse/parsson/tests/Issue25Test.java
index b8bf375e..545d19ed 100644
--- a/impl/src/test/java/org/eclipse/parsson/tests/Issue25Test.java
+++ b/impl/src/test/java/org/eclipse/parsson/tests/Issue25Test.java
@@ -16,14 +16,14 @@
package org.eclipse.parsson.tests;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import jakarta.json.JsonObject;
import jakarta.json.spi.JsonProvider;
@@ -32,7 +32,7 @@
public class Issue25Test {
@Test
- public void doubleClose() throws IOException {
+ void doubleClose() throws IOException {
byte[] content = "[\"test\"]".getBytes();
JsonProvider json = JsonProvider.provider();
for (int i = 0; i < 3; i++) {
@@ -54,7 +54,7 @@ public void doubleClose() throws IOException {
}
@Test
- public void doubleCloseWithMoreContent() throws IOException {
+ void doubleCloseWithMoreContent() throws IOException {
byte[] content = loadResource("/comments.json");
JsonProvider json = JsonProvider.provider();
for (int i = 0; i < 3; i++) {
diff --git a/impl/src/test/java/org/eclipse/parsson/tests/JsonArrayTest.java b/impl/src/test/java/org/eclipse/parsson/tests/JsonArrayTest.java
index 43e3ad15..79efec4d 100644
--- a/impl/src/test/java/org/eclipse/parsson/tests/JsonArrayTest.java
+++ b/impl/src/test/java/org/eclipse/parsson/tests/JsonArrayTest.java
@@ -16,23 +16,30 @@
package org.eclipse.parsson.tests;
-import junit.framework.TestCase;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
-import jakarta.json.*;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
+import jakarta.json.Json;
+import jakarta.json.JsonArray;
+import jakarta.json.JsonNumber;
+import jakarta.json.JsonReader;
+import jakarta.json.JsonValue;
+import jakarta.json.JsonWriter;
+
+import org.junit.jupiter.api.Test;
+
/**
* @author Jitendra Kotamraju
*/
-public class JsonArrayTest extends TestCase {
- public JsonArrayTest(String testName) {
- super(testName);
- }
-
- public void testArrayEquals() throws Exception {
+public class JsonArrayTest {
+ @Test
+ void testArrayEquals() throws Exception {
JsonArray expected = Json.createArrayBuilder()
.add(JsonValue.TRUE)
.add(JsonValue.FALSE)
@@ -59,7 +66,8 @@ public void testArrayEquals() throws Exception {
assertEquals(expected, actual);
}
- public void testArrayEqualsUsingCollection() {
+ @Test
+ void testArrayEqualsUsingCollection() {
List