diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java index 25c0a39dd7..527bfe7b2e 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java @@ -232,6 +232,7 @@ public static Test suite() suite.addTestSuite( MavenITmng2861RelocationsAndRangesTest.class ); suite.addTestSuite( MavenITmng2843PluginConfigPropertiesInjectionTest.class ); suite.addTestSuite( MavenITmng2831CustomArtifactHandlerAndCustomLifecycleTest.class ); + suite.addTestSuite( MavenITmng2820PomCommentsTest.class ); suite.addTestSuite( MavenITmng2790LastUpdatedMetadataTest.class ); suite.addTestSuite( MavenITmng2749ExtensionAvailableToPluginTest.class ); suite.addTestSuite( MavenITmng2744checksumVerificationTest.class ); diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2820PomCommentsTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2820PomCommentsTest.java new file mode 100644 index 0000000000..7729ce0020 --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2820PomCommentsTest.java @@ -0,0 +1,86 @@ +package org.apache.maven.it; + +/* + * 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.it.Verifier; +import org.apache.maven.it.util.FileUtils; +import org.apache.maven.it.util.ResourceExtractor; + +import java.io.File; + +/** + * This is a test set for MNG-2820. + * + * @author Benjamin Bentmann + */ +public class MavenITmng2820PomCommentsTest + extends AbstractMavenIntegrationTestCase +{ + + public MavenITmng2820PomCommentsTest() + { + // FIXME: Get this passing again for 2.1.0 + super( "[2.0.5,2.1.0),(2.1.0,)" ); + } + + /** + * Verify that installed/deployed POMs retain any XML-comments like license headers. + */ + public void testit() + throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2820" ); + + Verifier verifier = new Verifier( testDir.getAbsolutePath() ); + verifier.setAutoclean( false ); + verifier.deleteDirectory( "target" ); + verifier.deleteArtifacts( "org.apache.maven.its.mng2820" ); + verifier.executeGoal( "validate" ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + + File installed = new File( verifier.getArtifactPath( "org.apache.maven.its.mng2820", "test", "0.1", "pom" ) ); + assertPomComments( installed ); + + File deployed = new File( testDir, "target/repo/org/apache/maven/its/mng2820/test/0.1/test-0.1.pom" ); + assertPomComments( deployed ); + } + + private void assertPomComments( File pomFile ) + throws Exception + { + String pom = FileUtils.fileRead( pomFile, "UTF-8" ); + assertPomComment( pom, "DOCUMENT-COMMENT-PRE-1" ); + assertPomComment( pom, "DOCUMENT-COMMENT-PRE-2" ); + assertPomComment( pom, "DOCUMENT-COMMENT-POST-1" ); + assertPomComment( pom, "DOCUMENT-COMMENT-POST-2" ); + assertPomComment( pom, "MODEL-COMMENT" ); + assertPomComment( pom, "INLINE-COMMENT-1" ); + assertPomComment( pom, "INLINE-COMMENT-2" ); + assertPomComment( pom, "INLINE-COMMENT-3" ); + } + + private void assertPomComment( String pom, String comment ) + throws Exception + { + assertTrue( "Missing comment: " + comment, pom.indexOf( comment ) >= 0 ); + } + +} diff --git a/its/core-it-suite/src/test/resources/mng-2820/main.jar b/its/core-it-suite/src/test/resources/mng-2820/main.jar new file mode 100644 index 0000000000..51ee566df6 Binary files /dev/null and b/its/core-it-suite/src/test/resources/mng-2820/main.jar differ diff --git a/its/core-it-suite/src/test/resources/mng-2820/pom.xml b/its/core-it-suite/src/test/resources/mng-2820/pom.xml new file mode 100644 index 0000000000..5afbc12787 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-2820/pom.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + 4.0.0 + + org.apache.maven.its.mng2820 + test + 0.1 + + Maven Integration Test :: MNG-2820 + + + + Verify that installed/deployed POMs retain any XML-comments like license headers. + + + + + + maven-core-it + file:///${basedir}/target/repo + + + + + + + org.apache.maven.its.plugins + maven-it-plugin-artifact + 2.1-SNAPSHOT + + + test + validate + + main.jar + + + set + attach-pom + install + deploy + + + + + + + + + + +