Skip to content
This repository has been archived by the owner on Dec 20, 2022. It is now read-only.

Commit

Permalink
- cleanup of unit tests
Browse files Browse the repository at this point in the history
- added integration test cases
- renamed integration test cases
- updated documentation
  • Loading branch information
pfistererm committed Mar 8, 2020
1 parent 9077f4f commit 8d779c7
Show file tree
Hide file tree
Showing 21 changed files with 360 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ public void testExecutionJavaWithOutputsScanDirectory() throws Exception {
@Test
public void testExecutionJavaWithOutputsScanFiles() throws Exception {
final File scanDirectory = new File("src/test/resources/scans/empty");
final ScanLocation scanLocation = new ScanLocation(Arrays.asList(scanDirectory));
final ArrayList<ExecutionOutput> outputs = createTripleOutput();
final ExecutionParameters executionParameters = createExecutionParameters(ArchiveType.JAVA, scanDirectory,
outputs);
executionParameters.setScanLocation(new ScanLocation(Arrays.asList(scanDirectory)));
final ExecutionParameters executionParameters = createExecutionParameters(ArchiveType.JAVA, scanLocation,
outputs, true);
assertExecution(executionParameters);
}

Expand Down Expand Up @@ -226,8 +226,9 @@ public void testExecutionJavaWriteToDatabaseNoDatabaseConfiguredSnapshotVersionW
@Test(expected = LicenseScoutExecutionException.class)
public void testExecutionJavaNoReportExporterFactory() throws Exception {
final File scanDirectory = new File("src/test/resources/scans/java-unpacked-license-manifest");
final ScanLocation scanLocation = new ScanLocation(scanDirectory);
final ArrayList<ExecutionOutput> outputs = createTripleOutput();
final ExecutionParameters executionParameters = createExecutionParameters(ArchiveType.JAVA, scanDirectory,
final ExecutionParameters executionParameters = createExecutionParameters(ArchiveType.JAVA, scanLocation,
outputs, false);
assertExecution(executionParameters);
}
Expand Down Expand Up @@ -265,11 +266,8 @@ public void testExecutionJavaNotExistingScanDirectory() throws Exception {
*/
@Test(expected = LicenseScoutExecutionException.class)
public void testExecutionJavaNoScanLocation() throws Exception {
// TODO: clean up
final File scanDirectory = new File("not_existing");
final ExecutionParameters executionParameters = createExecutionParametersNoOutputs(ArchiveType.JAVA,
scanDirectory);
executionParameters.setScanLocation(null);
(ScanLocation) null);
assertExecution(executionParameters);
}

Expand Down Expand Up @@ -341,25 +339,33 @@ private ExecutionParameters createExecutionParametersNoOutputs(final ArchiveType
return createExecutionParameters(archiveType, scanDirectory, outputs);
}

private ExecutionParameters createExecutionParametersNoOutputs(final ArchiveType archiveType,
final ScanLocation scanLocation) {
final ArrayList<ExecutionOutput> outputs = new ArrayList<>();
return createExecutionParameters(archiveType, scanLocation, outputs, true);
}

private ExecutionParameters createExecutionParameters(final ArchiveType archiveType, final File scanDirectory,
final ArrayList<ExecutionOutput> outputs) {
return createExecutionParameters(archiveType, scanDirectory, outputs, true);
final ScanLocation scanLocation = new ScanLocation(scanDirectory);
return createExecutionParameters(archiveType, scanLocation, outputs, true);
}

/**
* @param archiveType
* @param scanDirectory
* @param scanLocation the scan location
* @param outputs
* @param withStandardReportExporterFactory
* @return an execution parameters instance
* @return
*/
private ExecutionParameters createExecutionParameters(final ArchiveType archiveType, final File scanDirectory,
private ExecutionParameters createExecutionParameters(final ArchiveType archiveType,
final ScanLocation scanLocation,
final ArrayList<ExecutionOutput> outputs,
final boolean withStandardReportExporterFactory) {
final ExecutionParameters executionParameters = new ExecutionParameters();
executionParameters.setArchiveType(archiveType);
executionParameters.setFilteredVendorNames(new ArrayList<>());
executionParameters.setScanLocation(new ScanLocation(scanDirectory));
executionParameters.setScanLocation(scanLocation);
executionParameters.setOutputDirectory(new File("target"));
executionParameters.setOutputs(outputs);
executionParameters.setCleanOutputActive(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ In one execution, LicenseScout can either scan for Java artifacts or for Javascr

=== Scan Location

The base directory where archives are searched for (recursively and also inside JARs) is configured by the parameter `scanDirectory`.
The location to b scanned can either be:

* a base directory where archives are searched for (recursively and also inside JARs). This is configured by the parameter `scanDirectory`.
* a list of Maven artifacts. The configured artifacts and their (transitive) dependencies are scanned. This is configured by the parameter `scanArtifacts`.
The parameter `scanArtifactScope` optionally allows to specify the
scope for dependency resolution.

[[output-types-and-files]]
=== Output types and files
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.aposin.licensescout.test</groupId>
<artifactId>org.aposin.licensescout.test.licensescout</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Simple Test for License Scout Maven Plugin</name>

<url>https://aposin.org/</url>

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

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<configuration>
<scanArtifacts>
<scanArtifact>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
</scanArtifact>
</scanArtifacts>
<outputs>
<output>
<type>CSV</type>
</output>
</outputs>
<configurationBundle>
<groupId>@project.groupId@</groupId>
<artifactId>org.aposin.licensescout.configuration.sample</artifactId>
<version>@project.version@</version>
<classifier>configuration</classifier>
<type>zip</type>
</configurationBundle>
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>scanJava</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright 2019 Association for the promotion of open-source insurance software and for the establishment of open interface standards in the insurance industry (Verein zur Förderung quelloffener Versicherungssoftware und Etablierung offener Schnittstellenstandards in der Versicherungsbranche)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
File reportFile = new File( basedir, "target/licensescout/licensereport.csv" );
assert reportFile.isFile();
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.aposin.licensescout.test</groupId>
<artifactId>org.aposin.licensescout.test.licensescout</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Simple Test for License Scout Maven Plugin</name>

<url>https://aposin.org/</url>

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

<build>
<plugins>

<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<configuration>
<scanArtifacts>
<scanArtifact>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
</scanArtifact>
</scanArtifacts>
<outputs>
<output>
<type>HTML</type>
</output>
</outputs>
<configurationBundle>
<groupId>@project.groupId@</groupId>
<artifactId>org.aposin.licensescout.configuration.sample</artifactId>
<version>@project.version@</version>
<classifier>configuration</classifier>
<type>zip</type>
</configurationBundle>
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>scanJava</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright 2019 Association for the promotion of open-source insurance software and for the establishment of open interface standards in the insurance industry (Verein zur Förderung quelloffener Versicherungssoftware und Etablierung offener Schnittstellenstandards in der Versicherungsbranche)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
File reportFile = new File( basedir, "target/licensescout/licensereport.html" );
assert reportFile.isFile();
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.aposin.licensescout.test</groupId>
<artifactId>org.aposin.licensescout.test.licensescout</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Simple Test for License Scout Maven Plugin</name>

<url>https://aposin.org/</url>

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


<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<configuration>
<scanArtifacts>
<scanArtifact>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
</scanArtifact>
</scanArtifacts>
<outputDirectory>${licensescout.outputDirectory}</outputDirectory>
<outputs>
<output>
<type>TXT</type>
</output>
</outputs>
<configurationBundle>
<groupId>@project.groupId@</groupId>
<artifactId>org.aposin.licensescout.configuration.sample</artifactId>
<version>@project.version@</version>
<classifier>configuration</classifier>
<type>zip</type>
</configurationBundle>
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>scanJava</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright 2019 Association for the promotion of open-source insurance software and for the establishment of open interface standards in the insurance industry (Verein zur Förderung quelloffener Versicherungssoftware und Etablierung offener Schnittstellenstandards in der Versicherungsbranche)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
File reportFile = new File( basedir, "target/licensescout/licensereport.txt" );
assert reportFile.isFile();
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.aposin.licensescout.test</groupId>
<artifactId>org.aposin.licensescout.test.licensescout</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Simple Test for License Scout Report Maven Plugin</name>

<url>https://aposin.org/</url>

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

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.8.2</version>
</plugin>

</plugins>
</pluginManagement>

</build>

<reporting>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<configuration>
<scanArtifacts>
<scanArtifact>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
</scanArtifact>
</scanArtifacts>
<configurationBundle>
<groupId>@project.groupId@</groupId>
<artifactId>org.aposin.licensescout.configuration.sample</artifactId>
<version>@project.version@</version>
<classifier>configuration</classifier>
<type>zip</type>
</configurationBundle>
</configuration>
</plugin>

</plugins>
</reporting>

</project>
Loading

0 comments on commit 8d779c7

Please sign in to comment.