You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2011/08/24 23:57:33 UTC
svn commit: r1161299 - in /maven/maven-3/trunk/maven-model-builder: ./
src/test/java/org/apache/maven/model/inheritance/
src/test/resources/poms/inheritance/
Author: hboutemy
Date: Wed Aug 24 21:57:33 2011
New Revision: 1161299
URL: http://svn.apache.org/viewvc?rev=1161299&view=rev
Log:
added plugin configuration inheritance test, particularly combine.children and combine.self attributes
Added:
maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/
maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java (with props)
maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/
maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-child.xml (with props)
maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-expected.xml (with props)
maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-parent.xml (with props)
Modified:
maven/maven-3/trunk/maven-model-builder/pom.xml
Modified: maven/maven-3/trunk/maven-model-builder/pom.xml
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/pom.xml?rev=1161299&r1=1161298&r2=1161299&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-model-builder/pom.xml (original)
+++ maven/maven-3/trunk/maven-model-builder/pom.xml Wed Aug 24 21:57:33 2011
@@ -41,11 +41,18 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
</dependency>
+
<dependency>
<groupId>org.sonatype.sisu</groupId>
<artifactId>sisu-inject-plexus</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ <version>1.3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
Added: maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java?rev=1161299&view=auto
==============================================================================
--- maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java (added)
+++ maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java Wed Aug 24 21:57:33 2011
@@ -0,0 +1,108 @@
+package org.apache.maven.model.inheritance;
+
+/*
+ * 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 java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+import org.apache.maven.model.Model;
+import org.apache.maven.model.building.SimpleProblemCollector;
+import org.apache.maven.model.io.ModelParseException;
+import org.apache.maven.model.io.ModelReader;
+import org.apache.maven.model.io.ModelWriter;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.IOUtil;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.custommonkey.xmlunit.XMLUnit;
+
+/**
+ * @author Hervé Boutemy
+ */
+public class DefaultInheritanceAssemblerTest
+ extends PlexusTestCase
+{
+ private ModelReader reader;
+
+ private ModelWriter writer;
+
+ private InheritanceAssembler assembler;
+
+ @Override
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ reader = lookup( ModelReader.class );
+ writer = lookup( ModelWriter.class );
+ assembler = lookup( InheritanceAssembler.class );
+ }
+
+ private File getPom( String name )
+ {
+ return getTestFile( "src/test/resources/poms/inheritance/" + name + ".xml" );
+ }
+
+ private Model getModel( String name )
+ throws ModelParseException, IOException
+ {
+ return reader.read( getPom( name ), null );
+ }
+
+ public void testPluginConfiguration()
+ throws Exception
+ {
+ Model parent = getModel( "plugin-configuration-parent" );
+
+ Model child = getModel( "plugin-configuration-child" );
+
+ SimpleProblemCollector problems = new SimpleProblemCollector();
+
+ assembler.assembleModelInheritance( child, parent, null, problems );
+
+ File actual = getTestFile( "target/test-classes/poms/inheritance/plugin-configuration-actual.xml" );
+
+ writer.write( actual, null, child );
+
+ // check with getPom( "plugin-configuration-effective" )
+ Reader control = null;
+ Reader test = null;
+ try
+ {
+ File expected = getPom( "plugin-configuration-expected" );
+ control = new InputStreamReader( new FileInputStream( expected ), "UTF-8" );
+
+ test = new InputStreamReader( new FileInputStream( actual ), "UTF-8" );
+
+ XMLUnit.setIgnoreComments( true );
+ XMLUnit.setIgnoreWhitespace( true );
+ XMLAssert.assertXMLEqual( control, test );
+ }
+ catch ( IOException ioe )
+ {
+ IOUtil.close( control );
+ IOUtil.close( test );
+ }
+ }
+
+}
Propchange: maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: maven/maven-3/trunk/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-child.xml
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-child.xml?rev=1161299&view=auto
==============================================================================
--- maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-child.xml (added)
+++ maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-child.xml Wed Aug 24 21:57:33 2011
@@ -0,0 +1,52 @@
+<?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 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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>child</artifactId>
+ <version>12-SNAPSHOT</version>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>inheritance.configuration</groupId>
+ <artifactId>default</artifactId>
+ <version>3.0</version>
+ <configuration>
+ <defaults>
+ <parent>child</parent>
+ <child>child</child>
+ </defaults>
+ <appends combine.children="append">
+ <parent>child</parent>
+ <child>child</child>
+ </appends>
+ <overrides combine.self="override">
+ <parent>child</parent>
+ <child>child</child>
+ </overrides>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Propchange: maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-child.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-child.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-child.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-expected.xml
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-expected.xml?rev=1161299&view=auto
==============================================================================
--- maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-expected.xml (added)
+++ maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-expected.xml Wed Aug 24 21:57:33 2011
@@ -0,0 +1,61 @@
+<?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 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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>inheritance</groupId>
+ <artifactId>child</artifactId>
+ <version>12-SNAPSHOT</version>
+
+ <!-- name is not inherited, but description is -->
+ <description>Model inheritance description</description>
+ <url>http://www.apache.org/child/</url><!-- child's artifactId added to parent url -->
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>inheritance.configuration</groupId>
+ <artifactId>default</artifactId>
+ <version>3.0</version>
+ <configuration>
+ <defaults><!-- equivalent to combine.children="merge" combine.self="merge" -->
+ <!-- merge the content of the configuration element according to element name -->
+ <parent>child</parent>
+ <child>child</child>
+ <parent-only>parent</parent-only>
+ </defaults>
+ <appends combine.children="append">
+ <parent-only>parent</parent-only>
+ <parent>parent</parent>
+ <parent>child</parent>
+ <child>child</child>
+ </appends>
+ <overrides combine.self="override">
+ <parent>child</parent>
+ <child>child</child>
+ </overrides>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Propchange: maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-expected.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-expected.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-expected.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-parent.xml
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-parent.xml?rev=1161299&view=auto
==============================================================================
--- maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-parent.xml (added)
+++ maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-parent.xml Wed Aug 24 21:57:33 2011
@@ -0,0 +1,57 @@
+<?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 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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>inheritance</groupId>
+ <artifactId>parent</artifactId>
+ <version>11-SNAPSHOT</version>
+
+ <name>Model inheritance test</name>
+ <description>Model inheritance description</description>
+ <url>http://www.apache.org/</url>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>inheritance.configuration</groupId>
+ <artifactId>default</artifactId>
+ <version>2.0</version>
+ <configuration>
+ <defaults>
+ <parent-only>parent</parent-only>
+ <parent>parent</parent>
+ </defaults>
+ <appends>
+ <parent-only>parent</parent-only>
+ <parent>parent</parent>
+ </appends>
+ <overrides>
+ <parent-only>parent</parent-only>
+ <parent>parent</parent>
+ </overrides>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Propchange: maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-parent.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-parent.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: maven/maven-3/trunk/maven-model-builder/src/test/resources/poms/inheritance/plugin-configuration-parent.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain