Author: mbenson
Date: Mon Jun  6 20:30:47 2011
New Revision: 1132750

URL: http://svn.apache.org/viewvc?rev=1132750&view=rev
Log:
test overriding grandparent properties also

Added:
    
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-override-grandparent-properties.pom
Modified:
    
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java

Modified: 
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java?rev=1132750&r1=1132749&r2=1132750&view=diff
==============================================================================
--- 
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
 (original)
+++ 
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
 Mon Jun  6 20:30:47 2011
@@ -721,13 +721,47 @@ public class PomModuleDescriptorParserTe
         
         DependencyDescriptor[] dds = md.getDependencies();
         assertNotNull(dds);
-        assertEquals(2, dds.length); 
+        assertEquals(2, dds.length);
         //2 are inherited from parent.  Only the first one is important for 
this test
         
         assertEquals(ModuleRevisionId.newInstance("org.apache", 
"test-yet-other", "5.79"), dds[1]
-                .getDependencyRevisionId());//present in the pom using a 
property defined in the parent
+                .getDependencyRevisionId());
     }
-    
+
+    public void testOverrideGrandparentProperties() throws ParseException, 
IOException {
+        settings.setDictatorResolver(new MockResolver() {
+            public ResolvedModuleRevision getDependency(DependencyDescriptor 
dd, ResolveData data) throws ParseException {
+                String resource;
+                if ("test".equals(dd.getDependencyId().getName())) {
+                    resource = "test-parent-properties.pom";
+                } else {
+                    resource = "test-version.pom";
+                }
+                try {
+                    ModuleDescriptor moduleDescriptor = 
PomModuleDescriptorParser.getInstance().parseDescriptor(
+                                            settings, 
getClass().getResource(resource), false);
+                    return new 
ResolvedModuleRevision(null,null,moduleDescriptor,null);
+                } catch (IOException e) {
+                    throw new AssertionError(e);
+                }
+            }
+        });
+
+        ModuleDescriptor md = 
PomModuleDescriptorParser.getInstance().parseDescriptor(
+            settings, 
getClass().getResource("test-override-grandparent-properties.pom"), false);
+        assertNotNull(md);
+        assertEquals("1.0", md.getRevision());
+        
+        DependencyDescriptor[] dds = md.getDependencies();
+        assertNotNull(dds);
+        assertEquals(3, dds.length); 
+        
+        assertEquals(ModuleRevisionId.newInstance("org.apache", 
"test-version-other", "5.79"), dds[0]
+                .getDependencyRevisionId());
+        assertEquals(ModuleRevisionId.newInstance("org.apache", 
"test-yet-other", "5.79"), dds[2]
+                .getDependencyRevisionId());
+    }
+
     public void testPomWithEntity() throws Exception {
         ModuleDescriptor md = 
PomModuleDescriptorParser.getInstance().parseDescriptor(
             settings, getClass().getResource("test-entity.pom"), true);

Added: 
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-override-grandparent-properties.pom
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-override-grandparent-properties.pom?rev=1132750&view=auto
==============================================================================
--- 
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-override-grandparent-properties.pom
 (added)
+++ 
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/test-override-grandparent-properties.pom
 Mon Jun  6 20:30:47 2011
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<!--
+   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>
+  <parent>
+    <artifactId>test</artifactId>
+    <groupId>org.apache</groupId>
+    <version>1.0</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache</groupId>
+  <artifactId>test-child</artifactId>
+  <name>Test Module for Ivy M2 parsing</name>
+  <version>${test-version-version}</version>
+  <url>http://ivy.jayasoft.org/</url>
+  <organization>
+    <name>Jayasoft</name>
+    <url>http://www.jayasoft.org/</url>
+  </organization>
+  <properties>
+       <test-yet-other-version>5.79</test-yet-other-version>
+  </properties>
+</project>


Reply via email to