maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r721102 - in /maven/components/trunk/maven-project-builder/src: main/java/org/apache/maven/project/builder/ test/java/ test/java/org/apache/maven/project/builder/ test/java/org/apache/maven/project/builder/profile/
Date Thu, 27 Nov 2008 06:50:12 GMT
Author: sisbell
Date: Wed Nov 26 22:50:12 2008
New Revision: 721102

URL: http://svn.apache.org/viewvc?rev=721102&view=rev
Log:
Unit test for dependency management with scope and classifier.

Added:
    maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/DefaultDomainModel.java
    maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/DefaultDomainModelFactory.java
    maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/
    maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/DefaultModelContainer.java
  (contents, props changed)
      - copied, changed from r721070, maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/DefaultModelContainer.java
    maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/FileMatcherTest.java
  (contents, props changed)
      - copied, changed from r721070, maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/FileMatcherTest.java
    maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/JdkMatcherTest.java
  (contents, props changed)
      - copied, changed from r721070, maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/JdkMatcherTest.java
    maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/ProfileContextTest.java
  (contents, props changed)
      - copied, changed from r721070, maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/ProfileContextTest.java
    maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/PropertyMatcherTest.java
  (contents, props changed)
      - copied, changed from r721070, maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/PropertyMatcherTest.java
Removed:
    maven/components/trunk/maven-project-builder/src/test/java/EnforcerPomTest.java
    maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/DefaultModelContainer.java
    maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/FileMatcherTest.java
    maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/JdkMatcherTest.java
    maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/ProfileContextTest.java
    maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/PropertyMatcherTest.java
Modified:
    maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java
    maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/EnforcerPomTest.java

Modified: maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java?rev=721102&r1=721101&r2=721102&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java
(original)
+++ maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java
Wed Nov 26 22:50:12 2008
@@ -545,6 +545,10 @@
         Collections.sort(ips1, new Comparator<InterpolatorProperty>()
         {
             public int compare(InterpolatorProperty o, InterpolatorProperty o1) {
+                if(o.getTag() == null || o1.getTag() == null)
+                {
+                    return 0;
+                }
                 return PomInterpolatorTag.valueOf(o.getTag()).compareTo(PomInterpolatorTag.valueOf(o1.getTag()));
             }
         });

Added: maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/DefaultDomainModel.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/DefaultDomainModel.java?rev=721102&view=auto
==============================================================================
--- maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/DefaultDomainModel.java
(added)
+++ maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/DefaultDomainModel.java
Wed Nov 26 22:50:12 2008
@@ -0,0 +1,28 @@
+package org.apache.maven.project.builder;
+
+import org.apache.maven.shared.model.DomainModel;
+import org.apache.maven.shared.model.ModelProperty;
+
+import java.util.List;
+import java.io.IOException;
+
+public class DefaultDomainModel implements DomainModel {
+
+    private List<ModelProperty> modelProperties;
+
+    public DefaultDomainModel(List<ModelProperty> modelProperties) {
+        this.modelProperties = modelProperties;
+    }
+
+    public List<ModelProperty> getModelProperties() throws IOException {
+        return modelProperties;
+    }
+
+    public String getEventHistory() {
+        return "";
+    }
+
+    public void setEventHistory(String s) {
+
+    }
+}

Added: maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/DefaultDomainModelFactory.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/DefaultDomainModelFactory.java?rev=721102&view=auto
==============================================================================
--- maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/DefaultDomainModelFactory.java
(added)
+++ maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/DefaultDomainModelFactory.java
Wed Nov 26 22:50:12 2008
@@ -0,0 +1,14 @@
+package org.apache.maven.project.builder;
+
+import org.apache.maven.shared.model.DomainModelFactory;
+import org.apache.maven.shared.model.DomainModel;
+import org.apache.maven.shared.model.ModelProperty;
+
+import java.util.List;
+import java.io.IOException;
+
+public class DefaultDomainModelFactory implements DomainModelFactory {
+    public DomainModel createDomainModel(List<ModelProperty> modelProperties) throws
IOException {
+        return new DefaultDomainModel(modelProperties);
+    }
+}

Modified: maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/EnforcerPomTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/EnforcerPomTest.java?rev=721102&r1=721101&r2=721102&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/EnforcerPomTest.java
(original)
+++ maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/EnforcerPomTest.java
Wed Nov 26 22:50:12 2008
@@ -1,12 +1,68 @@
 package org.apache.maven.project.builder;
 
