Author: markh
Date: Tue Jun 19 04:11:13 2007
New Revision: 548691

URL: http://svn.apache.org/viewvc?view=rev&rev=548691
Log:
[MNG-2621] Add stricter pattern filters to maven-common-artifact-filters

o Added new stricter pattern filters
o Added @see to new filters from original pattern filters

Added:
    
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilter.java
   (with props)
    
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilter.java
   (with props)
    
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilter.java
   (with props)
    
maven/shared/trunk/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilterTest.java
   (with props)
    
maven/shared/trunk/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilterTest.java
   (with props)
    
maven/shared/trunk/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilterTest.java
   (with props)
Modified:
    
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilter.java
    
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilter.java

Added: 
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilter.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilter.java?view=auto&rev=548691
==============================================================================
--- 
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilter.java
 (added)
+++ 
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilter.java
 Tue Jun 19 04:11:13 2007
@@ -0,0 +1,178 @@
+package org.apache.maven.shared.artifact.filter;
+
+/*
+ * 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.artifact.Artifact;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Filter to include or exclude artifacts from a list of patterns. The 
artifact pattern syntax is of the form:
+ * 
+ * <pre>
+ * [groupId]:[artifactId]:[type]:[version]
+ * </pre>
+ * 
+ * <p>
+ * Where each pattern segment is optional and supports full and partial 
<code>*</code> wildcards. An empty pattern
+ * segment is treated as an implicit wildcard.
+ * </p>
+ * 
+ * <p>
+ * For example, <code>org.apache.*</code> would match all artifacts whose 
group id started with
+ * <code>org.apache.</code>, and <code>:::*-SNAPSHOT</code> would match all 
snapshot artifacts.
+ * </p>
+ * 
+ * @author <a href="mailto:[EMAIL PROTECTED]">Mark Hobson</a>
+ * @version $Id$
+ */
+public abstract class AbstractStrictPatternArtifactFilter implements 
ArtifactFilter
+{
+    // fields -----------------------------------------------------------------
+
+    /**
+     * The list of artifact patterns to match, as described above.
+     */
+    private final List patterns;
+
+    /**
+     * Whether this filter should include or exclude artifacts that match the 
patterns.
+     */
+    private final boolean include;
+
+    // constructors -----------------------------------------------------------
+
+    /**
+     * Creates a new filter that matches the specified artifact patterns and 
includes or excludes them according to the
+     * specified flag.
+     * 
+     * @param patterns
+     *            the list of artifact patterns to match, as described above
+     * @param include
+     *            <code>true</code> to include artifacts that match the 
patterns, or <code>false</code> to exclude
+     *            them
+     */
+    public AbstractStrictPatternArtifactFilter( List patterns, boolean include 
)
+    {
+        this.patterns = patterns;
+        this.include = include;
+    }
+
+    // ArtifactFilter methods -------------------------------------------------
+
+    /*
+     * @see 
org.apache.maven.artifact.resolver.filter.ArtifactFilter#include(org.apache.maven.artifact.Artifact)
+     */
+    public boolean include( Artifact artifact )
+    {
+        boolean matched = false;
+
+        for ( Iterator i = patterns.iterator(); i.hasNext() & !matched; )
+        {
+            String pattern = (String) i.next();
+
+            if ( include( artifact, pattern ) )
+            {
+                matched = true;
+            }
+        }
+
+        return include ? matched : !matched;
+    }
+
+    // private methods --------------------------------------------------------
+
+    /**
+     * Gets whether the specified artifact matches the specified pattern.
+     * 
+     * @param artifact
+     *            the artifact to check
+     * @param pattern
+     *            the pattern to match, as defined above
+     * @return <code>true</code> if the specified artifact is matched by the 
specified pattern
+     */
+    private boolean include( Artifact artifact, String pattern )
+    {
+        String[] tokens =
+            new String[] { artifact.getGroupId(), artifact.getArtifactId(), 
artifact.getType(), artifact.getVersion() };
+
+        String[] patternTokens = pattern.split( ":" );
+
+        // fail immediately if pattern tokens outnumber tokens to match
+        boolean matched = ( patternTokens.length <= tokens.length );
+
+        for ( int i = 0; matched && i < patternTokens.length; i++ )
+        {
+            matched = matches( tokens[i], patternTokens[i] );
+        }
+
+        return matched;
+    }
+
+    /**
+     * Gets whether the specified token matches the specified pattern segment.
+     * 
+     * @param token
+     *            the token to check
+     * @param pattern
+     *            the pattern segment to match, as defined above
+     * @return <code>true</code> if the specified token is matched by the 
specified pattern segment
+     */
+    private boolean matches( String token, String pattern )
+    {
+        boolean matches;
+
+        // support full wildcard and implied wildcard
+        if ( "*".equals( pattern ) || pattern.length() == 0 )
+        {
+            matches = true;
+        }
+        // support contains wildcard
+        else if ( pattern.startsWith( "*" ) && pattern.endsWith( "*" ) )
+        {
+            String contains = pattern.substring( 1, pattern.length() - 1 );
+
+            matches = ( token.indexOf( contains ) != -1 );
+        }
+        // support leading wildcard
+        else if ( pattern.startsWith( "*" ) )
+        {
+            String suffix = pattern.substring( 1, pattern.length() );
+
+            matches = token.endsWith( suffix );
+        }
+        // support trailing wildcard
+        else if ( pattern.endsWith( "*" ) )
+        {
+            String prefix = pattern.substring( 0, pattern.length() - 1 );
+
+            matches = token.startsWith( prefix );
+        }
+        // support exact match
+        else
+        {
+            matches = token.equals( pattern );
+        }
+
+        return matches;
+    }
+}

