diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java b/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java index b803f35fe3..147ba0a162 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java @@ -94,17 +94,9 @@ public class DefaultProfileSelector { 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; diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationException.java b/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationException.java deleted file mode 100644 index 629e79d199..0000000000 --- a/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationException.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.apache.maven.model.profile; - -/* - * 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 org.apache.maven.model.Profile; - -/** - * Signals an error in determining the activation status of a profile (e.g. bad syntax of activation condition). - * - * @author Benjamin Bentmann - */ -public class ProfileActivationException - extends Exception -{ - - /** - * The profile which raised this error, can be {@code null}. - */ - private final Profile profile; - - /** - * Creates a new exception with specified detail message and cause for the given profile. - * - * @param message The detail message, may be {@code null}. - * @param profile The profile that caused the error, may be {@code null}. - * @param cause The cause, may be {@code null}. - */ - public ProfileActivationException( String message, Profile profile, Throwable cause ) - { - super( message, cause ); - this.profile = profile; - } - - /** - * Creates a new exception with specified detail message for the given profile. - * - * @param message The detail message, may be {@code null}. - * @param profile The profile that caused the error, may be {@code null}. - */ - public ProfileActivationException( String message, Profile profile ) - { - super( message ); - this.profile = profile; - } - - /** - * Gets the profile that caused this error (if any). - * - * @return The profile that caused this error or {@code null} if not applicable. - */ - public Profile getProfile() - { - return profile; - } - -} diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java b/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java index c20459a16c..c39bf7e609 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java @@ -24,9 +24,9 @@ import java.io.File; 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 @@ public class FileProfileActivator @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 @@ public class FileProfileActivator } 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 ); diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java b/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java index 665ba14782..eb479a2ffc 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java @@ -25,8 +25,8 @@ import java.util.List; 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 @@ public class JdkVersionProfileActivator 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 @@ public class JdkVersionProfileActivator 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( "!" ) ) diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java b/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java index 451332a5ef..d1c507a053 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java @@ -22,8 +22,8 @@ package org.apache.maven.model.profile.activation; 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 @@ public class OperatingSystemProfileActivator implements ProfileActivator { - public boolean isActive( Profile profile, ProfileActivationContext context ) - throws ProfileActivationException + public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ) { boolean active = false; diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/ProfileActivator.java b/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/ProfileActivator.java index 1fa49fd4a8..142dddf6b6 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/ProfileActivator.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/ProfileActivator.java @@ -20,8 +20,8 @@ package org.apache.maven.model.profile.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; /** * Determines whether a profile should be activated. @@ -37,11 +37,10 @@ public interface ProfileActivator * @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 ); } diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/PropertyProfileActivator.java b/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/PropertyProfileActivator.java index a0df222645..418ff6f764 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/PropertyProfileActivator.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/PropertyProfileActivator.java @@ -22,8 +22,8 @@ package org.apache.maven.model.profile.activation; 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 @@ public class PropertyProfileActivator implements ProfileActivator { - public boolean isActive( Profile profile, ProfileActivationContext context ) - throws ProfileActivationException + public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ) { boolean active = false; @@ -53,18 +52,18 @@ public class PropertyProfileActivator String name = property.getName(); boolean reverseName = false; - if ( name == null ) - { - throw new ProfileActivationException( "The property name is required to activate the profile " - + profile.getId(), profile ); - } - - if ( name.startsWith( "!" ) ) + if ( name != null && name.startsWith( "!" ) ) { reverseName = true; name = name.substring( 1 ); } + if ( name == null || name.length() <= 0 ) + { + problems.addError( "The property name is required to activate the profile " + profile.getId() ); + return false; + } + String sysValue = context.getUserProperties().getProperty( name ); if ( sysValue == null ) { diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/building/SimpleProblemCollector.java b/maven-model-builder/src/test/java/org/apache/maven/model/building/SimpleProblemCollector.java new file mode 100644 index 0000000000..e3b94587eb --- /dev/null +++ b/maven-model-builder/src/test/java/org/apache/maven/model/building/SimpleProblemCollector.java @@ -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 warnings = new ArrayList(); + + private List errors = new ArrayList(); + + 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 getWarnings() + { + return warnings; + } + + public List getErrors() + { + return errors; + } + +} diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/AbstractProfileActivatorTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/AbstractProfileActivatorTest.java index f5a332a775..7449c36b19 100644 --- a/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/AbstractProfileActivatorTest.java +++ b/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/AbstractProfileActivatorTest.java @@ -21,6 +21,8 @@ package org.apache.maven.model.profile.activation; 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 @@ public abstract class AbstractProfileActivatorTest 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() ); + } + } diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivatorTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivatorTest.java index ef915beeae..7c5204ff06 100644 --- a/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivatorTest.java +++ b/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivatorTest.java @@ -61,11 +61,11 @@ public class JdkVersionProfileActivatorTest { 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 @@ public class JdkVersionProfileActivatorTest { 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 @@ public class JdkVersionProfileActivatorTest { 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 @@ public class JdkVersionProfileActivatorTest { 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" ) ) ); } } diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/PropertyProfileActivatorTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/PropertyProfileActivatorTest.java index eee171cb3a..6434864806 100644 --- a/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/PropertyProfileActivatorTest.java +++ b/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/PropertyProfileActivatorTest.java @@ -66,11 +66,11 @@ public class PropertyProfileActivatorTest { 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 @@ public class PropertyProfileActivatorTest { 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 @@ public class PropertyProfileActivatorTest { 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 @@ public class PropertyProfileActivatorTest { 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 @@ public class PropertyProfileActivatorTest { 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 @@ public class PropertyProfileActivatorTest { 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 @@ public class PropertyProfileActivatorTest { 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 @@ public class PropertyProfileActivatorTest { 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 @@ public class PropertyProfileActivatorTest { 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 @@ public class PropertyProfileActivatorTest 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 ) ); } } diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java index 1adc4a853b..e95029a6b2 100644 --- a/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java +++ b/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java @@ -20,13 +20,12 @@ package org.apache.maven.model.validation; */ 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 @@ public class DefaultModelValidatorTest private DefaultModelValidator validator; - private static class SimpleProblemCollector - implements ModelProblemCollector - { - - private List warnings = new ArrayList(); - - private List errors = new ArrayList(); - - 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 getWarnings() - { - return warnings; - } - - public List getErrors() - { - return errors; - } - - } - private Model read( String pom ) throws Exception {