Simplify TCK usage, and add test to cover case where artifact pattern doesn't have segments (i.e. org.something*)
git-svn-id: https://svn.apache.org/repos/asf/maven/shared/trunk@1164295 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/PatternArtifactFilterTCK.java b/src/test/java/org/apache/maven/shared/artifact/filter/PatternArtifactFilterTCK.java
index 68c0155..13e56e8 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/PatternArtifactFilterTCK.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/PatternArtifactFilterTCK.java
@@ -40,7 +40,9 @@
protected abstract ArtifactFilter createFilter( List patterns, boolean actTransitively );
- public void testShouldTriggerBothPatternsWithWildcards( final boolean reverse )
+ protected abstract boolean isInclusionExpected();
+
+ public void testShouldTriggerBothPatternsWithWildcards()
{
final String groupId1 = "group";
final String artifactId1 = "artifact";
@@ -59,7 +61,7 @@
final ArtifactFilter filter = createFilter( patterns );
- if ( reverse )
+ if ( !isInclusionExpected() )
{
assertFalse( filter.include( mac1.artifact ) );
assertFalse( filter.include( mac2.artifact ) );
@@ -73,7 +75,7 @@
mockManager.verifyAll();
}
- public void testShouldTriggerBothPatternsWithNonColonWildcards( final boolean reverse )
+ public void testShouldTriggerBothPatternsWithNonColonWildcards()
{
final String groupId1 = "group";
final String artifactId1 = "artifact";
@@ -92,7 +94,7 @@
final ArtifactFilter filter = createFilter( patterns );
- if ( reverse )
+ if ( !isInclusionExpected() )
{
assertFalse( filter.include( mac1.artifact ) );
assertFalse( filter.include( mac2.artifact ) );
@@ -106,7 +108,7 @@
mockManager.verifyAll();
}
- public void testShouldIncludeDirectlyMatchedArtifactByGroupIdArtifactId( final boolean reverse )
+ public void testShouldIncludeDirectlyMatchedArtifactByGroupIdArtifactId()
{
final String groupId = "group";
final String artifactId = "artifact";
@@ -117,7 +119,7 @@
final ArtifactFilter filter = createFilter( Collections.singletonList( groupId + ":" + artifactId ) );
- if ( reverse )
+ if ( !isInclusionExpected() )
{
assertFalse( filter.include( mac.artifact ) );
}
@@ -129,7 +131,7 @@
mockManager.verifyAll();
}
- public void testShouldIncludeDirectlyMatchedArtifactByDependencyConflictId( final boolean reverse )
+ public void testShouldIncludeDirectlyMatchedArtifactByDependencyConflictId()
{
final String groupId = "group";
final String artifactId = "artifact";
@@ -140,7 +142,7 @@
final ArtifactFilter filter = createFilter( Collections.singletonList( groupId + ":" + artifactId + ":jar" ) );
- if ( reverse )
+ if ( !isInclusionExpected() )
{
assertFalse( filter.include( mac.artifact ) );
}
@@ -152,7 +154,7 @@
mockManager.verifyAll();
}
- public void testShouldNotIncludeWhenGroupIdDiffers( final boolean reverse )
+ public void testShouldNotIncludeWhenGroupIdDiffers()
{
final String groupId = "group";
final String artifactId = "artifact";
@@ -167,7 +169,7 @@
final ArtifactFilter filter = createFilter( patterns );
- if ( reverse )
+ if ( !isInclusionExpected() )
{
assertTrue( filter.include( mac.artifact ) );
}
@@ -179,7 +181,7 @@
mockManager.verifyAll();
}
- public void testShouldNotIncludeWhenArtifactIdDiffers( final boolean reverse )
+ public void testShouldNotIncludeWhenArtifactIdDiffers()
{
final String groupId = "group";
final String artifactId = "artifact";
@@ -195,7 +197,7 @@
final ArtifactFilter filter = createFilter( patterns );
- if ( reverse )
+ if ( !isInclusionExpected() )
{
assertTrue( filter.include( mac.artifact ) );
}
@@ -207,7 +209,7 @@
mockManager.verifyAll();
}
- public void testShouldNotIncludeWhenBothIdElementsDiffer( final boolean reverse )
+ public void testShouldNotIncludeWhenBothIdElementsDiffer()
{
final String groupId = "group";
final String artifactId = "artifact";
@@ -223,7 +225,7 @@
final ArtifactFilter filter = createFilter( patterns );
- if ( reverse )
+ if ( !isInclusionExpected() )
{
assertTrue( filter.include( mac.artifact ) );
}
@@ -235,7 +237,7 @@
mockManager.verifyAll();
}
- public void testShouldIncludeWhenPatternMatchesDependencyTrailAndTransitivityIsEnabled( final boolean reverse )
+ public void testShouldIncludeWhenPatternMatchesDependencyTrailAndTransitivityIsEnabled()
{
final String groupId = "group";
final String artifactId = "artifact";
@@ -252,7 +254,7 @@
final ArtifactFilter filter = createFilter( patterns, true );
- if ( reverse )
+ if ( !isInclusionExpected() )
{
assertFalse( filter.include( mac.artifact ) );
}
@@ -264,7 +266,7 @@
mockManager.verifyAll();
}
- public void testIncludeWhenPatternMatchesDepTrailWithTransitivityUsingNonColonWildcard( final boolean reverse )
+ public void testIncludeWhenPatternMatchesDepTrailWithTransitivityUsingNonColonWildcard()
{
final String groupId = "group";
final String artifactId = "artifact";
@@ -281,7 +283,7 @@
final ArtifactFilter filter = createFilter( patterns, true );
- if ( reverse )
+ if ( !isInclusionExpected() )
{
assertFalse( filter.include( mac.artifact ) );
}
@@ -293,7 +295,7 @@
mockManager.verifyAll();
}
- public void testShouldNotIncludeWhenNegativeMatch( final boolean reverse )
+ public void testShouldNotIncludeWhenNegativeMatch()
{
final String groupId = "group";
final String artifactId = "artifact";
@@ -308,7 +310,7 @@
final ArtifactFilter filter = createFilter( patterns );
- if ( reverse )
+ if ( !isInclusionExpected() )
{
assertTrue( filter.include( mac.artifact ) );
}
@@ -320,7 +322,7 @@
mockManager.verifyAll();
}
- public void testShouldIncludeWhenWildcardMatchesInsideSequence( final boolean reverse )
+ public void testShouldIncludeWhenWildcardMatchesInsideSequence()
{
final String groupId = "group";
final String artifactId = "artifact";
@@ -335,7 +337,7 @@
final ArtifactFilter filter = createFilter( patterns );
- if ( reverse )
+ if ( !isInclusionExpected() )
{
assertFalse( filter.include( mac.artifact ) );
}
@@ -347,7 +349,7 @@
mockManager.verifyAll();
}
- public void testShouldIncludeWhenWildcardMatchesOutsideSequence( final boolean reverse )
+ public void testShouldIncludeWhenWildcardMatchesOutsideSequence()
{
final String groupId = "group";
final String artifactId = "artifact";
@@ -362,7 +364,7 @@
final ArtifactFilter filter = createFilter( patterns );
- if ( reverse )
+ if ( !isInclusionExpected() )
{
assertFalse( filter.include( mac.artifact ) );
}
@@ -374,7 +376,7 @@
mockManager.verifyAll();
}
- public void testShouldIncludeWhenWildcardMatchesMiddleOfArtifactId( final boolean reverse )
+ public void testShouldIncludeWhenWildcardMatchesMiddleOfArtifactId()
{
final String groupId = "group";
final String artifactId = "some-artifact-id";
@@ -389,7 +391,7 @@
final ArtifactFilter filter = createFilter( patterns );
- if ( reverse )
+ if ( !isInclusionExpected() )
{
assertFalse( filter.include( mac.artifact ) );
}
@@ -401,7 +403,34 @@
mockManager.verifyAll();
}
- public void testShouldIncludeTransitiveDependencyWhenWildcardMatchesButDoesntMatchParent( final boolean reverse )
+ public void testShouldIncludeWhenWildcardCoversPartOfGroupIdAndEverythingElse()
+ {
+ final String groupId = "some.group.id";
+ final String artifactId = "some-artifact-id";
+
+ final ArtifactMockAndControl mac = new ArtifactMockAndControl( groupId, artifactId );
+
+ mockManager.replayAll();
+
+ final List patterns = new ArrayList();
+
+ patterns.add( "some.group*" );
+
+ final ArtifactFilter filter = createFilter( patterns );
+
+ if ( !isInclusionExpected() )
+ {
+ assertFalse( filter.include( mac.artifact ) );
+ }
+ else
+ {
+ assertTrue( filter.include( mac.artifact ) );
+ }
+
+ mockManager.verifyAll();
+ }
+
+ public void testShouldIncludeTransitiveDependencyWhenWildcardMatchesButDoesntMatchParent()
{
final String groupId = "group";
final String artifactId = "artifact";
@@ -422,7 +451,7 @@
final ArtifactFilter filter = createFilter( patterns, true );
- if ( reverse )
+ if ( !isInclusionExpected() )
{
assertTrue( filter.include( otherMac.artifact ) );
assertFalse( filter.include( mac.artifact ) );
@@ -458,7 +487,7 @@
//
// ArtifactFilter filter = createFilter( patterns, true );
//
- // if ( reverse )
+ // if ( isInclusionExpected() )
// {
// assertTrue( filter.include( otherMac.artifact ) );
// assertFalse( filter.include( mac.artifact ) );
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilterTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilterTest.java
index 1b6db12..37ed345 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilterTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilterTest.java
@@ -31,91 +31,144 @@
private final PatternArtifactFilterTCK tck = new PatternArtifactFilterTCK()
{
+ @Override
protected ArtifactFilter createFilter( final List patterns )
{
return new PatternExcludesArtifactFilter( patterns );
}
+ @Override
protected ArtifactFilter createFilter( final List patterns, final boolean actTransitively )
{
return new PatternExcludesArtifactFilter( patterns, actTransitively );
}
+ @Override
+ protected boolean isInclusionExpected()
+ {
+ return false;
+ }
+
};
public void testShouldTriggerBothPatternsWithNonColonWildcards()
{
- tck.testShouldTriggerBothPatternsWithNonColonWildcards( true );
+ tck.testShouldTriggerBothPatternsWithNonColonWildcards();
}
public void testIncludeWhenPatternMatchesDepTrailWithTransitivityUsingNonColonWildcard()
{
- tck.testIncludeWhenPatternMatchesDepTrailWithTransitivityUsingNonColonWildcard( true );
+ tck.testIncludeWhenPatternMatchesDepTrailWithTransitivityUsingNonColonWildcard();
}
public void testShouldTriggerBothPatternsWithWildcards()
{
- tck.testShouldTriggerBothPatternsWithWildcards( true );
+ tck.testShouldTriggerBothPatternsWithWildcards();
}
public void testShouldNotIncludeDirectlyMatchedArtifactByDependencyConflictId()
{
- tck.testShouldIncludeDirectlyMatchedArtifactByDependencyConflictId( true );
+ tck.testShouldIncludeDirectlyMatchedArtifactByDependencyConflictId();
}
public void testShouldNotIncludeDirectlyMatchedArtifactByGroupIdArtifactId()
{
- tck.testShouldIncludeDirectlyMatchedArtifactByGroupIdArtifactId( true );
+ tck.testShouldIncludeDirectlyMatchedArtifactByGroupIdArtifactId();
}
public void testShouldNotIncludeWhenPatternMatchesDependencyTrailAndTransitivityIsEnabled()
{
- tck.testShouldIncludeWhenPatternMatchesDependencyTrailAndTransitivityIsEnabled( true );
+ tck.testShouldIncludeWhenPatternMatchesDependencyTrailAndTransitivityIsEnabled();
}
public void testShouldIncludeWhenArtifactIdDiffers()
{
- tck.testShouldNotIncludeWhenArtifactIdDiffers( true );
+ tck.testShouldNotIncludeWhenArtifactIdDiffers();
}
public void testShouldIncludeWhenBothIdElementsDiffer()
{
- tck.testShouldNotIncludeWhenBothIdElementsDiffer( true );
+ tck.testShouldNotIncludeWhenBothIdElementsDiffer();
}
public void testShouldIncludeWhenGroupIdDiffers()
{
- tck.testShouldNotIncludeWhenGroupIdDiffers( true );
+ tck.testShouldNotIncludeWhenGroupIdDiffers();
}
public void testShouldIncludeWhenNegativeMatch()
{
- tck.testShouldNotIncludeWhenNegativeMatch( true );
+ tck.testShouldNotIncludeWhenNegativeMatch();
}
public void testShouldNotIncludeWhenWildcardMatchesInsideSequence()
{
- tck.testShouldIncludeWhenWildcardMatchesInsideSequence( true );
+ tck.testShouldIncludeWhenWildcardMatchesInsideSequence();
}
public void testShouldIncludeWhenWildcardMatchesOutsideSequence()
{
- tck.testShouldIncludeWhenWildcardMatchesOutsideSequence( true );
+ tck.testShouldIncludeWhenWildcardMatchesOutsideSequence();
}
public void testShouldIncludeTransitiveDependencyWhenWildcardMatchesButDoesntMatchParent()
{
- tck.testShouldIncludeTransitiveDependencyWhenWildcardMatchesButDoesntMatchParent( true );
+ tck.testShouldIncludeTransitiveDependencyWhenWildcardMatchesButDoesntMatchParent();
}
public void testShouldIncludeWhenWildcardMatchesMiddleOfArtifactId()
{
- tck.testShouldIncludeWhenWildcardMatchesMiddleOfArtifactId( true );
+ tck.testShouldIncludeWhenWildcardMatchesMiddleOfArtifactId();
+ }
+
+ public void testShouldIncludeWhenWildcardCoversPartOfGroupIdAndEverythingElse()
+ {
+ tck.testShouldIncludeWhenWildcardCoversPartOfGroupIdAndEverythingElse();
+ }
+
+ public void testShouldIncludeDirectlyMatchedArtifactByGroupIdArtifactId()
+ {
+ tck.testShouldIncludeDirectlyMatchedArtifactByGroupIdArtifactId();
+ }
+
+ public void testShouldIncludeDirectlyMatchedArtifactByDependencyConflictId()
+ {
+ tck.testShouldIncludeDirectlyMatchedArtifactByDependencyConflictId();
+ }
+
+ public void testShouldNotIncludeWhenGroupIdDiffers()
+ {
+ tck.testShouldNotIncludeWhenGroupIdDiffers();
+ }
+
+ public void testShouldNotIncludeWhenArtifactIdDiffers()
+ {
+ tck.testShouldNotIncludeWhenArtifactIdDiffers();
+ }
+
+ public void testShouldNotIncludeWhenBothIdElementsDiffer()
+ {
+ tck.testShouldNotIncludeWhenBothIdElementsDiffer();
+ }
+
+ public void testShouldIncludeWhenPatternMatchesDependencyTrailAndTransitivityIsEnabled()
+ {
+ tck.testShouldIncludeWhenPatternMatchesDependencyTrailAndTransitivityIsEnabled();
+ }
+
+ public void testShouldNotIncludeWhenNegativeMatch()
+ {
+ tck.testShouldNotIncludeWhenNegativeMatch();
+ }
+
+ public void testShouldIncludeWhenWildcardMatchesInsideSequence()
+ {
+ tck.testShouldIncludeWhenWildcardMatchesInsideSequence();
}
// See comment in TCK.
// public void testShouldIncludeDirectDependencyWhenInvertedWildcardMatchesButDoesntMatchTransitiveChild()
// {
- // tck.testShouldIncludeDirectDependencyWhenInvertedWildcardMatchesButDoesntMatchTransitiveChild( true );
+ // tck.testShouldIncludeDirectDependencyWhenInvertedWildcardMatchesButDoesntMatchTransitiveChild();
// }
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilterTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilterTest.java
index d6178b3..cbd97db 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilterTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilterTest.java
@@ -30,91 +30,104 @@
private final PatternArtifactFilterTCK tck = new PatternArtifactFilterTCK()
{
+ @Override
protected ArtifactFilter createFilter( final List patterns )
{
return new PatternIncludesArtifactFilter( patterns );
}
+ @Override
protected ArtifactFilter createFilter( final List patterns, final boolean actTransitively )
{
return new PatternIncludesArtifactFilter( patterns, actTransitively );
}
+ @Override
+ protected boolean isInclusionExpected()
+ {
+ return true;
+ }
+
};
public void testShouldTriggerBothPatternsWithNonColonWildcards()
{
- tck.testShouldTriggerBothPatternsWithNonColonWildcards( false );
+ tck.testShouldTriggerBothPatternsWithNonColonWildcards();
}
public void testShouldTriggerBothPatternsWithWildcards()
{
- tck.testShouldTriggerBothPatternsWithWildcards( false );
+ tck.testShouldTriggerBothPatternsWithWildcards();
}
public void testShouldIncludeDirectlyMatchedArtifactByDependencyConflictId()
{
- tck.testShouldIncludeDirectlyMatchedArtifactByDependencyConflictId( false );
+ tck.testShouldIncludeDirectlyMatchedArtifactByDependencyConflictId();
}
public void testShouldIncludeDirectlyMatchedArtifactByGroupIdArtifactId()
{
- tck.testShouldIncludeDirectlyMatchedArtifactByGroupIdArtifactId( false );
+ tck.testShouldIncludeDirectlyMatchedArtifactByGroupIdArtifactId();
}
public void testShouldIncludeWhenPatternMatchesDependencyTrailAndTransitivityIsEnabled()
{
- tck.testShouldIncludeWhenPatternMatchesDependencyTrailAndTransitivityIsEnabled( false );
+ tck.testShouldIncludeWhenPatternMatchesDependencyTrailAndTransitivityIsEnabled();
}
public void testIncludeWhenPatternMatchesDepTrailWithTransitivityUsingNonColonWildcard()
{
- tck.testIncludeWhenPatternMatchesDepTrailWithTransitivityUsingNonColonWildcard( false );
+ tck.testIncludeWhenPatternMatchesDepTrailWithTransitivityUsingNonColonWildcard();
}
public void testShouldNotIncludeWhenArtifactIdDiffers()
{
- tck.testShouldNotIncludeWhenArtifactIdDiffers( false );
+ tck.testShouldNotIncludeWhenArtifactIdDiffers();
}
public void testShouldNotIncludeWhenBothIdElementsDiffer()
{
- tck.testShouldNotIncludeWhenBothIdElementsDiffer( false );
+ tck.testShouldNotIncludeWhenBothIdElementsDiffer();
}
public void testShouldNotIncludeWhenGroupIdDiffers()
{
- tck.testShouldNotIncludeWhenGroupIdDiffers( false );
+ tck.testShouldNotIncludeWhenGroupIdDiffers();
}
public void testShouldNotIncludeWhenNegativeMatch()
{
- tck.testShouldNotIncludeWhenNegativeMatch( false );
+ tck.testShouldNotIncludeWhenNegativeMatch();
}
public void testShouldIncludeWhenWildcardMatchesInsideSequence()
{
- tck.testShouldIncludeWhenWildcardMatchesInsideSequence( false );
+ tck.testShouldIncludeWhenWildcardMatchesInsideSequence();
}
public void testShouldIncludeWhenWildcardMatchesOutsideSequence()
{
- tck.testShouldIncludeWhenWildcardMatchesOutsideSequence( false );
+ tck.testShouldIncludeWhenWildcardMatchesOutsideSequence();
}
public void testShouldIncludeTransitiveDependencyWhenWildcardMatchesButDoesntMatchParent()
{
- tck.testShouldIncludeTransitiveDependencyWhenWildcardMatchesButDoesntMatchParent( false );
+ tck.testShouldIncludeTransitiveDependencyWhenWildcardMatchesButDoesntMatchParent();
}
public void testShouldIncludeWhenWildcardMatchesMiddleOfArtifactId()
{
- tck.testShouldIncludeWhenWildcardMatchesMiddleOfArtifactId( false );
+ tck.testShouldIncludeWhenWildcardMatchesMiddleOfArtifactId();
+ }
+
+ public void testShouldIncludeWhenWildcardCoversPartOfGroupIdAndEverythingElse()
+ {
+ tck.testShouldIncludeWhenWildcardCoversPartOfGroupIdAndEverythingElse();
}
// See comment in TCK.
// public void testShouldIncludeDirectDependencyWhenInvertedWildcardMatchesButDoesntMatchTransitiveChild()
// {
- // tck.testShouldIncludeDirectDependencyWhenInvertedWildcardMatchesButDoesntMatchTransitiveChild( false );
+ // tck.testShouldIncludeDirectDependencyWhenInvertedWildcardMatchesButDoesntMatchTransitiveChild();
// }
}