diff --git a/.github/workflows/toml-compliance.yml b/.github/workflows/toml-compliance.yml
deleted file mode 100644
index 90498a5f..00000000
--- a/.github/workflows/toml-compliance.yml
+++ /dev/null
@@ -1,43 +0,0 @@
-name: TOML Compliance
-
-on:
- push:
- branches: ['3.*']
- paths:
- - '.github/workflows/toml-compliance.yml'
- - 'toml/**'
- pull_request:
- branches: ['3.*']
- paths:
- - '.github/workflows/toml-compliance.yml'
- - 'toml/**'
- workflow_dispatch:
-
-permissions:
- contents: read
-
-jobs:
- toml-compliance:
- runs-on: 'ubuntu-24.04'
- env:
- TOML_TEST_DIR: ${{ github.workspace }}/toml-test
- steps:
- - name: Check out jackson-dataformats-text
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- with:
- path: jackson-dataformats-text
- - name: Check out toml-test corpus
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- with:
- repository: toml-lang/toml-test
- ref: v2.2.0
- path: toml-test
- - name: Set up JDK
- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
- with:
- distribution: 'temurin'
- java-version: '21'
- cache: 'maven'
- - name: Run TOML compliance tests
- working-directory: jackson-dataformats-text
- run: ./mvnw -B -q -ff -ntp -pl toml -Dtest=ComplianceValidTest,ComplianceInvalidTest -Dtoml.corpus.dir="$TOML_TEST_DIR" test
diff --git a/toml/pom.xml b/toml/pom.xml
index 024ee46a..de3fe123 100644
--- a/toml/pom.xml
+++ b/toml/pom.xml
@@ -43,6 +43,12 @@
20.1.0
test
+
+ at.yawk.toml.test
+ toml-test-for-java
+ 0.1.0-2.2.0
+ test
+
diff --git a/toml/src/test/java/module-info.java b/toml/src/test/java/module-info.java
index b7283ac3..9b51adfc 100644
--- a/toml/src/test/java/module-info.java
+++ b/toml/src/test/java/module-info.java
@@ -8,6 +8,7 @@
requires tools.jackson.databind;
// Additional test lib/framework dependencies
+ requires at.yawk.toml.test;
requires org.assertj.core;
requires org.junit.jupiter.api;
requires org.junit.jupiter.params;
diff --git a/toml/src/test/java/tools/jackson/dataformat/toml/ComplianceInvalidTest.java b/toml/src/test/java/tools/jackson/dataformat/toml/ComplianceInvalidTest.java
index 120b3336..35ddaa1b 100644
--- a/toml/src/test/java/tools/jackson/dataformat/toml/ComplianceInvalidTest.java
+++ b/toml/src/test/java/tools/jackson/dataformat/toml/ComplianceInvalidTest.java
@@ -1,16 +1,13 @@
package tools.jackson.dataformat.toml;
-import java.nio.file.Path;
-import java.util.stream.Stream;
-
import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
+import at.yawk.toml.test.TomlTestCase;
+
import tools.jackson.databind.ObjectMapper;
import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assumptions.assumeTrue;
public class ComplianceInvalidTest extends TomlMapperTestBase
{
@@ -19,18 +16,8 @@ public class ComplianceInvalidTest extends TomlMapperTestBase
.build();
@ParameterizedTest
- @MethodSource("data")
- public void tomlTestInvalidCorpus(Path path) {
- assumeTrue(path != null, "Set -Dtoml.corpus.dir=/path/to/toml-test to run TOML corpus tests");
- assertThrows(TomlStreamReadException.class, () -> MAPPER.readTree(path.toFile()));
- }
-
- public static Stream data() throws Exception {
- Path corpusRoot = ComplianceValidTest.corpusRoot();
- if (corpusRoot == null) {
- return Stream.of(Arguments.of((Path) null));
- }
- return ComplianceValidTest.corpusFiles(corpusRoot, "invalid/").stream()
- .map(Arguments::of);
+ @MethodSource("at.yawk.toml.test.TomlTestSuite#invalidToml100")
+ public void tomlTestInvalidCorpus(TomlTestCase test) {
+ assertThrows(TomlStreamReadException.class, () -> MAPPER.readTree(test.tomlBytes()));
}
}
diff --git a/toml/src/test/java/tools/jackson/dataformat/toml/ComplianceValidTest.java b/toml/src/test/java/tools/jackson/dataformat/toml/ComplianceValidTest.java
index 062bab28..21768803 100644
--- a/toml/src/test/java/tools/jackson/dataformat/toml/ComplianceValidTest.java
+++ b/toml/src/test/java/tools/jackson/dataformat/toml/ComplianceValidTest.java
@@ -1,17 +1,15 @@
package tools.jackson.dataformat.toml;
-import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.nio.file.*;
import java.time.*;
-import java.util.*;
-import java.util.stream.Stream;
+import java.util.Map;
import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
+import at.yawk.toml.test.TomlTestCase;
+
import tools.jackson.core.io.NumberInput;
import tools.jackson.databind.JsonNode;
import tools.jackson.databind.ObjectMapper;
@@ -21,7 +19,6 @@
import tools.jackson.databind.node.ObjectNode;
import static org.junit.jupiter.api.Assertions.*;
-import static org.junit.jupiter.api.Assumptions.assumeTrue;
public class ComplianceValidTest extends TomlMapperTestBase
{
@@ -31,52 +28,17 @@ public class ComplianceValidTest extends TomlMapperTestBase
private static final ObjectMapper JSON_MAPPER = JsonMapper.shared();
@ParameterizedTest
- @MethodSource("data")
- public void tomlTestValidCorpus(Path toml, Path json) throws Exception {
- assumeTrue(toml != null, "Set -Dtoml.corpus.dir=/path/to/toml-test to run TOML corpus tests");
+ @MethodSource("at.yawk.toml.test.TomlTestSuite#validToml100")
+ public void tomlTestValidCorpus(TomlTestCase test) throws Exception {
+ String expectedJson = test.expectedJson();
+ assertNotNull(expectedJson, "valid TOML test must have expected JSON");
- JsonNode expected = mapFromComplianceNode(JSON_MAPPER.readTree(json.toFile()));
- JsonNode actual = TOML_MAPPER.readTree(toml.toFile());
+ JsonNode expected = mapFromComplianceNode(JSON_MAPPER.readTree(expectedJson));
+ JsonNode actual = TOML_MAPPER.readTree(test.tomlBytes());
assertTrue(semanticallyEquals(expected, actual),
"expected=" + expected + " actual=" + actual);
}
- public static Stream data() throws Exception {
- Path corpusRoot = corpusRoot();
- if (corpusRoot == null) {
- return Stream.of(Arguments.of(null, null));
- }
- return corpusFiles(corpusRoot, "valid/").stream()
- .map(toml -> Arguments.of(toml, expectedJson(toml)))
- .filter(args -> Files.isRegularFile((Path) args.get()[1]));
- }
-
- static Path corpusRoot() {
- String root = System.getProperty("toml.corpus.dir");
- if (root == null || root.isBlank()) {
- return null;
- }
- return Paths.get(root);
- }
-
- static List corpusFiles(Path corpusRoot, String prefix) throws IOException {
- Path testsRoot = corpusRoot.resolve("tests");
- Path fileList = testsRoot.resolve(System.getProperty("toml.corpus.fileList", "files-toml-1.0.0"));
- List files = new ArrayList<>();
- for (String line : Files.readAllLines(fileList)) {
- if (line.isBlank() || line.startsWith("#") || !line.endsWith(".toml") || !line.startsWith(prefix)) {
- continue;
- }
- files.add(testsRoot.resolve(line));
- }
- return files;
- }
-
- private static Path expectedJson(Path toml) {
- String fileName = toml.getFileName().toString();
- return toml.resolveSibling(fileName.substring(0, fileName.length() - 5) + ".json");
- }
-
private static JsonNode mapFromComplianceNode(JsonNode expected) {
final JsonNodeCreator nodeF = JsonMapper.shared().createObjectNode();
if (expected.isObject()) {