Skip to content

Commit

Permalink
Add a test to ensure we handle relocations, closes #289
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Conner <[email protected]>
  • Loading branch information
knrc committed May 8, 2023
1 parent b32e94d commit 65a28f5
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/test/java/org/cyclonedx/maven/Issue289Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.cyclonedx.maven;

import java.io.File;

import org.junit.Test;
import org.junit.runner.RunWith;

import io.takari.maven.testing.executor.MavenRuntime.MavenRuntimeBuilder;
import io.takari.maven.testing.executor.MavenVersions;
import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner;

/**
* test for https:/CycloneDX/cyclonedx-maven-plugin/issues/289
* NPE when handling relocations
*/
@RunWith(MavenJUnitTestRunner.class)
@MavenVersions({"3.6.3"})
public class Issue289Test extends BaseMavenVerifier {

public Issue289Test(MavenRuntimeBuilder runtimeBuilder) throws Exception {
super(runtimeBuilder);
}

@Test
public void testForRelocations() throws Exception {
File projDir = resources.getBasedir("issue-289");

verifier
.forProject(projDir)
.withCliOption("-Dcurrent.version=" + getCurrentVersion()) // inject cyclonedx-maven-plugin version
.withCliOption("-X") // debug
.withCliOption("-B")
.execute("clean", "package")
.assertErrorFreeLog();
}
}
32 changes: 32 additions & 0 deletions src/test/resources/issue-289/dependency1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.example</groupId>
<artifactId>issue289_parent</artifactId>
<version>1.0.0</version>
</parent>

<artifactId>issue289_dependency1</artifactId>

<name>Dependency 1</name>

<dependencies>
<dependency>
<groupId>axis</groupId>
<artifactId>axis-ant</artifactId>
<version>1.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
32 changes: 32 additions & 0 deletions src/test/resources/issue-289/dependency2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.example</groupId>
<artifactId>issue289_parent</artifactId>
<version>1.0.0</version>
</parent>

<artifactId>issue289_dependency2</artifactId>

<name>Dependency 2</name>

<dependencies>
<dependency>
<groupId>axis</groupId>
<artifactId>axis-ant</artifactId>
<version>1.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>issue289_dependency1</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
53 changes: 53 additions & 0 deletions src/test/resources/issue-289/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>issue289_parent</artifactId>
<packaging>pom</packaging>
<version>1.0.0</version>

<name>Issue 289 Parent</name>

<modules>
<module>dependency1</module>
<module>dependency2</module>
</modules>

<build>
<plugins>
<plugin>
<groupId>org.cyclonedx</groupId>
<artifactId>cyclonedx-maven-plugin</artifactId>
<version>${current.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>makeAggregateBom</goal>
</goals>
</execution>
</executions>
<configuration>
<projectType>library</projectType>
<schemaVersion>1.4</schemaVersion>
<includeBomSerialNumber>true</includeBomSerialNumber>
<includeCompileScope>true</includeCompileScope>
<includeProvidedScope>false</includeProvidedScope>
<includeRuntimeScope>false</includeRuntimeScope>
<includeSystemScope>false</includeSystemScope>
<includeTestScope>false</includeTestScope>
<includeLicenseText>false</includeLicenseText>
<outputFormat>xml</outputFormat>
</configuration>
</plugin>
</plugins>
</build>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

0 comments on commit 65a28f5

Please sign in to comment.