Skip to content

Commit 7d29d12

Browse files
authored
Refactor JSON Schema Test Suite with Abstract Base Class and Proper Test Skipping (#63)
* big refactor * make coding style part of AGENTS.md * test fixes * tidy * Fix NullPointerException in JsonSchemaDraft4Test logging - Replace ((Path) null).getFileName() with hardcoded filename - Addresses Copilot review comments about potential NPE * logging * test refactors and marked as skipped * compile - Reflects new abstract base class architecture and proper test skipping - Includes JsonSchemaCheckBaseIT, JsonSchemaCheckDraft4IT, and JsonSchemaCheck202012IT * Fix CI test count to actual 4426 tests
1 parent 0468c79 commit 7d29d12

File tree

9 files changed

+530
-363
lines changed

9 files changed

+530
-363
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ jobs:
3939
for k in totals: totals[k]+=int(r.get(k,'0'))
4040
except Exception:
4141
pass
42-
exp_tests=3667
43-
exp_skipped=1425
42+
exp_tests=4426
43+
exp_skipped=1715
4444
if totals['tests']!=exp_tests or totals['skipped']!=exp_skipped:
4545
print(f"Unexpected test totals: {totals} != expected tests={exp_tests}, skipped={exp_skipped}")
4646
sys.exit(1)

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
json-java21-schema/src/test/resources/draft4/
2+
json-java21-schema/src/test/resources/json-schema-test-suite-data/
13

24
.env
35
repomix-output*
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package io.github.simbo1905.json.schema;
2+
3+
import org.junit.jupiter.api.DynamicTest;
4+
import org.junit.jupiter.api.TestFactory;
5+
6+
import java.nio.file.Path;
7+
import java.nio.file.Paths;
8+
import java.util.Set;
9+
import java.util.stream.Stream;
10+
11+
/// Runs the official JSON-Schema-Test-Suite (Draft 2020-12) as JUnit dynamic tests.
12+
/// By default, this is lenient and will SKIP mismatches and unsupported schemas
13+
/// to provide a compatibility signal without breaking the build. Enable strict
14+
/// mode with -Djson.schema.strict=true to make mismatches fail the build.
15+
public class JsonSchemaCheck202012IT extends JsonSchemaCheckBaseIT {
16+
17+
private static final Path ZIP_FILE = Paths.get("src/test/resources/json-schema-test-suite-data.zip");
18+
private static final Path TARGET_SUITE_DIR = Paths.get("target/test-data/draft2020-12");
19+
20+
@Override
21+
protected Path getZipFile() {
22+
return ZIP_FILE;
23+
}
24+
25+
@Override
26+
protected Path getTargetSuiteDir() {
27+
return TARGET_SUITE_DIR;
28+
}
29+
30+
@Override
31+
protected String getSchemaPrefix() {
32+
return "draft2020-12/";
33+
}
34+
35+
@Override
36+
protected Set<String> getSkippedTests() {
37+
return Set.of(
38+
// Reference resolution issues - Unresolved $ref problems
39+
"ref.json#relative pointer ref to array#match array",
40+
"ref.json#relative pointer ref to array#mismatch array",
41+
"refOfUnknownKeyword.json#reference of a root arbitrary keyword #match",
42+
"refOfUnknownKeyword.json#reference of a root arbitrary keyword #mismatch",
43+
"refOfUnknownKeyword.json#reference of an arbitrary keyword of a sub-schema#match",
44+
"refOfUnknownKeyword.json#reference of an arbitrary keyword of a sub-schema#mismatch",
45+
46+
// JSON parsing issues with duplicate member names
47+
"required.json#required with escaped characters#object with all properties present is valid",
48+
"required.json#required with escaped characters#object with some properties missing is invalid"
49+
);
50+
}
51+
52+
@TestFactory
53+
@Override
54+
public Stream<DynamicTest> runOfficialSuite() throws Exception {
55+
return super.runOfficialSuite();
56+
}
57+
}

0 commit comments

Comments
 (0)