You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2006/11/02 01:45:46 UTC
svn commit: r470147 - in /maven/sandbox/maven-common-artifact-filters: ./
src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/maven/ src/main/java/org/apache/maven/shared/
src/main/java/org/apache/maven/s...
Author: jdcasey
Date: Wed Nov 1 16:45:43 2006
New Revision: 470147
URL: http://svn.apache.org/viewvc?view=rev&rev=470147
Log:
Adding common project for filters which have a broader use than just in the repository builder or the assembly plugin.
Added:
maven/sandbox/maven-common-artifact-filters/
maven/sandbox/maven-common-artifact-filters/pom.xml (with props)
maven/sandbox/maven-common-artifact-filters/src/
maven/sandbox/maven-common-artifact-filters/src/main/
maven/sandbox/maven-common-artifact-filters/src/main/java/
maven/sandbox/maven-common-artifact-filters/src/main/java/org/
maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/
maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/
maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/
maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/
maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/
maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilter.java (with props)
maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilter.java (with props)
maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilter.java (with props)
maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/StatisticsReportingArtifactFilter.java (with props)
maven/sandbox/maven-common-artifact-filters/src/test/
maven/sandbox/maven-common-artifact-filters/src/test/java/
maven/sandbox/maven-common-artifact-filters/src/test/java/org/
maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/
maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/
maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/
maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/
maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/
maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternArtifactFilterTCK.java (with props)
maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilterTest.java (with props)
maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilterTest.java (with props)
maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilterTest.java (with props)
Added: maven/sandbox/maven-common-artifact-filters/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-common-artifact-filters/pom.xml?view=auto&rev=470147
==============================================================================
--- maven/sandbox/maven-common-artifact-filters/pom.xml (added)
+++ maven/sandbox/maven-common-artifact-filters/pom.xml Wed Nov 1 16:45:43 2006
@@ -0,0 +1,50 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-shared-components</artifactId>
+ <version>4-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>maven-common-artifact-filters</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <name>Maven Common Artifact Filters</name>
+
+ <prerequisites>
+ <maven>2.0.2</maven>
+ </prerequisites>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>2.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ <version>1.0-alpha-9</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-test-tools</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>1.2_Java1.3</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Propchange: maven/sandbox/maven-common-artifact-filters/pom.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilter.java
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilter.java?view=auto&rev=470147
==============================================================================
--- maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilter.java (added)
+++ maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilter.java Wed Nov 1 16:45:43 2006
@@ -0,0 +1,63 @@
+package org.apache.maven.shared.artifact.filter;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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 java.util.List;
+
+/**
+ * TODO: include in maven-artifact in future
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class PatternExcludesArtifactFilter
+ extends PatternIncludesArtifactFilter
+{
+ public PatternExcludesArtifactFilter( List patterns )
+ {
+ super( patterns );
+ }
+
+ public PatternExcludesArtifactFilter( List patterns, boolean actTransitively )
+ {
+ super( patterns, actTransitively );
+ }
+
+ public boolean include( Artifact artifact )
+ {
+ boolean shouldInclude = !patternMatches( artifact );
+
+ if ( !shouldInclude )
+ {
+ addFilteredArtifactId( artifact.getId() );
+ }
+
+ return shouldInclude;
+ }
+
+ protected String getFilterDescription()
+ {
+ return "artifact exclusion filter";
+ }
+
+ public String toString()
+ {
+ return "Excludes filter:" + getPatternsAsString();
+ }
+
+}
Propchange: maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilter.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilter.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilter.java
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilter.java?view=auto&rev=470147
==============================================================================
--- maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilter.java (added)
+++ maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilter.java Wed Nov 1 16:45:43 2006
@@ -0,0 +1,313 @@
+package org.apache.maven.shared.artifact.filter;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.ArtifactUtils;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * TODO: include in maven-artifact in future
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class PatternIncludesArtifactFilter
+ implements ArtifactFilter, StatisticsReportingArtifactFilter
+{
+ private final List positivePatterns;
+ private final List negativePatterns;
+ private final boolean actTransitively;
+
+ private Set patternsTriggered = new HashSet();
+ private List filteredArtifactIds = new ArrayList();
+
+ public PatternIncludesArtifactFilter( List patterns )
+ {
+ this( patterns, false );
+ }
+
+ public PatternIncludesArtifactFilter( List patterns, boolean actTransitively )
+ {
+ this.actTransitively = actTransitively;
+ List pos = new ArrayList();
+ List neg = new ArrayList();
+ if ( patterns != null && !patterns.isEmpty() )
+ {
+ for ( Iterator it = patterns.iterator(); it.hasNext(); )
+ {
+ String pattern = (String) it.next();
+
+ if ( pattern.startsWith( "!" ) )
+ {
+ neg.add( pattern.substring( 1 ) );
+ }
+ else
+ {
+ pos.add( pattern );
+ }
+ }
+ }
+
+ this.positivePatterns = pos;
+ this.negativePatterns = neg;
+ }
+
+ public boolean include( Artifact artifact )
+ {
+ boolean shouldInclude = patternMatches( artifact );
+
+ if ( !shouldInclude )
+ {
+ addFilteredArtifactId( artifact.getId() );
+ }
+
+ return shouldInclude;
+ }
+
+ protected boolean patternMatches( Artifact artifact )
+ {
+ return positiveMatch( artifact ) == Boolean.TRUE || negativeMatch( artifact ) == Boolean.FALSE;
+ }
+
+ protected void addFilteredArtifactId( String artifactId )
+ {
+ filteredArtifactIds.add( artifactId );
+ }
+
+ private Boolean negativeMatch( Artifact artifact )
+ {
+ if ( negativePatterns == null || negativePatterns.isEmpty() )
+ {
+ return null;
+ }
+ else
+ {
+ return Boolean.valueOf( match( artifact, negativePatterns ) );
+ }
+ }
+
+ protected Boolean positiveMatch( Artifact artifact )
+ {
+ if ( positivePatterns == null || positivePatterns.isEmpty() )
+ {
+ return null;
+ }
+ else
+ {
+ return Boolean.valueOf( match( artifact, positivePatterns ) );
+ }
+ }
+
+ private boolean match( Artifact artifact, List patterns )
+ {
+ String shortId = ArtifactUtils.versionlessKey( artifact );
+ String id = artifact.getDependencyConflictId();
+ String wholeId = artifact.getId();
+
+ if ( matchAgainst( wholeId, patterns, false ) )
+ {
+ return true;
+ }
+
+ if ( matchAgainst( id, patterns, false ) )
+ {
+ return true;
+ }
+
+ if ( matchAgainst( shortId, patterns, false ) )
+ {
+ return true;
+ }
+
+ if ( actTransitively )
+ {
+ List depTrail = artifact.getDependencyTrail();
+
+ if ( depTrail != null && !depTrail.isEmpty() )
+ {
+ String trailStr = "," + StringUtils.join( depTrail.iterator(), "," );
+
+ return matchAgainst( trailStr, patterns, true );
+ }
+ }
+
+ return false;
+ }
+
+ private boolean matchAgainst( String value, List patterns, boolean regionMatch )
+ {
+ for ( Iterator i = patterns.iterator(); i.hasNext(); )
+ {
+ // TODO: what about wildcards? Just specifying groups? versions?
+ String pattern = (String) i.next();
+
+ // don't allow wildcards in region-matched searches...i.e. in transitive dependencies.
+ if ( regionMatch && pattern.indexOf( '*' ) > -1 )
+ {
+ continue;
+ }
+
+ if ( regionMatch )
+ {
+ if ( value.indexOf( pattern ) > -1 )
+ {
+ patternsTriggered.add( pattern );
+ return true;
+ }
+ }
+ else
+ {
+ if ( value.equals( pattern ) )
+ {
+ patternsTriggered.add( pattern );
+ return true;
+ }
+ }
+
+ if ( pattern.indexOf( '*' ) > -1 )
+ {
+ String[] subPatterns = pattern.split( "\\*" );
+ int[] idxes = new int[subPatterns.length];
+
+ for ( int j = 0; j < subPatterns.length; j++ )
+ {
+ String subPattern = subPatterns[j];
+
+ if ( subPattern == null || subPattern.length() < 1 )
+ {
+ idxes[j] = j == 0 ? 0 : idxes[j-1];
+
+ continue;
+ }
+
+ int lastIdx = j == 0 ? 0 : idxes[j-1];
+
+ idxes[j] = value.indexOf( subPattern, lastIdx );
+
+ if ( idxes[j] < 0 )
+ {
+ return false;
+ }
+ }
+
+ patternsTriggered.add( pattern );
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public void reportMissedCriteria( Logger logger )
+ {
+ // if there are no patterns, there is nothing to report.
+ if ( !positivePatterns.isEmpty() || !negativePatterns.isEmpty() )
+ {
+ List missed = new ArrayList();
+ missed.addAll( positivePatterns );
+ missed.addAll( negativePatterns );
+
+ missed.removeAll( patternsTriggered );
+
+ if ( !missed.isEmpty() && logger.isWarnEnabled() )
+ {
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append( "The following patterns were never triggered in this " );
+ buffer.append( getFilterDescription() );
+ buffer.append( ':' );
+
+ for ( Iterator it = missed.iterator(); it.hasNext(); )
+ {
+ String pattern = (String) it.next();
+
+ buffer.append( "\no \'" ).append( pattern ).append( "\'" );
+ }
+
+ buffer.append( "\n" );
+
+ logger.warn( buffer.toString() );
+ }
+ }
+ }
+
+ public String toString()
+ {
+ return "Includes filter:" + getPatternsAsString();
+ }
+
+ protected String getPatternsAsString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ for ( Iterator it = positivePatterns.iterator(); it.hasNext(); )
+ {
+ String pattern = ( String ) it.next();
+
+ buffer.append( "\no \'" ).append( pattern ).append( "\'" );
+ }
+
+ return buffer.toString();
+ }
+
+ protected String getFilterDescription()
+ {
+ return "artifact inclusion filter";
+ }
+
+ public void reportFilteredArtifacts( Logger logger )
+ {
+ if ( !filteredArtifactIds.isEmpty() && logger.isDebugEnabled() )
+ {
+ StringBuffer buffer = new StringBuffer( "The following artifacts were removed by this " + getFilterDescription() + ": " );
+
+ for ( Iterator it = filteredArtifactIds.iterator(); it.hasNext(); )
+ {
+ String artifactId = ( String ) it.next();
+
+ buffer.append( '\n' ).append( artifactId );
+ }
+
+ logger.debug( buffer.toString() );
+ }
+ }
+
+ public boolean hasMissedCriteria()
+ {
+ // if there are no patterns, there is nothing to report.
+ if ( !positivePatterns.isEmpty() || !negativePatterns.isEmpty() )
+ {
+ List missed = new ArrayList();
+ missed.addAll( positivePatterns );
+ missed.addAll( negativePatterns );
+
+ missed.removeAll( patternsTriggered );
+
+ return !missed.isEmpty();
+ }
+
+ return false;
+ }
+
+}
Propchange: maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilter.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilter.java
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilter.java?view=auto&rev=470147
==============================================================================
--- maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilter.java (added)
+++ maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilter.java Wed Nov 1 16:45:43 2006
@@ -0,0 +1,236 @@
+package org.apache.maven.shared.artifact.filter;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.DefaultArtifact;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.codehaus.plexus.logging.Logger;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * TODO: include in maven-artifact in future
+ */
+public class ScopeArtifactFilter
+ implements ArtifactFilter, StatisticsReportingArtifactFilter
+{
+ private final boolean compileScope;
+
+ private final boolean runtimeScope;
+
+ private final boolean testScope;
+
+ private final boolean providedScope;
+
+ private final boolean systemScope;
+
+ private boolean compileScopeHit = false;
+
+ private boolean runtimeScopeHit = false;
+
+ private boolean testScopeHit = false;
+
+ private boolean providedScopeHit = false;
+
+ private boolean systemScopeHit = false;
+
+ private List filteredArtifactIds = new ArrayList();
+
+ public ScopeArtifactFilter( String scope )
+ {
+ if ( DefaultArtifact.SCOPE_COMPILE.equals( scope ) )
+ {
+ systemScope = true;
+ providedScope = true;
+ compileScope = true;
+ runtimeScope = false;
+ testScope = false;
+ }
+ else if ( DefaultArtifact.SCOPE_RUNTIME.equals( scope ) )
+ {
+ systemScope = false;
+ providedScope = false;
+ compileScope = true;
+ runtimeScope = true;
+ testScope = false;
+ }
+ else if ( DefaultArtifact.SCOPE_TEST.equals( scope ) )
+ {
+ systemScope = true;
+ providedScope = true;
+ compileScope = true;
+ runtimeScope = true;
+ testScope = true;
+ }
+ else if ( DefaultArtifact.SCOPE_PROVIDED.equals( scope ) )
+ {
+ systemScope = false;
+ providedScope = true;
+ compileScope = false;
+ runtimeScope = false;
+ testScope = false;
+ }
+ else if ( DefaultArtifact.SCOPE_SYSTEM.equals( scope ) )
+ {
+ systemScope = true;
+ providedScope = false;
+ compileScope = false;
+ runtimeScope = false;
+ testScope = false;
+ }
+ else
+ {
+ systemScope = false;
+ providedScope = false;
+ compileScope = false;
+ runtimeScope = false;
+ testScope = false;
+ }
+ }
+
+ public boolean include( Artifact artifact )
+ {
+ boolean result = true;
+
+ if ( Artifact.SCOPE_COMPILE.equals( artifact.getScope() ) )
+ {
+ compileScopeHit = true;
+ result = compileScope;
+ }
+ else if ( Artifact.SCOPE_RUNTIME.equals( artifact.getScope() ) )
+ {
+ runtimeScopeHit = true;
+ result = runtimeScope;
+ }
+ else if ( Artifact.SCOPE_TEST.equals( artifact.getScope() ) )
+ {
+ testScopeHit = true;
+ result = testScope;
+ }
+ else if ( Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ) )
+ {
+ providedScopeHit = true;
+ result = providedScope;
+ }
+ else if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) )
+ {
+ systemScopeHit = true;
+ result = systemScope;
+ }
+
+ if ( !result )
+ {
+ filteredArtifactIds.add( artifact.getId() );
+ }
+
+ return result;
+ }
+
+ public String toString()
+ {
+ return "Scope filter [compile=" + compileScope + ", runtime=" + runtimeScope + ", test=" + testScope
+ + ", provided=" + providedScope + ", system=" + systemScope + "]";
+ }
+
+ public void reportFilteredArtifacts( Logger logger )
+ {
+ if ( !filteredArtifactIds.isEmpty() && logger.isDebugEnabled() )
+ {
+ StringBuffer buffer = new StringBuffer( "The following artifacts were removed by this filter: " );
+
+ for ( Iterator it = filteredArtifactIds.iterator(); it.hasNext(); )
+ {
+ String artifactId = ( String ) it.next();
+
+ buffer.append( '\n' ).append( artifactId );
+ }
+
+ logger.debug( buffer.toString() );
+ }
+ }
+
+ public void reportMissedCriteria( Logger logger )
+ {
+ if ( logger.isDebugEnabled() )
+ {
+ StringBuffer buffer = new StringBuffer();
+
+ boolean report = false;
+ if ( !compileScopeHit )
+ {
+ buffer.append( "\no Compile" );
+ report = true;
+ }
+ if ( !runtimeScopeHit )
+ {
+ buffer.append( "\no Runtime" );
+ report = true;
+ }
+ if ( !testScopeHit )
+ {
+ buffer.append( "\no Test" );
+ report = true;
+ }
+ if ( !providedScopeHit )
+ {
+ buffer.append( "\no Provided" );
+ report = true;
+ }
+ if ( !systemScopeHit )
+ {
+ buffer.append( "\no System" );
+ report = true;
+ }
+
+ if ( report )
+ {
+ logger.debug( "The following scope filters were not used: " + buffer.toString() );
+ }
+ }
+ }
+
+ public boolean hasMissedCriteria()
+ {
+ boolean report = false;
+
+ if ( !compileScopeHit )
+ {
+ report = true;
+ }
+ if ( !runtimeScopeHit )
+ {
+ report = true;
+ }
+ if ( !testScopeHit )
+ {
+ report = true;
+ }
+ if ( !providedScopeHit )
+ {
+ report = true;
+ }
+ if ( !systemScopeHit )
+ {
+ report = true;
+ }
+
+ return report;
+ }
+}
Propchange: maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilter.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/StatisticsReportingArtifactFilter.java
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/StatisticsReportingArtifactFilter.java?view=auto&rev=470147
==============================================================================
--- maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/StatisticsReportingArtifactFilter.java (added)
+++ maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/StatisticsReportingArtifactFilter.java Wed Nov 1 16:45:43 2006
@@ -0,0 +1,14 @@
+package org.apache.maven.shared.artifact.filter;
+
+import org.codehaus.plexus.logging.Logger;
+
+public interface StatisticsReportingArtifactFilter
+{
+
+ void reportMissedCriteria( Logger logger );
+
+ void reportFilteredArtifacts( Logger logger );
+
+ boolean hasMissedCriteria();
+
+}
Propchange: maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/StatisticsReportingArtifactFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/StatisticsReportingArtifactFilter.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: maven/sandbox/maven-common-artifact-filters/src/main/java/org/apache/maven/shared/artifact/filter/StatisticsReportingArtifactFilter.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternArtifactFilterTCK.java
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternArtifactFilterTCK.java?view=auto&rev=470147
==============================================================================
--- maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternArtifactFilterTCK.java (added)
+++ maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternArtifactFilterTCK.java Wed Nov 1 16:45:43 2006
@@ -0,0 +1,405 @@
+package org.apache.maven.shared.artifact.filter;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.shared.tools.easymock.MockManager;
+import org.easymock.MockControl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+
+public abstract class PatternArtifactFilterTCK
+ extends TestCase
+{
+
+ private MockManager mockManager = new MockManager();
+
+ protected abstract ArtifactFilter createFilter( List patterns );
+
+ protected abstract ArtifactFilter createFilter( List patterns, boolean actTransitively );
+
+ public void testShouldIncludeDirectlyMatchedArtifactByGroupIdArtifactId(boolean reverse)
+ {
+ String groupId = "group";
+ String artifactId = "artifact";
+
+ ArtifactMockAndControl mac = new ArtifactMockAndControl( groupId, artifactId );
+
+ mockManager.replayAll();
+
+ ArtifactFilter filter = createFilter( Collections.singletonList( groupId + ":" + artifactId ) );
+
+ if ( reverse )
+ {
+ assertFalse( filter.include( mac.artifact ) );
+ }
+ else
+ {
+ assertTrue( filter.include( mac.artifact ) );
+ }
+
+ mockManager.verifyAll();
+ }
+
+ public void testShouldIncludeDirectlyMatchedArtifactByDependencyConflictId(boolean reverse)
+ {
+ String groupId = "group";
+ String artifactId = "artifact";
+
+ ArtifactMockAndControl mac = new ArtifactMockAndControl( groupId, artifactId );
+
+ mockManager.replayAll();
+
+ ArtifactFilter filter = createFilter( Collections.singletonList( groupId + ":" + artifactId + ":jar" ) );
+
+ if ( reverse )
+ {
+ assertFalse( filter.include( mac.artifact ) );
+ }
+ else
+ {
+ assertTrue( filter.include( mac.artifact ) );
+ }
+
+ mockManager.verifyAll();
+ }
+
+ public void testShouldNotIncludeWhenGroupIdDiffers(boolean reverse)
+ {
+ String groupId = "group";
+ String artifactId = "artifact";
+
+ ArtifactMockAndControl mac = new ArtifactMockAndControl( groupId, artifactId );
+
+ mockManager.replayAll();
+ List patterns = new ArrayList();
+
+
+ patterns.add( "otherGroup:" + artifactId + ":jar" );
+ patterns.add( "otherGroup:" + artifactId );
+
+ ArtifactFilter filter = createFilter( patterns );
+
+ if ( reverse )
+ {
+ assertTrue( filter.include( mac.artifact ) );
+ }
+ else
+ {
+ assertFalse( filter.include( mac.artifact ) );
+ }
+
+ mockManager.verifyAll();
+ }
+
+ public void testShouldNotIncludeWhenArtifactIdDiffers(boolean reverse)
+ {
+ String groupId = "group";
+ String artifactId = "artifact";
+
+ ArtifactMockAndControl mac = new ArtifactMockAndControl( groupId, artifactId );
+
+ mockManager.replayAll();
+
+ List patterns = new ArrayList();
+
+ patterns.add( groupId + "otherArtifact:jar" );
+ patterns.add( groupId + "otherArtifact" );
+
+ ArtifactFilter filter = createFilter( patterns );
+
+ if ( reverse )
+ {
+ assertTrue( filter.include( mac.artifact ) );
+ }
+ else
+ {
+ assertFalse( filter.include( mac.artifact ) );
+ }
+
+ mockManager.verifyAll();
+ }
+
+ public void testShouldNotIncludeWhenBothIdElementsDiffer(boolean reverse)
+ {
+ String groupId = "group";
+ String artifactId = "artifact";
+
+ ArtifactMockAndControl mac = new ArtifactMockAndControl( groupId, artifactId );
+
+ mockManager.replayAll();
+
+ List patterns = new ArrayList();
+
+ patterns.add( "otherGroup:otherArtifact:jar" );
+ patterns.add( "otherGroup:otherArtifact" );
+
+ ArtifactFilter filter = createFilter( patterns );
+
+ if ( reverse )
+ {
+ assertTrue( filter.include( mac.artifact ) );
+ }
+ else
+ {
+ assertFalse( filter.include( mac.artifact ) );
+ }
+
+ mockManager.verifyAll();
+ }
+
+ public void testShouldIncludeWhenPatternMatchesDependencyTrailAndTransitivityIsEnabled(boolean reverse)
+ {
+ String groupId = "group";
+ String artifactId = "artifact";
+
+ String depTrailItem = "otherGroup:otherArtifact";
+ List depTrail = Collections.singletonList( depTrailItem + ":jar:1.0" );
+ List patterns = Collections.singletonList( depTrailItem );
+
+ ArtifactMockAndControl mac = new ArtifactMockAndControl( groupId, artifactId, depTrail );
+
+ mockManager.replayAll();
+
+ ArtifactFilter filter = createFilter( patterns, true );
+
+ if ( reverse )
+ {
+ assertFalse( filter.include( mac.artifact ) );
+ }
+ else
+ {
+ assertTrue( filter.include( mac.artifact ) );
+ }
+
+ mockManager.verifyAll();
+ }
+
+ public void testShouldNotIncludeWhenNegativeMatch( boolean reverse )
+ {
+ String groupId = "group";
+ String artifactId = "artifact";
+
+ ArtifactMockAndControl mac = new ArtifactMockAndControl( groupId, artifactId );
+
+ mockManager.replayAll();
+
+ List patterns = new ArrayList();
+
+ patterns.add( "!group:artifact:jar" );
+
+ ArtifactFilter filter = createFilter( patterns );
+
+ if ( reverse )
+ {
+ assertTrue( filter.include( mac.artifact ) );
+ }
+ else
+ {
+ assertFalse( filter.include( mac.artifact ) );
+ }
+
+ mockManager.verifyAll();
+ }
+
+ public void testShouldIncludeWhenWildcardMatchesInsideSequence( boolean reverse )
+ {
+ String groupId = "group";
+ String artifactId = "artifact";
+
+ ArtifactMockAndControl mac = new ArtifactMockAndControl( groupId, artifactId );
+
+ mockManager.replayAll();
+
+ List patterns = new ArrayList();
+
+ patterns.add( "group:*:jar" );
+
+ ArtifactFilter filter = createFilter( patterns );
+
+ if ( reverse )
+ {
+ assertFalse( filter.include( mac.artifact ) );
+ }
+ else
+ {
+ assertTrue( filter.include( mac.artifact ) );
+ }
+
+ mockManager.verifyAll();
+ }
+
+ public void testShouldIncludeWhenWildcardMatchesOutsideSequence( boolean reverse )
+ {
+ String groupId = "group";
+ String artifactId = "artifact";
+
+ ArtifactMockAndControl mac = new ArtifactMockAndControl( groupId, artifactId );
+
+ mockManager.replayAll();
+
+ List patterns = new ArrayList();
+
+ patterns.add( "*:artifact:*" );
+
+ ArtifactFilter filter = createFilter( patterns );
+
+ if ( reverse )
+ {
+ assertFalse( filter.include( mac.artifact ) );
+ }
+ else
+ {
+ assertTrue( filter.include( mac.artifact ) );
+ }
+
+ mockManager.verifyAll();
+ }
+
+ public void testShouldIncludeTransitiveDependencyWhenWildcardMatchesButDoesntMatchParent(boolean reverse)
+ {
+ String groupId = "group";
+ String artifactId = "artifact";
+
+ String otherGroup = "otherGroup";
+ String otherArtifact = "otherArtifact";
+ String otherType = "ejb";
+
+ String depTrailItem = otherGroup + ":" + otherArtifact + ":" + otherType + ":version";
+ List depTrail = Collections.singletonList( depTrailItem );
+ List patterns = Collections.singletonList( "*:jar:*" );
+
+ ArtifactMockAndControl mac = new ArtifactMockAndControl( groupId, artifactId, "jar", depTrail );
+ ArtifactMockAndControl otherMac = new ArtifactMockAndControl( otherGroup, otherArtifact, otherType, Collections.EMPTY_LIST );
+
+ mockManager.replayAll();
+
+ ArtifactFilter filter = createFilter( patterns, true );
+
+ if ( reverse )
+ {
+ assertTrue( filter.include( otherMac.artifact ) );
+ assertFalse( filter.include( mac.artifact ) );
+ }
+ else
+ {
+ assertFalse( filter.include( otherMac.artifact ) );
+ assertTrue( filter.include( mac.artifact ) );
+ }
+
+ mockManager.verifyAll();
+ }
+
+ public void testShouldIncludeDirectDependencyWhenInvertedWildcardMatchesButDoesntMatchTransitiveChild(boolean reverse)
+ {
+ String groupId = "group";
+ String artifactId = "artifact";
+
+ String otherGroup = "otherGroup";
+ String otherArtifact = "otherArtifact";
+ String otherType = "ejb";
+
+ String depTrailItem = otherGroup + ":" + otherArtifact + ":" + otherType + ":version";
+ List depTrail = Collections.singletonList( depTrailItem );
+ List patterns = Collections.singletonList( "!*:ejb:*" );
+
+ ArtifactMockAndControl mac = new ArtifactMockAndControl( groupId, artifactId, "jar", depTrail );
+ ArtifactMockAndControl otherMac = new ArtifactMockAndControl( otherGroup, otherArtifact, otherType, null );
+
+ mockManager.replayAll();
+
+ ArtifactFilter filter = createFilter( patterns, true );
+
+ if ( reverse )
+ {
+ assertTrue( filter.include( otherMac.artifact ) );
+ assertFalse( filter.include( mac.artifact ) );
+ }
+ else
+ {
+ assertFalse( filter.include( otherMac.artifact ) );
+ assertTrue( filter.include( mac.artifact ) );
+ }
+
+ mockManager.verifyAll();
+ }
+
+ private final class ArtifactMockAndControl
+ {
+ MockControl control;
+ Artifact artifact;
+ String groupId;
+ String artifactId;
+ List dependencyTrail;
+ String type;
+
+ ArtifactMockAndControl( String groupId, String artifactId, List depTrail )
+ {
+ this( groupId, artifactId, "jar", depTrail );
+ }
+
+ ArtifactMockAndControl( String groupId, String artifactId, String type, List dependencyTrail )
+ {
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.dependencyTrail = dependencyTrail;
+ this.type = type;
+
+ control = MockControl.createControl( Artifact.class );
+ mockManager.add( control );
+
+ artifact = (Artifact) control.getMock();
+
+ enableGetDependencyConflictId();
+ enableGetGroupIdAndArtifactId();
+ enableGetId();
+
+ if ( dependencyTrail != null )
+ {
+ enableGetDependencyTrail();
+ }
+ }
+
+ public ArtifactMockAndControl( String groupId, String artifactId )
+ {
+ this( groupId, artifactId, "jar", null );
+ }
+
+ public ArtifactMockAndControl( String groupId, String artifactId, String type )
+ {
+ this( groupId, artifactId, type, null );
+ }
+
+ void enableGetId()
+ {
+ artifact.getId();
+ control.setReturnValue( groupId + ":" + artifactId + ":" + type + ":version", MockControl.ZERO_OR_MORE );
+ }
+
+ void enableGetDependencyTrail()
+ {
+ artifact.getDependencyTrail();
+ control.setReturnValue( dependencyTrail, MockControl.ZERO_OR_MORE );
+ }
+
+ void enableGetDependencyConflictId()
+ {
+ artifact.getDependencyConflictId();
+ control.setReturnValue( groupId + ":" + artifactId + ":" + type, MockControl.ONE_OR_MORE );
+ }
+
+ void enableGetGroupIdAndArtifactId()
+ {
+ artifact.getGroupId();
+ control.setReturnValue( groupId, MockControl.ONE_OR_MORE );
+
+ artifact.getArtifactId();
+ control.setReturnValue( artifactId, MockControl.ONE_OR_MORE );
+ }
+ }
+
+}
Propchange: maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternArtifactFilterTCK.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternArtifactFilterTCK.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilterTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilterTest.java?view=auto&rev=470147
==============================================================================
--- maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilterTest.java (added)
+++ maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilterTest.java Wed Nov 1 16:45:43 2006
@@ -0,0 +1,84 @@
+package org.apache.maven.shared.artifact.filter;
+
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.shared.artifact.filter.PatternExcludesArtifactFilter;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+
+public class PatternExcludesArtifactFilterTest
+ extends TestCase
+{
+
+ private PatternArtifactFilterTCK tck = new PatternArtifactFilterTCK()
+ {
+
+ protected ArtifactFilter createFilter( List patterns )
+ {
+ return new PatternExcludesArtifactFilter( patterns );
+ }
+
+ protected ArtifactFilter createFilter( List patterns, boolean actTransitively )
+ {
+ return new PatternExcludesArtifactFilter( patterns, actTransitively );
+ }
+
+ };
+
+ public void testShouldNotIncludeDirectlyMatchedArtifactByDependencyConflictId()
+ {
+ tck.testShouldIncludeDirectlyMatchedArtifactByDependencyConflictId( true );
+ }
+
+ public void testShouldNotIncludeDirectlyMatchedArtifactByGroupIdArtifactId()
+ {
+ tck.testShouldIncludeDirectlyMatchedArtifactByGroupIdArtifactId( true );
+ }
+
+ public void testShouldNotIncludeWhenPatternMatchesDependencyTrailAndTransitivityIsEnabled()
+ {
+ tck.testShouldIncludeWhenPatternMatchesDependencyTrailAndTransitivityIsEnabled( true );
+ }
+
+ public void testShouldIncludeWhenArtifactIdDiffers()
+ {
+ tck.testShouldNotIncludeWhenArtifactIdDiffers( true );
+ }
+
+ public void testShouldIncludeWhenBothIdElementsDiffer()
+ {
+ tck.testShouldNotIncludeWhenBothIdElementsDiffer( true );
+ }
+
+ public void testShouldIncludeWhenGroupIdDiffers()
+ {
+ tck.testShouldNotIncludeWhenGroupIdDiffers( true );
+ }
+
+ public void testShouldIncludeWhenNegativeMatch()
+ {
+ tck.testShouldNotIncludeWhenNegativeMatch( true );
+ }
+
+ public void testShouldNotIncludeWhenWildcardMatchesInsideSequence()
+ {
+ tck.testShouldIncludeWhenWildcardMatchesInsideSequence( true );
+ }
+
+ public void testShouldIncludeWhenWildcardMatchesOutsideSequence()
+ {
+ tck.testShouldIncludeWhenWildcardMatchesOutsideSequence( true );
+ }
+
+ public void testShouldIncludeTransitiveDependencyWhenWildcardMatchesButDoesntMatchParent()
+ {
+ tck.testShouldIncludeTransitiveDependencyWhenWildcardMatchesButDoesntMatchParent( true );
+ }
+
+ public void testShouldIncludeDirectDependencyWhenInvertedWildcardMatchesButDoesntMatchTransitiveChild()
+ {
+ tck.testShouldIncludeDirectDependencyWhenInvertedWildcardMatchesButDoesntMatchTransitiveChild( true );
+ }
+}
Propchange: maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilterTest.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilterTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilterTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilterTest.java?view=auto&rev=470147
==============================================================================
--- maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilterTest.java (added)
+++ maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilterTest.java Wed Nov 1 16:45:43 2006
@@ -0,0 +1,83 @@
+package org.apache.maven.shared.artifact.filter;
+
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.shared.artifact.filter.PatternIncludesArtifactFilter;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+
+public class PatternIncludesArtifactFilterTest
+ extends TestCase
+{
+ private PatternArtifactFilterTCK tck = new PatternArtifactFilterTCK()
+ {
+
+ protected ArtifactFilter createFilter( List patterns )
+ {
+ return new PatternIncludesArtifactFilter( patterns );
+ }
+
+ protected ArtifactFilter createFilter( List patterns, boolean actTransitively )
+ {
+ return new PatternIncludesArtifactFilter( patterns, actTransitively );
+ }
+
+ };
+
+ public void testShouldIncludeDirectlyMatchedArtifactByDependencyConflictId()
+ {
+ tck.testShouldIncludeDirectlyMatchedArtifactByDependencyConflictId( false );
+ }
+
+ public void testShouldIncludeDirectlyMatchedArtifactByGroupIdArtifactId()
+ {
+ tck.testShouldIncludeDirectlyMatchedArtifactByGroupIdArtifactId( false );
+ }
+
+ public void testShouldIncludeWhenPatternMatchesDependencyTrailAndTransitivityIsEnabled()
+ {
+ tck.testShouldIncludeWhenPatternMatchesDependencyTrailAndTransitivityIsEnabled( false );
+ }
+
+ public void testShouldNotIncludeWhenArtifactIdDiffers()
+ {
+ tck.testShouldNotIncludeWhenArtifactIdDiffers( false );
+ }
+
+ public void testShouldNotIncludeWhenBothIdElementsDiffer()
+ {
+ tck.testShouldNotIncludeWhenBothIdElementsDiffer( false );
+ }
+
+ public void testShouldNotIncludeWhenGroupIdDiffers()
+ {
+ tck.testShouldNotIncludeWhenGroupIdDiffers( false );
+ }
+
+ public void testShouldNotIncludeWhenNegativeMatch()
+ {
+ tck.testShouldNotIncludeWhenNegativeMatch( false );
+ }
+
+ public void testShouldIncludeWhenWildcardMatchesInsideSequence()
+ {
+ tck.testShouldIncludeWhenWildcardMatchesInsideSequence( false );
+ }
+
+ public void testShouldIncludeWhenWildcardMatchesOutsideSequence()
+ {
+ tck.testShouldIncludeWhenWildcardMatchesOutsideSequence( false );
+ }
+
+ public void testShouldIncludeTransitiveDependencyWhenWildcardMatchesButDoesntMatchParent()
+ {
+ tck.testShouldIncludeTransitiveDependencyWhenWildcardMatchesButDoesntMatchParent( false );
+ }
+
+ public void testShouldIncludeDirectDependencyWhenInvertedWildcardMatchesButDoesntMatchTransitiveChild()
+ {
+ tck.testShouldIncludeDirectDependencyWhenInvertedWildcardMatchesButDoesntMatchTransitiveChild( false );
+ }
+}
Propchange: maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilterTest.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilterTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilterTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilterTest.java?view=auto&rev=470147
==============================================================================
--- maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilterTest.java (added)
+++ maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilterTest.java Wed Nov 1 16:45:43 2006
@@ -0,0 +1,159 @@
+package org.apache.maven.shared.artifact.filter;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.shared.artifact.filter.ScopeArtifactFilter;
+import org.apache.maven.shared.tools.easymock.MockManager;
+import org.easymock.MockControl;
+
+import junit.framework.TestCase;
+
+
+public class ScopeArtifactFilterTest
+ extends TestCase
+{
+
+ private MockManager mockManager = new MockManager();
+
+ public void testScopesShouldIncludeArtifactWithSameScope()
+ {
+ verifyIncluded( Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE );
+ verifyIncluded( Artifact.SCOPE_PROVIDED, Artifact.SCOPE_PROVIDED );
+ verifyIncluded( Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME );
+ verifyIncluded( Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM );
+ verifyIncluded( Artifact.SCOPE_TEST, Artifact.SCOPE_TEST );
+ verifyIncluded( null, null );
+ }
+
+ public void testCompileScopeShouldIncludeOnlyArtifactsWithNullSystemProvidedOrCompileScopes()
+ {
+ String scope = Artifact.SCOPE_COMPILE;
+
+ verifyIncluded( scope, null );
+ verifyIncluded( scope, Artifact.SCOPE_COMPILE );
+ verifyIncluded( scope, Artifact.SCOPE_PROVIDED );
+ verifyIncluded( scope, Artifact.SCOPE_SYSTEM );
+
+ verifyExcluded( scope, Artifact.SCOPE_RUNTIME );
+ verifyExcluded( scope, Artifact.SCOPE_TEST );
+ }
+
+ public void testRuntimeScopeShouldIncludeOnlyArtifactsWithNullRuntimeOrCompileScopes()
+ {
+ String scope = Artifact.SCOPE_RUNTIME;
+
+ verifyIncluded( scope, null );
+ verifyIncluded( scope, Artifact.SCOPE_COMPILE );
+ verifyIncluded( scope, Artifact.SCOPE_RUNTIME );
+
+ verifyExcluded( scope, Artifact.SCOPE_PROVIDED );
+ verifyExcluded( scope, Artifact.SCOPE_SYSTEM );
+ verifyExcluded( scope, Artifact.SCOPE_TEST );
+ }
+
+ public void testTestScopeShouldIncludeAllScopes()
+ {
+ String scope = Artifact.SCOPE_TEST;
+
+ verifyIncluded( scope, null );
+ verifyIncluded( scope, Artifact.SCOPE_COMPILE );
+ verifyIncluded( scope, Artifact.SCOPE_RUNTIME );
+
+ verifyIncluded( scope, Artifact.SCOPE_PROVIDED );
+ verifyIncluded( scope, Artifact.SCOPE_SYSTEM );
+ verifyIncluded( scope, Artifact.SCOPE_TEST );
+ }
+
+ public void testProvidedScopeShouldIncludeOnlyArtifactsWithNullOrProvidedScopes()
+ {
+ String scope = Artifact.SCOPE_PROVIDED;
+
+ verifyIncluded( scope, null );
+ verifyExcluded( scope, Artifact.SCOPE_COMPILE );
+ verifyExcluded( scope, Artifact.SCOPE_RUNTIME );
+
+ verifyIncluded( scope, Artifact.SCOPE_PROVIDED );
+
+ verifyExcluded( scope, Artifact.SCOPE_SYSTEM );
+ verifyExcluded( scope, Artifact.SCOPE_TEST );
+ }
+
+ public void testSystemScopeShouldIncludeOnlyArtifactsWithNullOrSystemScopes()
+ {
+ String scope = Artifact.SCOPE_SYSTEM;
+
+ verifyIncluded( scope, null );
+ verifyExcluded( scope, Artifact.SCOPE_COMPILE );
+ verifyExcluded( scope, Artifact.SCOPE_RUNTIME );
+ verifyExcluded( scope, Artifact.SCOPE_PROVIDED );
+
+ verifyIncluded( scope, Artifact.SCOPE_SYSTEM );
+
+ verifyExcluded( scope, Artifact.SCOPE_TEST );
+ }
+
+ private void verifyIncluded( String filterScope, String artifactScope )
+ {
+ ArtifactMockAndControl mac = new ArtifactMockAndControl( artifactScope );
+
+ mockManager.replayAll();
+
+ ArtifactFilter filter = new ScopeArtifactFilter( filterScope );
+
+ assertTrue( "Artifact scope: " + artifactScope + " NOT included using filter scope: " + filterScope, filter.include( mac.artifact ) );
+
+ mockManager.verifyAll();
+
+ // enable multiple calls to this method within a single test.
+ mockManager.clear();
+ }
+
+ private void verifyExcluded( String filterScope, String artifactScope )
+ {
+ ArtifactMockAndControl mac = new ArtifactMockAndControl( artifactScope );
+
+ mockManager.replayAll();
+
+ ArtifactFilter filter = new ScopeArtifactFilter( filterScope );
+
+ assertFalse( "Artifact scope: " + artifactScope + " NOT excluded using filter scope: " + filterScope, filter.include( mac.artifact ) );
+
+ mockManager.verifyAll();
+
+ // enable multiple calls to this method within a single test.
+ mockManager.clear();
+ }
+
+ private final class ArtifactMockAndControl
+ {
+ Artifact artifact;
+ MockControl control;
+ private final String scope;
+
+ ArtifactMockAndControl( String scope )
+ {
+ this.scope = scope;
+
+ control = MockControl.createControl( Artifact.class );
+ mockManager.add( control );
+
+ artifact = (Artifact) control.getMock();
+
+ enableGetScope();
+ enableGetId();
+ }
+
+ void enableGetScope()
+ {
+ artifact.getScope();
+ control.setReturnValue( scope, MockControl.ONE_OR_MORE );
+ }
+
+ void enableGetId()
+ {
+ artifact.getId();
+ control.setReturnValue( "group:artifact:type:version", MockControl.ZERO_OR_MORE );
+ }
+ }
+
+}
Propchange: maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilterTest.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: maven/sandbox/maven-common-artifact-filters/src/test/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilterTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"