[MNG-4764] @required plugin parameters using default-value with expressions are not validated

o Extended related IT

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@985664 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2010-08-15 12:47:32 +00:00
parent 6907ff5eeb
commit ca5077bf4c
5 changed files with 280 additions and 38 deletions

View File

@ -41,11 +41,86 @@ public class MavenITmng4615ValidateRequiredPluginParameterTest
/**
* Verify that Maven validates required mojo parameters (and doesn't just have the plugins die with NPEs).
* This scenario checks the case of all required parameters being set via plugin configuration.
*/
public void testit()
public void testitAllSet()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4615" );
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4615/test-0" );
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
Properties props = verifier.loadProperties( "target/config.properties" );
assertEquals( "one", props.get( "requiredParam" ) );
assertEquals( "two", props.get( "requiredParamWithDefault" ) );
}
/**
* Verify that Maven validates required mojo parameters (and doesn't just have the plugins die with NPEs).
* This scenario checks the case of a parameter missing its backing system property.
*/
public void testitExprMissing()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4615/test-1" );
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
verifier.setLogFileName( "log-a.txt" );
try
{
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
fail( "Build did not fail despite required plugin parameter missing" );
}
catch ( VerificationException e )
{
// expected
}
verifier.resetStreams();
}
/**
* Verify that Maven validates required mojo parameters (and doesn't just have the plugins die with NPEs).
* This scenario checks the case of a parameter having its backing system property set.
*/
public void testitExprSet()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4615/test-1" );
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
verifier.setSystemProperty( "config.requiredParam", "CLI" );
verifier.setLogFileName( "log-b.txt" );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
Properties props = verifier.loadProperties( "target/config.properties" );
assertEquals( "CLI", props.get( "requiredParam" ) );
assertEquals( "two", props.get( "requiredParamWithDefault" ) );
}
/**
* Verify that Maven validates required mojo parameters (and doesn't just have the plugins die with NPEs).
* This scenario checks the case of a parameter missing its backing POM value.
*/
public void testitPomValMissing()
throws Exception
{
// cf. MNG-4764
requiresMavenVersion( "[3.0-beta-2,)" );
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4615/test-2a" );
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
@ -61,26 +136,28 @@ public class MavenITmng4615ValidateRequiredPluginParameterTest
// expected
}
// sanity check that adding the param makes it work
verifier.setLogFileName( "log-2.txt" );
verifier.getCliOptions().add( "-Pmng4615" );
verifier.deleteDirectory( "target" );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
Properties props = verifier.loadProperties( "target/config.properties" );
assertEquals( "PROFILE", props.get( "requiredParam" ) );
verifier.setLogFileName( "log-3.txt" );
verifier.getCliOptions().remove( "-Pmng4615" );
verifier.setSystemProperty( "config.requiredParam", "CLI" );
verifier.deleteDirectory( "target" );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
props = verifier.loadProperties( "target/config.properties" );
assertEquals( "CLI", props.get( "requiredParam" ) );
verifier.resetStreams();
}
/**
* Verify that Maven validates required mojo parameters (and doesn't just have the plugins die with NPEs).
* This scenario checks the case of a parameter having its backing POM value set.
*/
public void testitPomValSet()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4615/test-2b" );
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
Properties props = verifier.loadProperties( "target/config.properties" );
assertEquals( "one", props.get( "requiredParam" ) );
assertEquals( "http://foo.bar/", props.get( "requiredParamWithDefault" ) );
}
}

View File

@ -30,6 +30,7 @@ under the License.
<name>Maven Integration Test :: MNG-4615</name>
<description>
Verify that Maven validates required mojo parameters (and doesn't just have the plugins die with NPEs).
This scenario checks the case of all required parameters being set via plugin configuration.
</description>
<build>
@ -40,6 +41,8 @@ under the License.
<version>2.1-SNAPSHOT</version>
<configuration>
<propertiesFile>target/config.properties</propertiesFile>
<requiredParam>one</requiredParam>
<requiredParamWithDefault>two</requiredParamWithDefault>
</configuration>
<executions>
<execution>
@ -53,21 +56,4 @@ under the License.
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>mng4615</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-configuration</artifactId>
<configuration>
<requiredParam>PROFILE</requiredParam>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -0,0 +1,59 @@
<?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.mng4615</groupId>
<artifactId>test</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<name>Maven Integration Test :: MNG-4615</name>
<description>
Verify that Maven validates required mojo parameters (and doesn't just have the plugins die with NPEs).
This scenario checks the case of a parameter missing its backing system property.
</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-configuration</artifactId>
<version>2.1-SNAPSHOT</version>
<configuration>
<propertiesFile>target/config.properties</propertiesFile>
<!-- missing <requiredParam>one</requiredParam> -->
<requiredParamWithDefault>two</requiredParamWithDefault>
</configuration>
<executions>
<execution>
<id>test</id>
<phase>validate</phase>
<goals>
<goal>required-config</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,60 @@
<?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.mng4615</groupId>
<artifactId>test</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<name>Maven Integration Test :: MNG-4615</name>
<description>
Verify that Maven validates required mojo parameters (and doesn't just have the plugins die with NPEs).
This scenario checks the case of a parameter missing its backing POM value.
</description>
<!-- missing: <url>http://foo.bar/</url> -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-configuration</artifactId>
<version>2.1-SNAPSHOT</version>
<configuration>
<propertiesFile>target/config.properties</propertiesFile>
<requiredParam>one</requiredParam>
<!-- missing: <requiredParamWithDefault>two</requiredParamWithDefault> -->
</configuration>
<executions>
<execution>
<id>test</id>
<phase>validate</phase>
<goals>
<goal>required-config</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,60 @@
<?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.mng4615</groupId>
<artifactId>test</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<name>Maven Integration Test :: MNG-4615</name>
<description>
Verify that Maven validates required mojo parameters (and doesn't just have the plugins die with NPEs).
This scenario checks the case of a parameter defaulting to its backing POM value.
</description>
<url>http://foo.bar/</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-configuration</artifactId>
<version>2.1-SNAPSHOT</version>
<configuration>
<propertiesFile>target/config.properties</propertiesFile>
<requiredParam>one</requiredParam>
<!-- missing: <requiredParamWithDefault>two</requiredParamWithDefault> -->
</configuration>
<executions>
<execution>
<id>test</id>
<phase>validate</phase>
<goals>
<goal>required-config</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>