Propchange: 
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilter.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: 
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilter.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilter.java?view=diff&rev=548691&r1=548690&r2=548691
==============================================================================
--- 
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilter.java
 (original)
+++ 
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilter.java
 Tue Jun 19 04:11:13 2007
@@ -26,6 +26,7 @@
  * TODO: include in maven-artifact in future
  *
  * @author <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a>
+ * @see StrictPatternExcludesArtifactFilter
  */
 public class PatternExcludesArtifactFilter
     extends PatternIncludesArtifactFilter

Modified: 
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilter.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilter.java?view=diff&rev=548691&r1=548690&r2=548691
==============================================================================
--- 
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilter.java
 (original)
+++ 
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilter.java
 Tue Jun 19 04:11:13 2007
@@ -34,6 +34,7 @@
  * TODO: include in maven-artifact in future
  *
  * @author <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a>
+ * @see StrictPatternIncludesArtifactFilter
  */
 public class PatternIncludesArtifactFilter
     implements ArtifactFilter, StatisticsReportingArtifactFilter

Added: 
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilter.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilter.java?view=auto&rev=548691
==============================================================================
--- 
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilter.java
 (added)
+++ 
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilter.java
 Tue Jun 19 04:11:13 2007
@@ -0,0 +1,45 @@
+package org.apache.maven.shared.artifact.filter;
+
+/*
+ * 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.List;
+
+/**
+ * Filter to exclude artifacts from a list of patterns. 
<code>AbstractStrictPatternArtifactFilter</code> describes the
+ * artifact pattern syntax.
+ * 
+ * @author <a href="mailto:[EMAIL PROTECTED]">Mark Hobson</a>
+ * @version $Id$
+ * @see AbstractStrictPatternArtifactFilter
+ * @see PatternExcludesArtifactFilter
+ */
+public class StrictPatternExcludesArtifactFilter extends 
AbstractStrictPatternArtifactFilter
+{
+    /**
+     * Creates a new filter that excludes artifacts that match the specified 
patterns.
+     * 
+     * @param patterns
+     *            the list of artifact patterns to match, as described above
+     */
+    public StrictPatternExcludesArtifactFilter( List patterns )
+    {
+        super( patterns, false );
+    }
+}

Propchange: 
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilter.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: 
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilter.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilter.java?view=auto&rev=548691
==============================================================================
--- 
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilter.java
 (added)
+++ 
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilter.java
 Tue Jun 19 04:11:13 2007
