You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2022/03/25 16:11:44 UTC

[maven-integration-testing] branch master updated: [MNG-828] add regression test for listing plugin configuration values in debug

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

sjaranowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-integration-testing.git


The following commit(s) were added to refs/heads/master by this push:
     new 20560b6  [MNG-828] add regression test for listing plugin configuration values in debug
20560b6 is described below

commit 20560b6accf351c6956e4af14d0d022e609af851
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Tue Mar 22 22:12:48 2022 +0100

    [MNG-828] add regression test for listing plugin configuration values in debug
---
 .../org/apache/maven/it/IntegrationTestSuite.java  |   1 +
 ...avenITmng0828PluginConfigValuesInDebugTest.java | 105 ++++++++++++++++++
 core-it-suite/src/test/resources/mng-0828/pom.xml  | 117 +++++++++++++++++++++
 3 files changed, 223 insertions(+)

diff --git a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
index 6c9bd8f..a7de66a 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
@@ -668,6 +668,7 @@ public class IntegrationTestSuite
         suite.addTestSuite( MavenITmng0866EvaluateDefaultValueTest.class );
         suite.addTestSuite( MavenITmng0848SystemPropOverridesDefaultValueTest.class );
         suite.addTestSuite( MavenITmng0836PluginParentResolutionTest.class );
