From 419f9f98f82441b5f7da29a27edf71ac22ea5c25 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Tue, 22 Mar 2022 22:12:48 +0100 Subject: [PATCH] [MNG-828] add regression test for listing plugin configuration values in debug --- .../apache/maven/it/IntegrationTestSuite.java | 1 + ...Tmng0828PluginConfigValuesInDebugTest.java | 105 ++++++++++++++++ .../src/test/resources/mng-0828/pom.xml | 117 ++++++++++++++++++ 3 files changed, 223 insertions(+) create mode 100644 core-it-suite/src/test/java/org/apache/maven/it/MavenITmng0828PluginConfigValuesInDebugTest.java create mode 100644 core-it-suite/src/test/resources/mng-0828/pom.xml 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 6c9bd8f4d..a7de66a05 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 static Test suite() 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 000000000..75471219b --- /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 MNG-828. + * + * @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 = one" + NL + + "two" + NL + + "three" + NL + + "four" + NL + + "" ); + 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 000000000..bfa9137b4 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-0828/pom.xml @@ -0,0 +1,117 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng0828 + test1 + 1.0-SNAPSHOT + + Maven Integration Test :: MNG-828 + + Verify that plain plugin configuration values are listed correctly in debug mode. + + + + + + + + org.apache.maven.its.plugins + maven-it-plugin-configuration + 2.1-SNAPSHOT + + + + + + org.apache.maven.its.plugins + maven-it-plugin-configuration + + target/plugin-config.properties + true + 42 + -12345 + 0 + 9876543210 + 0.0 + -1.5 + X + Hello World! + pom.xml + 2008-11-09 11:59:03.0 AM + http://maven.apache.org/ + + one + two + three + four + + + one + two + three + four + + + item + item + + + value1 + value2 + + + + key1 + value1 + + + key2 + value2 + + + + field + setter + + + one + two + three + four + + + + + validate + + config + + + + + + +