You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/09/02 13:12:43 UTC

svn commit: r810452 - in /maven/components/trunk/maven-model-builder/src: main/java/org/apache/maven/model/profile/ main/java/org/apache/maven/model/profile/activation/ test/java/org/apache/maven/model/building/ test/java/org/apache/maven/model/profile...

Author: bentmann
Date: Wed Sep  2 11:12:43 2009
New Revision: 810452

URL: http://svn.apache.org/viewvc?rev=810452&view=rev
Log:
o Refactored profile activators to use problem collector

Added:
    maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/building/   (with props)
    maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/building/SimpleProblemCollector.java   (with props)
Removed:
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationException.java
Modified:
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/ProfileActivator.java
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/PropertyProfileActivator.java
    maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/AbstractProfileActivatorTest.java
    maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivatorTest.java
    maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/PropertyProfileActivatorTest.java
    maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java

Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java?rev=810452&r1=810451&r2=810452&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java (original)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java Wed Sep  2 11:12:43 2009
@@ -94,17 +94,9 @@
     {
         for ( ProfileActivator activator : activators )
         {
-            try
+            if ( activator.isActive( profile, context, problems ) )
             {
-                if ( activator.isActive( profile, context ) )
-                {
-                    return true;
-                }
-            }
-            catch ( ProfileActivationException e )
-            {
-                problems.addError( "Invalid activation condition for profile " + profile.getId() + ": "
-                    + e.getMessage() );
+                return true;
             }
         }
         return false;

Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java?rev=810452&r1=810451&r2=810452&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java (original)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java Wed Sep  2 11:12:43 2009
@@ -24,9 +24,9 @@
 import org.apache.maven.model.Activation;
 import org.apache.maven.model.ActivationFile;
 import org.apache.maven.model.Profile;
+import org.apache.maven.model.building.ModelProblemCollector;
 import org.apache.maven.model.path.PathTranslator;
 import org.apache.maven.model.profile.ProfileActivationContext;
-import org.apache.maven.model.profile.ProfileActivationException;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.interpolation.AbstractValueSource;
@@ -47,8 +47,7 @@
     @Requirement
     private PathTranslator pathTranslator;
 
-    public boolean isActive( Profile profile, ProfileActivationContext context )
-        throws ProfileActivationException
+    public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems )
     {
         Activation activation = profile.getActivation();
 
@@ -119,8 +118,9 @@
         }
         catch ( Exception e )
         {
-            throw new ProfileActivationException( "Failed to interpolate file location " + path + " for profile "
-                + profile.getId() + ": " + e.getMessage(), profile, e );
+            problems.addError( "Failed to interpolate file location " + path + " for profile " + profile.getId() + ": "
+                + e.getMessage(), e );
+            return false;
         }
 
         path = pathTranslator.alignToBaseDirectory( path, basedir );

Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java?rev=810452&r1=810451&r2=810452&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java (original)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java Wed Sep  2 11:12:43 2009
@@ -25,8 +25,8 @@
 
 import org.apache.maven.model.Activation;
 import org.apache.maven.model.Profile;
+import org.apache.maven.model.building.ModelProblemCollector;
 import org.apache.maven.model.profile.ProfileActivationContext;
-import org.apache.maven.model.profile.ProfileActivationException;
 import org.codehaus.plexus.component.annotations.Component;
 
 /**
@@ -39,8 +39,7 @@
     implements ProfileActivator
 {
 
-    public boolean isActive( Profile profile, ProfileActivationContext context )
-        throws ProfileActivationException
+    public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems )
     {
         boolean active = false;
 
@@ -56,8 +55,8 @@
 
                 if ( version.length() <= 0 )
                 {
-                    throw new ProfileActivationException( "Failed to determine Java version for profile "
-                        + profile.getId(), profile );
+                    problems.addError( "Failed to determine Java version for profile " + profile.getId() );
+                    return false;
                 }
 
                 if ( jdk.startsWith( "!" ) )

Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java?rev=810452&r1=810451&r2=810452&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java (original)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java Wed Sep  2 11:12:43 2009
@@ -22,8 +22,8 @@
 import org.apache.maven.model.Activation;
 import org.apache.maven.model.ActivationOS;
 import org.apache.maven.model.Profile;
+import org.apache.maven.model.building.ModelProblemCollector;
 import org.apache.maven.model.profile.ProfileActivationContext;
-import org.apache.maven.model.profile.ProfileActivationException;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.util.Os;
 
@@ -37,8 +37,7 @@
     implements ProfileActivator
 {
 
-    public boolean isActive( Profile profile, ProfileActivationContext context )
-        throws ProfileActivationException
+    public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems )
     {
         boolean active = false;
 

Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/ProfileActivator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/ProfileActivator.java?rev=810452&r1=810451&r2=810452&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/ProfileActivator.java (original)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/ProfileActivator.java Wed Sep  2 11:12:43 2009
@@ -20,8 +20,8 @@
  */
 
 import org.apache.maven.model.Profile;
