Skip to content

Commit 31cfed4

Browse files
simbo1905claude
andcommitted
Issue #85 Remove strict/lenient complexity, implement RFC-only approach
Simplified the JTD implementation to follow RFC 8927 exactly: **Removed:** - Strict/lenient mode complexity (-Djtd.strict system property) - SKIPPED_TESTS set and conditional test skipping - Complex metrics with skipped test counting - Lenient mode logging and failure handling **Simplified:** - Single test execution path - all tests must pass - Clean metrics: total/passed/failed only - Direct test failure reporting without mode conditions - Architecture docs updated to remove strict/lenient references **What remains:** - Official JTD Test Suite (365 tests): validation.json + invalid_schemas.json - RFC-compliant error format: instancePath + schemaPath - Single command: $(command -v mvnd || command -v mvn || command -v ./mvnw) test -pl json-java21-jtd -Dtest=JtdSpecIT - Comprehensive /// javadoc documentation This follows the RFC specification without additional complexity. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent c837c25 commit 31cfed4

File tree

2 files changed

+16
-27
lines changed

2 files changed

+16
-27
lines changed

json-java21-jtd/ARCHITECTURE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,15 @@ if (!result.valid()) {
264264
}
265265
```
266266

267+
## Testing
268+
269+
Run the official JTD Test Suite:
270+
271+
```bash
272+
# Run all JTD spec compliance tests
273+
$(command -v mvnd || command -v mvn || command -v ./mvnw) test -pl json-java21-jtd -Dtest=JtdSpecIT
274+
```
275+
267276
## Performance Considerations
268277

269278
1. **Immutable Records**: Zero mutation during validation

json-java21-jtd/src/test/java/json/java21/jtd/JtdSpecIT.java

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -63,38 +63,30 @@
6363
/// ```
6464
///
6565
/// The test suite is extracted from the embedded ZIP file and run as dynamic tests.
66-
/// In strict mode (-Djtd.strict=true), all tests must pass. In lenient mode, failures are logged but don't fail the build.
66+
/// All tests must pass for RFC 8927 compliance.
6767
public class JtdSpecIT extends JtdTestBase {
6868

6969
private static final ObjectMapper MAPPER = new ObjectMapper();
70-
private static final boolean STRICT = Boolean.getBoolean("jtd.strict");
7170
private static final Path VALIDATION_TEST_FILE = Paths.get("target/test-data/json-typedef-spec-2025-09-27/tests/validation.json");
7271
private static final Path INVALID_SCHEMAS_FILE = Paths.get("target/test-data/json-typedef-spec-2025-09-27/tests/invalid_schemas.json");
73-
74-
/// Tests that are known to fail and should be skipped in non-strict mode
75-
private static final Set<String> SKIPPED_TESTS = Set.of(
76-
// Add known failing tests here as they are discovered
77-
);
7872

7973
/// Metrics tracking for test results
8074
private static int totalTests = 0;
8175
private static int passedTests = 0;
8276
private static int failedTests = 0;
83-
private static int skippedTests = 0;
8477

8578
@AfterAll
8679
static void printMetrics() {
87-
LOG.info(() -> String.format("JTD-SPEC-COMPAT: total=%d passed=%d failed=%d skipped=%d strict=%b",
88-
totalTests, passedTests, failedTests, skippedTests, STRICT));
80+
LOG.info(() -> String.format("JTD-SPEC-COMPAT: total=%d passed=%d failed=%d",
81+
totalTests, passedTests, failedTests));
8982

90-
if (STRICT) {
91-
assertEquals(totalTests, passedTests + failedTests, "Strict mode accounting mismatch");
92-
}
83+
// RFC compliance: all tests must pass
84+
assertEquals(totalTests, passedTests + failedTests, "Test accounting mismatch");
9385
}
9486

9587
@TestFactory
9688
Stream<DynamicTest> runJtdSpecSuite() throws Exception {
97-
LOG.info(() -> "Running JTD Test Suite in " + (STRICT ? "STRICT" : "LENIENT") + " mode");
89+
LOG.info(() -> "Running JTD Test Suite");
9890

9991
// Ensure test data is extracted
10092
extractTestData();
@@ -181,14 +173,6 @@ private DynamicTest createValidationTest(String testName, JsonNode testCase) {
181173
return DynamicTest.dynamicTest(testName, () -> {
182174
totalTests++;
183175

184-
// Check if this test should be skipped
185-
String baseName = testName.replace("validation: ", "");
186-
if (!STRICT && SKIPPED_TESTS.contains(baseName)) {
187-
skippedTests++;
188-
LOG.fine(() -> "Skipping validation test: " + testName);
189-
return;
190-
}
191-
192176
LOG.fine(() -> "Running validation test: " + testName);
193177

194178
try {
@@ -214,11 +198,7 @@ private DynamicTest createValidationTest(String testName, JsonNode testCase) {
214198

215199
} catch (Exception e) {
216200
failedTests++;
217-
if (STRICT) {
218-
throw new RuntimeException("Validation test failed in strict mode: " + testName, e);
219-
} else {
220-
LOG.warning(() -> "Validation test failed (lenient mode): " + testName + " - " + e.getMessage());
221-
}
201+
throw new RuntimeException("Validation test failed: " + testName, e);
222202
}
223203
});
224204
}

0 commit comments

Comments
 (0)