-import org.apache.maven.shared.model.DomainModel;
+import org.apache.maven.shared.model.*;
+import org.apache.maven.shared.model.impl.DefaultModelDataSource;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.io.IOException;
+
+import static org.junit.Assert.*;
 
 public class EnforcerPomTest
 {
-    public void testConstructionOfTheEnforcerPom()
-        throws Exception
+    @org.junit.Test
+    public void dependencyManagementWithScopeAndClassifier() throws IOException
     {
-        DomainModel model = null;
+        List<ModelProperty> mp = new ArrayList<ModelProperty>();
+        mp.add(new ModelProperty(ProjectUri.xUri, null));
+        mp.add(new ModelProperty(ProjectUri.DependencyManagement.xUri, null));
+        mp.add(new ModelProperty(ProjectUri.DependencyManagement.Dependencies.xUri, null));
+        mp.add(new ModelProperty(ProjectUri.DependencyManagement.Dependencies.Dependency.xUri,
null));
+        mp.add(new ModelProperty(ProjectUri.DependencyManagement.Dependencies.Dependency.groupId,
"gid"));
+        mp.add(new ModelProperty(ProjectUri.DependencyManagement.Dependencies.Dependency.artifactId,
"aid"));
+        mp.add(new ModelProperty(ProjectUri.DependencyManagement.Dependencies.Dependency.version,
"v1"));
+        mp.add(new ModelProperty(ProjectUri.DependencyManagement.Dependencies.Dependency.scope,
"test"));
+        mp.add(new ModelProperty(ProjectUri.DependencyManagement.Dependencies.Dependency.classifier,
"tests"));
+        mp.add(new ModelProperty(ProjectUri.DependencyManagement.Dependencies.Dependency.xUri,
null));
+        mp.add(new ModelProperty(ProjectUri.DependencyManagement.Dependencies.Dependency.groupId,
"gid"));
+        mp.add(new ModelProperty(ProjectUri.DependencyManagement.Dependencies.Dependency.artifactId,
"aid"));
+        mp.add(new ModelProperty(ProjectUri.DependencyManagement.Dependencies.Dependency.version,
"v1"));
+
+        List<ModelProperty> mp2 = new ArrayList<ModelProperty>();
+        mp2.add(new ModelProperty(ProjectUri.xUri, null));
+        mp2.add(new ModelProperty(ProjectUri.Dependencies.xUri, null));
+        mp2.add(new ModelProperty(ProjectUri.Dependencies.Dependency.xUri, null));
+        mp2.add(new ModelProperty(ProjectUri.Dependencies.Dependency.groupId, "gid"));
+        mp2.add(new ModelProperty(ProjectUri.Dependencies.Dependency.artifactId, "aid"));
+        mp2.add(new ModelProperty(ProjectUri.Dependencies.Dependency.xUri, null));
+        mp2.add(new ModelProperty(ProjectUri.Dependencies.Dependency.groupId, "gid"));
+        mp2.add(new ModelProperty(ProjectUri.Dependencies.Dependency.artifactId, "aid"));
+        mp2.add(new ModelProperty(ProjectUri.Dependencies.Dependency.classifier, "tests"));
+
+        DomainModel childModel = new DefaultDomainModel(mp2);
+        DomainModel parentModel = new DefaultDomainModel(mp);
+
+        ModelTransformerContext ctx = new ModelTransformerContext(Arrays.asList(new ArtifactModelContainerFactory(),
+                new IdModelContainerFactory()));
+
+        ModelTransformer transformer = new PomTransformer(new DefaultDomainModelFactory());
+        DomainModel domainModel = ctx.transform( Arrays.asList(childModel, parentModel),
transformer, transformer );
+
+        DefaultModelDataSource source = new DefaultModelDataSource();
+        source.init(domainModel.getModelProperties(), Arrays.asList(new ArtifactModelContainerFactory(),
new IdModelContainerFactory()));
+        List<ModelContainer> containers = source.queryFor(ProjectUri.Dependencies.Dependency.xUri);
+        assertTrue(containers.size() == 1 );
+        assertTrue(contains(ProjectUri.Dependencies.Dependency.version, "v1", containers.get(0)));
+    }
+
+    private boolean contains(String name, String value, ModelContainer modelContainer) {
+        for(ModelProperty mp : modelContainer.getProperties()) {
+            if(mp.getUri().equals(name) && mp.getValue() != null && mp.getValue().equals(value))
{
+                return true;
+            }
+        }
+        return false;
     }
 }

