Simplify TestProbe property passing 47/113047/4
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 8 Aug 2024 19:58:43 +0000 (21:58 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 26 Aug 2024 14:29:04 +0000 (16:29 +0200)
Rather than defining a property in our VM and using
propagateSystemProperties(), use direct systemProperty() call.

Change-Id: I2076fa17d2c34434807e9e517f7fb7ae05b4dd4c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
features-test-plugin/src/main/java/org/opendaylight/odlparent/features/test/plugin/PaxOptionUtils.java
features-test-plugin/src/main/java/org/opendaylight/odlparent/features/test/plugin/TestFeaturesMojo.java
features-test-plugin/src/main/java/org/opendaylight/odlparent/features/test/plugin/TestProbe.java

index b386ba2fc8a6ac47fa14a6a77ba6b91cdd5efc71..5767ccb859ca722471f6d8a428877dd4805ce1a8 100644 (file)
@@ -12,7 +12,6 @@ import static org.opendaylight.odlparent.features.test.plugin.DependencyUtils.RE
 import static org.ops4j.pax.exam.CoreOptions.bootDelegationPackages;
 import static org.ops4j.pax.exam.CoreOptions.maven;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.propagateSystemProperties;
 import static org.ops4j.pax.exam.CoreOptions.systemPackages;
 import static org.ops4j.pax.exam.CoreOptions.when;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole;
@@ -165,10 +164,6 @@ final class PaxOptionUtils {
                 .toArray(Option[]::new);
     }
 
-    static Option[] probePropertiesOptions() {
-        return new Option[]{propagateSystemProperties(TestProbe.ALL_PROPERTY_KEYS)};
-    }
-
     private static MavenArtifactUrlReference urlReferenceOf(final Artifact artifact) {
         return maven().groupId(artifact.getGroupId()).artifactId(artifact.getArtifactId())
             .type(artifact.getExtension()).classifier(artifact.getClassifier())
index 0e1358d376d3a9ad18f346ee56e55669f4a76a8d..f3a691c442c6f49c9bf2fb801266926c2de9056c 100644 (file)
@@ -12,9 +12,9 @@ import static org.opendaylight.odlparent.features.test.plugin.PaxOptionUtils.dep
 import static org.opendaylight.odlparent.features.test.plugin.PaxOptionUtils.karafConfigOptions;
 import static org.opendaylight.odlparent.features.test.plugin.PaxOptionUtils.karafDistroOptions;
 import static org.opendaylight.odlparent.features.test.plugin.PaxOptionUtils.miscOptions;
-import static org.opendaylight.odlparent.features.test.plugin.PaxOptionUtils.probePropertiesOptions;
 import static org.opendaylight.odlparent.features.test.plugin.PaxOptionUtils.profileOptions;
 import static org.opendaylight.odlparent.features.test.plugin.PaxOptionUtils.vmOptions;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 
 import java.io.File;
 import java.io.IOException;
@@ -36,6 +36,7 @@ import org.eclipse.aether.RepositorySystem;
 import org.eclipse.aether.RepositorySystemSession;
 import org.eclipse.aether.repository.RemoteRepository;
 import org.ops4j.pax.exam.ExamSystem;
+import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.karaf.container.internal.KarafTestContainerFactory;
 import org.ops4j.pax.exam.spi.PaxExamRuntime;
 import org.slf4j.Logger;
@@ -158,15 +159,18 @@ public final class TestFeaturesMojo extends AbstractMojo {
             karafConfigOptions(buildDir, localRepository),
             dependencyFeaturesOptions(pluginDependencyFeatures),
             dependencyFeaturesOptions(projectDependencyFeatures),
-            probePropertiesOptions(),
+
+            // probe parameters
+            new Option[] {
+                systemProperty(TestProbe.FEATURE_FILE_URI_PROP).value(featureFile.toURI().toString()),
+                systemProperty(TestProbe.BUNDLE_CHECK_SKIP).value(String.valueOf(bundleStateCheckSkip)),
+                systemProperty(TestProbe.BUNDLE_CHECK_TIMEOUT_SECONDS).value(String.valueOf(bundleStateCheckTimeout)),
+                systemProperty(TestProbe.BUNDLE_CHECK_INTERVAL_SECONDS).value(String.valueOf(bundleStateCheckInterval))
+            },
+
             miscOptions()
         );
 
-        // probe parameters
-        System.setProperty(TestProbe.FEATURE_FILE_URI_PROP, featureFile.toURI().toString());
-        System.setProperty(TestProbe.BUNDLE_CHECK_SKIP, String.valueOf(bundleStateCheckSkip));
-        System.setProperty(TestProbe.BUNDLE_CHECK_TIMEOUT_SECONDS, String.valueOf(bundleStateCheckTimeout));
-        System.setProperty(TestProbe.BUNDLE_CHECK_INTERVAL_SECONDS, String.valueOf(bundleStateCheckInterval));
 
         final ExamSystem system;
         try {
index 05fb6757dfb92f602786289e04f97f4d6a94f9eb..a6f7dc494aca963b8d9b518a6b9915f83f0a7881 100644 (file)
@@ -32,15 +32,15 @@ import org.slf4j.LoggerFactory;
  * All dependencies which are absent on target environment expected to be packaged using same
  * {@link org.ops4j.pax.exam.ProbeBuilder}. Input parameters are passed through system properties. in order to be
  * delivered properly all affected properties require explicit declaration using associated Pax options -- see
- * {@link PaxOptionUtils#probePropertiesOptions()}.
+ * {@link PaxOptionUtils} and setup in {@link TestFeaturesMojo#execute()}.
  *
  * <p>
  * Pax Exam module references:
  * <ul>
  *     <li>Probe bundle deployment handling is served by pax-exam-extender-service</li>
  *     <li>Service instances lookup and injection into probe instance is served by pax-exam-inject</li>
- *     <li>Test method invocation is served by pax-exam-invoker-junit, uses JUnitCore v.4, which requires @Test
- *     annotation for method to be eligible for invocation</li>
+ *     <li>Test method invocation is served by pax-exam-invoker-junit, uses JUnitCore v.4, which requires {@code @Test}
+ *         annotation for method to be eligible for invocation</li>
  * </ul>
  */
 public final class TestProbe {
@@ -73,13 +73,6 @@ public final class TestProbe {
     static final String DEFAULT_TIMEOUT = "300";
     static final String DEFAULT_INTERVAL = "1";
 
-    static final String[] ALL_PROPERTY_KEYS = {
-        FEATURE_FILE_URI_PROP,
-        BUNDLE_CHECK_SKIP,
-        BUNDLE_CHECK_TIMEOUT_SECONDS,
-        BUNDLE_CHECK_INTERVAL_SECONDS
-    };
-
     private static final Logger LOG = LoggerFactory.getLogger(TestProbe.class);
     private static final Map<String, ContainerState> ELIGIBLE_STATES = Map.of(
         "slf4j.log4j12", ContainerState.INSTALLED,