mirror of https://github.com/apache/maven.git
[MNG-3099] Integration test for user-settings profile, but not global-settings profile, since global-settings command-line specification is not well defined for 2.1-SNAPSHOT (yet).
git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@618427 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1487acfa31
commit
5e1a92dcb3
|
@ -19,13 +19,14 @@ package org.apache.maven.integrationtests;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
import org.apache.maven.it.VerificationException;
|
||||
import org.apache.maven.it.Verifier;
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
public class IntegrationTestSuite
|
||||
extends AbstractMavenIntegrationTestCase
|
||||
{
|
||||
|
@ -186,6 +187,7 @@ public class IntegrationTestSuite
|
|||
suite.addTestSuite( MavenIT0115CustomArtifactHandlerAndCustomLifecycleTest.class );
|
||||
suite.addTestSuite( MavenIT0119PluginPrefixOrder.class );
|
||||
suite.addTestSuite( MavenITmng3372DirectInvocationOfPlugins.class );
|
||||
suite.addTestSuite( MavenITmng3099SettingsProfilesWithNoPOM.class );
|
||||
// suite.addTestSuite( MavenIT0120EjbClientDependency.class ); -- not passing for 2.0.7 either, looks to be 2.1+ ?
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
package org.apache.maven.integrationtests;
|
||||
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This is a sample integration test. The IT tests typically
|
||||
* operate by having a sample project in the
|
||||
* /src/test/resources folder along with a junit test like
|
||||
* this one. The junit test uses the verifier (which uses
|
||||
* the invoker) to invoke a new instance of Maven on the
|
||||
* project in the resources folder. It then checks the
|
||||
* results. This is a non-trivial example that shows two
|
||||
* phases. See more information inline in the code.
|
||||
*
|
||||
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
|
||||
*
|
||||
*/
|
||||
public class MavenITmng3099SettingsProfilesWithNoPOM
|
||||
extends AbstractMavenIntegrationTestCase
|
||||
{
|
||||
public void testitMNG3099 ()
|
||||
throws Exception
|
||||
{
|
||||
// The testdir is computed from the location of this
|
||||
// file.
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3099-settingsProfilesWithNoPOM" );
|
||||
|
||||
File plugin = new File( testDir, "plugin" );
|
||||
|
||||
Verifier verifier;
|
||||
|
||||
verifier = new Verifier( plugin.getAbsolutePath() );
|
||||
|
||||
verifier.executeGoal( "install" );
|
||||
|
||||
/*
|
||||
* Reset the streams before executing the verifier
|
||||
* again.
|
||||
*/
|
||||
verifier.resetStreams();
|
||||
|
||||
verifier = new Verifier( testDir.getAbsolutePath() );
|
||||
|
||||
/*
|
||||
* Use the settings for this test, which contains the profile we're looking for.
|
||||
*/
|
||||
List cliOptions = new ArrayList();
|
||||
cliOptions.add( "-s" );
|
||||
cliOptions.add( new File( testDir, "settings.xml" ).getAbsolutePath() );
|
||||
|
||||
verifier.setCliOptions( cliOptions );
|
||||
|
||||
verifier.setAutoclean( false );
|
||||
verifier.executeGoal( "org.apache.maven.its.mng3099:maven-mng3099-plugin:1:profile-props" );
|
||||
|
||||
|
||||
List lines = verifier.loadFile( new File( testDir, "log.txt" ), false );
|
||||
boolean found = false;
|
||||
for ( Iterator it = lines.iterator(); it.hasNext(); )
|
||||
{
|
||||
String line = (String) it.next();
|
||||
if ( line.indexOf( "local-profile-prop=local-profile-prop-value" ) > -1 )
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !found )
|
||||
{
|
||||
fail( "Profile-injected property value: local-profile-prop-value was not found in log output." );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.apache.maven.its.mng3099</groupId>
|
||||
<artifactId>maven-mng3099-plugin</artifactId>
|
||||
<version>1</version>
|
||||
<packaging>maven-plugin</packaging>
|
||||
|
||||
<name>maven-mng3099-plugin</name>
|
||||
<description>Tests properties injected as a result of active profiles in the user settings file.</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-api</artifactId>
|
||||
<version>2.0.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-project</artifactId>
|
||||
<version>2.0.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,40 @@
|
|||
package org.apache.maven.its.mng3099;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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 org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
|
||||
/**
|
||||
* Tests MNG-3099.
|
||||
*
|
||||
* @goal profile-props
|
||||
* @requiresProject false
|
||||
*/
|
||||
public final class MNG3099Mojo extends AbstractMojo {
|
||||
|
||||
/**
|
||||
* @parameter expression="${local-profile-prop}"
|
||||
*/
|
||||
private String localProfileProp;
|
||||
|
||||
|
||||
public void execute() throws MojoExecutionException {
|
||||
|
||||
this.getLog().info("local-profile-prop=" + this.localProfileProp);
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
This IT checks that profiles which are brought in from settings files (and which are activated via activeProfiles) are present even if no POM is in use.
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<settings
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>local-profile</id>
|
||||
<properties>
|
||||
<local-profile-prop>local-profile-prop-value</local-profile-prop>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<activeProfiles>
|
||||
<activeProfile>local-profile</activeProfile>
|
||||
</activeProfiles>
|
||||
|
||||
</settings>
|
Loading…
Reference in New Issue