|
32 | 32 | import org.cyclonedx.model.License; |
33 | 33 | import org.cyclonedx.model.LicenseChoice; |
34 | 34 | import org.cyclonedx.model.Metadata; |
| 35 | +import org.cyclonedx.model.OrganizationalContact; |
35 | 36 | import org.cyclonedx.model.Service; |
36 | 37 | import org.cyclonedx.model.license.Expression; |
| 38 | +import org.cyclonedx.model.metadata.ToolInformation; |
37 | 39 | import org.cyclonedx.parsers.JsonParser; |
38 | 40 | import org.cyclonedx.parsers.XmlParser; |
39 | 41 | import org.junit.jupiter.api.AfterEach; |
|
50 | 52 | import java.nio.file.Path; |
51 | 53 | import java.util.ArrayList; |
52 | 54 | import java.util.Arrays; |
| 55 | +import java.util.LinkedList; |
53 | 56 | import java.util.List; |
| 57 | +import java.util.UUID; |
54 | 58 | import java.util.stream.Stream; |
55 | 59 | import java.util.Objects; |
56 | 60 |
|
@@ -672,11 +676,67 @@ public void testXxeProtection() { |
672 | 676 |
|
673 | 677 | @Test |
674 | 678 | public void testIssue408Regression_extensibleTypes() throws Exception { |
| 679 | + Bom bom = new Bom(); |
| 680 | + bom.setSerialNumber("urn:uuid:" + UUID.randomUUID()); |
| 681 | + |
| 682 | + Metadata meta = new Metadata(); |
| 683 | + |
| 684 | + // ToolInformation test |
| 685 | + Component tool1 = new Component(); |
| 686 | + tool1.setType(Component.Type.APPLICATION); |
| 687 | + tool1.setName("TOOL 1"); |
| 688 | + tool1.setVersion("v1"); |
| 689 | + |
| 690 | + Component tool2 = new Component(); |
| 691 | + tool2.setType(Component.Type.APPLICATION); |
| 692 | + tool2.setName("TOOL 2"); |
| 693 | + tool2.setVersion("v2"); |
| 694 | + |
| 695 | + ToolInformation tools = new ToolInformation(); |
| 696 | + List<Component> components = new LinkedList<>(); |
| 697 | + components.add(tool1); |
| 698 | + components.add(tool2); |
| 699 | + tools.setComponents(components); |
| 700 | + meta.setToolChoice(tools); |
| 701 | + |
| 702 | + // Author test |
| 703 | + OrganizationalContact auth1 = new OrganizationalContact(); |
| 704 | + auth1.setName("Author 1"); |
| 705 | + meta.addAuthor(auth1); |
| 706 | + |
| 707 | + OrganizationalContact auth2 = new OrganizationalContact(); |
| 708 | + auth2.setName("Author 2"); |
| 709 | + meta.addAuthor(auth2); |
| 710 | + |
| 711 | + bom.setMetadata(meta); |
| 712 | + |
| 713 | + BomXmlGenerator generator = BomGeneratorFactory.createXml(Version.VERSION_16, bom); |
| 714 | + File loadedFile = writeToFile(generator.toXmlString()); |
| 715 | + |
| 716 | + XmlParser parser = new XmlParser(); |
| 717 | + assertTrue(parser.isValid(loadedFile, Version.VERSION_16)); |
| 718 | + } |
| 719 | + |
| 720 | + @Test |
| 721 | + public void testIssue562() throws Exception { |
675 | 722 | Version version = Version.VERSION_15; |
676 | | - Bom bom = createCommonBomXml("/regression/issue408-extensible-type.xml"); |
677 | | - addExtensibleTypes(bom); |
| 723 | + Bom bom = createCommonBomXml("/regression/issue562.xml"); |
678 | 724 |
|
679 | 725 | BomXmlGenerator generator = BomGeneratorFactory.createXml(version, bom); |
| 726 | + |
| 727 | + File loadedFile = writeToFile(generator.toXmlString()); |
| 728 | + |
| 729 | + XmlParser parser = new XmlParser(); |
| 730 | + assertTrue(parser.isValid(loadedFile, version)); |
| 731 | + } |
| 732 | + |
| 733 | + @Test |
| 734 | + public void testIssue492() throws Exception { |
| 735 | + Version version = Version.VERSION_15; |
| 736 | + Bom bom = createCommonBomXml("/regression/issue492.xml"); |
| 737 | + |
| 738 | + BomXmlGenerator generator = BomGeneratorFactory.createXml(version, bom); |
| 739 | + |
680 | 740 | File loadedFile = writeToFile(generator.toXmlString()); |
681 | 741 |
|
682 | 742 | XmlParser parser = new XmlParser(); |
|
0 commit comments