maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r796912 - /maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/PropertyProfileActivatorTest.java
Date Wed, 22 Jul 2009 23:36:22 GMT
Author: bentmann
Date: Wed Jul 22 23:36:22 2009
New Revision: 796912

URL: http://svn.apache.org/viewvc?rev=796912&view=rev
Log:
o Added UT for PropertyProfileActivator

Added:
    maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/PropertyProfileActivatorTest.java
  (with props)

Added: 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=796912&view=auto
==============================================================================
--- maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/PropertyProfileActivatorTest.java
(added)
+++ maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/PropertyProfileActivatorTest.java
Wed Jul 22 23:36:22 2009
@@ -0,0 +1,185 @@
+package org.apache.maven.model.profile.activation;
+
+/*
+ * 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.Properties;
+
+import org.apache.maven.model.Activation;
+import org.apache.maven.model.ActivationProperty;
+import org.apache.maven.model.Profile;
+
+/**
+ * Tests {@link PropertyProfileActivator}.
+ * 
+ * @author Benjamin Bentmann
+ */
+public class PropertyProfileActivatorTest
+    extends AbstractProfileActivatorTest<PropertyProfileActivator>
+{
+
+    public PropertyProfileActivatorTest()
+    {
+        super( PropertyProfileActivator.class );
+    }
+
+    private Profile newProfile( String key, String value )
+    {
+        ActivationProperty ap = new ActivationProperty();
+        ap.setName( key );
+        ap.setValue( value );
+
+        Activation a = new Activation();
+        a.setProperty( ap );
+
+        Profile p = new Profile();
+        p.setActivation( a );
+
+        return p;
+    }
+
+    private Properties newProperties( String key, String value )
+    {
+        Properties props = new Properties();
+        props.setProperty( key, value );
+        return props;
+    }
+
+    public void testNullSafe()
+        throws Exception
+    {
+        Profile p = new Profile();
+
+        assertFalse( activator.isActive( p, newContext( null, null ) ) );
+
+        p.setActivation( new Activation() );
+
+        assertFalse( activator.isActive( p, newContext( null, null ) ) );
+    }
+
+    public void testWithNameOnly_UserProperty()
+        throws Exception
+    {
+        Profile profile = newProfile( "prop", null );
+
+        assertTrue( activator.isActive( profile, newContext( newProperties( "prop", "value"
), null ) ) );
+
+        assertFalse( activator.isActive( profile, newContext( newProperties( "prop", "" ),
null ) ) );
+
+        assertFalse( activator.isActive( profile, newContext( newProperties( "other", "value"
), null ) ) );
+    }
+
+    public void testWithNameOnly_SystemProperty()
+        throws Exception
+    {
+        Profile profile = newProfile( "prop", null );
+
+        assertTrue( activator.isActive( profile, newContext( null, newProperties( "prop",
"value" ) ) ) );
+
+        assertFalse( activator.isActive( profile, newContext( null, newProperties( "prop",
"" ) ) ) );
+
+        assertFalse( activator.isActive( profile, newContext( null, newProperties( "other",
"value" ) ) ) );
+    }
+
+    public void testWithNegatedNameOnly_UserProperty()
+        throws Exception
+    {
+        Profile profile = newProfile( "!prop", null );
+
+        assertFalse( activator.isActive( profile, newContext( newProperties( "prop", "value"
), null ) ) );
+
+        assertTrue( activator.isActive( profile, newContext( newProperties( "prop", "" ),
null ) ) );
+
+        assertTrue( activator.isActive( profile, newContext( newProperties( "other", "value"
), null ) ) );
+    }
+
+    public void testWithNegatedNameOnly_SystemProperty()
+        throws Exception
+    {
+        Profile profile = newProfile( "!prop", null );
+
+        assertFalse( activator.isActive( profile, newContext( null, newProperties( "prop",
"value" ) ) ) );
+
+        assertTrue( activator.isActive( profile, newContext( null, newProperties( "prop",
"" ) ) ) );
+
+        assertTrue( activator.isActive( profile, newContext( null, newProperties( "other",
"value" ) ) ) );
+    }
+
+    public void testWithValue_UserProperty()
+        throws Exception
+    {
+        Profile profile = newProfile( "prop", "value" );
+
+        assertTrue( activator.isActive( profile, newContext( newProperties( "prop", "value"
), null ) ) );
+
+        assertFalse( activator.isActive( profile, newContext( newProperties( "prop", "other"
), null ) ) );
+
+        assertFalse( activator.isActive( profile, newContext( newProperties( "prop", "" ),
null ) ) );
+    }
+
+    public void testWithValue_SystemProperty()
+        throws Exception
+    {
+        Profile profile = newProfile( "prop", "value" );
+
+        assertTrue( activator.isActive( profile, newContext( null, newProperties( "prop",
"value" ) ) ) );
+
+        assertFalse( activator.isActive( profile, newContext( null, newProperties( "prop",
"other" ) ) ) );
+
+        assertFalse( activator.isActive( profile, newContext( null, newProperties( "other",
"" ) ) ) );
+    }
+
+    public void testWithNegatedValue_UserProperty()
+        throws Exception
+    {
+        Profile profile = newProfile( "prop", "!value" );
+
+        assertFalse( activator.isActive( profile, newContext( newProperties( "prop", "value"
), null ) ) );
+
+        assertTrue( activator.isActive( profile, newContext( newProperties( "prop", "other"
), null ) ) );
+
+        assertTrue( activator.isActive( profile, newContext( newProperties( "prop", "" ),
null ) ) );
+    }
+
+    public void testWithNegatedValue_SystemProperty()
+        throws Exception
+    {
+        Profile profile = newProfile( "prop", "!value" );
+
+        assertFalse( activator.isActive( profile, newContext( null, newProperties( "prop",
"value" ) ) ) );
+
+        assertTrue( activator.isActive( profile, newContext( null, newProperties( "prop",
"other" ) ) ) );
+
+        assertTrue( activator.isActive( profile, newContext( null, newProperties( "other",
"" ) ) ) );
+    }
+
+    public void testWithValue_UserPropertyDominantOverSystemProperty()
+        throws Exception
+    {
+        Profile profile = newProfile( "prop", "value" );
+
+        Properties props1 = newProperties( "prop", "value" );
+        Properties props2 = newProperties( "prop", "other" );
+
+        assertTrue( activator.isActive( profile, newContext( props1, props2 ) ) );
+
+        assertFalse( activator.isActive( profile, newContext( props2, props1 ) ) );
+    }
+
+}

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

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



Mime
View raw message