[MNG-6198] improved IT to check module case

This commit is contained in:
Hervé Boutemy 2017-04-02 20:45:59 +02:00
parent d9c9a8551d
commit 07a70f03c5
7 changed files with 188 additions and 63 deletions

View File

@ -114,7 +114,7 @@ public static Test suite()
suite.addTestSuite( MavenITmng6173GetAllProjectsInReactorTest.class );
suite.addTestSuite( MavenITmng5958LifecyclePhaseBinaryCompat.class );
suite.addTestSuite( MavenITmng5898BuildMultimoduleWithEARFailsToResolveWARTest.class );
suite.addTestSuite( MavenITmng5889CoreExtensionsTest.class );
suite.addTestSuite( MavenITmng5889FindBasedir.class );
suite.addTestSuite( MavenITmng5840ParentVersionRanges.class );
suite.addTestSuite( MavenITmng5840RelativePathReactorMatching.class );
suite.addTestSuite( MavenITmng5805PkgTypeMojoConfiguration.class );

View File

@ -1,62 +0,0 @@
package org.apache.maven.it;
import java.io.File;
import org.apache.maven.it.util.ResourceExtractor;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-5889">MNG-5889</a>:
* check that extensions in <code>.mvn/</code> are found when Maven is run with <code>-f path/to/pom.xml</code>.
* Reuses MNG-5771 core extensions IT to run the test in new conditions.
*
* @see MavenITmng5771CoreExtensionsTest
*/
public class MavenITmng5889CoreExtensionsTest
extends AbstractMavenIntegrationTestCase
{
public MavenITmng5889CoreExtensionsTest()
{
super( "[3.5.0,)" );
}
/**
* check that <code>.mvn/</code> is found when current dir does not contain <code>pom.xml</code>
* but path to POM set by <code>--file path/to/pom.xml</code>
*/
public void testMvnFileLongOption()
throws Exception
{
runCoreExtensionWithOption( "--file" );
}
/**
* check that <code>.mvn/</code> is found when current dir does not contain <code>pom.xml</code>
* but path to POM set by <code>-f path/to/pom.xml</code>
*/
public void testMvnFileShortOption()
throws Exception
{
runCoreExtensionWithOption( "-f" );
}
private void runCoreExtensionWithOption( String option )
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5771-core-extensions" );
Verifier verifier = newVerifier( testDir.getAbsolutePath() ); // not client directory
verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties() );
verifier = newVerifier( testDir.getAbsolutePath() );
verifier.deleteDirectory( "client/target" );
verifier.deleteArtifacts( "org.apache.maven.its.it-core-extensions" );
verifier.getCliOptions().add( "-s" );
verifier.getCliOptions().add( new File( testDir, "settings.xml" ).getAbsolutePath() );
verifier.getCliOptions().add( option ); // -f/--file client/pom.xml
verifier.getCliOptions().add( new File( testDir, "client/pom.xml" ).getAbsolutePath() );
verifier.setForkJvm( true ); // force forked JVM since we need the shell script to detect .mvn/ location
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
}
}

View File

@ -0,0 +1,84 @@
package org.apache.maven.it;
import java.io.File;
import java.util.Properties;
import org.apache.maven.it.util.ResourceExtractor;
/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-5889">MNG-5889</a>:
* check that extensions in <code>.mvn/</code> are found when Maven is run with <code>-f path/to/pom.xml</code>.
*/
public class MavenITmng5889FindBasedir
extends AbstractMavenIntegrationTestCase
{
public MavenITmng5889FindBasedir()
{
super( "[3.5.0,)" );
}
/**
* check that <code>path/to/.mvn/</code> is found when path to POM set by <code>--file path/to/pom.xml</code>
*/
public void testMvnFileLongOption()
throws Exception
{
runCoreExtensionWithOption( "--file", null );
}
/**
* check that <code>path/to/.mvn/</code> is found when path to POM set by <code>-f path/to/pom.xml</code>
*/
public void testMvnFileShortOption()
throws Exception
{
runCoreExtensionWithOption( "-f", null );
}
/**
* check that <code>path/to/.mvn/</code> is found when path to POM set by <code>--file path/to/module/pom.xml</code>
*/
public void testMvnFileLongOptionModule()
throws Exception
{
runCoreExtensionWithOption( "--file", "module" );
}
/**
* check that <code>path/to/.mvn/</code> is found when path to POM set by <code>-f path/to/module/pom.xml</code>
*/
public void testMvnFileShortOptionModule()
throws Exception
{
runCoreExtensionWithOption( "-f", "module" );
}
private void runCoreExtensionWithOption( String option, String subdir )
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5889-find.mvn" );
File basedir = new File( testDir, "../mng-5889-find.mvn" + option );
basedir.mkdir();
if ( subdir != null )
{
testDir = new File( testDir, subdir );
basedir = new File( basedir, subdir );
basedir.mkdirs();
}
Verifier verifier = newVerifier( basedir.getAbsolutePath() );
verifier.getCliOptions().add( "-Dexpression.outputFile=" + new File( basedir, "expression.properties" ).getAbsolutePath() );
verifier.getCliOptions().add( option ); // -f/--file client/pom.xml
verifier.getCliOptions().add( new File( testDir, "pom.xml" ).getAbsolutePath() );
verifier.setForkJvm( true ); // force forked JVM since we need the shell script to detect .mvn/ location
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
Properties props = verifier.loadProperties( "expression.properties" );
assertEquals( "ok", props.getProperty( "project.properties.jvm-config" ) );
assertEquals( "ok", props.getProperty( "project.properties.maven-config" ) );
}
}

View File

@ -0,0 +1 @@
-Djvm.config=ok

View File

@ -0,0 +1 @@
-Dmaven.config=ok

View File

@ -0,0 +1,32 @@
<?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>
<parent>
<groupId>org.apache.maven.its.mng5889</groupId>
<artifactId>test</artifactId>
<version>1</version>
</parent>
<artifactId>module</artifactId>
</project>

View File

@ -0,0 +1,69 @@
<?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.mng5889</groupId>
<artifactId>test</artifactId>
<version>1</version>
<packaging>pom</packaging>
<name>Maven Integration Test :: MNG-5889</name>
<description>
Verify that path/to/.mvn directory is found when using -f/--file path/to/[module/]pom.xml.
</description>
<properties>
<jvm-config>${jvm.config}</jvm-config>
<maven-config>${maven.config}</maven-config>
<user-dir>${user.dir}</user-dir>
<maven-multiModuleProjectDirectory>${maven.multiModuleProjectDirectory}</maven-multiModuleProjectDirectory>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-expression</artifactId>
<version>2.1-SNAPSHOT</version>
<configuration>
<expressions>
<expression>project/properties/jvm-config</expression>
<expression>project/properties/maven-config</expression>
<expression>project/properties/user-dir</expression>
<expression>project/properties/maven-multiModuleProjectDirectory</expression>
<expression>project/basedir</expression>
</expressions>
</configuration>
<executions>
<execution>
<id>test</id>
<phase>validate</phase>
<goals>
<goal>eval</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>