+import org.apache.maven.model.building.ModelProblemCollector;
 import org.apache.maven.model.profile.ProfileActivationContext;
-import org.apache.maven.model.profile.ProfileActivationException;
 
 /**
  * Determines whether a profile should be activated.
@@ -37,11 +37,10 @@
      * @param profile The profile whose activation status should be determined, must not be {@code null}.
      * @param context The environmental context used to determine the activation status of the profile, must not be
      *            {@code null}.
+     * @param problems The container used to collect problems (e.g. bad syntax) that were encountered, must not be
+     *            {@code null}.
      * @return {@code true} if the profile is active, {@code false} otherwise.
-     * @throws ProfileActivationException If the activation status of the profile could not be determined (e.g. due to
-     *             missing values or bad syntax).
      */
-    boolean isActive( Profile profile, ProfileActivationContext context )
-        throws ProfileActivationException;
+    boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems );
 
 }

Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/PropertyProfileActivator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/PropertyProfileActivator.java?rev=810452&r1=810451&r2=810452&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/PropertyProfileActivator.java (original)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/PropertyProfileActivator.java Wed Sep  2 11:12:43 2009
@@ -22,8 +22,8 @@
 import org.apache.maven.model.Activation;
 import org.apache.maven.model.ActivationProperty;
 import org.apache.maven.model.Profile;
+import org.apache.maven.model.building.ModelProblemCollector;
 import org.apache.maven.model.profile.ProfileActivationContext;
-import org.apache.maven.model.profile.ProfileActivationException;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.util.StringUtils;
 
@@ -37,8 +37,7 @@
     implements ProfileActivator
 {
 
-    public boolean isActive( Profile profile, ProfileActivationContext context )
-        throws ProfileActivationException
+    public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems )
     {
         boolean active = false;
 
@@ -53,16 +52,16 @@
                 String name = property.getName();
                 boolean reverseName = false;
 
-                if ( name == null )
+                if ( name != null && name.startsWith( "!" ) )
                 {
-                    throw new ProfileActivationException( "The property name is required to activate the profile "
-                        + profile.getId(), profile );
+                    reverseName = true;
+                    name = name.substring( 1 );
                 }
 
-                if ( name.startsWith( "!" ) )
+                if ( name == null || name.length() <= 0 )
                 {
-                    reverseName = true;
-                    name = name.substring( 1 );
+                    problems.addError( "The property name is required to activate the profile " + profile.getId() );
+                    return false;
                 }
 
                 String sysValue = context.getUserProperties().getProperty( name );

Propchange: maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/building/
------------------------------------------------------------------------------
    bugtraq:label = Enter issue ID:

Propchange: maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/building/
------------------------------------------------------------------------------
    bugtraq:message = Issue id: %BUGID%

Propchange: maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/building/
------------------------------------------------------------------------------
    bugtraq:number = false

Propchange: maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/building/
------------------------------------------------------------------------------
    bugtraq:url = http://jira.codehaus.org/browse/%BUGID%

Added: maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/building/SimpleProblemCollector.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/building/SimpleProblemCollector.java?rev=810452&view=auto
==============================================================================
--- maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/building/SimpleProblemCollector.java (added)
+++ maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/building/SimpleProblemCollector.java Wed Sep  2 11:12:43 2009
@@ -0,0 +1,68 @@
+package org.apache.maven.model.building;
+
+/*
+ * 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.ArrayList;
+import java.util.List;
+
+/**
+ * A simple model problem collector for testing the model building components.
+ * 
+ * @author Benjamin Bentmann
+ */
+public class SimpleProblemCollector
+    implements ModelProblemCollector
+{
+
+    private List<String> warnings = new ArrayList<String>();
+
+    private List<String> errors = new ArrayList<String>();
+
+    public void addError( String message )
+    {
+        errors.add( message );
+    }
+
+    public void addError( String message, Exception cause )
+    {
+        addError( message );
+    }
+
+    public void addWarning( String message )
+    {
+        warnings.add( message );
+    }
+
+    public void addWarning( String message, Exception cause )
+    {
+        addWarning( message );
+    }
+
+    public List<String> getWarnings()
+    {
+        return warnings;
+    }
+
+    public List<String> getErrors()
+    {
+        return errors;
+    }
+
+}

Propchange: maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/building/SimpleProblemCollector.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/building/SimpleProblemCollector.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/AbstractProfileActivatorTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/AbstractProfileActivatorTest.java?rev=810452&r1=810451&r2=810452&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/AbstractProfileActivatorTest.java (original)
+++ maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/AbstractProfileActivatorTest.java Wed Sep  2 11:12:43 2009
@@ -21,6 +21,8 @@
 
 import java.util.Properties;
 
+import org.apache.maven.model.Profile;
+import org.apache.maven.model.building.SimpleProblemCollector;
 import org.apache.maven.model.profile.DefaultProfileActivationContext;
 import org.apache.maven.model.profile.ProfileActivationContext;
 import org.codehaus.plexus.PlexusTestCase;
@@ -77,4 +79,14 @@
         return context.setUserProperties( userProperties ).setSystemProperties( systemProperties );
     }
 