Copied: maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/DefaultModelContainer.java
(from r721070, maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/DefaultModelContainer.java)
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/DefaultModelContainer.java?p2=maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/DefaultModelContainer.java&p1=maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/DefaultModelContainer.java&r1=721070&r2=721102&rev=721102&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/DefaultModelContainer.java
(original)
+++ maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/DefaultModelContainer.java
Wed Nov 26 22:50:12 2008
@@ -1,4 +1,4 @@
-package org.apache.maven.project.builder;
+package org.apache.maven.project.builder.profile;
 
 import org.apache.maven.shared.model.ModelContainer;
 import org.apache.maven.shared.model.ModelContainerAction;

Propchange: maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/DefaultModelContainer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/DefaultModelContainer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/FileMatcherTest.java
(from r721070, maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/FileMatcherTest.java)
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/FileMatcherTest.java?p2=maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/FileMatcherTest.java&p1=maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/FileMatcherTest.java&r1=721070&r2=721102&rev=721102&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/FileMatcherTest.java
(original)
+++ maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/FileMatcherTest.java
Wed Nov 26 22:50:12 2008
@@ -1,6 +1,7 @@
-package org.apache.maven.project.builder;
+package org.apache.maven.project.builder.profile;
 
 import org.apache.maven.project.builder.profile.FileMatcher;
+import org.apache.maven.project.builder.ProjectUri;
 import org.apache.maven.shared.model.InterpolatorProperty;
 import org.apache.maven.shared.model.ModelContainer;
 import org.apache.maven.shared.model.ModelProperty;

Propchange: maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/FileMatcherTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/FileMatcherTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/JdkMatcherTest.java
(from r721070, maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/JdkMatcherTest.java)
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/JdkMatcherTest.java?p2=maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/JdkMatcherTest.java&p1=maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/JdkMatcherTest.java&r1=721070&r2=721102&rev=721102&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/JdkMatcherTest.java
(original)
+++ maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/JdkMatcherTest.java
Wed Nov 26 22:50:12 2008
@@ -1,6 +1,7 @@
-package org.apache.maven.project.builder;
+package org.apache.maven.project.builder.profile;
 
 import org.apache.maven.project.builder.profile.JdkMatcher;
+import org.apache.maven.project.builder.ProjectUri;
 import org.apache.maven.shared.model.InterpolatorProperty;
 import org.apache.maven.shared.model.ModelContainer;
 import org.apache.maven.shared.model.ModelProperty;

Propchange: maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/JdkMatcherTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/JdkMatcherTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/ProfileContextTest.java
(from r721070, maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/ProfileContextTest.java)
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/ProfileContextTest.java?p2=maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/ProfileContextTest.java&p1=maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/ProfileContextTest.java&r1=721070&r2=721102&rev=721102&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/ProfileContextTest.java
(original)
+++ maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/ProfileContextTest.java
Wed Nov 26 22:50:12 2008
@@ -1,6 +1,9 @@
-package org.apache.maven.project.builder;
+package org.apache.maven.project.builder.profile;
 
 import org.apache.maven.project.builder.profile.ProfileContext;
+import org.apache.maven.project.builder.ProjectUri;
+import org.apache.maven.project.builder.ArtifactModelContainerFactory;
+import org.apache.maven.project.builder.IdModelContainerFactory;
 import org.apache.maven.shared.model.DataSourceException;
 import org.apache.maven.shared.model.InterpolatorProperty;
 import org.apache.maven.shared.model.ModelContainer;

Propchange: maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/ProfileContextTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/ProfileContextTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/PropertyMatcherTest.java
(from r721070, maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/PropertyMatcherTest.java)
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/PropertyMatcherTest.java?p2=maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/PropertyMatcherTest.java&p1=maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/PropertyMatcherTest.java&r1=721070&r2=721102&rev=721102&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/PropertyMatcherTest.java
(original)
+++ maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/PropertyMatcherTest.java
Wed Nov 26 22:50:12 2008
@@ -1,6 +1,6 @@
-package org.apache.maven.project.builder;
+package org.apache.maven.project.builder.profile;
 
-import org.apache.maven.project.builder.profile.PropertyMatcher;
+import org.apache.maven.project.builder.ProjectUri;
 import org.apache.maven.shared.model.InterpolatorProperty;
 import org.apache.maven.shared.model.ModelContainer;
 import org.apache.maven.shared.model.ModelProperty;

Propchange: maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/PropertyMatcherTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/profile/PropertyMatcherTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message