Author: jdcasey Date: Wed May 20 16:26:49 2009 New Revision: 776755 URL: http://svn.apache.org/viewvc?rev=776755&view=rev Log: [MNG-4167] Adding integration test for plugins that produce derivatives of the POM in cases where the POM contains expressions in artifact-coordinate elements.
Added: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4167PluginAndCoordXFormPOMTest.java (with props) maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4167/ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4167/pom.xml (with props) maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-touch/src/main/java/org/apache/maven/plugin/coreit/CopyPomMojo.java (with props) Added: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4167PluginAndCoordXFormPOMTest.java URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4167PluginAndCoordXFormPOMTest.java?rev=776755&view=auto ============================================================================== --- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4167PluginAndCoordXFormPOMTest.java (added) +++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4167PluginAndCoordXFormPOMTest.java Wed May 20 16:26:49 2009 @@ -0,0 +1,81 @@ +/* + * 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. + */ + +package org.apache.maven.it; + +import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; +import org.apache.maven.integrationtests.AbstractMavenIntegrationTestCase; +import org.apache.maven.it.util.ResourceExtractor; + +import java.io.File; +import java.util.Collections; +import java.util.List; + +/** + * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4167">MNG-4167</a>. + * + * @todo Fill in a better description of what this test verifies! + * + * @author <a href="mailto:bri...@apache.org">Brian Fox</a> + * @author jdcasey + * + */ +public class MavenITmng4167PluginAndCoordXFormPOMTest + extends AbstractMavenIntegrationTestCase +{ + public MavenITmng4167PluginAndCoordXFormPOMTest() + throws InvalidVersionSpecificationException + { + super( "(2.1.0,)" ); // only test in 2.0.9+ + } + + public void testIt () + throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4167" ); + + Verifier verifier; + + verifier = new Verifier( testDir.getAbsolutePath() ); + verifier.deleteArtifact( "org.apache.maven.its.mng4167", "mng-4167", "1", "pom" ); + + String specVersion = System.getProperty( "java.specification.version" ); + verifier.deleteArtifact( "org.apache.maven.its.mng4167", "mng-4167", "1-" + specVersion, "pom" ); + + verifier.setCliOptions( Collections.singletonList( "-X" ) ); + + verifier.executeGoal( "install" ); + + List originalPomLines = verifier.loadFile( new File( testDir, "pom.xml" ), false ); + + List derivedPomLines = verifier.loadFile( new File( testDir, "target/pom-copy.xml" ), false ); + + assertFalse( derivedPomLines.equals( originalPomLines ) ); + + File repoPomPath = new File( verifier.getArtifactPath( "org.apache.maven.its.mng4167", "mng-4167", "1-" + specVersion, "pom" ) ); + + List repoPomLines = verifier.loadFile( repoPomPath, false ); + + assertEquals( repoPomLines, derivedPomLines ); + + verifier.verifyErrorFreeLog(); + + verifier.resetStreams(); + } +} Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4167PluginAndCoordXFormPOMTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4167/pom.xml URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4167/pom.xml?rev=776755&view=auto ============================================================================== --- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4167/pom.xml (added) +++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4167/pom.xml Wed May 20 16:26:49 2009 @@ -0,0 +1,25 @@ +<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.mng4167</groupId> + <artifactId>mng-4167</artifactId> + <packaging>pom</packaging> + <version>1-${java.specification.version}</version> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.its.plugins</groupId> + <artifactId>maven-it-plugin-touch</artifactId> + <version>2.1-SNAPSHOT</version> + <executions> + <execution> + <id>copy-pom</id> + <goals> + <goal>copy-pom</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4167/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-touch/src/main/java/org/apache/maven/plugin/coreit/CopyPomMojo.java URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-touch/src/main/java/org/apache/maven/plugin/coreit/CopyPomMojo.java?rev=776755&view=auto ============================================================================== --- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-touch/src/main/java/org/apache/maven/plugin/coreit/CopyPomMojo.java (added) +++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-touch/src/main/java/org/apache/maven/plugin/coreit/CopyPomMojo.java Wed May 20 16:26:49 2009 @@ -0,0 +1,85 @@ +package org.apache.maven.plugin.coreit; + +/* + * 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. + */ + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.MavenProject; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; + +/** + * @goal copy-pom + * + * @phase generate-sources + * + * @description Mojo which makes a copy of the POM using MavenProject.getFile() to locate the file. + */ +public class CopyPomMojo + extends AbstractMojo +{ + /** + * @parameter default-value="${project.file}" + */ + private File pomFile; + + /** + * @parameter default-value="${project.build.directory}/pom-copy.xml" + * @required + */ + private String outputFile; + + public void execute() + throws MojoExecutionException + { + try + { + File dest = new File( outputFile ); + File dir = dest.getParentFile(); + + if ( !dir.exists() ) + { + dir.mkdirs(); + } + + getLog().info( "Copying POM to file: " + dest.getAbsolutePath() ); + + FileInputStream in = new FileInputStream( pomFile ); + FileOutputStream out = new FileOutputStream( dest ); + + int read = -1; + byte[] buf = new byte[4096]; + while( ( read = in.read( buf ) ) > -1 ) + { + out.write( buf, 0, read ); + } + + in.close(); + out.close(); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Error copying POM", e ); + } + } +} Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-touch/src/main/java/org/apache/maven/plugin/coreit/CopyPomMojo.java ------------------------------------------------------------------------------ svn:eol-style = native