You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2023/07/06 16:18:04 UTC

[sling-slingfeature-maven-plugin] branch master updated (bd0d2da -> 58f6bb7)

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

rombert pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-slingfeature-maven-plugin.git


    from bd0d2da  SLING-11935 - JarDecompressorTest.testWithEmbeddedJar fails on Jenkins/Windows (#72)
     new 0914e52  SLING-11936 - Sling Feature Maven Plugin fails on Java 17: module java.base does not "opens java.lang" to unnamed module @74fa148d
     new 58f6bb7  SLING-11936 - Sling Feature Maven Plugin fails on Java 17: module java.base does not "opens java.lang" to unnamed module @74fa148d

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .sling-module.json                                 |  5 ---
 pom.xml                                            |  4 +-
 .../maven/mojos/FeatureLauncherMojoTest.java       | 50 +++++++++++-----------
 3 files changed, 27 insertions(+), 32 deletions(-)
 delete mode 100644 .sling-module.json


[sling-slingfeature-maven-plugin] 01/02: SLING-11936 - Sling Feature Maven Plugin fails on Java 17: module java.base does not "opens java.lang" to unnamed module @74fa148d

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-slingfeature-maven-plugin.git

commit 0914e529e337ded7e8c8dc65876da54b61e52e98
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Thu Jul 6 16:43:56 2023 +0300

    SLING-11936 - Sling Feature Maven Plugin fails on Java 17: module java.base does not "opens java.lang" to unnamed module @74fa148d
    
    - updated to the latest version of mockito-core
    - replace usage of removed APIs
---
 pom.xml                                            |  4 +-
 .../maven/mojos/FeatureLauncherMojoTest.java       | 50 +++++++++++-----------
 2 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/pom.xml b/pom.xml
index 1686dc3..fd0fa6c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -377,8 +377,8 @@
         <!-- testing -->
         <dependency>
             <groupId>org.mockito</groupId>
-            <artifactId>mockito-all</artifactId>
-            <version>1.10.19</version>
+            <artifactId>mockito-core</artifactId>
+            <version>5.3.1</version>
             <scope>test</scope>
         </dependency>
         <dependency>
diff --git a/src/test/java/org/apache/sling/feature/maven/mojos/FeatureLauncherMojoTest.java b/src/test/java/org/apache/sling/feature/maven/mojos/FeatureLauncherMojoTest.java
index 4b46cc2..899a6bd 100644
--- a/src/test/java/org/apache/sling/feature/maven/mojos/FeatureLauncherMojoTest.java
+++ b/src/test/java/org/apache/sling/feature/maven/mojos/FeatureLauncherMojoTest.java
@@ -19,7 +19,7 @@ package org.apache.sling.feature.maven.mojos;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.mock;
@@ -40,6 +40,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.commons.lang.reflect.FieldUtils;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Build;
@@ -52,7 +53,6 @@ import org.apache.sling.feature.io.json.FeatureJSONReader;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.internal.util.reflection.Whitebox;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 
@@ -76,10 +76,10 @@ public class FeatureLauncherMojoTest {
     }
 
     @Test
-    public void testSimpleFeature() throws MojoExecutionException, IOException, MojoFailureException {
+    public void testSimpleFeature() throws MojoExecutionException, IOException, MojoFailureException, IllegalAccessException {
         final FeatureSelectionConfig cfg = new FeatureSelectionConfig();
         cfg.setIncludeClassifier("example-runtime");
-        Whitebox.setInternalState(mojo, "selection", cfg);
+        FieldUtils.getField(FeatureLauncherMojo.class, "selection", true).set(mojo, cfg);
         Map<String, Feature> featureMap = new HashMap<>();
         File featureFile = new File(
             getClass().getResource("/aggregate-features/test-aggregated-feature-example-runtime.json").getFile());
@@ -124,10 +124,10 @@ public class FeatureLauncherMojoTest {
     }
 
     @Test
-    public void testFullLaunch() throws MojoFailureException, MojoExecutionException, IOException {
+    public void testFullLaunch() throws MojoFailureException, MojoExecutionException, IOException, IllegalAccessException {
         final FeatureSelectionConfig cfg = new FeatureSelectionConfig();
         cfg.setIncludeClassifier("example-runtime");
-        Whitebox.setInternalState(mojo, "selection", cfg);
+        FieldUtils.getField(FeatureLauncherMojo.class, "selection", true).set(mojo, cfg);
         Map<String, Feature> featureMap = new HashMap<>();
         File featureFile = new File(
             getClass().getResource("/aggregate-features/test-aggregated-feature-example-runtime.json").getFile());
@@ -135,16 +135,16 @@ public class FeatureLauncherMojoTest {
         String cacheKey = ASSEMBLED_FEATURE_JSON + "-cache";
         featureMap.put(feature.getId().toMvnId(), feature);
 
-        Whitebox.setInternalState(mojo, "artifactClashOverrides", new String[] { "*:*:test" });
-        Whitebox.setInternalState(mojo, "repositoryUrl", "~/.m2/repository");
-        Whitebox.setInternalState(mojo, "frameworkProperties", new String[] { "one=two", "three=four" });
-        Whitebox.setInternalState(mojo, "variableValues", new String[] { "a=b" });
-        Whitebox.setInternalState(mojo, "verbose", true);
-        Whitebox.setInternalState(mojo, "cacheDirectory", new File("./launcher/cache"));
-        Whitebox.setInternalState(mojo, "homeDirectory", new File("./launcher"));
-        Whitebox.setInternalState(mojo, "extensionConfigurations", new String[] { "whatever" });
-        Whitebox.setInternalState(mojo, "frameworkVersion", "1.0.0");
-        Whitebox.setInternalState(mojo, "frameworkArtifacts", new String[] { "next-cool-thing" });
+        FieldUtils.getField(FeatureLauncherMojo.class, "artifactClashOverrides", true).set(mojo, new String[] { "*:*:test" });
+        FieldUtils.getField(FeatureLauncherMojo.class, "repositoryUrl", true).set(mojo, "~/.m2/repository");
+        FieldUtils.getField(FeatureLauncherMojo.class, "frameworkProperties", true).set(mojo, new String[] { "one=two", "three=four" });
+        FieldUtils.getField(FeatureLauncherMojo.class, "variableValues", true).set(mojo, new String[] { "a=b" });
+        FieldUtils.getField(FeatureLauncherMojo.class, "verbose", true).set(mojo, true);
+        FieldUtils.getField(FeatureLauncherMojo.class, "cacheDirectory", true).set(mojo, new File("./launcher/cache"));
+        FieldUtils.getField(FeatureLauncherMojo.class, "homeDirectory", true).set(mojo, new File("./launcher"));
+        FieldUtils.getField(FeatureLauncherMojo.class, "extensionConfigurations", true).set(mojo,  new String[] { "whatever" });
+        FieldUtils.getField(FeatureLauncherMojo.class, "frameworkVersion", true).set(mojo,  "1.0.0");
+        FieldUtils.getField(FeatureLauncherMojo.class, "frameworkArtifacts", true).set(mojo,  new String[] { "next-cool-thing" } );
 
         Build mockBuild = mock(Build.class);
         when(mockBuild.getDirectory()).thenReturn(tempDir.toString());
@@ -183,10 +183,10 @@ public class FeatureLauncherMojoTest {
     }
 
     @Test
-    public void testMainReflection() throws MojoFailureException, MojoExecutionException, IOException {
+    public void testMainReflection() throws MojoFailureException, MojoExecutionException, IOException, IllegalAccessException {
         final FeatureSelectionConfig cfg = new FeatureSelectionConfig();
         cfg.setIncludeClassifier("example-runtime");
-        Whitebox.setInternalState(mojo, "selection", cfg);
+        FieldUtils.getField(FeatureLauncherMojo.class, "selection", true).set(mojo, cfg);
         Map<String, Feature> featureMap = new HashMap<>();
         File featureFile = new File(
             getClass().getResource("/aggregate-features/test-aggregated-feature-example-runtime.json").getFile());
@@ -194,7 +194,7 @@ public class FeatureLauncherMojoTest {
         String cacheKey = ASSEMBLED_FEATURE_JSON + "-cache";
         featureMap.put(feature.getId().toMvnId(), feature);
 
-        Whitebox.setInternalState(mojo, "artifactClashOverrides", new String[] { "*:*:test" });
+        FieldUtils.getField(FeatureLauncherMojo.class, "artifactClashOverrides", true).set(mojo, new String[] { "*:*:test" });
         Build mockBuild = mock(Build.class);
         when(mockBuild.getDirectory()).thenReturn(tempDir.toString());
 
@@ -221,10 +221,10 @@ public class FeatureLauncherMojoTest {
     }
 
     @Test
-    public void testMainReflectionFailure() throws MojoFailureException, MojoExecutionException, IOException {
+    public void testMainReflectionFailure() throws MojoFailureException, MojoExecutionException, IOException, IllegalAccessException {
         final FeatureSelectionConfig cfg = new FeatureSelectionConfig();
         cfg.setIncludeClassifier("example-runtime");
-        Whitebox.setInternalState(mojo, "selection", cfg);
+        FieldUtils.getField(FeatureLauncherMojo.class, "selection", true).set(mojo, cfg);
         Map<String, Feature> featureMap = new HashMap<>();
         File featureFile = new File(
             getClass().getResource("/aggregate-features/test-aggregated-feature-example-runtime.json").getFile());
@@ -232,7 +232,7 @@ public class FeatureLauncherMojoTest {
         String cacheKey = ASSEMBLED_FEATURE_JSON + "-cache";
         featureMap.put(feature.getId().toMvnId(), feature);
 
-        Whitebox.setInternalState(mojo, "artifactClashOverrides", new String[] { "do-fail" });
+        FieldUtils.getField(FeatureLauncherMojo.class, "artifactClashOverrides", true).set(mojo, new String[] { "do-fail" });
         Build mockBuild = mock(Build.class);
         when(mockBuild.getDirectory()).thenReturn(tempDir.toString());
 
@@ -263,10 +263,10 @@ public class FeatureLauncherMojoTest {
     }
 
     @Test
-    public void testFeatureFileReadingIssue() throws MojoFailureException, MojoExecutionException, IOException {
+    public void testFeatureFileReadingIssue() throws MojoFailureException, MojoExecutionException, IOException, IllegalAccessException {
         final FeatureSelectionConfig cfg = new FeatureSelectionConfig();
         cfg.setIncludeClassifier("example-runtime");
-        Whitebox.setInternalState(mojo, "selection", cfg);
+        FieldUtils.getField(FeatureLauncherMojo.class, "selection", true).set(mojo, cfg);
         Map<String, Feature> featureMap = new HashMap<>();
         File featureFile = new File(
             getClass().getResource("/aggregate-features/test-aggregated-feature-example-runtime.json").getFile());
@@ -274,7 +274,7 @@ public class FeatureLauncherMojoTest {
         String cacheKey = ASSEMBLED_FEATURE_JSON + "-cache";
         featureMap.put(feature.getId().toMvnId(), feature);
 
-        Whitebox.setInternalState(mojo, "artifactClashOverrides", new String[] { "*:*:test" });
+        FieldUtils.getField(FeatureLauncherMojo.class, "artifactClashOverrides", true).set(mojo, new String[] { "*:*:test" });
         Build mockBuild = mock(Build.class);
         when(mockBuild.getDirectory()).thenReturn(tempDir.toString());
 


[sling-slingfeature-maven-plugin] 02/02: SLING-11936 - Sling Feature Maven Plugin fails on Java 17: module java.base does not "opens java.lang" to unnamed module @74fa148d

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-slingfeature-maven-plugin.git

commit 58f6bb7879ee86e39dfc540f83859300b14f4256
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Thu Jul 6 18:09:00 2023 +0300

    SLING-11936 - Sling Feature Maven Plugin fails on Java 17: module java.base does not "opens java.lang" to unnamed module @74fa148d
    
    Re-enable Jenkins tests on Java 17
---
 .sling-module.json | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/.sling-module.json b/.sling-module.json
deleted file mode 100644
index bca6582..0000000
--- a/.sling-module.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
-    "jenkins": {
-        "jdks": [11]
-    }
-}