From a158788316641fb1ad09e6f41a87057be0a1b063 Mon Sep 17 00:00:00 2001
From: Benjamin Bentmann <bentmann@apache.org>
Date: Tue, 30 Mar 2010 22:51:46 +0000
Subject: [PATCH] [MNG-4418] Dependency resolution appears to misbehave if a
 remote repository uses the id "local"

o Added IT

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@929328 13f79535-47bb-0310-9956-ffa450edef68
---
 .../apache/maven/it/IntegrationTestSuite.java |  1 +
 ...MavenITmng4418ReservedRepoIdLocalTest.java | 67 +++++++++++++++++++
 .../apache/maven/its/mng4403/b/0.1/b-0.1.pom  |  3 +-
 .../src/test/resources/mng-4418/pom.xml       | 47 +++++++++++++
 4 files changed, 117 insertions(+), 1 deletion(-)
 create mode 100644 its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4418ReservedRepoIdLocalTest.java
 create mode 100644 its/core-it-suite/src/test/resources/mng-4418/pom.xml

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 d422ab7e39..fae5d8eea2 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
@@ -121,6 +121,7 @@ public static Test suite()
         suite.addTestSuite( MavenITmng4423SessionDataFromPluginParameterExpressionTest.class );
         suite.addTestSuite( MavenITmng4422PluginExecutionPhaseInterpolationTest.class );
         suite.addTestSuite( MavenITmng4421DeprecatedPomInterpolationExpressionsTest.class );
+        suite.addTestSuite( MavenITmng4418ReservedRepoIdLocalTest.class );
         suite.addTestSuite( MavenITmng4416PluginOrderAfterProfileInjectionTest.class );
         suite.addTestSuite( MavenITmng4415InheritedPluginOrderTest.class );
         suite.addTestSuite( MavenITmng4413MirroringOfDependencyRepoTest.class );
diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4418ReservedRepoIdLocalTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4418ReservedRepoIdLocalTest.java
new file mode 100644
index 0000000000..0db3a78c84
--- /dev/null
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4418ReservedRepoIdLocalTest.java
@@ -0,0 +1,67 @@
+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.ResourceExtractor;
+
+import java.io.File;
+
+/**
+ * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4418">MNG-4418</a>.
+ * 
+ * @author Benjamin Bentmann
+ */
+public class MavenITmng4418ReservedRepoIdLocalTest
+    extends AbstractMavenIntegrationTestCase
+{
+
+    public MavenITmng4418ReservedRepoIdLocalTest()
+    {
+        super( "[3.0-alpha-8,)" );
+    }
+
+    /**
+     * Test that remote repositories may not use the id "local" which is reserved for the local repository.
+     */
+    public void testit()
+        throws Exception
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4418" );
+
+        Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+        verifier.setAutoclean( false );
+        try
+        {
+            verifier.executeGoal( "validate" );
+            verifier.verifyErrorFreeLog();
+            fail( "Reserved id 'local' should have caused model validation error." );
+        }
+        catch ( VerificationException e )
+        {
+            verifier.verifyTextInLog( "must not be 'local'" );
+        }
+        finally
+        {
+            verifier.resetStreams();
+        }
+    }
+
+}
diff --git a/its/core-it-suite/src/test/resources/mng-4403/repo/org/apache/maven/its/mng4403/b/0.1/b-0.1.pom b/its/core-it-suite/src/test/resources/mng-4403/repo/org/apache/maven/its/mng4403/b/0.1/b-0.1.pom
index b5bca9b8b7..98c0f7894f 100644
--- a/its/core-it-suite/src/test/resources/mng-4403/repo/org/apache/maven/its/mng4403/b/0.1/b-0.1.pom
+++ b/its/core-it-suite/src/test/resources/mng-4403/repo/org/apache/maven/its/mng4403/b/0.1/b-0.1.pom
@@ -36,7 +36,8 @@ under the License.
 
   <distributionManagement>
     <repository>
-      <id>maven-core-it</id>
+      <!-- reserved id (MNG-4418) -->
+      <id>local</id>
       <url>file:///${basedir}/repo</url>
     </repository>
     <!-- remote-only field (MNG-4430) -->
diff --git a/its/core-it-suite/src/test/resources/mng-4418/pom.xml b/its/core-it-suite/src/test/resources/mng-4418/pom.xml
new file mode 100644
index 0000000000..f7b01e4d58
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/mng-4418/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.mng4418</groupId>
+  <artifactId>test</artifactId>
+  <version>0.1</version>
+
+  <name>Maven Integration Test :: MNG-4418</name>
+  <description>
+    Test that remote repositories may not use the id "local" which is reserved for the local repository.
+  </description>
+
+  <repositories>
+    <repository>
+      <id>local</id>
+      <url>http://localhost/</url>
+    </repository>
+  </repositories>
+
+  <distributionManagement>
+    <repository>
+      <id>local</id>
+      <url>http://localhost/</url>
+    </repository>
+  </distributionManagement>
+</project>