http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/filter/PatternInclusionsDependencyFilterTest.java ---------------------------------------------------------------------- diff --git a/aether-util/src/test/java/org/eclipse/aether/util/filter/PatternInclusionsDependencyFilterTest.java b/aether-util/src/test/java/org/eclipse/aether/util/filter/PatternInclusionsDependencyFilterTest.java deleted file mode 100644 index cb85431..0000000 --- a/aether-util/src/test/java/org/eclipse/aether/util/filter/PatternInclusionsDependencyFilterTest.java +++ /dev/null @@ -1,184 +0,0 @@ -package org.eclipse.aether.util.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 static org.junit.Assert.*; - -import java.util.LinkedList; -import java.util.List; - -import org.eclipse.aether.graph.DependencyNode; -import org.eclipse.aether.internal.test.util.NodeBuilder; -import org.eclipse.aether.util.filter.PatternInclusionsDependencyFilter; -import org.eclipse.aether.util.version.GenericVersionScheme; -import org.eclipse.aether.version.VersionScheme; -import org.junit.Test; - -public class PatternInclusionsDependencyFilterTest - extends AbstractDependencyFilterTest -{ - - @Test - public void acceptTestCornerCases() - { - NodeBuilder builder = new NodeBuilder(); - builder.artifactId( "testArtifact" ); - DependencyNode node = builder.build(); - List<DependencyNode> parents = new LinkedList<DependencyNode>(); - - // Empty String, Empty List - assertTrue( accept( node, "" ) ); - assertFalse( new PatternInclusionsDependencyFilter( new LinkedList<String>() ).accept( node, parents ) ); - assertFalse( new PatternInclusionsDependencyFilter( (String[]) null ).accept( node, parents ) ); - assertFalse( new PatternInclusionsDependencyFilter( (VersionScheme) null, "[1,10]" ).accept( node, parents ) ); - } - - @Test - public void acceptTestMatches() - { - NodeBuilder builder = new NodeBuilder(); - builder.groupId( "com.example.test" ).artifactId( "testArtifact" ).ext( "jar" ).version( "1.0.3" ); - DependencyNode node = builder.build(); - - // full match - assertEquals( "com.example.test:testArtifact:jar:1.0.3", true, - accept( node, "com.example.test:testArtifact:jar:1.0.3" ) ); - - // single wildcard - assertEquals( "*:testArtifact:jar:1.0.3", true, accept( node, "*:testArtifact:jar:1.0.3" ) ); - assertEquals( "com.example.test:*:jar:1.0.3", true, accept( node, "com.example.test:*:jar:1.0.3" ) ); - assertEquals( "com.example.test:testArtifact:*:1.0.3", true, - accept( node, "com.example.test:testArtifact:*:1.0.3" ) ); - assertEquals( "com.example.test:testArtifact:*:1.0.3", true, - accept( node, "com.example.test:testArtifact:*:1.0.3" ) ); - - // implicit wildcard - assertEquals( ":testArtifact:jar:1.0.3", true, accept( node, ":testArtifact:jar:1.0.3" ) ); - assertEquals( "com.example.test::jar:1.0.3", true, accept( node, "com.example.test::jar:1.0.3" ) ); - assertEquals( "com.example.test:testArtifact::1.0.3", true, - accept( node, "com.example.test:testArtifact::1.0.3" ) ); - assertEquals( "com.example.test:testArtifact:jar:", true, accept( node, "com.example.test:testArtifact:jar:" ) ); - - // multi wildcards - assertEquals( "*:*:jar:1.0.3", true, accept( node, "*:*:jar:1.0.3" ) ); - assertEquals( "com.example.test:*:*:1.0.3", true, accept( node, "com.example.test:*:*:1.0.3" ) ); - assertEquals( "com.example.test:testArtifact:*:*", true, accept( node, "com.example.test:testArtifact:*:*" ) ); - assertEquals( "*:testArtifact:jar:*", true, accept( node, "*:testArtifact:jar:*" ) ); - assertEquals( "*:*:jar:*", true, accept( node, "*:*:jar:*" ) ); - assertEquals( ":*:jar:", true, accept( node, ":*:jar:" ) ); - - // partial wildcards - assertEquals( "*.example.test:testArtifact:jar:1.0.3", true, - accept( node, "*.example.test:testArtifact:jar:1.0.3" ) ); - assertEquals( "com.example.test:testArtifact:*ar:1.0.*", true, - accept( node, "com.example.test:testArtifact:*ar:1.0.*" ) ); - assertEquals( "com.example.test:testArtifact:jar:1.0.*", true, - accept( node, "com.example.test:testArtifact:jar:1.0.*" ) ); - assertEquals( "*.example.*:testArtifact:jar:1.0.3", true, accept( node, "*.example.*:testArtifact:jar:1.0.3" ) ); - - // wildcard as empty string - assertEquals( "com.example.test*:testArtifact:jar:1.0.3", true, - accept( node, "com.example.test*:testArtifact:jar:1.0.3" ) ); - } - - @Test - public void acceptTestLessToken() - { - NodeBuilder builder = new NodeBuilder(); - builder.groupId( "com.example.test" ).artifactId( "testArtifact" ).ext( "jar" ).version( "1.0.3" ); - DependencyNode node = builder.build(); - - assertEquals( "com.example.test:testArtifact:jar", true, accept( node, "com.example.test:testArtifact:jar" ) ); - assertEquals( "com.example.test:testArtifact", true, accept( node, "com.example.test:testArtifact" ) ); - assertEquals( "com.example.test", true, accept( node, "com.example.test" ) ); - - assertEquals( "com.example.foo", false, accept( node, "com.example.foo" ) ); - } - - @Test - public void acceptTestMissmatch() - { - NodeBuilder builder = new NodeBuilder(); - builder.groupId( "com.example.test" ).artifactId( "testArtifact" ).ext( "jar" ).version( "1.0.3" ); - DependencyNode node = builder.build(); - - assertEquals( "OTHER.GROUP.ID:testArtifact:jar:1.0.3", false, - accept( node, "OTHER.GROUP.ID:testArtifact:jar:1.0.3" ) ); - assertEquals( "com.example.test:OTHER_ARTIFACT:jar:1.0.3", false, - accept( node, "com.example.test:OTHER_ARTIFACT:jar:1.0.3" ) ); - assertEquals( "com.example.test:OTHER_ARTIFACT:jar:1.0.3", false, - accept( node, "com.example.test:OTHER_ARTIFACT:jar:1.0.3" ) ); - assertEquals( "com.example.test:testArtifact:WAR:1.0.3", false, - accept( node, "com.example.test:testArtifact:WAR:1.0.3" ) ); - assertEquals( "com.example.test:testArtifact:jar:SNAPSHOT", false, - accept( node, "com.example.test:testArtifact:jar:SNAPSHOT" ) ); - - assertEquals( "*:*:war:*", false, accept( node, "*:*:war:*" ) ); - assertEquals( "OTHER.GROUP.ID", false, accept( node, "OTHER.GROUP.ID" ) ); - } - - @Test - public void acceptTestMoreToken() - { - NodeBuilder builder = new NodeBuilder(); - builder.groupId( "com.example.test" ).artifactId( "testArtifact" ).ext( "jar" ).version( "1.0.3" ); - - DependencyNode node = builder.build(); - assertEquals( "com.example.test:testArtifact:jar:1.0.3:foo", false, - accept( node, "com.example.test:testArtifact:jar:1.0.3:foo" ) ); - } - - @Test - public void acceptTestRange() - { - NodeBuilder builder = new NodeBuilder(); - builder.groupId( "com.example.test" ).artifactId( "testArtifact" ).ext( "jar" ).version( "1.0.3" ); - DependencyNode node = builder.build(); - - String prefix = "com.example.test:testArtifact:jar:"; - - assertTrue( prefix + "[1.0.3,1.0.4)", acceptVersionRange( node, prefix + "[1.0.3,1.0.4)" ) ); - assertTrue( prefix + "[1.0.3,)", acceptVersionRange( node, prefix + "[1.0.3,)" ) ); - assertTrue( prefix + "[1.0.3,]", acceptVersionRange( node, prefix + "[1.0.3,]" ) ); - assertTrue( prefix + "(,1.0.3]", acceptVersionRange( node, prefix + "(,1.0.3]" ) ); - assertTrue( prefix + "[1.0,]", acceptVersionRange( node, prefix + "[1.0,]" ) ); - assertTrue( prefix + "[1,4]", acceptVersionRange( node, prefix + "[1,4]" ) ); - assertTrue( prefix + "(1,4)", acceptVersionRange( node, prefix + "(1,4)" ) ); - - assertTrue( prefix + "(1.0.2,1.0.3]", acceptVersionRange( node, prefix + "(1.0.2,1.0.3]", prefix + "(1.1,)" ) ); - - assertFalse( prefix + "(1.0.3,2.0]", acceptVersionRange( node, prefix + "(1.0.3,2.0]" ) ); - assertFalse( prefix + "(1,1.0.2]", acceptVersionRange( node, prefix + "(1,1.0.2]" ) ); - - assertFalse( prefix + "(1.0.2,1.0.3)", acceptVersionRange( node, prefix + "(1.0.2,1.0.3)", prefix + "(1.0.3,)" ) ); - } - - public boolean accept( DependencyNode node, String expression ) - { - return new PatternInclusionsDependencyFilter( expression ).accept( node, new LinkedList<DependencyNode>() ); - } - - public boolean acceptVersionRange( DependencyNode node, String... expression ) - { - return new PatternInclusionsDependencyFilter( new GenericVersionScheme(), expression ).accept( node, - new LinkedList<DependencyNode>() ); - } - -}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/filter/ScopeDependencyFilterTest.java ---------------------------------------------------------------------- diff --git a/aether-util/src/test/java/org/eclipse/aether/util/filter/ScopeDependencyFilterTest.java b/aether-util/src/test/java/org/eclipse/aether/util/filter/ScopeDependencyFilterTest.java deleted file mode 100644 index e943df9..0000000 --- a/aether-util/src/test/java/org/eclipse/aether/util/filter/ScopeDependencyFilterTest.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.eclipse.aether.util.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 static org.junit.Assert.*; - -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; - -import org.eclipse.aether.graph.DependencyNode; -import org.eclipse.aether.internal.test.util.NodeBuilder; -import org.eclipse.aether.util.filter.ScopeDependencyFilter; -import org.junit.Test; - -public class ScopeDependencyFilterTest - extends AbstractDependencyFilterTest -{ - - @Test - public void acceptTest() - { - - NodeBuilder builder = new NodeBuilder(); - builder.scope( "compile" ).artifactId( "test" ); - List<DependencyNode> parents = new LinkedList<DependencyNode>(); - - // null or empty - assertTrue( new ScopeDependencyFilter( null, null ).accept( builder.build(), parents ) ); - assertTrue( new ScopeDependencyFilter( new LinkedList<String>(), new LinkedList<String>() ).accept( builder.build(), - parents ) ); - assertTrue( new ScopeDependencyFilter( (String[]) null ).accept( builder.build(), parents ) ); - - // only excludes - assertTrue( new ScopeDependencyFilter( "test" ).accept( builder.build(), parents ) ); - assertFalse( new ScopeDependencyFilter( "compile" ).accept( builder.build(), parents ) ); - assertFalse( new ScopeDependencyFilter( "compile", "test" ).accept( builder.build(), parents ) ); - - // Both - String[] excludes1 = { "provided" }; - String[] includes1 = { "compile", "test" }; - assertTrue( new ScopeDependencyFilter( Arrays.asList( includes1 ), Arrays.asList( excludes1 ) ).accept( builder.build(), - parents ) ); - assertTrue( new ScopeDependencyFilter( Arrays.asList( includes1 ), null ).accept( builder.build(), parents ) ); - - // exclude wins - String[] excludes2 = { "compile" }; - String[] includes2 = { "compile" }; - assertFalse( new ScopeDependencyFilter( Arrays.asList( includes2 ), Arrays.asList( excludes2 ) ).accept( builder.build(), - parents ) ); - - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/manager/ClassicDependencyManagerTest.java ---------------------------------------------------------------------- diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/manager/ClassicDependencyManagerTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/manager/ClassicDependencyManagerTest.java deleted file mode 100644 index 2593585..0000000 --- a/aether-util/src/test/java/org/eclipse/aether/util/graph/manager/ClassicDependencyManagerTest.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.eclipse.aether.util.graph.manager; - -/* - * 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 static org.junit.Assert.*; - -import java.util.Arrays; - -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.artifact.DefaultArtifact; -import org.eclipse.aether.collection.DependencyCollectionContext; -import org.eclipse.aether.collection.DependencyManagement; -import org.eclipse.aether.collection.DependencyManager; -import org.eclipse.aether.graph.Dependency; -import org.eclipse.aether.internal.test.util.TestUtils; -import org.junit.Before; -import org.junit.Test; - -public class ClassicDependencyManagerTest -{ - - private final Artifact A = new DefaultArtifact( "test", "a", "", "" ); - - private final Artifact A1 = new DefaultArtifact( "test", "a", "", "1" ); - - private final Artifact B = new DefaultArtifact( "test", "b", "", "" ); - - private final Artifact B1 = new DefaultArtifact( "test", "b", "", "1" ); - - private RepositorySystemSession session; - - private DependencyCollectionContext newContext( Dependency... managedDependencies ) - { - return TestUtils.newCollectionContext( session, null, Arrays.asList( managedDependencies ) ); - } - - @Before - public void setUp() - { - session = TestUtils.newSession(); - } - - @Test - public void testManageOptional() - { - DependencyManager manager = new ClassicDependencyManager(); - - manager = - manager.deriveChildManager( newContext( new Dependency( A, null, null ), new Dependency( B, null, true ) ) ); - DependencyManagement mngt; - mngt = manager.manageDependency( new Dependency( A1, null ) ); - assertNull( mngt ); - mngt = manager.manageDependency( new Dependency( B1, null ) ); - assertNull( mngt ); - - manager = manager.deriveChildManager( newContext() ); - mngt = manager.manageDependency( new Dependency( A1, null ) ); - assertNull( mngt ); - mngt = manager.manageDependency( new Dependency( B1, null ) ); - assertNotNull( mngt ); - assertEquals( Boolean.TRUE, mngt.getOptional() ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/selector/AndDependencySelectorTest.java ---------------------------------------------------------------------- diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/selector/AndDependencySelectorTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/selector/AndDependencySelectorTest.java deleted file mode 100644 index b0f2b09..0000000 --- a/aether-util/src/test/java/org/eclipse/aether/util/graph/selector/AndDependencySelectorTest.java +++ /dev/null @@ -1,153 +0,0 @@ -package org.eclipse.aether.util.graph.selector; - -/* - * 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 static org.junit.Assert.*; - -import org.eclipse.aether.artifact.DefaultArtifact; -import org.eclipse.aether.collection.DependencyCollectionContext; -import org.eclipse.aether.collection.DependencySelector; -import org.eclipse.aether.graph.Dependency; -import org.junit.Test; - -public class AndDependencySelectorTest -{ - - static class DummyDependencySelector - implements DependencySelector - { - - private final boolean select; - - private final DependencySelector child; - - public DummyDependencySelector() - { - this( true ); - } - - public DummyDependencySelector( boolean select ) - { - this.select = select; - this.child = this; - } - - public DummyDependencySelector( boolean select, DependencySelector child ) - { - this.select = select; - this.child = child; - } - - public boolean selectDependency( Dependency dependency ) - { - return select; - } - - public DependencySelector deriveChildSelector( DependencyCollectionContext context ) - { - return child; - } - - } - - @Test - public void testNewInstance() - { - assertNull( AndDependencySelector.newInstance( null, null ) ); - DependencySelector selector = new DummyDependencySelector(); - assertSame( selector, AndDependencySelector.newInstance( selector, null ) ); - assertSame( selector, AndDependencySelector.newInstance( null, selector ) ); - assertSame( selector, AndDependencySelector.newInstance( selector, selector ) ); - assertNotNull( AndDependencySelector.newInstance( selector, new DummyDependencySelector() ) ); - } - - @Test - public void testTraverseDependency() - { - Dependency dependency = new Dependency( new DefaultArtifact( "g:a:v:1" ), "runtime" ); - - DependencySelector selector = new AndDependencySelector(); - assertTrue( selector.selectDependency( dependency ) ); - - selector = - new AndDependencySelector( new DummyDependencySelector( false ), new DummyDependencySelector( false ) ); - assertFalse( selector.selectDependency( dependency ) ); - - selector = - new AndDependencySelector( new DummyDependencySelector( true ), new DummyDependencySelector( false ) ); - assertFalse( selector.selectDependency( dependency ) ); - - selector = new AndDependencySelector( new DummyDependencySelector( true ), new DummyDependencySelector( true ) ); - assertTrue( selector.selectDependency( dependency ) ); - } - - @Test - public void testDeriveChildSelector_Unchanged() - { - DependencySelector other1 = new DummyDependencySelector( true ); - DependencySelector other2 = new DummyDependencySelector( false ); - DependencySelector selector = new AndDependencySelector( other1, other2 ); - assertSame( selector, selector.deriveChildSelector( null ) ); - } - - @Test - public void testDeriveChildSelector_OneRemaining() - { - DependencySelector other1 = new DummyDependencySelector( true ); - DependencySelector other2 = new DummyDependencySelector( false, null ); - DependencySelector selector = new AndDependencySelector( other1, other2 ); - assertSame( other1, selector.deriveChildSelector( null ) ); - } - - @Test - public void testDeriveChildSelector_ZeroRemaining() - { - DependencySelector other1 = new DummyDependencySelector( true, null ); - DependencySelector other2 = new DummyDependencySelector( false, null ); - DependencySelector selector = new AndDependencySelector( other1, other2 ); - assertNull( selector.deriveChildSelector( null ) ); - } - - @Test - public void testEquals() - { - DependencySelector other1 = new DummyDependencySelector( true ); - DependencySelector other2 = new DummyDependencySelector( false ); - DependencySelector selector1 = new AndDependencySelector( other1, other2 ); - DependencySelector selector2 = new AndDependencySelector( other2, other1 ); - DependencySelector selector3 = new AndDependencySelector( other1 ); - assertEquals( selector1, selector1 ); - assertEquals( selector1, selector2 ); - assertNotEquals( selector1, selector3 ); - assertNotEquals( selector1, this ); - assertNotEquals( selector1, null ); - } - - @Test - public void testHashCode() - { - DependencySelector other1 = new DummyDependencySelector( true ); - DependencySelector other2 = new DummyDependencySelector( false ); - DependencySelector selector1 = new AndDependencySelector( other1, other2 ); - DependencySelector selector2 = new AndDependencySelector( other2, other1 ); - assertEquals( selector1.hashCode(), selector2.hashCode() ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/AbstractDependencyGraphTransformerTest.java ---------------------------------------------------------------------- diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/AbstractDependencyGraphTransformerTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/AbstractDependencyGraphTransformerTest.java deleted file mode 100644 index b5947ed..0000000 --- a/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/AbstractDependencyGraphTransformerTest.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.eclipse.aether.util.graph.transformer; - -/* - * 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 static org.junit.Assert.*; - -import java.util.LinkedList; -import java.util.List; - -import org.eclipse.aether.DefaultRepositorySystemSession; -import org.eclipse.aether.collection.DependencyGraphTransformationContext; -import org.eclipse.aether.collection.DependencyGraphTransformer; -import org.eclipse.aether.graph.DependencyNode; -import org.eclipse.aether.internal.test.util.DependencyGraphParser; -import org.eclipse.aether.internal.test.util.TestUtils; -import org.junit.After; -import org.junit.Before; - -/** - */ -public abstract class AbstractDependencyGraphTransformerTest -{ - - protected DependencyGraphTransformer transformer; - - protected DependencyGraphParser parser; - - protected DefaultRepositorySystemSession session; - - protected DependencyGraphTransformationContext context; - - protected abstract DependencyGraphTransformer newTransformer(); - - protected abstract DependencyGraphParser newParser(); - - protected DependencyNode transform( DependencyNode root ) - throws Exception - { - context = TestUtils.newTransformationContext( session ); - root = transformer.transformGraph( root, context ); - assertNotNull( root ); - return root; - } - - protected DependencyNode parseResource( String resource, String... substitutions ) - throws Exception - { - parser.setSubstitutions( substitutions ); - return parser.parseResource( resource ); - } - - protected DependencyNode parseLiteral( String literal, String... substitutions ) - throws Exception - { - parser.setSubstitutions( substitutions ); - return parser.parseLiteral( literal ); - } - - protected List<DependencyNode> find( DependencyNode node, String id ) - { - LinkedList<DependencyNode> trail = new LinkedList<DependencyNode>(); - find( trail, node, id ); - return trail; - } - - private boolean find( LinkedList<DependencyNode> trail, DependencyNode node, String id ) - { - trail.addFirst( node ); - - if ( isMatch( node, id ) ) - { - return true; - } - - for ( DependencyNode child : node.getChildren() ) - { - if ( find( trail, child, id ) ) - { - return true; - } - } - - trail.removeFirst(); - - return false; - } - - private boolean isMatch( DependencyNode node, String id ) - { - if ( node.getDependency() == null ) - { - return false; - } - return id.equals( node.getDependency().getArtifact().getArtifactId() ); - } - - @Before - public void setUp() - { - transformer = newTransformer(); - parser = newParser(); - session = new DefaultRepositorySystemSession(); - } - - @After - public void tearDown() - { - transformer = null; - parser = null; - session = null; - context = null; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/ConflictIdSorterTest.java ---------------------------------------------------------------------- diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/ConflictIdSorterTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/ConflictIdSorterTest.java deleted file mode 100644 index b24a920..0000000 --- a/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/ConflictIdSorterTest.java +++ /dev/null @@ -1,129 +0,0 @@ -package org.eclipse.aether.util.graph.transformer; - -/* - * 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 static org.junit.Assert.*; - -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; - -import org.eclipse.aether.collection.DependencyGraphTransformer; -import org.eclipse.aether.graph.DependencyNode; -import org.eclipse.aether.internal.test.util.DependencyGraphParser; -import org.eclipse.aether.util.graph.transformer.ConflictIdSorter; -import org.eclipse.aether.util.graph.transformer.TransformationContextKeys; -import org.junit.Test; - -/** - */ -public class ConflictIdSorterTest - extends AbstractDependencyGraphTransformerTest -{ - - @Override - protected DependencyGraphTransformer newTransformer() - { - return new ChainedDependencyGraphTransformer( new SimpleConflictMarker(), new ConflictIdSorter() ); - } - - @Override - protected DependencyGraphParser newParser() - { - return new DependencyGraphParser( "transformer/conflict-id-sorter/" ); - } - - private void expectOrder( List<String> sorted, String... ids ) - { - Queue<String> queue = new LinkedList<String>( sorted ); - - for ( String id : ids ) - { - String item = queue.poll(); - assertNotNull( String.format( "not enough conflict groups (no match for '%s'", id ), item ); - - if ( !"*".equals( id ) ) - { - assertEquals( id, item ); - } - } - - assertTrue( String.format( "leftover conflict groups (remaining: '%s')", queue ), queue.isEmpty() ); - } - - private void expectOrder( String... id ) - { - @SuppressWarnings( "unchecked" ) - List<String> sorted = (List<String>) context.get( TransformationContextKeys.SORTED_CONFLICT_IDS ); - expectOrder( sorted, id ); - } - - private void expectCycle( boolean cycle ) - { - Collection<?> cycles = (Collection<?>) context.get( TransformationContextKeys.CYCLIC_CONFLICT_IDS ); - assertEquals( cycle, !cycles.isEmpty() ); - } - - @Test - public void testSimple() - throws Exception - { - DependencyNode node = parseResource( "simple.txt" ); - assertSame( node, transform( node ) ); - - expectOrder( "gid2:aid::jar", "gid:aid::jar", "gid:aid2::jar" ); - expectCycle( false ); - } - - @Test - public void testCycle() - throws Exception - { - DependencyNode node = parseResource( "cycle.txt" ); - assertSame( node, transform( node ) ); - - expectOrder( "gid:aid::jar", "gid2:aid::jar" ); - expectCycle( true ); - } - - @Test - public void testCycles() - throws Exception - { - DependencyNode node = parseResource( "cycles.txt" ); - assertSame( node, transform( node ) ); - - expectOrder( "*", "*", "*", "gid:aid::jar" ); - expectCycle( true ); - } - - @Test - public void testNoConflicts() - throws Exception - { - DependencyNode node = parseResource( "no-conflicts.txt" ); - assertSame( node, transform( node ) ); - - expectOrder( "gid:aid::jar", "gid3:aid::jar", "gid2:aid::jar", "gid4:aid::jar" ); - expectCycle( false ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/ConflictMarkerTest.java ---------------------------------------------------------------------- diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/ConflictMarkerTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/ConflictMarkerTest.java deleted file mode 100644 index 550a0c6..0000000 --- a/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/ConflictMarkerTest.java +++ /dev/null @@ -1,122 +0,0 @@ -package org.eclipse.aether.util.graph.transformer; - -/* - * 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 static org.junit.Assert.*; - -import java.util.Map; - -import org.eclipse.aether.collection.DependencyGraphTransformer; -import org.eclipse.aether.graph.DependencyNode; -import org.eclipse.aether.internal.test.util.DependencyGraphParser; -import org.eclipse.aether.util.graph.transformer.ConflictMarker; -import org.eclipse.aether.util.graph.transformer.TransformationContextKeys; -import org.junit.Test; - -/** - */ -public class ConflictMarkerTest - extends AbstractDependencyGraphTransformerTest -{ - - @Override - protected DependencyGraphTransformer newTransformer() - { - return new ConflictMarker(); - } - - @Override - protected DependencyGraphParser newParser() - { - return new DependencyGraphParser( "transformer/conflict-marker/" ); - } - - @Test - public void testSimple() - throws Exception - { - DependencyNode root = parseResource( "simple.txt" ); - - assertSame( root, transform( root ) ); - - Map<?, ?> ids = (Map<?, ?>) context.get( TransformationContextKeys.CONFLICT_IDS ); - assertNotNull( ids ); - - assertNull( ids.get( root ) ); - assertNotNull( ids.get( root.getChildren().get( 0 ) ) ); - assertNotNull( ids.get( root.getChildren().get( 1 ) ) ); - assertNotSame( ids.get( root.getChildren().get( 0 ) ), ids.get( root.getChildren().get( 1 ) ) ); - assertFalse( ids.get( root.getChildren().get( 0 ) ).equals( ids.get( root.getChildren().get( 1 ) ) ) ); - } - - @Test - public void testRelocation1() - throws Exception - { - DependencyNode root = parseResource( "relocation1.txt" ); - - assertSame( root, transform( root ) ); - - Map<?, ?> ids = (Map<?, ?>) context.get( TransformationContextKeys.CONFLICT_IDS ); - assertNotNull( ids ); - - assertNull( ids.get( root ) ); - assertNotNull( ids.get( root.getChildren().get( 0 ) ) ); - assertNotNull( ids.get( root.getChildren().get( 1 ) ) ); - assertSame( ids.get( root.getChildren().get( 0 ) ), ids.get( root.getChildren().get( 1 ) ) ); - } - - @Test - public void testRelocation2() - throws Exception - { - DependencyNode root = parseResource( "relocation2.txt" ); - - assertSame( root, transform( root ) ); - - Map<?, ?> ids = (Map<?, ?>) context.get( TransformationContextKeys.CONFLICT_IDS ); - assertNotNull( ids ); - - assertNull( ids.get( root ) ); - assertNotNull( ids.get( root.getChildren().get( 0 ) ) ); - assertNotNull( ids.get( root.getChildren().get( 1 ) ) ); - assertSame( ids.get( root.getChildren().get( 0 ) ), ids.get( root.getChildren().get( 1 ) ) ); - } - - @Test - public void testRelocation3() - throws Exception - { - DependencyNode root = parseResource( "relocation3.txt" ); - - assertSame( root, transform( root ) ); - - Map<?, ?> ids = (Map<?, ?>) context.get( TransformationContextKeys.CONFLICT_IDS ); - assertNotNull( ids ); - - assertNull( ids.get( root ) ); - assertNotNull( ids.get( root.getChildren().get( 0 ) ) ); - assertNotNull( ids.get( root.getChildren().get( 1 ) ) ); - assertNotNull( ids.get( root.getChildren().get( 2 ) ) ); - assertSame( ids.get( root.getChildren().get( 0 ) ), ids.get( root.getChildren().get( 1 ) ) ); - assertSame( ids.get( root.getChildren().get( 1 ) ), ids.get( root.getChildren().get( 2 ) ) ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/JavaDependencyContextRefinerTest.java ---------------------------------------------------------------------- diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/JavaDependencyContextRefinerTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/JavaDependencyContextRefinerTest.java deleted file mode 100644 index bb0d65a..0000000 --- a/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/JavaDependencyContextRefinerTest.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.eclipse.aether.util.graph.transformer; - -/* - * 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 static org.junit.Assert.*; - -import org.eclipse.aether.collection.DependencyGraphTransformer; -import org.eclipse.aether.graph.DependencyNode; -import org.eclipse.aether.internal.test.util.DependencyGraphParser; -import org.eclipse.aether.util.graph.transformer.JavaDependencyContextRefiner; -import org.junit.Test; - -/** - */ -public class JavaDependencyContextRefinerTest - extends AbstractDependencyGraphTransformerTest -{ - - @Override - protected DependencyGraphTransformer newTransformer() - { - return new JavaDependencyContextRefiner(); - } - - @Override - protected DependencyGraphParser newParser() - { - return new DependencyGraphParser( "transformer/context-refiner/" ); - } - - @Test - public void testDoNotRefineOtherContext() - throws Exception - { - DependencyNode node = parseLiteral( "gid:aid:cls:ver" ); - node.setRequestContext( "otherContext" ); - - DependencyNode refinedNode = transform( node ); - assertEquals( node, refinedNode ); - } - - @Test - public void testRefineToCompile() - throws Exception - { - String expected = "project/compile"; - - DependencyNode node = parseLiteral( "gid:aid:ver compile" ); - node.setRequestContext( "project" ); - DependencyNode refinedNode = transform( node ); - assertEquals( expected, refinedNode.getRequestContext() ); - - node = parseLiteral( "gid:aid:ver system" ); - node.setRequestContext( "project" ); - refinedNode = transform( node ); - assertEquals( expected, refinedNode.getRequestContext() ); - - node = parseLiteral( "gid:aid:ver provided" ); - node.setRequestContext( "project" ); - refinedNode = transform( node ); - assertEquals( expected, refinedNode.getRequestContext() ); - } - - @Test - public void testRefineToTest() - throws Exception - { - String expected = "project/test"; - - DependencyNode node = parseLiteral( "gid:aid:ver test" ); - node.setRequestContext( "project" ); - DependencyNode refinedNode = transform( node ); - assertEquals( expected, refinedNode.getRequestContext() ); - } - - @Test - public void testRefineToRuntime() - throws Exception - { - String expected = "project/runtime"; - - DependencyNode node = parseLiteral( "gid:aid:ver runtime" ); - node.setRequestContext( "project" ); - DependencyNode refinedNode = transform( node ); - assertEquals( expected, refinedNode.getRequestContext() ); - } - - @Test - public void testDoNotRefineUnknownScopes() - throws Exception - { - String expected = "project"; - - DependencyNode node = parseLiteral( "gid:aid:ver unknownScope" ); - node.setRequestContext( "project" ); - DependencyNode refinedNode = transform( node ); - assertEquals( expected, refinedNode.getRequestContext() ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/JavaScopeSelectorTest.java ---------------------------------------------------------------------- diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/JavaScopeSelectorTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/JavaScopeSelectorTest.java deleted file mode 100644 index 2737803..0000000 --- a/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/JavaScopeSelectorTest.java +++ /dev/null @@ -1,261 +0,0 @@ -package org.eclipse.aether.util.graph.transformer; - -/* - * 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 static org.junit.Assert.*; - -import java.util.Locale; - -import org.eclipse.aether.collection.DependencyGraphTransformer; -import org.eclipse.aether.graph.DependencyNode; -import org.eclipse.aether.internal.test.util.DependencyGraphParser; -import org.junit.Test; - -public class JavaScopeSelectorTest - extends AbstractDependencyGraphTransformerTest -{ - - private enum Scope - { - TEST, PROVIDED, RUNTIME, COMPILE; - - @Override - public String toString() - { - return super.name().toLowerCase( Locale.ENGLISH ); - } - } - - @Override - protected DependencyGraphTransformer newTransformer() - { - return new ConflictResolver( new NearestVersionSelector(), new JavaScopeSelector(), - new SimpleOptionalitySelector(), new JavaScopeDeriver() ); - } - - @Override - protected DependencyGraphParser newParser() - { - return new DependencyGraphParser( "transformer/scope-calculator/" ); - } - - private void expectScope( String expected, DependencyNode root, int... coords ) - { - expectScope( null, expected, root, coords ); - } - - private void expectScope( String msg, String expected, DependencyNode root, int... coords ) - { - if ( msg == null ) - { - msg = ""; - } - try - { - DependencyNode node = root; - node = path( node, coords ); - - assertEquals( msg + "\nculprit: " + node.toString() + "\n", expected, node.getDependency().getScope() ); - } - catch ( IndexOutOfBoundsException e ) - { - throw new IllegalArgumentException( "Illegal coordinates for child", e ); - } - catch ( NullPointerException e ) - { - throw new IllegalArgumentException( "Illegal coordinates for child", e ); - } - } - - private DependencyNode path( DependencyNode node, int... coords ) - { - for ( int coord : coords ) - { - node = node.getChildren().get( coord ); - } - return node; - } - - @Test - public void testScopeInheritanceProvided() - throws Exception - { - String resource = "inheritance.txt"; - - String expected = "test"; - DependencyNode root = transform( parseResource( resource, "provided", "test" ) ); - expectScope( parser.dump( root ), expected, root, 0, 0 ); - } - - @Test - public void testConflictWinningScopeGetsUsedForInheritance() - throws Exception - { - DependencyNode root = parseResource( "conflict-and-inheritance.txt" ); - assertSame( root, transform( root ) ); - - expectScope( "compile", root, 0, 0 ); - expectScope( "compile", root, 0, 0, 0 ); - } - - @Test - public void testScopeOfDirectDependencyWinsConflictAndGetsUsedForInheritanceToChildrenEverywhereInGraph() - throws Exception - { - DependencyNode root = parseResource( "direct-with-conflict-and-inheritance.txt" ); - assertSame( root, transform( root ) ); - - expectScope( "test", root, 0, 0 ); - } - - @Test - public void testCycleA() - throws Exception - { - DependencyNode root = parseResource( "cycle-a.txt" ); - assertSame( root, transform( root ) ); - - expectScope( "compile", root, 0 ); - expectScope( "runtime", root, 1 ); - } - - @Test - public void testCycleB() - throws Exception - { - DependencyNode root = parseResource( "cycle-b.txt" ); - assertSame( root, transform( root ) ); - - expectScope( "runtime", root, 0 ); - expectScope( "compile", root, 1 ); - } - - @Test - public void testCycleC() - throws Exception - { - DependencyNode root = parseResource( "cycle-c.txt" ); - assertSame( root, transform( root ) ); - - expectScope( "runtime", root, 0 ); - expectScope( "runtime", root, 0, 0 ); - expectScope( "runtime", root, 1 ); - expectScope( "runtime", root, 1, 0 ); - } - - @Test - public void testCycleD() - throws Exception - { - DependencyNode root = parseResource( "cycle-d.txt" ); - assertSame( root, transform( root ) ); - - expectScope( "compile", root, 0 ); - expectScope( "compile", root, 0, 0 ); - } - - @Test - public void testDirectNodesAlwaysWin() - throws Exception - { - - for ( Scope directScope : Scope.values() ) - { - String direct = directScope.toString(); - - DependencyNode root = parseResource( "direct-nodes-winning.txt", direct ); - - String msg = - String.format( "direct node should be setting scope ('%s') for all nodes.\n" + parser.dump( root ), - direct ); - assertSame( root, transform( root ) ); - msg += "\ntransformed:\n" + parser.dump( root ); - - expectScope( msg, direct, root, 0 ); - } - } - - @Test - public void testNonDirectMultipleInheritance() - throws Exception - { - for ( Scope scope1 : Scope.values() ) - { - for ( Scope scope2 : Scope.values() ) - { - DependencyNode root = parseResource( "multiple-inheritance.txt", scope1.toString(), scope2.toString() ); - - String expected = scope1.compareTo( scope2 ) >= 0 ? scope1.toString() : scope2.toString(); - String msg = String.format( "expected '%s' to win\n" + parser.dump( root ), expected ); - - assertSame( root, transform( root ) ); - msg += "\ntransformed:\n" + parser.dump( root ); - - expectScope( msg, expected, root, 0, 0 ); - } - } - } - - @Test - public void testConflictScopeOrdering() - throws Exception - { - for ( Scope scope1 : Scope.values() ) - { - for ( Scope scope2 : Scope.values() ) - { - DependencyNode root = parseResource( "dueling-scopes.txt", scope1.toString(), scope2.toString() ); - - String expected = scope1.compareTo( scope2 ) >= 0 ? scope1.toString() : scope2.toString(); - String msg = String.format( "expected '%s' to win\n" + parser.dump( root ), expected ); - - assertSame( root, transform( root ) ); - msg += "\ntransformed:\n" + parser.dump( root ); - - expectScope( msg, expected, root, 0, 0 ); - } - } - } - - /** - * obscure case (illegal maven POM). - */ - @Test - public void testConflictingDirectNodes() - throws Exception - { - for ( Scope scope1 : Scope.values() ) - { - for ( Scope scope2 : Scope.values() ) - { - DependencyNode root = parseResource( "conflicting-direct-nodes.txt", scope1.toString(), scope2.toString() ); - - String expected = scope1.toString(); - String msg = String.format( "expected '%s' to win\n" + parser.dump( root ), expected ); - - assertSame( root, transform( root ) ); - msg += "\ntransformed:\n" + parser.dump( root ); - - expectScope( msg, expected, root, 0 ); - } - } - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/NearestVersionSelectorTest.java ---------------------------------------------------------------------- diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/NearestVersionSelectorTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/NearestVersionSelectorTest.java deleted file mode 100644 index b71adab..0000000 --- a/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/NearestVersionSelectorTest.java +++ /dev/null @@ -1,244 +0,0 @@ -package org.eclipse.aether.util.graph.transformer; - -/* - * 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 static org.junit.Assert.*; - -import java.util.List; - -import org.eclipse.aether.collection.UnsolvableVersionConflictException; -import org.eclipse.aether.graph.DependencyNode; -import org.eclipse.aether.internal.test.util.DependencyGraphParser; -import org.junit.Test; - -/** - */ -public class NearestVersionSelectorTest - extends AbstractDependencyGraphTransformerTest -{ - - @Override - protected ConflictResolver newTransformer() - { - return new ConflictResolver( new NearestVersionSelector(), new JavaScopeSelector(), - new SimpleOptionalitySelector(), new JavaScopeDeriver() ); - } - - @Override - protected DependencyGraphParser newParser() - { - return new DependencyGraphParser( "transformer/version-resolver/" ); - } - - @Test - public void testSelectHighestVersionFromMultipleVersionsAtSameLevel() - throws Exception - { - DependencyNode root = parseResource( "sibling-versions.txt" ); - assertSame( root, transform( root ) ); - - assertEquals( 1, root.getChildren().size() ); - assertEquals( "3", root.getChildren().get( 0 ).getArtifact().getVersion() ); - } - - @Test - public void testSelectedVersionAtDeeperLevelThanOriginallySeen() - throws Exception - { - DependencyNode root = parseResource( "nearest-underneath-loser-a.txt" ); - - assertSame( root, transform( root ) ); - - List<DependencyNode> trail = find( root, "j" ); - assertEquals( 5, trail.size() ); - } - - @Test - public void testNearestDirtyVersionUnderneathRemovedNode() - throws Exception - { - DependencyNode root = parseResource( "nearest-underneath-loser-b.txt" ); - - assertSame( root, transform( root ) ); - - List<DependencyNode> trail = find( root, "j" ); - assertEquals( 5, trail.size() ); - } - - @Test - public void testViolationOfHardConstraintFallsBackToNearestSeenNotFirstSeen() - throws Exception - { - DependencyNode root = parseResource( "range-backtracking.txt" ); - - assertSame( root, transform( root ) ); - - List<DependencyNode> trail = find( root, "x" ); - assertEquals( 3, trail.size() ); - assertEquals( "2", trail.get( 0 ).getArtifact().getVersion() ); - } - - @Test - public void testCyclicConflictIdGraph() - throws Exception - { - DependencyNode root = parseResource( "conflict-id-cycle.txt" ); - - assertSame( root, transform( root ) ); - - assertEquals( 2, root.getChildren().size() ); - assertEquals( "a", root.getChildren().get( 0 ).getArtifact().getArtifactId() ); - assertEquals( "b", root.getChildren().get( 1 ).getArtifact().getArtifactId() ); - assertTrue( root.getChildren().get( 0 ).getChildren().isEmpty() ); - assertTrue( root.getChildren().get( 1 ).getChildren().isEmpty() ); - } - - @Test( expected = UnsolvableVersionConflictException.class ) - public void testUnsolvableRangeConflictBetweenHardConstraints() - throws Exception - { - DependencyNode root = parseResource( "unsolvable.txt" ); - - assertSame( root, transform( root ) ); - } - - @Test( expected = UnsolvableVersionConflictException.class ) - public void testUnsolvableRangeConflictWithUnrelatedCycle() - throws Exception - { - DependencyNode root = parseResource( "unsolvable-with-cycle.txt" ); - - transform( root ); - } - - @Test - public void testSolvableConflictBetweenHardConstraints() - throws Exception - { - DependencyNode root = parseResource( "ranges.txt" ); - - assertSame( root, transform( root ) ); - } - - @Test - public void testConflictGroupCompletelyDroppedFromResolvedTree() - throws Exception - { - DependencyNode root = parseResource( "dead-conflict-group.txt" ); - - assertSame( root, transform( root ) ); - - assertEquals( 2, root.getChildren().size() ); - assertEquals( "a", root.getChildren().get( 0 ).getArtifact().getArtifactId() ); - assertEquals( "b", root.getChildren().get( 1 ).getArtifact().getArtifactId() ); - assertTrue( root.getChildren().get( 0 ).getChildren().isEmpty() ); - assertTrue( root.getChildren().get( 1 ).getChildren().isEmpty() ); - } - - @Test - public void testNearestSoftVersionPrunedByFartherRange() - throws Exception - { - DependencyNode root = parseResource( "soft-vs-range.txt" ); - - assertSame( root, transform( root ) ); - - assertEquals( 2, root.getChildren().size() ); - assertEquals( "a", root.getChildren().get( 0 ).getArtifact().getArtifactId() ); - assertEquals( 0, root.getChildren().get( 0 ).getChildren().size() ); - assertEquals( "b", root.getChildren().get( 1 ).getArtifact().getArtifactId() ); - assertEquals( 1, root.getChildren().get( 1 ).getChildren().size() ); - } - - @Test - public void testCyclicGraph() - throws Exception - { - DependencyNode root = parseResource( "cycle.txt" ); - - assertSame( root, transform( root ) ); - - assertEquals( 2, root.getChildren().size() ); - assertEquals( 1, root.getChildren().get( 0 ).getChildren().size() ); - assertEquals( 0, root.getChildren().get( 0 ).getChildren().get( 0 ).getChildren().size() ); - assertEquals( 0, root.getChildren().get( 1 ).getChildren().size() ); - } - - @Test - public void testLoop() - throws Exception - { - DependencyNode root = parseResource( "loop.txt" ); - - assertSame( root, transform( root ) ); - - assertEquals( 0, root.getChildren().size() ); - } - - @Test - public void testOverlappingCycles() - throws Exception - { - DependencyNode root = parseResource( "overlapping-cycles.txt" ); - - assertSame( root, transform( root ) ); - - assertEquals( 2, root.getChildren().size() ); - } - - @Test - public void testScopeDerivationAndConflictResolutionCantHappenForAllNodesBeforeVersionSelection() - throws Exception - { - DependencyNode root = parseResource( "scope-vs-version.txt" ); - - assertSame( root, transform( root ) ); - - DependencyNode[] nodes = find( root, "y" ).toArray( new DependencyNode[0] ); - assertEquals( 3, nodes.length ); - assertEquals( "test", nodes[1].getDependency().getScope() ); - assertEquals( "test", nodes[0].getDependency().getScope() ); - } - - @Test - public void testVerboseMode() - throws Exception - { - DependencyNode root = parseResource( "verbose.txt" ); - - session.setConfigProperty( ConflictResolver.CONFIG_PROP_VERBOSE, Boolean.TRUE ); - assertSame( root, transform( root ) ); - - assertEquals( 2, root.getChildren().size() ); - assertEquals( 1, root.getChildren().get( 0 ).getChildren().size() ); - DependencyNode winner = root.getChildren().get( 0 ).getChildren().get( 0 ); - assertEquals( "test", winner.getDependency().getScope() ); - assertEquals( "compile", winner.getData().get( ConflictResolver.NODE_DATA_ORIGINAL_SCOPE ) ); - assertEquals( false, winner.getData().get( ConflictResolver.NODE_DATA_ORIGINAL_OPTIONALITY) ); - assertEquals( 1, root.getChildren().get( 1 ).getChildren().size() ); - DependencyNode loser = root.getChildren().get( 1 ).getChildren().get( 0 ); - assertEquals( "test", loser.getDependency().getScope() ); - assertEquals( 0, loser.getChildren().size() ); - assertSame( winner, loser.getData().get( ConflictResolver.NODE_DATA_WINNER ) ); - assertEquals( "compile", loser.getData().get( ConflictResolver.NODE_DATA_ORIGINAL_SCOPE ) ); - assertEquals( false, loser.getData().get( ConflictResolver.NODE_DATA_ORIGINAL_OPTIONALITY ) ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/RootQueueTest.java ---------------------------------------------------------------------- diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/RootQueueTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/RootQueueTest.java deleted file mode 100644 index f609ed7..0000000 --- a/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/RootQueueTest.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.eclipse.aether.util.graph.transformer; - -/* - * 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 static org.junit.Assert.*; - -import org.eclipse.aether.util.graph.transformer.ConflictIdSorter.ConflictId; -import org.eclipse.aether.util.graph.transformer.ConflictIdSorter.RootQueue; -import org.junit.Test; - -public class RootQueueTest -{ - - @Test - public void testIsEmpty() - { - ConflictId id = new ConflictId( "a", 0 ); - RootQueue queue = new RootQueue( 10 ); - assertTrue( queue.isEmpty() ); - queue.add( id ); - assertFalse( queue.isEmpty() ); - assertSame( id, queue.remove() ); - assertTrue( queue.isEmpty() ); - } - - @Test - public void testAddSortsByDepth() - { - ConflictId id1 = new ConflictId( "a", 0 ); - ConflictId id2 = new ConflictId( "b", 1 ); - ConflictId id3 = new ConflictId( "c", 2 ); - ConflictId id4 = new ConflictId( "d", 3 ); - - RootQueue queue = new RootQueue( 10 ); - queue.add( id1 ); - queue.add( id2 ); - queue.add( id3 ); - queue.add( id4 ); - assertSame( id1, queue.remove() ); - assertSame( id2, queue.remove() ); - assertSame( id3, queue.remove() ); - assertSame( id4, queue.remove() ); - - queue = new RootQueue( 10 ); - queue.add( id4 ); - queue.add( id3 ); - queue.add( id2 ); - queue.add( id1 ); - assertSame( id1, queue.remove() ); - assertSame( id2, queue.remove() ); - assertSame( id3, queue.remove() ); - assertSame( id4, queue.remove() ); - } - - @Test - public void testAddWithArrayCompact() - { - ConflictId id = new ConflictId( "a", 0 ); - - RootQueue queue = new RootQueue( 10 ); - assertTrue( queue.isEmpty() ); - queue.add( id ); - assertFalse( queue.isEmpty() ); - assertSame( id, queue.remove() ); - assertTrue( queue.isEmpty() ); - queue.add( id ); - assertFalse( queue.isEmpty() ); - assertSame( id, queue.remove() ); - assertTrue( queue.isEmpty() ); - } - - @Test - public void testAddMinimumAfterSomeRemoves() - { - ConflictId id1 = new ConflictId( "a", 0 ); - ConflictId id2 = new ConflictId( "b", 1 ); - ConflictId id3 = new ConflictId( "c", 2 ); - - RootQueue queue = new RootQueue( 10 ); - queue.add( id2 ); - queue.add( id3 ); - assertSame( id2, queue.remove() ); - queue.add( id1 ); - assertSame( id1, queue.remove() ); - assertSame( id3, queue.remove() ); - assertTrue( queue.isEmpty() ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/SimpleConflictMarker.java ---------------------------------------------------------------------- diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/SimpleConflictMarker.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/SimpleConflictMarker.java deleted file mode 100644 index df30368..0000000 --- a/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/SimpleConflictMarker.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.eclipse.aether.util.graph.transformer; - -/* - * 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.IdentityHashMap; -import java.util.Map; - -import org.eclipse.aether.RepositoryException; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.collection.DependencyGraphTransformationContext; -import org.eclipse.aether.collection.DependencyGraphTransformer; -import org.eclipse.aether.graph.Dependency; -import org.eclipse.aether.graph.DependencyNode; -import org.eclipse.aether.util.graph.transformer.TransformationContextKeys; - -/** - * Set "groupId:artId:classifier:extension" as conflict marker for every node. - */ -class SimpleConflictMarker - implements DependencyGraphTransformer -{ - - public DependencyNode transformGraph( DependencyNode node, DependencyGraphTransformationContext context ) - throws RepositoryException - { - @SuppressWarnings( "unchecked" ) - Map<DependencyNode, Object> conflictIds = - (Map<DependencyNode, Object>) context.get( TransformationContextKeys.CONFLICT_IDS ); - if ( conflictIds == null ) - { - conflictIds = new IdentityHashMap<DependencyNode, Object>(); - context.put( TransformationContextKeys.CONFLICT_IDS, conflictIds ); - } - - mark( node, conflictIds ); - - return node; - } - - private void mark( DependencyNode node, Map<DependencyNode, Object> conflictIds ) - { - Dependency dependency = node.getDependency(); - if ( dependency != null ) - { - Artifact artifact = dependency.getArtifact(); - - String key = - String.format( "%s:%s:%s:%s", artifact.getGroupId(), artifact.getArtifactId(), - artifact.getClassifier(), artifact.getExtension() ); - - if ( conflictIds.put( node, key ) != null ) - { - return; - } - } - - for ( DependencyNode child : node.getChildren() ) - { - mark( child, conflictIds ); - } - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/SimpleOptionalitySelectorTest.java ---------------------------------------------------------------------- diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/SimpleOptionalitySelectorTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/SimpleOptionalitySelectorTest.java deleted file mode 100644 index f6d268f..0000000 --- a/aether-util/src/test/java/org/eclipse/aether/util/graph/transformer/SimpleOptionalitySelectorTest.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.eclipse.aether.util.graph.transformer; - -/* - * 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 static org.junit.Assert.*; - -import org.eclipse.aether.collection.DependencyGraphTransformer; -import org.eclipse.aether.graph.DependencyNode; -import org.eclipse.aether.internal.test.util.DependencyGraphParser; -import org.junit.Test; - -public class SimpleOptionalitySelectorTest - extends AbstractDependencyGraphTransformerTest -{ - - @Override - protected DependencyGraphTransformer newTransformer() - { - return new ConflictResolver( new NearestVersionSelector(), new JavaScopeSelector(), - new SimpleOptionalitySelector(), new JavaScopeDeriver() ); - } - - @Override - protected DependencyGraphParser newParser() - { - return new DependencyGraphParser( "transformer/optionality-selector/" ); - } - - @Test - public void testDeriveOptionality() - throws Exception - { - DependencyNode root = parseResource( "derive.txt" ); - assertSame( root, transform( root ) ); - - assertEquals( 2, root.getChildren().size() ); - assertEquals( true, root.getChildren().get( 0 ).getDependency().isOptional() ); - assertEquals( true, root.getChildren().get( 0 ).getChildren().get( 0 ).getDependency().isOptional() ); - assertEquals( false, root.getChildren().get( 1 ).getDependency().isOptional() ); - assertEquals( false, root.getChildren().get( 1 ).getChildren().get( 0 ).getDependency().isOptional() ); - } - - @Test - public void testResolveOptionalityConflict_NonOptionalWins() - throws Exception - { - DependencyNode root = parseResource( "conflict.txt" ); - assertSame( root, transform( root ) ); - - assertEquals( 2, root.getChildren().size() ); - assertEquals( true, root.getChildren().get( 0 ).getDependency().isOptional() ); - assertEquals( false, root.getChildren().get( 0 ).getChildren().get( 0 ).getDependency().isOptional() ); - } - - @Test - public void testResolveOptionalityConflict_DirectDeclarationWins() - throws Exception - { - DependencyNode root = parseResource( "conflict-direct-dep.txt" ); - assertSame( root, transform( root ) ); - - assertEquals( 2, root.getChildren().size() ); - assertEquals( true, root.getChildren().get( 1 ).getDependency().isOptional() ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/traverser/AndDependencyTraverserTest.java ---------------------------------------------------------------------- diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/traverser/AndDependencyTraverserTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/traverser/AndDependencyTraverserTest.java deleted file mode 100644 index 74d744e..0000000 --- a/aether-util/src/test/java/org/eclipse/aether/util/graph/traverser/AndDependencyTraverserTest.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.eclipse.aether.util.graph.traverser; - -/* - * 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 static org.junit.Assert.*; - -import org.eclipse.aether.artifact.DefaultArtifact; -import org.eclipse.aether.collection.DependencyCollectionContext; -import org.eclipse.aether.collection.DependencyTraverser; -import org.eclipse.aether.graph.Dependency; -import org.junit.Test; - -public class AndDependencyTraverserTest -{ - - static class DummyDependencyTraverser - implements DependencyTraverser - { - - private final boolean traverse; - - private final DependencyTraverser child; - - public DummyDependencyTraverser() - { - this( true ); - } - - public DummyDependencyTraverser( boolean traverse ) - { - this.traverse = traverse; - this.child = this; - } - - public DummyDependencyTraverser( boolean traverse, DependencyTraverser child ) - { - this.traverse = traverse; - this.child = child; - } - - public boolean traverseDependency( Dependency dependency ) - { - return traverse; - } - - public DependencyTraverser deriveChildTraverser( DependencyCollectionContext context ) - { - return child; - } - - } - - @Test - public void testNewInstance() - { - assertNull( AndDependencyTraverser.newInstance( null, null ) ); - DependencyTraverser traverser = new DummyDependencyTraverser(); - assertSame( traverser, AndDependencyTraverser.newInstance( traverser, null ) ); - assertSame( traverser, AndDependencyTraverser.newInstance( null, traverser ) ); - assertSame( traverser, AndDependencyTraverser.newInstance( traverser, traverser ) ); - assertNotNull( AndDependencyTraverser.newInstance( traverser, new DummyDependencyTraverser() ) ); - } - - @Test - public void testTraverseDependency() - { - Dependency dependency = new Dependency( new DefaultArtifact( "g:a:v:1" ), "runtime" ); - - DependencyTraverser traverser = new AndDependencyTraverser(); - assertTrue( traverser.traverseDependency( dependency ) ); - - traverser = - new AndDependencyTraverser( new DummyDependencyTraverser( false ), new DummyDependencyTraverser( false ) ); - assertFalse( traverser.traverseDependency( dependency ) ); - - traverser = - new AndDependencyTraverser( new DummyDependencyTraverser( true ), new DummyDependencyTraverser( false ) ); - assertFalse( traverser.traverseDependency( dependency ) ); - - traverser = - new AndDependencyTraverser( new DummyDependencyTraverser( true ), new DummyDependencyTraverser( true ) ); - assertTrue( traverser.traverseDependency( dependency ) ); - } - - @Test - public void testDeriveChildTraverser_Unchanged() - { - DependencyTraverser other1 = new DummyDependencyTraverser( true ); - DependencyTraverser other2 = new DummyDependencyTraverser( false ); - DependencyTraverser traverser = new AndDependencyTraverser( other1, other2 ); - assertSame( traverser, traverser.deriveChildTraverser( null ) ); - } - - @Test - public void testDeriveChildTraverser_OneRemaining() - { - DependencyTraverser other1 = new DummyDependencyTraverser( true ); - DependencyTraverser other2 = new DummyDependencyTraverser( false, null ); - DependencyTraverser traverser = new AndDependencyTraverser( other1, other2 ); - assertSame( other1, traverser.deriveChildTraverser( null ) ); - } - - @Test - public void testDeriveChildTraverser_ZeroRemaining() - { - DependencyTraverser other1 = new DummyDependencyTraverser( true, null ); - DependencyTraverser other2 = new DummyDependencyTraverser( false, null ); - DependencyTraverser traverser = new AndDependencyTraverser( other1, other2 ); - assertNull( traverser.deriveChildTraverser( null ) ); - } - - @Test - public void testEquals() - { - DependencyTraverser other1 = new DummyDependencyTraverser( true ); - DependencyTraverser other2 = new DummyDependencyTraverser( false ); - DependencyTraverser traverser1 = new AndDependencyTraverser( other1, other2 ); - DependencyTraverser traverser2 = new AndDependencyTraverser( other2, other1 ); - DependencyTraverser traverser3 = new AndDependencyTraverser( other1 ); - assertEquals( traverser1, traverser1 ); - assertEquals( traverser1, traverser2 ); - assertNotEquals( traverser1, traverser3 ); - assertNotEquals( traverser1, this ); - assertNotEquals( traverser1, null ); - } - - @Test - public void testHashCode() - { - DependencyTraverser other1 = new DummyDependencyTraverser( true ); - DependencyTraverser other2 = new DummyDependencyTraverser( false ); - DependencyTraverser traverser1 = new AndDependencyTraverser( other1, other2 ); - DependencyTraverser traverser2 = new AndDependencyTraverser( other2, other1 ); - assertEquals( traverser1.hashCode(), traverser2.hashCode() ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/traverser/FatArtifactTraverserTest.java ---------------------------------------------------------------------- diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/traverser/FatArtifactTraverserTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/traverser/FatArtifactTraverserTest.java deleted file mode 100644 index 641e593..0000000 --- a/aether-util/src/test/java/org/eclipse/aether/util/graph/traverser/FatArtifactTraverserTest.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.eclipse.aether.util.graph.traverser; - -/* - * 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 static org.junit.Assert.*; - -import java.util.Collections; -import java.util.Map; - -import org.eclipse.aether.artifact.ArtifactProperties; -import org.eclipse.aether.artifact.DefaultArtifact; -import org.eclipse.aether.collection.DependencyTraverser; -import org.eclipse.aether.graph.Dependency; -import org.junit.Test; - -public class FatArtifactTraverserTest -{ - - @Test - public void testTraverseDependency() - { - DependencyTraverser traverser = new FatArtifactTraverser(); - Map<String, String> props = null; - assertTrue( traverser.traverseDependency( new Dependency( new DefaultArtifact( "g:a:v:1", props ), "test" ) ) ); - props = Collections.singletonMap( ArtifactProperties.INCLUDES_DEPENDENCIES, "false" ); - assertTrue( traverser.traverseDependency( new Dependency( new DefaultArtifact( "g:a:v:1", props ), "test" ) ) ); - props = Collections.singletonMap( ArtifactProperties.INCLUDES_DEPENDENCIES, "unrecognized" ); - assertTrue( traverser.traverseDependency( new Dependency( new DefaultArtifact( "g:a:v:1", props ), "test" ) ) ); - props = Collections.singletonMap( ArtifactProperties.INCLUDES_DEPENDENCIES, "true" ); - assertFalse( traverser.traverseDependency( new Dependency( new DefaultArtifact( "g:a:v:1", props ), "test" ) ) ); - } - - @Test - public void testDeriveChildTraverser() - { - DependencyTraverser traverser = new FatArtifactTraverser(); - assertSame( traverser, traverser.deriveChildTraverser( null ) ); - } - - @Test - public void testEquals() - { - DependencyTraverser traverser1 = new FatArtifactTraverser(); - DependencyTraverser traverser2 = new FatArtifactTraverser(); - assertEquals( traverser1, traverser1 ); - assertEquals( traverser1, traverser2 ); - assertNotEquals( traverser1, this ); - assertNotEquals( traverser1, null ); - } - - @Test - public void testHashCode() - { - DependencyTraverser traverser1 = new FatArtifactTraverser(); - DependencyTraverser traverser2 = new FatArtifactTraverser(); - assertEquals( traverser1.hashCode(), traverser2.hashCode() ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/traverser/StaticDependencyTraverserTest.java ---------------------------------------------------------------------- diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/traverser/StaticDependencyTraverserTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/traverser/StaticDependencyTraverserTest.java deleted file mode 100644 index 0ac1d91..0000000 --- a/aether-util/src/test/java/org/eclipse/aether/util/graph/traverser/StaticDependencyTraverserTest.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.eclipse.aether.util.graph.traverser; - -/* - * 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 static org.junit.Assert.*; - -import org.eclipse.aether.artifact.DefaultArtifact; -import org.eclipse.aether.collection.DependencyTraverser; -import org.eclipse.aether.graph.Dependency; -import org.junit.Test; - -public class StaticDependencyTraverserTest -{ - - @Test - public void testTraverseDependency() - { - Dependency dependency = new Dependency( new DefaultArtifact( "g:a:v:1" ), "runtime" ); - DependencyTraverser traverser = new StaticDependencyTraverser( true ); - assertTrue( traverser.traverseDependency( dependency ) ); - traverser = new StaticDependencyTraverser( false ); - assertFalse( traverser.traverseDependency( dependency ) ); - } - - @Test - public void testDeriveChildTraverser() - { - DependencyTraverser traverser = new StaticDependencyTraverser( true ); - assertSame( traverser, traverser.deriveChildTraverser( null ) ); - } - - @Test - public void testEquals() - { - DependencyTraverser traverser1 = new StaticDependencyTraverser( true ); - DependencyTraverser traverser2 = new StaticDependencyTraverser( true ); - DependencyTraverser traverser3 = new StaticDependencyTraverser( false ); - assertEquals( traverser1, traverser1 ); - assertEquals( traverser1, traverser2 ); - assertNotEquals( traverser1, traverser3 ); - assertNotEquals( traverser1, this ); - assertNotEquals( traverser1, null ); - } - - @Test - public void testHashCode() - { - DependencyTraverser traverser1 = new StaticDependencyTraverser( true ); - DependencyTraverser traverser2 = new StaticDependencyTraverser( true ); - assertEquals( traverser1.hashCode(), traverser2.hashCode() ); - } - -}