Skip to content

Commit b58781e

Browse files
authored
fix CI (#50)
1 parent 9368a2a commit b58781e

File tree

12 files changed

+172
-230
lines changed

12 files changed

+172
-230
lines changed

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ This is a simplified backport with the following changes from the original:
9090

9191
These vulnerabilities exist in the upstream OpenJDK sandbox implementation and are reported here for transparency.
9292

93-
## JSON Schema Validator (2020-12)
93+
## JSON Schema Validator
9494

9595
By including a basic schema validator that demonstrates how to build a realistic feature out of the core API. To demonstrate the power of the core API, it follows Data Oriented Programming principles: it parses JSON Schema into an immutable structure of records, then for validation it parses the JSON to the generic structure and uses the thread-safe parsed schema as the model to validate the JSON being checked.
9696

97-
A simple JSON Schema (2020-12 subset) validator is included (module: json-java21-schema).
97+
A simple JSON Schema validator is included (module: json-java21-schema).
9898

9999
```java
100100
var schema = io.github.simbo1905.json.schema.JsonSchema.compile(
@@ -328,12 +328,9 @@ This backport includes a compatibility report tool that tests against the [JSON
328328

329329
### Running the Compatibility Report
330330

331-
First, build the project and download the test suite:
331+
The test data is bundled as ZIP files and extracted automatically at runtime:
332332

333333
```bash
334-
# Build project and download test suite
335-
mvn clean compile generate-test-resources -pl json-compatibility-suite
336-
337334
# Run human-readable report
338335
mvn exec:java -pl json-compatibility-suite
339336

json-compatibility-suite/pom.xml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,30 +50,30 @@
5050
<build>
5151
<plugins>
5252
<plugin>
53-
<groupId>com.googlecode.maven-download-plugin</groupId>
54-
<artifactId>download-maven-plugin</artifactId>
55-
<executions>
56-
<execution>
57-
<id>download-json-test-suite</id>
58-
<phase>pre-integration-test</phase>
59-
<goals>
60-
<goal>wget</goal>
61-
</goals>
62-
<configuration>
63-
<url>https://github.com/nst/JSONTestSuite/archive/refs/heads/master.zip</url>
64-
<outputDirectory>${project.build.directory}/test-resources</outputDirectory>
65-
<outputFileName>json-test-suite.zip</outputFileName>
66-
<unpack>true</unpack>
67-
</configuration>
68-
</execution>
69-
</executions>
53+
<groupId>org.apache.maven.plugins</groupId>
54+
<artifactId>maven-compiler-plugin</artifactId>
55+
<configuration>
56+
<excludes>
57+
<exclude>src/test/resources/**/*.java</exclude>
58+
</excludes>
59+
</configuration>
60+
</plugin>
61+
<plugin>
62+
<groupId>org.apache.maven.plugins</groupId>
63+
<artifactId>maven-surefire-plugin</artifactId>
64+
<configuration>
65+
<excludes>
66+
<exclude>**/JSONTestSuite-20250921/**/*.java</exclude>
67+
<exclude>**/parsers/**/*.java</exclude>
68+
</excludes>
69+
</configuration>
7070
</plugin>
7171
<plugin>
7272
<groupId>org.codehaus.mojo</groupId>
7373
<artifactId>exec-maven-plugin</artifactId>
7474
<version>3.4.1</version>
7575
<configuration>
76-
<mainClass>jdk.sandbox.compatibility.JsonTestSuiteSummary</mainClass>
76+
<mainClass>jdk.sandbox.compatibility.JsonCompatibilitySummary</mainClass>
7777
<includePluginDependencies>false</includePluginDependencies>
7878
</configuration>
7979
</plugin>

json-compatibility-suite/src/main/java/jdk/sandbox/compatibility/JsonTestSuiteSummary.java renamed to json-compatibility-suite/src/main/java/jdk/sandbox/compatibility/JsonCompatibilitySummary.java

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,71 @@
1515
import java.util.ArrayList;
1616
import java.util.List;
1717
import java.util.logging.Logger;
18+
import java.io.FileInputStream;
19+
import java.io.IOException;
20+
import java.util.zip.ZipEntry;
21+
import java.util.zip.ZipInputStream;
1822

1923
/// Generates a conformance summary report.
2024
/// Run with: mvn exec:java -pl json-compatibility-suite
21-
public class JsonTestSuiteSummary {
25+
/// Test data location: see src/test/resources/json-test-suite-data.zip
26+
public class JsonCompatibilitySummary {
2227

23-
private static final Logger LOGGER = Logger.getLogger(JsonTestSuiteSummary.class.getName());
24-
private static final Path TEST_DIR = Paths.get("json-compatibility-suite/target/test-resources/JSONTestSuite-master/test_parsing");
28+
private static final Logger LOGGER = Logger.getLogger(JsonCompatibilitySummary.class.getName());
29+
private static final Path ZIP_FILE = findZipFile();
30+
private static final Path TARGET_TEST_DIR = Paths.get("target/test-data/json-test-suite/test_parsing");
31+
32+
private static Path findZipFile() {
33+
// Try different possible locations for the ZIP file
34+
Path[] candidates = {
35+
Paths.get("src/test/resources/json-test-suite-data.zip"),
36+
Paths.get("json-compatibility-suite/src/test/resources/json-test-suite-data.zip"),
37+
Paths.get("../json-compatibility-suite/src/test/resources/json-test-suite-data.zip")
38+
};
39+
40+
for (Path candidate : candidates) {
41+
if (Files.exists(candidate)) {
42+
return candidate;
43+
}
44+
}
45+
46+
// If none found, return the first candidate and let it fail with a clear message
47+
return candidates[0];
48+
}
2549

2650
public static void main(String[] args) throws Exception {
2751
boolean jsonOutput = args.length > 0 && "--json".equals(args[0]);
28-
JsonTestSuiteSummary summary = new JsonTestSuiteSummary();
52+
JsonCompatibilitySummary summary = new JsonCompatibilitySummary();
53+
summary.extractTestData();
2954
if (jsonOutput) {
3055
summary.generateJsonReport();
3156
} else {
3257
summary.generateConformanceReport();
3358
}
3459
}
3560

61+
void extractTestData() throws IOException {
62+
if (!Files.exists(ZIP_FILE)) {
63+
throw new RuntimeException("Test data ZIP file not found: " + ZIP_FILE.toAbsolutePath());
64+
}
65+
66+
// Create target directory
67+
Files.createDirectories(TARGET_TEST_DIR.getParent());
68+
69+
// Extract ZIP file
70+
try (ZipInputStream zis = new ZipInputStream(new FileInputStream(ZIP_FILE.toFile()))) {
71+
ZipEntry entry;
72+
while ((entry = zis.getNextEntry()) != null) {
73+
if (!entry.isDirectory() && entry.getName().startsWith("test_parsing/")) {
74+
Path outputPath = TARGET_TEST_DIR.getParent().resolve(entry.getName());
75+
Files.createDirectories(outputPath.getParent());
76+
Files.copy(zis, outputPath, java.nio.file.StandardCopyOption.REPLACE_EXISTING);
77+
}
78+
zis.closeEntry();
79+
}
80+
}
81+
}
82+
3683
void generateConformanceReport() throws Exception {
3784
LOGGER.fine(() -> "Starting conformance report generation");
3885
TestResults results = runTests();
@@ -84,9 +131,9 @@ void generateJsonReport() throws Exception {
84131
}
85132

86133
private TestResults runTests() throws Exception {
87-
LOGGER.fine(() -> "Walking test files under: " + TEST_DIR.toAbsolutePath());
88-
if (!Files.exists(TEST_DIR)) {
89-
throw new RuntimeException("Test suite not downloaded. Run: ./mvnw clean compile generate-test-resources -pl json-compatibility-suite");
134+
LOGGER.fine(() -> "Walking test files under: " + TARGET_TEST_DIR.toAbsolutePath());
135+
if (!Files.exists(TARGET_TEST_DIR)) {
136+
throw new RuntimeException("Test data not extracted. Run extractTestData() first.");
90137
}
91138

92139
List<String> shouldPassButFailed = new ArrayList<>();
@@ -98,7 +145,7 @@ private TestResults runTests() throws Exception {
98145
int iAccept = 0, iReject = 0;
99146

100147
List<Path> files;
101-
try (var stream = Files.walk(TEST_DIR)) {
148+
try (var stream = Files.walk(TARGET_TEST_DIR)) {
102149
files = stream
103150
.filter(p -> p.toString().endsWith(".json"))
104151
.sorted()

json-compatibility-suite/src/test/java/jdk/sandbox/compatibility/DownloadVerificationTest.java

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,26 @@
99
public class DownloadVerificationTest {
1010
@Test
1111
void testSuiteDownloaded() {
12-
Path testDir = Paths.get("target/test-resources/JSONTestSuite-master/test_parsing");
13-
assertThat(testDir)
14-
.as("JSON Test Suite should be downloaded and extracted")
15-
.exists()
16-
.isDirectory();
17-
18-
// Verify some test files exist
19-
assertThat(testDir.resolve("y_structure_whitespace_array.json"))
20-
.as("Should contain valid test files")
21-
.exists();
12+
// The test data is now extracted from ZIP at runtime
13+
// Create a summary instance and extract the data manually for testing
14+
try {
15+
JsonCompatibilitySummary summary = new JsonCompatibilitySummary();
16+
summary.extractTestData();
17+
18+
// Verify the target directory exists after extraction
19+
Path targetDir = Paths.get("target/test-data/json-test-suite/test_parsing");
20+
assertThat(targetDir)
21+
.as("JSON Test Suite should be extracted to target directory")
22+
.exists()
23+
.isDirectory();
24+
25+
// Verify some test files exist
26+
assertThat(targetDir.resolve("y_valid_sample.json"))
27+
.as("Should contain valid test files")
28+
.exists();
29+
30+
} catch (Exception e) {
31+
throw new RuntimeException("Failed to extract JSON test suite data", e);
32+
}
2233
}
2334
}

json-compatibility-suite/src/test/java/jdk/sandbox/compatibility/JsonTestSuiteTest.java

Lines changed: 0 additions & 138 deletions
This file was deleted.
Binary file not shown.

json-java21-schema/pom.xml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -96,36 +96,6 @@
9696
</includes>
9797
</configuration>
9898
</plugin>
99-
100-
<!-- Download & unzip the official test-suite -->
101-
<plugin>
102-
<groupId>org.apache.maven.plugins</groupId>
103-
<artifactId>maven-antrun-plugin</artifactId>
104-
<version>3.1.0</version>
105-
<executions>
106-
<execution>
107-
<id>fetch-json-schema-suite</id>
108-
<phase>pre-integration-test</phase>
109-
<goals>
110-
<goal>run</goal>
111-
</goals>
112-
<configuration>
113-
<target>
114-
<mkdir dir="${project.build.directory}/json-schema-test-suite"/>
115-
<get src="https://github.com/json-schema-org/JSON-Schema-Test-Suite/archive/refs/tags/23.1.0.zip"
116-
dest="${project.build.directory}/json-schema-test-suite.zip"
117-
skipexisting="true"/>
118-
<unzip src="${project.build.directory}/json-schema-test-suite.zip"
119-
dest="${project.build.directory}/json-schema-test-suite"
120-
overwrite="false"/>
121-
<!-- Rename the extracted directory for stable path -->
122-
<move file="${project.build.directory}/json-schema-test-suite/JSON-Schema-Test-Suite-23.1.0"
123-
tofile="${project.build.directory}/json-schema-test-suite"/>
124-
</target>
125-
</configuration>
126-
</execution>
127-
</executions>
128-
</plugin>
12999
</plugins>
130100
</build>
131101
</project>

0 commit comments

Comments
 (0)