+        suite.addTestSuite( MavenITmng0828PluginConfigValuesInDebugTest.class );
         suite.addTestSuite( MavenITmng0823MojoContextPassingTest.class );
         suite.addTestSuite( MavenITmng0820ConflictResolutionTest.class );
         suite.addTestSuite( MavenITmng0818WarDepsNotTransitiveTest.class );
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng0828PluginConfigValuesInDebugTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng0828PluginConfigValuesInDebugTest.java
new file mode 100644
index 0000000..7547121
--- /dev/null
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng0828PluginConfigValuesInDebugTest.java
@@ -0,0 +1,105 @@
+package org.apache.maven.it;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.File;
+
+import org.apache.maven.it.util.ResourceExtractor;
+import org.apache.maven.shared.utils.io.FileUtils;
+
+/**
+ * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-828">MNG-828</a>.
+ *
+ * @author Slawomir Jaranowski
+ */
+public class MavenITmng0828PluginConfigValuesInDebugTest
+    extends AbstractMavenIntegrationTestCase
+{
+
+    private static final String NL = System.lineSeparator();
+
+    public MavenITmng0828PluginConfigValuesInDebugTest()
+    {
+        super( ALL_MAVEN_VERSIONS );
+    }
+
+    /**
+     * Verify that plain plugin configuration values are listed correctly in debug mode.
+     *
+     * @throws Exception in case of failure
+     */
+    public void testitMNG0828()
+        throws Exception
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-0828" );
+
+        Verifier verifier = newVerifier( testDir.getAbsolutePath() );
+        verifier.setAutoclean( false );
+        verifier.deleteDirectory( "target" );
+        verifier.setMavenDebug( true );
+        verifier.executeGoal( "validate" );
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+
+        String log = FileUtils.fileRead( new File( verifier.getBasedir(), verifier.getLogFileName() ) );
+
+        checkLog( log, "(f) aliasDefaultExpressionParam = test" );
+        checkLog( log, "(f) basedir = " + testDir.getCanonicalPath() );
+        checkLog( log,
+                  "(f) beanParam = org.apache.maven.plugin.coreit.Bean[fieldParam=field, setterParam=setter, setterCalled=true]" );
+        checkLog( log, "(f) booleanParam = true" );
+        checkLog( log, "(f) byteParam = 42" );
+        checkLog( log, "(f) byteParam = 42" );
+        checkLog( log, "(f) characterParam = X" );
+        checkLog( log, "(f) dateParam = Sun Nov 09 11:59:03 CET 2008" );
+        checkLog( log, "(f) defaultParam = maven-core-it" );
+        checkLog( log, "(f) defaultParamWithExpression = org.apache.maven.its.mng0828:test1:1.0-SNAPSHOT" );
+        checkLog( log, "(f) domParam = <domParam><echo>one</echo>" + NL
+            + "<echo>two</echo>" + NL
+            + "<echo>three</echo>" + NL
+            + "<echo>four</echo>" + NL
+            + "</domParam>" );
+        checkLog( log, "(f) doubleParam = -1.5" );
+        checkLog( log, "(f) fieldParam = field" );
+        checkLog( log, "(f) fileParam = " + new File( testDir, "pom.xml" ).getCanonicalPath() );
+        checkLog( log, "(f) floatParam = 0.0" );
+        checkLog( log, "(f) integerParam = 0" );
+        checkLog( log, "(f) listParam = [one, two, three, four]" );
+        checkLog( log, "(f) longParam = 9876543210" );
+        checkLog( log, "(f) mapParam = {key1=value1, key2=value2}" );
+        checkLog( log, "(f) propertiesFile = " + new File( testDir,
+                                                           "target/plugin-config.properties" ).getCanonicalPath() );
+        checkLog( log, "(f) propertiesParam = {key2=value2, key1=value1}" );
+        checkLog( log, "(f) setParam = [item]" );
+        checkLog( log, "(f) shortParam = -12345" );
+        checkLog( log, "(f) stringParam = Hello World!" );
+        checkLog( log, "(f) stringParams = [one, two, three, four]" );
+        checkLog( log, "(f) urlParam = http://maven.apache.org/" );
+        checkLog( log, "(s) setterParam = setter" );
+    }
+
+    private void checkLog( String log, String expected )
+    {
+        String toSearch = "[DEBUG]   " + expected + NL;
+        assertTrue( NL + ">>>" + NL + log + "<<<" + NL + NL + "does not contains: " + NL + toSearch,
+                    log.contains( toSearch ) );
+    }
+
+}
diff --git a/core-it-suite/src/test/resources/mng-0828/pom.xml b/core-it-suite/src/test/resources/mng-0828/pom.xml
new file mode 100644
index 0000000..bfa9137
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-0828/pom.xml
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.mng0828</groupId>
+  <artifactId>test1</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <name>Maven Integration Test :: MNG-828</name>
+  <description>
+    Verify that plain plugin configuration values are listed correctly in debug mode.
+  </description>
+
+  <build>
+    <pluginManagement>
+      <!--
+      NOTE: The usage of <pluginManagement> for the employed IT plugin is crucial to exhibit the bug!
+      -->
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.its.plugins</groupId>
+          <artifactId>maven-it-plugin-configuration</artifactId>
+          <version>2.1-SNAPSHOT</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.plugins</groupId>
+        <artifactId>maven-it-plugin-configuration</artifactId>
+        <configuration>
+          <propertiesFile>target/plugin-config.properties</propertiesFile>
+          <booleanParam>true</booleanParam>
+          <byteParam>42</byteParam>
+          <shortParam>-12345</shortParam>
+          <integerParam>0</integerParam>
+          <longParam>9876543210</longParam>
+          <floatParam>0.0</floatParam>
+          <doubleParam>-1.5</doubleParam>
+          <characterParam>X</characterParam>
+          <stringParam>Hello World!</stringParam>
+          <fileParam>pom.xml</fileParam>
+          <dateParam>2008-11-09 11:59:03.0 AM</dateParam>
+          <urlParam>http://maven.apache.org/</urlParam>
+          <stringParams>
+            <stringParam>one</stringParam>
+            <stringParam>two</stringParam>
+            <stringParam>three</stringParam>
+            <stringParam>four</stringParam>
+          </stringParams>
+          <listParam>
+            <listParam>one</listParam>
+            <listParam>two</listParam>
+            <listParam>three</listParam>
+            <listParam>four</listParam>
+          </listParam>
+          <setParam>
+            <setParam>item</setParam>
+            <setParam>item</setParam>
+          </setParam>
+          <mapParam>
+            <key1>value1</key1>
+            <key2>value2</key2>
+          </mapParam>
+          <propertiesParam>
+            <property>
+              <name>key1</name>
+              <value>value1</value>
+            </property>
+            <property>
+              <name>key2</name>
+              <value>value2</value>
+            </property>
+          </propertiesParam>
+          <beanParam>
+            <fieldParam>field</fieldParam>
+            <setterParam>setter</setterParam>
+          </beanParam>
+          <domParam>
+            <echo>one</echo>
+            <echo>two</echo>
+            <echo>three</echo>
+            <echo>four</echo>
+          </domParam>
+        </configuration>
+        <executions>
+          <execution>
+            <phase>validate</phase>
+            <goals>
+              <goal>config</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>