Skip to content

Commit

Permalink
Fix Issue 492
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-zepol committed Dec 10, 2024
1 parent 2082a52 commit f4cc7f4
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/test/java/org/cyclonedx/BomJsonGeneratorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ public void testIssue408Regression_xmlToJson_externalReferenceBom() throws Excep

@Test
public void testIssue562() throws Exception {
Version version = Version.VERSION_15;
Version version = Version.VERSION_16;
Bom bom = createCommonJsonBom("/regression/issue562.json");


Expand All @@ -558,7 +558,18 @@ public void testIssue562() throws Exception {
assertTrue(parser.isValid(loadedFile, version));
}

@Test
public void testIssue492() throws Exception {
Version version = Version.VERSION_14;
Bom bom = createCommonJsonBom("/regression/issue492.json");


BomJsonGenerator generator = BomGeneratorFactory.createJson(version, bom);
File loadedFile = writeToFile(generator.toJsonString());

JsonParser parser = new JsonParser();
assertTrue(parser.isValid(loadedFile, version));
}

private void assertExternalReferenceInfo(Bom bom) {
assertEquals(3, bom.getExternalReferences().size());
Expand Down
13 changes: 13 additions & 0 deletions src/test/java/org/cyclonedx/BomXmlGeneratorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,19 @@ public void testIssue562() throws Exception {
assertTrue(parser.isValid(loadedFile, version));
}

@Test
public void testIssue492() throws Exception {
Version version = Version.VERSION_15;
Bom bom = createCommonBomXml("/regression/issue492.xml");

BomXmlGenerator generator = BomGeneratorFactory.createXml(version, bom);

File loadedFile = writeToFile(generator.toXmlString());

XmlParser parser = new XmlParser();
assertTrue(parser.isValid(loadedFile, version));
}

private void addExtensibleTypes(Bom bom) {
ExtensibleType t1 = new ExtensibleType("abc", "test", "test");
ExtensibleType t2 = new ExtensibleType("abc", "test", "test1");
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/org/cyclonedx/parsers/JsonParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -575,4 +575,10 @@ public void testIssue562Regression() throws Exception {
assertEquals(2, bom.getMetadata().getToolChoice().getComponents().size());
assertEquals(2, bom.getMetadata().getAuthors().size());
}

@Test
public void testIssue492Regression() throws Exception {
final Bom bom = getJsonBom("regression/issue492.json");
assertEquals(2, bom.getMetadata().getTools().size());
}
}
6 changes: 6 additions & 0 deletions src/test/java/org/cyclonedx/parsers/XmlParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -720,4 +720,10 @@ public void testIssue562Regression() throws Exception {
assertEquals(2, bom.getMetadata().getToolChoice().getComponents().size());
assertEquals(2, bom.getMetadata().getAuthors().size());
}

@Test
public void testIssue492Regression() throws Exception {
final Bom bom = getXmlBom("regression/issue492.xml");
assertEquals(2, bom.getMetadata().getTools().size());
}
}
17 changes: 17 additions & 0 deletions src/test/resources/regression/issue492.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"bomFormat":"CycloneDX",
"specVersion":"1.4",
"serialNumber":"urn:uuid:0c81ff2e-d64e-4897-bfa4-2f0f7d8ab767",
"version" : 1,
"metadata" : {
"timestamp":"2024-12-09T21:56:45Z",
"tools": [
{
"name": "tool-a"
},
{
"name": "tool-b"
}
]
}
}
18 changes: 18 additions & 0 deletions src/test/resources/regression/issue492.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<bom xmlns="http://cyclonedx.org/schema/bom/1.4" serialNumber="urn:uuid:0c81ff2e-d64e-4897-bfa4-2f0f7d8ab767" version="1">
<metadata>
<timestamp>2024-12-09T21:56:45Z</timestamp>
<tools>
<tool>
<vendor>corp A</vendor>
<name>tool A</name>
<version>1-A</version>
</tool>
<tool>
<vendor>corp B</vendor>
<name>tool B</name>
<version>1-B</version>
</tool>
</tools>
</metadata>
</bom>

0 comments on commit f4cc7f4

Please sign in to comment.