mirror of https://github.com/apache/maven.git
o make sure that even when all the configurations handed to the embedder are crap
it will still start up. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@512585 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e981109693
commit
0b0949ab86
|
@ -0,0 +1,53 @@
|
|||
package org.apache.maven.embedder;
|
||||
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.apache.maven.execution.MavenExecutionRequest;
|
||||
import org.apache.maven.execution.DefaultMavenExecutionRequest;
|
||||
import org.apache.maven.execution.MavenExecutionResult;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class MavenEmbedderCrappySettingsConfigurationTest
|
||||
extends PlexusTestCase
|
||||
{
|
||||
public void testEmbedderWillStilStartupWhenTheSettingsConfigurationIsCrap()
|
||||
throws Exception
|
||||
{
|
||||
// START SNIPPET: simple-embedder-example
|
||||
|
||||
File projectDirectory = new File( getBasedir(), "src/examples/simple-project" );
|
||||
|
||||
File user = new File( projectDirectory, "invalid-settings.xml" );
|
||||
|
||||
Configuration configuration = new DefaultConfiguration()
|
||||
.setUserSettingsFile( user )
|
||||
.setClassLoader( Thread.currentThread().getContextClassLoader() );
|
||||
|
||||
ConfigurationValidationResult validationResult = MavenEmbedder.validateConfiguration( configuration );
|
||||
|
||||
assertFalse( validationResult.isValid() );
|
||||
|
||||
MavenEmbedder embedder = new MavenEmbedder( configuration );
|
||||
|
||||
assertNotNull( embedder.getLocalRepository().getBasedir() );
|
||||
|
||||
MavenExecutionRequest request = new DefaultMavenExecutionRequest()
|
||||
.setBaseDirectory( projectDirectory )
|
||||
.setGoals( Arrays.asList( new String[]{"clean", "install"} ) );
|
||||
|
||||
MavenExecutionResult result = embedder.execute( request );
|
||||
|
||||
assertNotNull( result.getMavenProject() );
|
||||
|
||||
MavenProject project = result.getMavenProject();
|
||||
|
||||
String environment = project.getProperties().getProperty( "environment" );
|
||||
|
||||
assertEquals( "development", environment );
|
||||
|
||||
// END SNIPPET: simple-embedder-example
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue