This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ant-antlibs-cyclonedx.git
The following commit(s) were added to refs/heads/main by this push:
new 5d326d4 extend maximal test to be really maximal
5d326d4 is described below
commit 5d326d47fbaf57baaa9b8200c44a56f750442611
Author: Stefan Bodewig <[email protected]>
AuthorDate: Sat May 9 08:20:29 2026 +0200
extend maximal test to be really maximal
---
src/main/org/apache/ant/cyclonedx/Component.java | 31 +++++++++---
src/tests/antunit/componentbom-test.xml | 61 +++++++++++++++++++++++-
2 files changed, 84 insertions(+), 8 deletions(-)
diff --git a/src/main/org/apache/ant/cyclonedx/Component.java
b/src/main/org/apache/ant/cyclonedx/Component.java
index abe5a3e..3d77ec7 100644
--- a/src/main/org/apache/ant/cyclonedx/Component.java
+++ b/src/main/org/apache/ant/cyclonedx/Component.java
@@ -55,7 +55,7 @@ public class Component extends DataType {
private boolean unknownDependencies = false;
private boolean sbomLinkResolved = false;
private List<OrganizationalContact> authors = new ArrayList<>();
- private List<String> tags = new ArrayList<>();
+ private List<Tag> tags = new ArrayList<>();
private List<Property> properties = new ArrayList<>();
private String mimeType;
private Union sbomLink;
@@ -145,7 +145,7 @@ public class Component extends DataType {
authors.add(author);
}
- public void addTag(String tag) {
+ public void addTag(Tag tag) {
checkChildrenAllowed();
tags.add(tag);
}
@@ -432,9 +432,9 @@ public class Component extends DataType {
component.setProperties(properties);
}
if (!tags.isEmpty()) {
- Tags t = new Tags();
- t.setTags(tags);
- component.setTags(t);
+ Tags ts = new Tags();
+ ts.setTags(tags.stream().map(t ->
t.getTag()).collect(Collectors.toList()));
+ component.setTags(ts);
}
if (!licenses.isEmpty()) {
LicenseChoice lc = new LicenseChoice();
@@ -501,7 +501,14 @@ public class Component extends DataType {
}
if (real.getTags() != null && real.getTags().getTags() != null) {
tags.clear();
- tags.addAll(real.getTags().getTags());
+ tags.addAll(real.getTags().getTags()
+ .stream()
+ .map(t -> {
+ Tag tag = new Tag();
+ tag.addText(t);
+ return tag;
+ })
+ .collect(Collectors.toList()));
}
if (real.getComponents() != null) {
nestedComponents.clear();
@@ -604,6 +611,18 @@ public class Component extends DataType {
}
}
+ public static class Tag {
+ private String tag;
+
+ public void addText(String text) {
+ tag = text;
+ }
+
+ public String getTag() {
+ return tag;
+ }
+ }
+
/**
* Perform the check for circular references and return the
* referenced Component.
diff --git a/src/tests/antunit/componentbom-test.xml
b/src/tests/antunit/componentbom-test.xml
index 5032b50..dd8036a 100644
--- a/src/tests/antunit/componentbom-test.xml
+++ b/src/tests/antunit/componentbom-test.xml
@@ -116,6 +116,10 @@
xmlns:au="antlib:org.apache.ant.antunit"
resource="${output}/bom.xml"
value='<url>https://github.com/apache/ant-antlibs-cyclonedx</url>'/>
+ <au:assertPropertyEquals
+ xmlns:au="antlib:org.apache.ant.antunit"
+ name="bom.metadata.tools.components.component.publisher"
+ value="The Apache Software Foundation"/>
</target>
<target name="testSupplierAndManufacturerInMeta">
@@ -278,15 +282,28 @@
<checksum property="ant.file.sha256" file="${ant.file}"
algorithm="SHA-256"/>
<cdx:componentbom outputdirectory="${output}" format="xml"
xmlns:cdx="antlib:org.apache.ant.cyclonedx">
- <component name="testname" group="org.example" version="1.0"
- description="My Test Library">
+ <component
+ name="testname"
+ group="org.example"
+ version="1.0"
+ description="My Test Library"
+ publisher="test publisher"
+ copyright="Copyright 2026 ACME Com"
+ mimeType="text/plain"
+ >
<file file="${ant.file}"/>
<manufacturer name="Example">
<url url="https://example.org/"/>
</manufacturer>
+ <supplier name="Example 2">
+ <url url="https://example.com/"/>
+ </supplier>
<license licenseId="Apache-2.0"/>
<externalReference type="WEBSITE" url="https://example.com/"/>
<component name="other-test" group="org.example" version="1.1"/>
+ <author name="Author" email="[email protected]"/>
+ <tag>label</tag>
+ <property name="foo" value="bar"/>
</component>
</cdx:componentbom>
<xmlproperty file="${output}/bom.xml"/>
@@ -306,6 +323,18 @@
xmlns:au="antlib:org.apache.ant.antunit"
name="bom.metadata.component.version"
value="1.0"/>
+ <au:assertPropertyEquals
+ xmlns:au="antlib:org.apache.ant.antunit"
+ name="bom.metadata.component.publisher"
+ value="test publisher"/>
+ <au:assertPropertyEquals
+ xmlns:au="antlib:org.apache.ant.antunit"
+ name="bom.metadata.component.copyright"
+ value="Copyright 2026 ACME Com"/>
+ <au:assertPropertyEquals
+ xmlns:au="antlib:org.apache.ant.antunit"
+ name="bom.metadata.component(mime-type)"
+ value="text/plain"/>
<au:assertPropertyEquals
xmlns:au="antlib:org.apache.ant.antunit"
name="bom.metadata.component.purl"
@@ -314,6 +343,14 @@
xmlns:au="antlib:org.apache.ant.antunit"
name="bom.metadata.component(bom-ref)"
value="pkg:maven/org.example/[email protected]?type=jar"/>
+ <au:assertPropertyEquals
+ xmlns:au="antlib:org.apache.ant.antunit"
+ name="bom.metadata.component.authors.author.name"
+ value="Author"/>
+ <au:assertPropertyEquals
+ xmlns:au="antlib:org.apache.ant.antunit"
+ name="bom.metadata.component.authors.author.email"
+ value="[email protected]"/>
<au:assertPropertyEquals
xmlns:au="antlib:org.apache.ant.antunit"
name="bom.metadata.component.manufacturer.name"
@@ -322,6 +359,14 @@
xmlns:au="antlib:org.apache.ant.antunit"
name="bom.metadata.component.manufacturer.url"
value="https://example.org/"/>
+ <au:assertPropertyEquals
+ xmlns:au="antlib:org.apache.ant.antunit"
+ name="bom.metadata.component.supplier.name"
+ value="Example 2"/>
+ <au:assertPropertyEquals
+ xmlns:au="antlib:org.apache.ant.antunit"
+ name="bom.metadata.component.supplier.url"
+ value="https://example.com/"/>
<au:assertPropertyEquals
xmlns:au="antlib:org.apache.ant.antunit"
name="bom.metadata.component.licenses.license.id"
@@ -330,6 +375,18 @@
xmlns:au="antlib:org.apache.ant.antunit"
resource="${output}/bom.xml"
value='<hash alg="SHA-256">${ant.file.sha256}</hash>'/>
+ <au:assertPropertyEquals
+ xmlns:au="antlib:org.apache.ant.antunit"
+ name="bom.metadata.component.tags.tag"
+ value="label"/>
+ <au:assertPropertyEquals
+ xmlns:au="antlib:org.apache.ant.antunit"
+ name="bom.metadata.component.properties.property(name)"
+ value="foo"/>
+ <au:assertPropertyEquals
+ xmlns:au="antlib:org.apache.ant.antunit"
+ name="bom.metadata.component.properties.property"
+ value="bar"/>
<au:assertPropertyEquals
xmlns:au="antlib:org.apache.ant.antunit"
name="bom.metadata.component.components.component.name"