+    protected void assertActivation( boolean active, Profile profile, ProfileActivationContext context )
+    {
+        SimpleProblemCollector problems = new SimpleProblemCollector();
+
+        assertEquals( active, activator.isActive( profile, context, problems ) );
+
+        assertEquals( problems.getErrors().toString(), 0, problems.getErrors().size() );
+        assertEquals( problems.getWarnings().toString(), 0, problems.getWarnings().size() );
+    }
+
 }

Modified: maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivatorTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivatorTest.java?rev=810452&r1=810451&r2=810452&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivatorTest.java (original)
+++ maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivatorTest.java Wed Sep  2 11:12:43 2009
@@ -61,11 +61,11 @@
     {
         Profile p = new Profile();
 
-        assertFalse( activator.isActive( p, newContext( null, null ) ) );
+        assertActivation( false, p, newContext( null, null ) );
 
         p.setActivation( new Activation() );
 
-        assertFalse( activator.isActive( p, newContext( null, null ) ) );
+        assertActivation( false, p, newContext( null, null ) );
     }
 
     public void testPrefix()
@@ -73,13 +73,13 @@
     {
         Profile profile = newProfile( "1.4" );
 
-        assertTrue( activator.isActive( profile, newContext( null, newProperties( "1.4" ) ) ) );
+        assertActivation( true, profile, newContext( null, newProperties( "1.4" ) ) );
 
-        assertTrue( activator.isActive( profile, newContext( null, newProperties( "1.4.2" ) ) ) );
+        assertActivation( true, profile, newContext( null, newProperties( "1.4.2" ) ) );
 
-        assertFalse( activator.isActive( profile, newContext( null, newProperties( "1.3" ) ) ) );
+        assertActivation( false, profile, newContext( null, newProperties( "1.3" ) ) );
 
-        assertFalse( activator.isActive( profile, newContext( null, newProperties( "1.5" ) ) ) );
+        assertActivation( false, profile, newContext( null, newProperties( "1.5" ) ) );
     }
 
     public void testPrefixNegated()
@@ -87,13 +87,13 @@
     {
         Profile profile = newProfile( "!1.4" );
 
-        assertFalse( activator.isActive( profile, newContext( null, newProperties( "1.4" ) ) ) );
+        assertActivation( false, profile, newContext( null, newProperties( "1.4" ) ) );
 
-        assertFalse( activator.isActive( profile, newContext( null, newProperties( "1.4.2" ) ) ) );
+        assertActivation( false, profile, newContext( null, newProperties( "1.4.2" ) ) );
 
-        assertTrue( activator.isActive( profile, newContext( null, newProperties( "1.3" ) ) ) );
+        assertActivation( true, profile, newContext( null, newProperties( "1.3" ) ) );
 
-        assertTrue( activator.isActive( profile, newContext( null, newProperties( "1.5" ) ) ) );
+        assertActivation( true, profile, newContext( null, newProperties( "1.5" ) ) );
     }
 
     public void testVersionRange()
@@ -101,13 +101,13 @@
     {
         Profile profile = newProfile( "(1.3,1.6)" );
 
-        assertTrue( activator.isActive( profile, newContext( null, newProperties( "1.5.0_16" ) ) ) );
+        assertActivation( true, profile, newContext( null, newProperties( "1.5.0_16" ) ) );
 
-        assertFalse( activator.isActive( profile, newContext( null, newProperties( "1.3" ) ) ) );
+        assertActivation( false, profile, newContext( null, newProperties( "1.3" ) ) );
 
-        assertTrue( activator.isActive( profile, newContext( null, newProperties( "1.3.1" ) ) ) );
+        assertActivation( true, profile, newContext( null, newProperties( "1.3.1" ) ) );
 
-        assertFalse( activator.isActive( profile, newContext( null, newProperties( "1.6" ) ) ) );
+        assertActivation( false, profile, newContext( null, newProperties( "1.6" ) ) );
     }
 
 }