@@ -0,0 +1,45 @@
+package org.apache.maven.shared.artifact.filter;
+
+/*
+ * 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.List;
+
+/**
+ * Filter to include artifacts from a list of patterns. 
<code>AbstractStrictPatternArtifactFilter</code> describes the
+ * artifact pattern syntax.
+ * 
+ * @author <a href="mailto:[EMAIL PROTECTED]">Mark Hobson</a>
+ * @version $Id$
+ * @see AbstractStrictPatternArtifactFilter
+ * @see PatternIncludesArtifactFilter
+ */
+public class StrictPatternIncludesArtifactFilter extends 
AbstractStrictPatternArtifactFilter
+{
+    /**
+     * Creates a new filter that includes artifacts that match the specified 
patterns.
+     * 
+     * @param patterns
+     *            the list of artifact patterns to match, as described above
+     */
+    public StrictPatternIncludesArtifactFilter( List patterns )
+    {
+        super( patterns, true );
+    }
+}

Propchange: 
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/shared/trunk/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilter.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: 
maven/shared/trunk/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilterTest.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilterTest.java?view=auto&rev=548691
==============================================================================
--- 
maven/shared/trunk/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilterTest.java
 (added)
+++ 
maven/shared/trunk/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilterTest.java
 Tue Jun 19 04:11:13 2007
