mirror of https://github.com/apache/maven.git
trim a heap of time off the test by reading the POMs directly, and filter to a new file rather than overwriting so the test behaves the same way each run
git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@746124 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c88a8113c8
commit
7741914080
|
@ -56,7 +56,7 @@ under the License.
|
|||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-utils</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.5.8</version>
|
||||
<!-- NOTE: Use compile scope for transitivity. -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -33,6 +32,10 @@ import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException
|
|||
import org.apache.maven.it.util.IOUtil;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
import org.apache.maven.it.util.StringUtils;
|
||||
import org.codehaus.plexus.util.ReaderFactory;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
|
||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3057">MNG-3057</a>.
|
||||
|
@ -71,19 +74,20 @@ public class MavenITmng3057VersionExprTransformations
|
|||
{
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3057" );
|
||||
|
||||
URI remoteRepo = new File( testDir, "target/deployment" ).toURI();
|
||||
File remoteRepo = new File( testDir, "target/deployment" );
|
||||
|
||||
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
|
||||
verifier.deleteArtifacts( "org.apache.maven.its.mng3057" );
|
||||
|
||||
Properties properties = verifier.newDefaultFilterProperties();
|
||||
properties.setProperty( "@deployTo@", remoteRepo.toURL().toExternalForm() );
|
||||
properties.setProperty( "@deployTo@", remoteRepo.toURI().toURL().toExternalForm() );
|
||||
|
||||
verifier.filterFile( "pom.xml", "pom.xml", "UTF-8", properties );
|
||||
verifier.filterFile( "pom.xml", "pom-filtered.xml", "UTF-8", properties );
|
||||
|
||||
List cliOptions = new ArrayList();
|
||||
cliOptions.add( "-V" );
|
||||
cliOptions.add( "-DtestVersion=1" );
|
||||
cliOptions.add( "-f pom-filtered.xml" );
|
||||
|
||||
verifier.setCliOptions( cliOptions );
|
||||
|
||||
|
@ -95,58 +99,29 @@ public class MavenITmng3057VersionExprTransformations
|
|||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
assertVersionExpressions( new File( verifier.getArtifactPath( "org.apache.maven.its.mng3057", "mng-3057", "1", "pom" ) ) );
|
||||
assertVersionExpressions( new File( verifier.getArtifactPath( "org.apache.maven.its.mng3057", "level2", "1", "pom" ) ) );
|
||||
assertVersionExpressions( new File( verifier.getArtifactPath( "org.apache.maven.its.mng3057", "level3", "1", "pom" ) ) );
|
||||
assertVersions( new File( verifier.getArtifactPath( "org.apache.maven.its.mng3057", "mng-3057", "1", "pom" ) ), "1", null );
|
||||
assertVersions( new File( verifier.getArtifactPath( "org.apache.maven.its.mng3057", "level2", "1", "pom" ) ), "1", "1" );
|
||||
assertVersions( new File( verifier.getArtifactPath( "org.apache.maven.its.mng3057", "level3", "1", "pom" ) ), "1", "1" );
|
||||
|
||||
assertVersionExpressions( new File( remoteRepo.getPath(), "org/apache/maven/its/mng3057/mng-3057/1/mng-3057-1.pom" ) );
|
||||
assertVersionExpressions( new File( remoteRepo.getPath(), "org/apache/maven/its/mng3057/level2/1/level2-1.pom" ) );
|
||||
assertVersionExpressions( new File( remoteRepo.getPath(), "org/apache/maven/its/mng3057/level3/1/level3-1.pom" ) );
|
||||
assertVersions( new File( remoteRepo, "org/apache/maven/its/mng3057/mng-3057/1/mng-3057-1.pom" ), "1", null );
|
||||
assertVersions( new File( remoteRepo, "org/apache/maven/its/mng3057/level2/1/level2-1.pom" ), "1", "1" );
|
||||
assertVersions( new File( remoteRepo, "org/apache/maven/its/mng3057/level2/1/level2-1.pom" ), "1", "1" );
|
||||
}
|
||||
|
||||
private void assertVersionExpressions( File pomFile )
|
||||
throws VerificationException, IOException
|
||||
private void assertVersions( File file, String version, String parentVersion )
|
||||
throws XmlPullParserException, IOException
|
||||
{
|
||||
Verifier verifier = new Verifier( pomFile.getParentFile().getAbsolutePath() );
|
||||
|
||||
List cliOptions = new ArrayList();
|
||||
cliOptions.add( "-V" );
|
||||
cliOptions.add( "-N" );
|
||||
cliOptions.add( "-Dexpression.outputFile=expressions.properties" );
|
||||
cliOptions.add( "-Dexpression.expressions=" + StringUtils.join( VERIFICATION_EXPRESSIONS.iterator(), "," ) );
|
||||
cliOptions.add( "-f" );
|
||||
cliOptions.add( pomFile.getName() );
|
||||
|
||||
|
||||
verifier.setCliOptions( cliOptions );
|
||||
|
||||
verifier.setAutoclean( false );
|
||||
verifier.executeGoal( "org.apache.maven.its.plugins:maven-it-plugin-expression:2.1-SNAPSHOT:eval" );
|
||||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
File propsFile = new File( pomFile.getParentFile(), "expressions.properties" );
|
||||
InputStream is = null;
|
||||
Properties props = new Properties();
|
||||
try
|
||||
Xpp3Dom dom = Xpp3DomBuilder.build( ReaderFactory.newXmlReader( file ) );
|
||||
assertEquals( version, dom.getChild( "version" ).getValue() );
|
||||
Xpp3Dom parent = dom.getChild( "parent" );
|
||||
if ( parentVersion != null )
|
||||
{
|
||||
is = new FileInputStream( propsFile );
|
||||
props.load( is );
|
||||
assertNotNull( parent );
|
||||
assertEquals( parentVersion, parent.getChild( "version" ).getValue() );
|
||||
}
|
||||
finally
|
||||
else
|
||||
{
|
||||
IOUtil.close( is );
|
||||
}
|
||||
|
||||
for ( Iterator it = VERIFICATION_EXPRESSIONS.iterator(); it.hasNext(); )
|
||||
{
|
||||
String expr = (String ) it.next();
|
||||
String value = props.getProperty( expr );
|
||||
if ( value != null )
|
||||
{
|
||||
assertEquals( "POM expression not interpolated: '" + expr + "'\nin: '" + pomFile + "'.", "1", value );
|
||||
assertNull( parent );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue