[MNG-2477] rewrite the POM on deployment without elements that old versions of Maven won't understand. Needs improvement, but this revision would be useful for other elements in the interim while we wait for better repository metadata


git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/branches/MNG-2477@682589 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java b/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java
index d53d6d8..e41f4db 100644
--- a/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java
+++ b/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java
@@ -76,6 +76,7 @@
 MavenITmng3645POMSyntaxErrorTest
 */
 
+        suite.addTestSuite( MavenITmng2477RepositorySecurityTest.class );
         suite.addTestSuite( MavenITmng3694ReactorProjectsDynamismTest.class );
         suite.addTestSuite( MavenITmng3693PomFileBasedirChangeTest.class );
         suite.addTestSuite( MavenITmng3599useHttpProxyForWebDAV.class );
diff --git a/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng2477RepositorySecurityTest.java b/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng2477RepositorySecurityTest.java
new file mode 100644
index 0000000..294bd9e
--- /dev/null
+++ b/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng2477RepositorySecurityTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.integrationtests;
+
+import java.io.File;
+import java.util.Collections;
+
+import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+import org.apache.maven.it.Verifier;
+import org.apache.maven.it.util.FileUtils;
+import org.apache.maven.it.util.ResourceExtractor;
+
+/**
+ * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3052">MNG-3052</a>. When a project dependency
+ * declares its own repositories, they should be used to resolve that dependency's dependencies. This includes both
+ * steps: determining the dependency artifact information (version, etc.) AND resolving the actual artifact itself.
+ * NOTE: The SNAPSHOT versions are CRITICAL in this test, since they force the correct resolution of artifact metadata,
+ * which depends on having the correct set of repositories present.
+ * 
+ * @author jdcasey
+ */
+public class MavenITmng2477RepositorySecurityTest
+    extends AbstractMavenIntegrationTestCase
+{
+    public MavenITmng2477RepositorySecurityTest()
+        throws InvalidVersionSpecificationException
+    {
+        super( "(2.0.100,)" ); // only test in 2.1+
+    }
+
+    public void testitMNG2477DeploymentPOMIsConvertedToModelv400()
+        throws Exception
+    {
+        File testDir =
+            ResourceExtractor.simpleExtractResources( getClass(), "/mng-2477-repository-security" ).getCanonicalFile();
+
+        File repository = new File( testDir, "deployment-repository" );
+        FileUtils.deleteDirectory( repository );
+
+        File file = new File( repository, "org/apache/maven/its/mng2477/test-project/1.0/test-project-1.0.pom" );
+        assertFalse( file.exists() );
+
+        Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+        verifier.deleteArtifact( "org.apache.maven.its.mng2477", "test-project", "1.0", "pom" );
+        
+        verifier.setCliOptions( Collections.singletonList( "-X" ) );
+        
+        verifier.executeGoal( "deploy" );
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+
+        assertTrue( file.exists() );
+
+        // TODO: would be better to read it back as a model
+        String contents = FileUtils.fileRead( file );
+        assertFalse( contents.indexOf( "signaturePolicy" ) >= 0 );
+        // not implementeed yet
+        // assertTrue( contents.indexOf( "requiredChecksum value=\"99129f16442844f6a4a11ae22fbbee40b14d774f\" pom=\"16d74791c801c89b0071b1680ea0bc85c93417bb\"" ) >= 0 );
+    }
+}
diff --git a/core-integration-tests/src/test/resources/mng-2477-repository-security/pom.xml b/core-integration-tests/src/test/resources/mng-2477-repository-security/pom.xml
new file mode 100644
index 0000000..4e48e63
--- /dev/null
+++ b/core-integration-tests/src/test/resources/mng-2477-repository-security/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0"?><project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.its.mng2477</groupId>
+  <version>1.0</version>
+  <artifactId>test-project</artifactId>
+  <name>test-project</name>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+<!-- later
+      <requiredChecksum value="99129f16442844f6a4a11ae22fbbee40b14d774f" pom="16d74791c801c89b0071b1680ea0bc85c93417bb" />
+-->
+    </dependency>
+  </dependencies>
+  <distributionManagement>
+    <repository>
+      <id>id</id>
+      <url>file:${basedir}/deployment-repository</url>
+    </repository>
+  </distributionManagement>
+  <repositories>
+    <repository>
+      <id>apache.snapshots</id>
+      <url>http://people.apache.org/repo/m2-snapshot-repository</url>
+      <snapshots>
+        <enabled>true</enabled>
+        <signaturePolicy>warn</signaturePolicy>
+      </snapshots>
+      <releases>
+        <enabled>false</enabled>
+        <signaturePolicy>warn</signaturePolicy>
+      </releases>
+    </repository>
+  </repositories>
+</project>
+