You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ol...@apache.org on 2021/06/22 09:33:23 UTC

[sling-org-apache-sling-commons-clam] 01/02: SLING-9698 Enable code coverage with JaCoCo

This is an automated email from the ASF dual-hosted git repository.

olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-clam.git

commit 7b94209baa764aa716692ce7de02c414ff6d0c6c
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Tue Jun 22 11:31:40 2021 +0200

    SLING-9698 Enable code coverage with JaCoCo
    
    inherit system properties from parent and check command
---
 pom.xml                                            | 26 ----------------------
 .../commons/clam/it/tests/ClamTestSupport.java     | 13 ++++++++++-
 2 files changed, 12 insertions(+), 27 deletions(-)

diff --git a/pom.xml b/pom.xml
index f4d8fa0..ba6b423 100644
--- a/pom.xml
+++ b/pom.xml
@@ -88,35 +88,9 @@
               <name>bundle.filename</name>
               <value>${basedir}/target/${project.build.finalName}.jar</value>
             </property>
-            <property>
-              <name>jacoco.command</name>
-              <value>${jacoco.command}</value>
-            </property>
           </systemProperties>
         </configuration>
       </plugin>
-      <plugin>
-        <groupId>org.jacoco</groupId>
-        <artifactId>jacoco-maven-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>prepare-agent</id>
-            <configuration>
-              <propertyName>jacoco.command</propertyName>
-            </configuration>
-            <goals>
-              <goal>prepare-agent</goal>
-            </goals>
-          </execution>
-          <execution>
-            <id>report</id>
-            <phase>post-integration-test</phase>
-            <goals>
-              <goal>report</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
     </plugins>
   </build>
 
diff --git a/src/test/java/org/apache/sling/commons/clam/it/tests/ClamTestSupport.java b/src/test/java/org/apache/sling/commons/clam/it/tests/ClamTestSupport.java
index 647158e..733fdad 100644
--- a/src/test/java/org/apache/sling/commons/clam/it/tests/ClamTestSupport.java
+++ b/src/test/java/org/apache/sling/commons/clam/it/tests/ClamTestSupport.java
@@ -22,11 +22,14 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.time.Duration;
 import java.util.Arrays;
+import java.util.Objects;
 
 import org.apache.sling.testing.paxexam.TestSupport;
 import org.jetbrains.annotations.NotNull;
 import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.options.OptionalCompositeOption;
+import org.ops4j.pax.exam.options.extra.VMOption;
 import org.testcontainers.containers.GenericContainer;
 
 import static org.apache.sling.testing.paxexam.SlingOptions.scr;
@@ -35,6 +38,7 @@ import static org.ops4j.pax.exam.CoreOptions.junitBundles;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.CoreOptions.options;
 import static org.ops4j.pax.exam.CoreOptions.vmOption;
+import static org.ops4j.pax.exam.CoreOptions.when;
 import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
 
 public abstract class ClamTestSupport extends TestSupport {
@@ -73,10 +77,17 @@ public abstract class ClamTestSupport extends TestSupport {
             // testing
             testcontainers(),
             junitBundles(),
-            vmOption(System.getProperty("jacoco.command"))
+            jacoco() // remove with Testing PaxExam 4.0
         );
     }
 
+    // remove with Testing PaxExam 4.0
+    protected OptionalCompositeOption jacoco() {
+        final String jacocoCommand = System.getProperty("jacoco.command");
+        final VMOption option = Objects.nonNull(jacocoCommand) && !jacocoCommand.trim().isEmpty() ? vmOption(jacocoCommand) : null;
+        return when(Objects.nonNull(option)).useOptions(option);
+    }
+
     protected static class InfiniteInputStream extends InputStream {
 
         @Override