michael-o commented on code in PR #165: URL: https://github.com/apache/maven-integration-testing/pull/165#discussion_r883016754
########## core-it-support/core-it-plugins/maven-it-plugin-configuration/src/main/java/org/apache/maven/plugin/coreit/TouchMojo.java: ########## @@ -0,0 +1,73 @@ +package org.apache.maven.plugin.coreit; + +/* + * 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 java.io.IOException; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; + +/** + * simple Touch Mojo + * + * @author Slawomir Jaranowski + */ +@Mojo( name = "touch", defaultPhase = LifecyclePhase.VALIDATE ) +public class TouchMojo + extends AbstractMojo +{ + @Parameter( defaultValue = "${project.build.directory}" ) + private File outputDirectory; + + @Parameter( alias = "validParameterAlias" ) + private String validParameter; + + public void execute() + throws MojoExecutionException + { + + getLog().info( "[MAVEN-CORE-IT-LOG] Using output directory " + outputDirectory ); + touch( outputDirectory, "touch.txt" ); + + } + + static void touch( File dir, String file ) + throws MojoExecutionException + { + try + { + if ( !dir.exists() ) + { + dir.mkdirs(); + } + + File touch = new File( dir, file ); + touch.createNewFile(); Review Comment: https://www.youtube.com/watch?v=_NNYI8VbFyY ########## core-it-suite/src/test/resources/mng-7468-unsupported-params/config-build-execution/pom.xml: ########## @@ -0,0 +1,57 @@ +<?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.mng7464</groupId> + <artifactId>maven-it-mng7468</artifactId> + <version>1.0</version> + + <name>Maven Integration Test :: mng7468</name> + <description> + Test that ensures that warning about unsupported mojo parameters are generated. + </description> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.its.plugins</groupId> + <artifactId>maven-it-plugin-configuration</artifactId> + <version>2.1-SNAPSHOT</version> + <executions> + <execution> + <goals> + <goal>touch</goal> + </goals> + <configuration> + <invalidValue>value</invalidValue> + <invalidXml> + <item>value</item> + </invalidXml> + </configuration> Review Comment: This confuses me a bit. We don't validate the value, but only the param, no? So why not `invalidParam`? What am I missing? The next block is an Xpp3Dom, so I guess `invalidXml` is correct. ########## core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7468UnsupportedPluginsParametersTest.java: ########## @@ -0,0 +1,183 @@ +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 java.util.ArrayList; +import java.util.List; +import java.util.regex.Pattern; + +import org.apache.maven.it.util.ResourceExtractor; + +/** + * Test for + * <a href="https://issues.apache.org/jira/browse/MNG-7468">MNG-7468</a> + * + * @author Slawomir Jaranowski + */ +public class MavenITmng7468UnsupportedPluginsParametersTest extends AbstractMavenIntegrationTestCase +{ + public MavenITmng7468UnsupportedPluginsParametersTest() + { + super( "[4.0.0-alpha-1,)" ); + } + + /** + * Test that ensures that warning is not printed for empty configuration + */ + public void testNoConfiguration() throws Exception + { + List<String> warnLines = performTest( "no-config" ); + assertTrue( "Unwanted warnings: " + warnLines, warnLines.isEmpty() ); + } + + /** + * Test that ensures that warning is not printed for valid parameters + */ + public void testValidParameter() throws Exception + { + List<String> warnLines = performTest( "valid-parameter" ); + assertTrue( "Unwanted warnings: " + warnLines, warnLines.isEmpty() ); + } + + /** + * Test that ensures that warning is not printed for valid parameters + */ + public void testValidParameterAlias() throws Exception + { + List<String> warnLines = performTest( "valid-parameter-alias" ); + assertTrue( "Unwanted warnings: " + warnLines, warnLines.isEmpty() ); + } + + /** + * Test that ensures that warning is not printed for valid parameters + */ + public void testValidParameterForOtherGoal() throws Exception + { + List<String> warnLines = performTest( "valid-parameter-other-goal" ); + assertTrue( "Unwanted warnings: " + warnLines, warnLines.isEmpty() ); + } + + /** + * Test that ensures that warning is printed for configuration + */ + public void testInBuildPlugin() throws Exception + { + List<String> warnLines = performTest( "config-build-plugin" ); + assertWarningContains( warnLines ); + } + + /** + * Test that ensures that warning is printed for configuration + */ + public void testInBuildExecution() throws Exception + { + List<String> warnLines = performTest( "config-build-execution" ); + assertWarningContains( warnLines ); + } + + /** + * Test that ensures that warning is printed for configuration + */ + public void testInBuildMixed() throws Exception + { + List<String> warnLines = performTest( "config-build-mixed" ); + assertWarningContains( warnLines ); + } + + /** + * Test that ensures that warning is printed for configuration + */ + public void testInPluginManagement() throws Exception + { + List<String> warnLines = performTest( "config-plugin-management" ); + assertWarningContains( warnLines ); + } + + /** + * Test that ensures that warning is printed for configuration + */ + public void testInPluginManagementParent() throws Exception + { + List<String> warnLines = performTest( "config-plugin-management-parent" ); + assertWarningContains( warnLines ); + } + + /** + * Test that ensures that warning is printed for configuration + */ + public void testWithForkedGoalExecution() throws Exception + { + List<String> warnLines = performTest( "config-with-fork-goal" ); + + assertTrue( warnLines.remove( + "[WARNING] Parameter 'invalidXml' is unknown for plugin 'maven-it-plugin-fork:2.1-SNAPSHOT:fork-goal (fork)'" ) ); + + assertTrue( warnLines.remove( + "[WARNING] Parameter 'invalidValue' is unknown for plugin 'maven-it-plugin-fork:2.1-SNAPSHOT:fork-goal (fork)'" ) ); + + assertTrue( warnLines.remove( + "[WARNING] Parameter 'invalidXml' is unknown for plugin 'maven-it-plugin-fork:2.1-SNAPSHOT:touch (touch)'" ) ); + + assertTrue( warnLines.remove( + "[WARNING] Parameter 'invalidValue' is unknown for plugin 'maven-it-plugin-fork:2.1-SNAPSHOT:touch (touch)'" ) ); + + assertTrue( "Not verified line: " + warnLines, warnLines.isEmpty() ); + } + + private List<String> performTest( String project ) throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-7468-unsupported-params" ); + + Verifier verifier = newVerifier( new File( testDir, project ).getAbsolutePath() ); + verifier.executeGoal( "validate" ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + + List<String> logLines = verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false ); + return findUnknownWarning( logLines ); + } + + private void assertWarningContains( List<String> warnLines ) + { + assertTrue( warnLines.remove( + "[WARNING] Parameter 'invalidValue' is unknown for plugin 'maven-it-plugin-configuration:2.1-SNAPSHOT:touch (default)'" ) ); + + assertTrue( warnLines.remove( + "[WARNING] Parameter 'invalidXml' is unknown for plugin 'maven-it-plugin-configuration:2.1-SNAPSHOT:touch (default)'" ) ); + + assertTrue( "Not verified line: " + warnLines, warnLines.isEmpty() ); + } + + private List<String> findUnknownWarning( List<String> logLines ) + { + Pattern pattern = Pattern.compile( "\\[WARNING] Parameter .* is unknown.*" ); Review Comment: WE rather require content: `.+`, no? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org