Modified: maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/PropertyProfileActivatorTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/PropertyProfileActivatorTest.java?rev=810452&r1=810451&r2=810452&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/PropertyProfileActivatorTest.java (original)
+++ maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/PropertyProfileActivatorTest.java Wed Sep  2 11:12:43 2009
@@ -66,11 +66,11 @@
     {
         Profile p = new Profile();
 
-        assertFalse( activator.isActive( p, newContext( null, null ) ) );
+        assertActivation( false, p, newContext( null, null ) );
 
         p.setActivation( new Activation() );
 
-        assertFalse( activator.isActive( p, newContext( null, null ) ) );
+        assertActivation( false, p, newContext( null, null ) );
     }
 
     public void testWithNameOnly_UserProperty()
@@ -78,11 +78,11 @@
     {
         Profile profile = newProfile( "prop", null );
 
-        assertTrue( activator.isActive( profile, newContext( newProperties( "prop", "value" ), null ) ) );
+        assertActivation( true, profile, newContext( newProperties( "prop", "value" ), null ) );
 
-        assertFalse( activator.isActive( profile, newContext( newProperties( "prop", "" ), null ) ) );
+        assertActivation( false, profile, newContext( newProperties( "prop", "" ), null ) );
 
-        assertFalse( activator.isActive( profile, newContext( newProperties( "other", "value" ), null ) ) );
+        assertActivation( false, profile, newContext( newProperties( "other", "value" ), null ) );
     }
 
     public void testWithNameOnly_SystemProperty()
@@ -90,11 +90,11 @@
     {
         Profile profile = newProfile( "prop", null );
 
-        assertTrue( activator.isActive( profile, newContext( null, newProperties( "prop", "value" ) ) ) );
+        assertActivation( true, profile, newContext( null, newProperties( "prop", "value" ) ) );
 
-        assertFalse( activator.isActive( profile, newContext( null, newProperties( "prop", "" ) ) ) );
+        assertActivation( false, profile, newContext( null, newProperties( "prop", "" ) ) );
 
-        assertFalse( activator.isActive( profile, newContext( null, newProperties( "other", "value" ) ) ) );
+        assertActivation( false, profile, newContext( null, newProperties( "other", "value" ) ) );
     }
 
     public void testWithNegatedNameOnly_UserProperty()
@@ -102,11 +102,11 @@
     {
         Profile profile = newProfile( "!prop", null );
 
-        assertFalse( activator.isActive( profile, newContext( newProperties( "prop", "value" ), null ) ) );
+        assertActivation( false, profile, newContext( newProperties( "prop", "value" ), null ) );
 
-        assertTrue( activator.isActive( profile, newContext( newProperties( "prop", "" ), null ) ) );
+        assertActivation( true, profile, newContext( newProperties( "prop", "" ), null ) );
 
-        assertTrue( activator.isActive( profile, newContext( newProperties( "other", "value" ), null ) ) );
+        assertActivation( true, profile, newContext( newProperties( "other", "value" ), null ) );
     }
 
     public void testWithNegatedNameOnly_SystemProperty()
@@ -114,11 +114,11 @@
     {
         Profile profile = newProfile( "!prop", null );
 
-        assertFalse( activator.isActive( profile, newContext( null, newProperties( "prop", "value" ) ) ) );
+        assertActivation( false, profile, newContext( null, newProperties( "prop", "value" ) ) );
 
-        assertTrue( activator.isActive( profile, newContext( null, newProperties( "prop", "" ) ) ) );
+        assertActivation( true, profile, newContext( null, newProperties( "prop", "" ) ) );
 
-        assertTrue( activator.isActive( profile, newContext( null, newProperties( "other", "value" ) ) ) );
+        assertActivation( true, profile, newContext( null, newProperties( "other", "value" ) ) );
     }
 
     public void testWithValue_UserProperty()
@@ -126,11 +126,11 @@
     {
         Profile profile = newProfile( "prop", "value" );
 
-        assertTrue( activator.isActive( profile, newContext( newProperties( "prop", "value" ), null ) ) );
+        assertActivation( true, profile, newContext( newProperties( "prop", "value" ), null ) );
 
-        assertFalse( activator.isActive( profile, newContext( newProperties( "prop", "other" ), null ) ) );
+        assertActivation( false, profile, newContext( newProperties( "prop", "other" ), null ) );
 
-        assertFalse( activator.isActive( profile, newContext( newProperties( "prop", "" ), null ) ) );
+        assertActivation( false, profile, newContext( newProperties( "prop", "" ), null ) );
     }
 
     public void testWithValue_SystemProperty()