@@ -0,0 +1,371 @@
+package org.apache.maven.shared.artifact.filter;
+
+/*
+ * 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.Collections;
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+import org.apache.maven.artifact.versioning.VersionRange;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+/**
+ * Tests subclasses of <code>AbstractStrictPatternArtifactFilter</code>.
+ * 
+ * @author <a href="mailto:[EMAIL PROTECTED]">Mark Hobson</a>
+ * @version $Id$
+ * @see AbstractStrictPatternArtifactFilter
+ */
+public abstract class AbstractStrictPatternArtifactFilterTest extends TestCase
+{
+    // fields -----------------------------------------------------------------
+
+    private Artifact artifact;
+
+    // TestCase methods -------------------------------------------------------
+
+    /*
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        VersionRange version = VersionRange.createFromVersion( "version" );
+        ArtifactHandler handler = new DefaultArtifactHandler();
+
+        artifact = new DefaultArtifact( "groupId", "artifactId", version, 
null, "type", null, handler );
+    }
+
+    // tests ------------------------------------------------------------------
+
+    public void testExactIncluded()
+    {
+        assertIncluded( "groupId:artifactId" );
+    }
+
+    public void testExactExcluded()
+    {
+        assertExcluded( "differentGroupId:differentArtifactId" );
+    }
+
+    public void testGroupIdIncluded()
+    {
+        assertIncluded( "groupId" );
+    }
+
+    public void testGroupIdExcluded()
+    {
+        assertExcluded( "differentGroupId" );
+    }
+
+    public void testGroupIdWildcardIncluded()
+    {
+        assertIncluded( "*" );
+    }
+
+    public void testGroupIdImplicitWildcardIncluded()
+    {
+        assertIncluded( "" );
+    }
+
+    public void testGroupIdStartsWithWildcardIncluded()
+    {
+        assertIncluded( "groupId*" );
+    }
+
+    public void testGroupIdStartsWithPartialWildcardIncluded()
+    {
+        assertIncluded( "group*" );
+    }
+
+    public void testGroupIdStartsWithWildcardExcluded()
+    {
+        assertExcluded( "different*" );
+    }
+
+    public void testGroupIdEndsWithWildcardIncluded()
+    {
+        assertIncluded( "*groupId" );
+    }
+
+    public void testGroupIdEndsWithPartialWildcardIncluded()
+    {
+        assertIncluded( "*Id" );
+    }
+
+    public void testGroupIdEndsWithWildcardExcluded()
+    {
+        assertExcluded( "*different" );
+    }
+
+    public void testGroupIdContainsWildcardIncluded()
+    {
+        assertIncluded( "*oup*" );
+    }
+
+    public void testGroupIdContainsWildcardExcluded()
+    {
+        assertExcluded( "*different*" );
+    }
+
+    public void testArtifactIdIncluded()
+    {
+        assertIncluded( ":artifactId" );
+    }
+
+    public void testArtifactIdExcluded()
+    {
+        assertExcluded( ":differentArtifactId" );
+    }
+
+    public void testArtifactIdWildcardIncluded()
+    {
+        assertIncluded( ":*" );
+    }
+
+    public void testArtifactIdImplicitWildcardIncluded()
+    {
+        assertIncluded( ":" );
+    }
+
+    public void testArtifactIdStartsWithWildcardIncluded()
+    {
+        assertIncluded( ":artifactId*" );
+    }
+
+    public void testArtifactIdStartsWithPartialWildcardIncluded()
+    {
+        assertIncluded( ":artifact*" );
+    }
+
+    public void testArtifactIdStartsWithWildcardExcluded()
+    {
+        assertExcluded( ":different*" );
+    }
+
+    public void testArtifactIdEndsWithWildcardIncluded()
+    {
+        assertIncluded( ":*artifactId" );
+    }
+
+    public void testArtifactIdEndsWithPartialWildcardIncluded()
+    {
+        assertIncluded( ":*Id" );
+    }
+
+    public void testArtifactIdEndsWithWildcardExcluded()
+    {
+        assertExcluded( ":*different" );
+    }
+
+    public void testArtifactIdContainsWildcardIncluded()
+    {
+        assertIncluded( ":*fact*" );
+    }
+
+    public void testArtifactIdContainsWildcardExcluded()
+    {
+        assertExcluded( ":*different*" );
+    }
+
+    public void testTypeIncluded()
+    {
+        assertIncluded( "::type" );
+    }
+
+    public void testTypeExcluded()
+    {
+        assertExcluded( "::differentType" );
+    }
+
+    public void testTypeWildcardIncluded()
+    {
+        assertIncluded( "::*" );
+    }
+
+    public void testTypeImplicitWildcardIncluded()
+    {
+        assertIncluded( "::" );
+    }
+
+    public void testTypeStartsWithWildcardIncluded()
+    {
+        assertIncluded( "::type*" );
+    }
+
+    public void testTypeStartsWithPartialWildcardIncluded()
+    {
+        assertIncluded( "::t*" );
+    }
+
+    public void testTypeStartsWithWildcardExcluded()
+    {
+        assertExcluded( "::different*" );
+    }
+
+    public void testTypeEndsWithWildcardIncluded()
+    {
+        assertIncluded( "::*type" );
+    }
+
+    public void testTypeEndsWithPartialWildcardIncluded()
+    {
+        assertIncluded( "::*e" );
+    }
+
+    public void testTypeEndsWithWildcardExcluded()
+    {
+        assertExcluded( "::*different" );
+    }
+
+    public void testTypeContainsWildcardIncluded()
+    {
+        assertIncluded( "::*yp*" );
+    }
+
+    public void testTypeContainsWildcardExcluded()
+    {
+        assertExcluded( "::*different*" );
+    }
+
+    public void testVersionIncluded()
+    {
+        assertIncluded( ":::version" );
+    }
+
+    public void testVersionExcluded()
+    {
+        assertExcluded( ":::differentVersion" );
+    }
+
+    public void testVersionWildcardIncluded()
+    {
+        assertIncluded( ":::*" );
+    }
+
+    public void testVersionImplicitWildcardIncluded()
+    {
+        assertIncluded( ":::" );
+    }
+
+    public void testVersionStartsWithWildcardIncluded()
+    {
+        assertIncluded( ":::version*" );
+    }
+
+    public void testVersionStartsWithPartialWildcardIncluded()
+    {
+        assertIncluded( ":::ver*" );
+    }
+
+    public void testVersionStartsWithWildcardExcluded()
+    {
+        assertExcluded( ":::different*" );
+    }
+
+    public void testVersionEndsWithWildcardIncluded()
+    {
+        assertIncluded( ":::*version" );
+    }
+
+    public void testVersionEndsWithPartialWildcardIncluded()
+    {
+        assertIncluded( ":::*ion" );
+    }
+
+    public void testVersionEndsWithWildcardExcluded()
+    {
+        assertExcluded( ":::*different" );
+    }
+
+    public void testVersionContainsWildcardIncluded()
+    {
+        assertIncluded( ":::*si*" );
+    }
+
+    public void testVersionContainsWildcardExcluded()
+    {
+        assertExcluded( ":::*different*" );
+    }
+
+    public void testComplex()
+    {
+        assertIncluded( "group*:*Id:*:version" );
+    }
+
+    // protected methods ------------------------------------------------------
+
+    /**
+     * Asserts that the specified pattern is included by the filter being 
tested.
+     * 
+     * @param pattern
+     *            the pattern to test for inclusion
+     * @throws AssertionFailedError
+     *             if the assertion fails
+     */
+    protected void assertIncluded( String pattern )
+    {
+        assertFilter( true, pattern );
+    }
+
+    /**
+     * Asserts that the specified pattern is excluded by the filter being 
tested.
+     * 
+     * @param pattern
+     *            the pattern to test for exclusion
+     * @throws AssertionFailedError
+     *             if the assertion fails
+     */
+    protected void assertExcluded( String pattern )
+    {
+        assertFilter( false, pattern );
+    }
+
+    /**
+     * Asserts that the filter being tested returns the specified result for 
the specified pattern.
+     * 
+     * @param expected
+     *            the result expected from the filter
+     * @param pattern
+     *            the pattern to test
+     * @throws AssertionFailedError
+     *             if the assertion fails
+     */
+    protected void assertFilter( boolean expected, String pattern )
+    {
+        List patterns = Collections.singletonList( pattern );
+        AbstractStrictPatternArtifactFilter filter = createFilter( patterns );
+
+        assertEquals( expected, filter.include( artifact ) );
+    }
+
+    /**
+     * Creates the strict pattern artifact filter to test for the specified 
patterns.
+     * 
+     * @param patterns
+     *            the list of artifact patterns that the filter should match
+     * @return the filter to test
+     */
+    protected abstract AbstractStrictPatternArtifactFilter createFilter( List 
patterns );
+}

