From 562295a3788cfc7b17ba5bbbf2d3ae87a0489e0f Mon Sep 17 00:00:00 2001 From: Simon Massey Date: Sun, 27 Jul 2025 22:10:27 +0100 Subject: [PATCH 1/3] step1 --- json-compatibility-suite/pom.xml | 41 +++++ .../sandbox/testsuite/PlaceholderTest.java | 11 ++ pom.xml | 140 +++++------------- 3 files changed, 86 insertions(+), 106 deletions(-) create mode 100644 json-compatibility-suite/pom.xml create mode 100644 json-compatibility-suite/src/test/java/jdk/sandbox/testsuite/PlaceholderTest.java diff --git a/json-compatibility-suite/pom.xml b/json-compatibility-suite/pom.xml new file mode 100644 index 0000000..15699a4 --- /dev/null +++ b/json-compatibility-suite/pom.xml @@ -0,0 +1,41 @@ + + + 4.0.0 + + + io.github.simbo1905.json + json-java21-parent + 0.1-SNAPSHOT + + + json-compatibility-suite + jar + + JSON Compatibility Suite + + + + io.github.simbo1905.json + json-java21 + ${project.version} + + + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.assertj + assertj-core + test + + + diff --git a/json-compatibility-suite/src/test/java/jdk/sandbox/testsuite/PlaceholderTest.java b/json-compatibility-suite/src/test/java/jdk/sandbox/testsuite/PlaceholderTest.java new file mode 100644 index 0000000..4e25067 --- /dev/null +++ b/json-compatibility-suite/src/test/java/jdk/sandbox/testsuite/PlaceholderTest.java @@ -0,0 +1,11 @@ +package jdk.sandbox.testsuite; + +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + +public class PlaceholderTest { + @Test + void moduleExists() { + assertThat(true).isTrue(); + } +} diff --git a/pom.xml b/pom.xml index 4909985..514f988 100644 --- a/pom.xml +++ b/pom.xml @@ -4,116 +4,44 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - io.github.simbo1905.json - json-java21-parent - 0.1-SNAPSHOT - pom - - java.util.json Backport Parent - A backport of the upcoming java.util.json API for Java 21+ - https://simbo1905.github.io/java.util.json.Java21/ - - - - GNU General Public License, version 2, with the Classpath Exception - https://openjdk.org/legal/gplv2+ce.html - - - - - - Simon - simon@simon.com - simon - https://github.com/simbo1905 - - + + io.github.simbo1905.json + json-java21-parent + 0.1-SNAPSHOT + - - scm:git:git://github.com/simbo1905/java.util.json.Java21.git - scm:git:ssh://github.com:simbo1905/java.util.json.Java21.git - https://github.com/simbo1905/java.util.json.Java21/tree/main - + json-test-suite + pom json-java21 + json-compatibility-suite json-java21-api-tracker - - UTF-8 - 21 - 5.10.2 - 3.25.3 - - - 3.4.0 - 3.3.1 - 3.13.0 - 3.2.5 - 3.4.2 - 3.1.2 - - - - - - - - org.junit.jupiter - junit-jupiter-api - ${junit.jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit.jupiter.version} - test - - - org.assertj - assertj-core - ${assertj.version} - test - - - - - - - - - org.apache.maven.plugins - maven-clean-plugin - ${maven-clean-plugin.version} - - - org.apache.maven.plugins - maven-resources-plugin - ${maven-resources-plugin.version} - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - org.apache.maven.plugins - maven-jar-plugin - ${maven-jar-plugin.version} - - - org.apache.maven.plugins - maven-install-plugin - ${maven-install-plugin.version} - - - - - \ No newline at end of file + JSON Java21 Backport + + + + io.github.simbo1905.json + json-java21 + ${project.version} + + + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.assertj + assertj-core + test + + + From f2b5c9532b19e43772f74ef63d1a9a8b5c4e1852 Mon Sep 17 00:00:00 2001 From: Simon Massey Date: Sun, 27 Jul 2025 22:14:34 +0100 Subject: [PATCH 2/3] step1 --- pom.xml | 141 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 107 insertions(+), 34 deletions(-) diff --git a/pom.xml b/pom.xml index 514f988..0551f8d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,44 +4,117 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - - io.github.simbo1905.json - json-java21-parent - 0.1-SNAPSHOT - - - json-test-suite + io.github.simbo1905.json + json-java21-parent + 0.1-SNAPSHOT pom + java.util.json Backport Parent + A backport of the upcoming java.util.json API for Java 21+ + https://simbo1905.github.io/java.util.json.Java21/ + + + + GNU General Public License, version 2, with the Classpath Exception + https://openjdk.org/legal/gplv2+ce.html + + + + + + Simon + simon@simon.com + simon + https://github.com/simbo1905 + + + + + scm:git:git://github.com/simbo1905/java.util.json.Java21.git + scm:git:ssh://github.com:simbo1905/java.util.json.Java21.git + https://github.com/simbo1905/java.util.json.Java21/tree/main + + json-java21 - json-compatibility-suite json-java21-api-tracker + json-compatibility-suite - JSON Java21 Backport - - - - io.github.simbo1905.json - json-java21 - ${project.version} - - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - org.assertj - assertj-core - test - - - + + UTF-8 + 21 + 5.10.2 + 3.25.3 + + + 3.4.0 + 3.3.1 + 3.13.0 + 3.2.5 + 3.4.2 + 3.1.2 + + + + + + + + org.junit.jupiter + junit-jupiter-api + ${junit.jupiter.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit.jupiter.version} + test + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + + + + + org.apache.maven.plugins + maven-clean-plugin + ${maven-clean-plugin.version} + + + org.apache.maven.plugins + maven-resources-plugin + ${maven-resources-plugin.version} + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + org.apache.maven.plugins + maven-jar-plugin + ${maven-jar-plugin.version} + + + org.apache.maven.plugins + maven-install-plugin + ${maven-install-plugin.version} + + + + + \ No newline at end of file From 98797cc87fe9bae4942d98577fe876ef03fd4310 Mon Sep 17 00:00:00 2001 From: Simon Massey Date: Sun, 27 Jul 2025 22:41:45 +0100 Subject: [PATCH 3/3] compat test but got failures --- json-compatibility-suite/pom.xml | 24 +++++++ .../DownloadVerificationTest.java | 23 ++++++ .../compatibility/JsonTestSuiteTest.java | 71 +++++++++++++++++++ .../sandbox/testsuite/PlaceholderTest.java | 11 --- pom.xml | 8 ++- 5 files changed, 125 insertions(+), 12 deletions(-) create mode 100644 json-compatibility-suite/src/test/java/jdk/sandbox/compatibility/DownloadVerificationTest.java create mode 100644 json-compatibility-suite/src/test/java/jdk/sandbox/compatibility/JsonTestSuiteTest.java delete mode 100644 json-compatibility-suite/src/test/java/jdk/sandbox/testsuite/PlaceholderTest.java diff --git a/json-compatibility-suite/pom.xml b/json-compatibility-suite/pom.xml index 15699a4..f1fb066 100644 --- a/json-compatibility-suite/pom.xml +++ b/json-compatibility-suite/pom.xml @@ -38,4 +38,28 @@ test + + + + + com.googlecode.maven-download-plugin + download-maven-plugin + + + download-json-test-suite + generate-test-resources + + wget + + + https://github.com/nst/JSONTestSuite/archive/refs/heads/master.zip + ${project.build.directory}/test-resources + json-test-suite.zip + true + + + + + + diff --git a/json-compatibility-suite/src/test/java/jdk/sandbox/compatibility/DownloadVerificationTest.java b/json-compatibility-suite/src/test/java/jdk/sandbox/compatibility/DownloadVerificationTest.java new file mode 100644 index 0000000..2a9a176 --- /dev/null +++ b/json-compatibility-suite/src/test/java/jdk/sandbox/compatibility/DownloadVerificationTest.java @@ -0,0 +1,23 @@ +package jdk.sandbox.compatibility; + +import org.junit.jupiter.api.Test; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import static org.assertj.core.api.Assertions.assertThat; + +public class DownloadVerificationTest { + @Test + void testSuiteDownloaded() { + Path testDir = Paths.get("target/test-resources/JSONTestSuite-master/test_parsing"); + assertThat(testDir) + .as("JSON Test Suite should be downloaded and extracted") + .exists() + .isDirectory(); + + // Verify some test files exist + assertThat(testDir.resolve("y_structure_whitespace_array.json")) + .as("Should contain valid test files") + .exists(); + } +} diff --git a/json-compatibility-suite/src/test/java/jdk/sandbox/compatibility/JsonTestSuiteTest.java b/json-compatibility-suite/src/test/java/jdk/sandbox/compatibility/JsonTestSuiteTest.java new file mode 100644 index 0000000..c4878f1 --- /dev/null +++ b/json-compatibility-suite/src/test/java/jdk/sandbox/compatibility/JsonTestSuiteTest.java @@ -0,0 +1,71 @@ +package jdk.sandbox.compatibility; + +import jdk.sandbox.java.util.json.Json; +import jdk.sandbox.java.util.json.JsonParseException; +import org.junit.jupiter.api.DynamicTest; +import org.junit.jupiter.api.TestFactory; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.stream.Stream; + +import static org.assertj.core.api.Assertions.*; + +/** + * Runs the JSON Test Suite against our implementation. + * Files are categorized: + * - y_*.json: Valid JSON that MUST parse successfully + * - n_*.json: Invalid JSON that MUST fail to parse + * - i_*.json: Implementation-defined (may accept or reject) + */ +public class JsonTestSuiteTest { + + private static final Path TEST_DIR = Paths.get("target/test-resources/JSONTestSuite-master/test_parsing"); + + @TestFactory + Stream runJsonTestSuite() throws Exception { + if (!Files.exists(TEST_DIR)) { + System.err.println("Test suite not found. Run: mvn test-compile"); + return Stream.empty(); + } + + return Files.walk(TEST_DIR) + .filter(p -> p.toString().endsWith(".json")) + .sorted() + .map(this::createTest); + } + + private DynamicTest createTest(Path file) { + String filename = file.getFileName().toString(); + + return DynamicTest.dynamicTest(filename, () -> { + String content = Files.readString(file); + + if (filename.startsWith("y_")) { + // Valid JSON - must parse successfully + assertThatCode(() -> Json.parse(content)) + .as("File %s should parse successfully", filename) + .doesNotThrowAnyException(); + + } else if (filename.startsWith("n_")) { + // Invalid JSON - must fail to parse + assertThatThrownBy(() -> Json.parse(content)) + .as("File %s should fail to parse", filename) + .isInstanceOf(JsonParseException.class); + + } else if (filename.startsWith("i_")) { + // Implementation defined - just verify no crash + try { + Json.parse(content); + // OK - we accepted it + } catch (JsonParseException e) { + // OK - we rejected it + } catch (Exception e) { + // NOT OK - unexpected exception type + fail("Unexpected exception for %s: %s", filename, e); + } + } + }); + } +} diff --git a/json-compatibility-suite/src/test/java/jdk/sandbox/testsuite/PlaceholderTest.java b/json-compatibility-suite/src/test/java/jdk/sandbox/testsuite/PlaceholderTest.java deleted file mode 100644 index 4e25067..0000000 --- a/json-compatibility-suite/src/test/java/jdk/sandbox/testsuite/PlaceholderTest.java +++ /dev/null @@ -1,11 +0,0 @@ -package jdk.sandbox.testsuite; - -import org.junit.jupiter.api.Test; -import static org.assertj.core.api.Assertions.assertThat; - -public class PlaceholderTest { - @Test - void moduleExists() { - assertThat(true).isTrue(); - } -} diff --git a/pom.xml b/pom.xml index 0551f8d..81afde2 100644 --- a/pom.xml +++ b/pom.xml @@ -54,6 +54,7 @@ 3.2.5 3.4.2 3.1.2 + 1.7.1 @@ -114,7 +115,12 @@ maven-install-plugin ${maven-install-plugin.version} + + com.googlecode.maven-download-plugin + download-maven-plugin + ${download-maven-plugin.version} + - \ No newline at end of file +