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:58:38 UTC

[sling-org-apache-sling-commons-messaging-mail] 03/03: SLING-9697 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-messaging-mail.git

commit ccd9e1516be2e23d978bb566e8d5f9e022e4f076
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Tue Jun 22 11:58:26 2021 +0200

    SLING-9697 Enable code coverage with JaCoCo
    
    inherit system properties from parent and check command
---
 pom.xml                                            | 35 ++--------------------
 .../messaging/mail/it/tests/MailTestSupport.java   | 13 +++++++-
 2 files changed, 15 insertions(+), 33 deletions(-)

diff --git a/pom.xml b/pom.xml
index 4f2bdaa..2c760a0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -77,40 +77,11 @@
         </executions>
         <configuration>
           <redirectTestOutputToFile>true</redirectTestOutputToFile>
-          <systemProperties>
-            <property>
-              <name>bundle.filename</name>
-              <value>${basedir}/target/${project.build.finalName}.jar</value>
-            </property>
-            <property>
-              <name>jacoco.command</name>
-              <value>${jacoco.command}</value>
-            </property>
-          </systemProperties>
+          <systemPropertyVariables combine.children="append">
+            <bundle.filename>${basedir}/target/${project.build.finalName}.jar</bundle.filename>
+          </systemPropertyVariables>
         </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/messaging/mail/it/tests/MailTestSupport.java b/src/test/java/org/apache/sling/commons/messaging/mail/it/tests/MailTestSupport.java
index f426351..98dc4ae 100644
--- a/src/test/java/org/apache/sling/commons/messaging/mail/it/tests/MailTestSupport.java
+++ b/src/test/java/org/apache/sling/commons/messaging/mail/it/tests/MailTestSupport.java
@@ -23,6 +23,7 @@ import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Objects;
 
 import javax.inject.Inject;
 
@@ -31,6 +32,8 @@ import org.apache.sling.testing.paxexam.SlingOptions;
 import org.apache.sling.testing.paxexam.TestSupport;
 import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
 import org.ops4j.pax.exam.options.ModifiableCompositeOption;
+import org.ops4j.pax.exam.options.OptionalCompositeOption;
+import org.ops4j.pax.exam.options.extra.VMOption;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.thymeleaf.ITemplateEngine;
@@ -47,6 +50,7 @@ import static org.ops4j.pax.exam.CoreOptions.composite;
 import static org.ops4j.pax.exam.CoreOptions.junitBundles;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.CoreOptions.vmOption;
+import static org.ops4j.pax.exam.CoreOptions.when;
 import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
 
 public abstract class MailTestSupport extends TestSupport {
@@ -79,10 +83,17 @@ public abstract class MailTestSupport extends TestSupport {
             mavenBundle().groupId("commons-io").artifactId("commons-io").versionAsInProject(),
             greenmail(),
             thymeleaf(),
-            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);
+    }
+
     private static ModifiableCompositeOption greenmail() {
         final MavenArtifactProvisionOption greenmail = mavenBundle().groupId("com.icegreen").artifactId("greenmail").versionAsInProject();
         final MavenArtifactProvisionOption slf4j_api = mavenBundle().groupId("org.slf4j").artifactId("slf4j-api").versionAsInProject();