]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1204] - org.apache.maven.archiva.repository.project.ProjectModelMerge.merge...
authorJevica Arianne B. Zurbano <jzurbano@apache.org>
Thu, 20 Aug 2009 08:07:04 +0000 (08:07 +0000)
committerJevica Arianne B. Zurbano <jzurbano@apache.org>
Thu, 20 Aug 2009 08:07:04 +0000 (08:07 +0000)
- added unit test

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@806081 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/ProjectModelMergeTest.java [new file with mode: 0644]

diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/ProjectModelMergeTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/ProjectModelMergeTest.java
new file mode 100644 (file)
index 0000000..93716ce
--- /dev/null
@@ -0,0 +1,106 @@
+package org.apache.maven.archiva.repository.project;
+
+/*
+ * 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.util.Enumeration;
+import java.util.Properties;
+
+import org.apache.maven.archiva.repository.project.ProjectModelMerge;
+import org.apache.maven.archiva.model.ArchivaProjectModel;
+import org.apache.maven.archiva.model.VersionedReference;
+import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+
+/**
+ * ProjectModelMergeTest
+ * 
+ * @author jzurbano
+ */
+public class ProjectModelMergeTest
+    extends PlexusInSpringTestCase
+{
+    private ProjectModelMerge modelMerge;
+    
+    private Enumeration<String> keys;
+    
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        modelMerge = new ProjectModelMerge();
+    }
+    
+    @SuppressWarnings("unchecked")
+    public void testPropertiesMerge()
+        throws Exception
+    {
+        ArchivaProjectModel mainProject = createMainProject();
+        ArchivaProjectModel parentProject = createParentProject();
+    
+        assertNotNull( mainProject.getProperties() );
+    
+        Properties prop = parentProject.getProperties();
+        assertNotNull( prop );
+    
+        keys = (Enumeration<String>) prop.propertyNames();
+        assertTrue( keys.hasMoreElements() );
+    
+        modelMerge.merge( mainProject, parentProject );
+    }
+    
+    private ArchivaProjectModel createMainProject()
+    {
+        ArchivaProjectModel mainProject = new ArchivaProjectModel();
+    
+        VersionedReference parent = new VersionedReference();
+        parent.setGroupId( "org.apache" );
+        parent.setArtifactId( "apache" );
+        parent.setVersion( "4" );
+    
+        mainProject.setParentProject( parent );
+        mainProject.setGroupId( "org.apache.servicemix" );
+        mainProject.setArtifactId( "servicemix-pom" );
+        mainProject.setVersion( "2" );
+        mainProject.setPackaging( "pom" );
+        mainProject.setName( "ServiceMix POM" );
+        mainProject.setUrl( "http://servicemix.apache.org/" );
+        mainProject.setDescription( "This pom provides project information that is common to all ServiceMix branches." );
+        mainProject.setProperties( new Properties() );
+    
+        return mainProject;
+    }
+    
+    private ArchivaProjectModel createParentProject()
+    {
+        ArchivaProjectModel parentProject = new ArchivaProjectModel();
+    
+        parentProject.setGroupId( "org.apache" );
+        parentProject.setArtifactId( "apache" );
+        parentProject.setVersion( "4" );
+        parentProject.setPackaging( "pom" );
+    
+        Properties prop = new Properties();
+        prop.setProperty( "test.key", "" );
+        parentProject.setProperties( prop );
+    
+        return parentProject;
+    }
+}