Skip to content

Commit 7c630cc

Browse files
authored
tests: Update to cyclonedx-core-java-9.0.2 for test runners (#480)
2 parents 491e813 + fa50287 commit 7c630cc

File tree

3 files changed

+39
-23
lines changed

3 files changed

+39
-23
lines changed

tools/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<lib.commons.lang3.version>3.6</lib.commons.lang3.version>
5656
<lib.commons.text.version>1.12.0</lib.commons.text.version>
5757
<lib.unirest.version>1.4.9</lib.unirest.version>
58-
<lib.cyclonedx.core.java.version>8.0.3</lib.cyclonedx.core.java.version>
58+
<lib.cyclonedx.core.java.version>9.0.2</lib.cyclonedx.core.java.version>
5959
</properties>
6060

6161
<scm>

tools/src/test/java/org/cyclonedx/schema/JsonSchemaVerificationTest.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@
1313
*/
1414
package org.cyclonedx.schema;
1515

16-
import org.cyclonedx.CycloneDxSchema;
17-
import org.cyclonedx.parsers.JsonParser;
18-
import org.junit.jupiter.api.DynamicTest;
19-
import org.junit.jupiter.api.TestFactory;
2016
import java.io.File;
2117
import java.util.ArrayList;
2218
import java.util.Collection;
2319
import java.util.List;
2420

21+
import org.cyclonedx.parsers.JsonParser;
22+
import org.cyclonedx.Version;
23+
import org.junit.jupiter.api.DynamicTest;
24+
import org.junit.jupiter.api.TestFactory;
25+
2526
import static org.junit.jupiter.api.Assertions.assertTrue;
2627
import static org.junit.jupiter.api.Assertions.assertFalse;
2728

@@ -33,15 +34,15 @@ Collection<DynamicTest> dynamicTestsWithCollection() throws Exception {
3334
final List<DynamicTest> dynamicTests = new ArrayList<>();
3435
for (final String file: files) {
3536
if (file.endsWith(".json")) {
36-
final CycloneDxSchema.Version schemaVersion;
37+
final Version schemaVersion;
3738
if (file.endsWith("-1.2.json")) {
38-
schemaVersion = CycloneDxSchema.Version.VERSION_12;
39+
schemaVersion = Version.VERSION_12;
3940
} else if (file.endsWith("-1.3.json")) {
40-
schemaVersion = CycloneDxSchema.Version.VERSION_13;
41+
schemaVersion = Version.VERSION_13;
4142
} else if (file.endsWith("-1.4.json")) {
42-
schemaVersion = CycloneDxSchema.Version.VERSION_14;
43+
schemaVersion = Version.VERSION_14;
4344
} else if (file.endsWith("-1.5.json")) {
44-
schemaVersion = CycloneDxSchema.Version.VERSION_15;
45+
schemaVersion = Version.VERSION_15;
4546
} else {
4647
schemaVersion = null;
4748
}
@@ -57,7 +58,7 @@ Collection<DynamicTest> dynamicTestsWithCollection() throws Exception {
5758
return dynamicTests;
5859
}
5960

60-
private boolean isValidJson(CycloneDxSchema.Version version, String resource) throws Exception {
61+
private boolean isValidJson(Version version, String resource) throws Exception {
6162
final File file = new File(this.getClass().getResource(resource).getFile());
6263
final JsonParser parser = new JsonParser();
6364
return parser.isValid(file, version);

tools/src/test/java/org/cyclonedx/schema/XmlSchemaVerificationTest.java

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,46 @@
1313
*/
1414
package org.cyclonedx.schema;
1515

16-
import org.cyclonedx.CycloneDxSchema;
17-
import org.cyclonedx.parsers.XmlParser;
18-
import org.junit.jupiter.api.DynamicTest;
19-
import org.junit.jupiter.api.TestFactory;
2016
import java.io.File;
2117
import java.util.ArrayList;
2218
import java.util.Collection;
2319
import java.util.List;
2420

21+
import org.cyclonedx.parsers.XmlParser;
22+
import org.cyclonedx.Version;
23+
import org.junit.jupiter.api.DynamicTest;
24+
import org.junit.jupiter.api.TestFactory;
25+
2526
import static org.junit.jupiter.api.Assertions.assertTrue;
2627
import static org.junit.jupiter.api.Assertions.assertFalse;
2728

2829
public class XmlSchemaVerificationTest extends BaseSchemaVerificationTest {
2930

3031
@TestFactory
32+
/**
33+
* Generates a collection of dynamic tests based on the available XML files.
34+
*
35+
* @return Collection<DynamicTest> a collection of dynamic tests
36+
* @throws Exception if an error occurs during the generation of the dynamic tests
37+
*/
3138
Collection<DynamicTest> dynamicTestsWithCollection() throws Exception {
3239
final List<String> files = getAllResources();
3340
final List<DynamicTest> dynamicTests = new ArrayList<>();
3441
for (final String file: files) {
3542
if (file.endsWith(".xml")) {
36-
final CycloneDxSchema.Version schemaVersion;
43+
final Version schemaVersion;
3744
if (file.endsWith("-1.0.xml")) {
38-
schemaVersion = CycloneDxSchema.Version.VERSION_10;
45+
schemaVersion = Version.VERSION_10;
3946
} else if (file.endsWith("-1.1.xml")) {
40-
schemaVersion = CycloneDxSchema.Version.VERSION_11;
47+
schemaVersion = Version.VERSION_11;
4148
} else if (file.endsWith("-1.2.xml")) {
42-
schemaVersion = CycloneDxSchema.Version.VERSION_12;
49+
schemaVersion = Version.VERSION_12;
4350
} else if (file.endsWith("-1.3.xml")) {
44-
schemaVersion = CycloneDxSchema.Version.VERSION_13;
51+
schemaVersion = Version.VERSION_13;
4552
} else if (file.endsWith("-1.4.xml")) {
46-
schemaVersion = CycloneDxSchema.Version.VERSION_14;
53+
schemaVersion = Version.VERSION_14;
4754
} else if (file.endsWith("-1.5.xml")) {
48-
schemaVersion = CycloneDxSchema.Version.VERSION_15;
55+
schemaVersion = Version.VERSION_15;
4956
} else {
5057
schemaVersion = null;
5158
}
@@ -61,7 +68,15 @@ Collection<DynamicTest> dynamicTestsWithCollection() throws Exception {
6168
return dynamicTests;
6269
}
6370

64-
private boolean isValid(CycloneDxSchema.Version version, String resource) throws Exception {
71+
/**
72+
* Validates the given XML file against the specified CycloneDX schema version.
73+
*
74+
* @param version the CycloneDX schema version to validate against
75+
* @param resource the path to the XML file to be validated
76+
* @return boolean true if the XML file is valid according to the specified schema version, false otherwise
77+
* @throws Exception if an error occurs during the validation process
78+
*/
79+
private boolean isValid(Version version, String resource) throws Exception {
6580
final File file = new File(this.getClass().getResource(resource).getFile());
6681
final XmlParser parser = new XmlParser();
6782
return parser.isValid(file, version);

0 commit comments

Comments
 (0)