@@ -138,11 +138,11 @@
     {
         Profile profile = newProfile( "prop", "value" );
 
-        assertTrue( activator.isActive( profile, newContext( null, newProperties( "prop", "value" ) ) ) );
+        assertActivation( true, profile, newContext( null, newProperties( "prop", "value" ) ) );
 
-        assertFalse( activator.isActive( profile, newContext( null, newProperties( "prop", "other" ) ) ) );
+        assertActivation( false, profile, newContext( null, newProperties( "prop", "other" ) ) );
 
-        assertFalse( activator.isActive( profile, newContext( null, newProperties( "other", "" ) ) ) );
+        assertActivation( false, profile, newContext( null, newProperties( "other", "" ) ) );
     }
 
     public void testWithNegatedValue_UserProperty()
@@ -150,11 +150,11 @@
     {
         Profile profile = newProfile( "prop", "!value" );
 
-        assertFalse( activator.isActive( profile, newContext( newProperties( "prop", "value" ), null ) ) );
+        assertActivation( false, profile, newContext( newProperties( "prop", "value" ), null ) );
 
-        assertTrue( activator.isActive( profile, newContext( newProperties( "prop", "other" ), null ) ) );
+        assertActivation( true, profile, newContext( newProperties( "prop", "other" ), null ) );
 
-        assertTrue( activator.isActive( profile, newContext( newProperties( "prop", "" ), null ) ) );
+        assertActivation( true, profile, newContext( newProperties( "prop", "" ), null ) );
     }
 
     public void testWithNegatedValue_SystemProperty()
@@ -162,11 +162,11 @@
     {
         Profile profile = newProfile( "prop", "!value" );
 
-        assertFalse( activator.isActive( profile, newContext( null, newProperties( "prop", "value" ) ) ) );
+        assertActivation( false, profile, newContext( null, newProperties( "prop", "value" ) ) );
 
-        assertTrue( activator.isActive( profile, newContext( null, newProperties( "prop", "other" ) ) ) );
+        assertActivation( true, profile, newContext( null, newProperties( "prop", "other" ) ) );
 
-        assertTrue( activator.isActive( profile, newContext( null, newProperties( "other", "" ) ) ) );
+        assertActivation( true, profile, newContext( null, newProperties( "other", "" ) ) );
     }
 
     public void testWithValue_UserPropertyDominantOverSystemProperty()
@@ -177,9 +177,9 @@
         Properties props1 = newProperties( "prop", "value" );
         Properties props2 = newProperties( "prop", "other" );
 
-        assertTrue( activator.isActive( profile, newContext( props1, props2 ) ) );
+        assertActivation( true, profile, newContext( props1, props2 ) );
 
-        assertFalse( activator.isActive( profile, newContext( props2, props1 ) ) );
+        assertActivation( false, profile, newContext( props2, props1 ) );
     }
 
 }

Modified: maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java?rev=810452&r1=810451&r2=810452&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java (original)
+++ maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java Wed Sep  2 11:12:43 2009
@@ -20,13 +20,12 @@
  */
 
 import java.io.InputStream;
-import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.maven.model.Model;
 import org.apache.maven.model.building.DefaultModelBuildingRequest;
 import org.apache.maven.model.building.ModelBuildingRequest;
-import org.apache.maven.model.building.ModelProblemCollector;
+import org.apache.maven.model.building.SimpleProblemCollector;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.codehaus.plexus.PlexusTestCase;
 
@@ -40,46 +39,6 @@
 
     private DefaultModelValidator validator;
 
-    private static class SimpleProblemCollector
-        implements ModelProblemCollector
-    {
-
-        private List<String> warnings = new ArrayList<String>();
-
-        private List<String> errors = new ArrayList<String>();
-
-        public void addError( String message )
-        {
-            errors.add( message );
-        }
-
-        public void addError( String message, Exception cause )
-        {
-            addError( message );
-        }
-
-        public void addWarning( String message )
-        {
-            warnings.add( message );
-        }
-
-        public void addWarning( String message, Exception cause )
-        {
-            addWarning( message );
-        }
-
-        public List<String> getWarnings()
-        {
-            return warnings;
-        }
-
-        public List<String> getErrors()
-        {
-            return errors;
-        }
-
-    }
-
     private Model read( String pom )
         throws Exception
     {