Propchange: 
maven/shared/trunk/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/shared/trunk/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilterTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: 
maven/shared/trunk/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilterTest.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilterTest.java?view=auto&rev=548691
==============================================================================
--- 
maven/shared/trunk/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilterTest.java
 (added)
+++ 
maven/shared/trunk/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilterTest.java
 Tue Jun 19 04:11:13 2007
@@ -0,0 +1,51 @@
+package org.apache.maven.shared.artifact.filter;
+
+/*
+ * 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.List;
+
+/**
+ * Tests <code>StrictPatternExcludesArtifactFilter</code>.
+ * 
+ * @author <a href="mailto:[EMAIL PROTECTED]">Mark Hobson</a>
+ * @version $Id$
+ * @see StrictPatternExcludesArtifactFilter
+ */
+public class StrictPatternExcludesArtifactFilterTest extends 
AbstractStrictPatternArtifactFilterTest
+{
+    // AbstractStrictPatternArtifactFilterTest methods ------------------------
+
+    /*
+     * @see 
org.apache.maven.shared.artifact.filter.AbstractStrictPatternArtifactFilterTest#createFilter(java.util.List)
+     */
+    protected AbstractStrictPatternArtifactFilter createFilter( List patterns )
+    {
+        return new StrictPatternExcludesArtifactFilter( patterns );
+    }
+
+    /*
+     * @see 
org.apache.maven.shared.artifact.filter.AbstractStrictPatternArtifactFilterTest#assertFilter(boolean,
+     *      java.lang.String)
+     */
+    protected void assertFilter( boolean expected, String pattern )
+    {
+        super.assertFilter( !expected, pattern );
+    }
+}

Propchange: 
maven/shared/trunk/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/shared/trunk/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilterTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: 
maven/shared/trunk/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilterTest.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilterTest.java?view=auto&rev=548691
==============================================================================
--- 
maven/shared/trunk/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilterTest.java
 (added)
+++ 
maven/shared/trunk/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilterTest.java
 Tue Jun 19 04:11:13 2007
@@ -0,0 +1,42 @@
+package org.apache.maven.shared.artifact.filter;
+
+/*
+ * 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.List;
+
+/**
+ * Tests <code>StrictPatternIncludesArtifactFilter</code>.
+ * 
+ * @author <a href="mailto:[EMAIL PROTECTED]">Mark Hobson</a>
+ * @version $Id$
+ * @see StrictPatternIncludesArtifactFilter
+ */
+public class StrictPatternIncludesArtifactFilterTest extends 
AbstractStrictPatternArtifactFilterTest
+{
+    // AbstractStrictPatternArtifactFilterTest methods ------------------------
+
+    /*
+     * @see 
org.apache.maven.shared.artifact.filter.AbstractStrictPatternArtifactFilterTest#createFilter(java.util.List)
+     */
+    protected AbstractStrictPatternArtifactFilter createFilter( List patterns )
+    {
+        return new StrictPatternIncludesArtifactFilter( patterns );
+    }
+}

Propchange: 
maven/shared/trunk/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/shared/trunk/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilterTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"


Reply via email to