You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2017/01/22 14:02:04 UTC
[09/54] [abbrv] [partial] maven-resolver git commit: [MNG-6007]
renamed Aether to Maven Artifact Resolver
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/versions/AbstractVersionFilterTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/versions/AbstractVersionFilterTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/versions/AbstractVersionFilterTest.java
deleted file mode 100644
index 13fd4b0..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/graph/versions/AbstractVersionFilterTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package org.eclipse.aether.util.graph.versions;
-
-/*
- * 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.Iterator;
-
-import org.eclipse.aether.DefaultRepositorySystemSession;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.eclipse.aether.collection.VersionFilter;
-import org.eclipse.aether.graph.Dependency;
-import org.eclipse.aether.internal.test.util.TestUtils;
-import org.eclipse.aether.resolution.VersionRangeRequest;
-import org.eclipse.aether.resolution.VersionRangeResult;
-import org.eclipse.aether.util.version.GenericVersionScheme;
-import org.eclipse.aether.version.InvalidVersionSpecificationException;
-import org.eclipse.aether.version.Version;
-import org.eclipse.aether.version.VersionScheme;
-import org.junit.After;
-import org.junit.Before;
-
-public abstract class AbstractVersionFilterTest
-{
-
- protected DefaultRepositorySystemSession session;
-
- @Before
- public void setUp()
- {
- session = TestUtils.newSession();
- }
-
- @After
- public void tearDown()
- {
- session = null;
- }
-
- protected VersionFilter.VersionFilterContext newContext( String gav, String... versions )
- {
- VersionRangeRequest request = new VersionRangeRequest();
- request.setArtifact( new DefaultArtifact( gav ) );
- VersionRangeResult result = new VersionRangeResult( request );
- VersionScheme scheme = new GenericVersionScheme();
- try
- {
- result.setVersionConstraint( scheme.parseVersionConstraint( request.getArtifact().getVersion() ) );
- for ( String version : versions )
- {
- result.addVersion( scheme.parseVersion( version ) );
- }
- }
- catch ( InvalidVersionSpecificationException e )
- {
- throw new IllegalArgumentException( e );
- }
- return TestUtils.newVersionFilterContext( session, result );
- }
-
- protected VersionFilter derive( VersionFilter filter, String gav )
- {
- return filter.deriveChildFilter( TestUtils.newCollectionContext( session,
- new Dependency( new DefaultArtifact( gav ), "" ),
- null ) );
- }
-
- protected void assertVersions( VersionFilter.VersionFilterContext context, String... versions )
- {
- assertEquals( versions.length, context.getCount() );
- Iterator<Version> it = context.iterator();
- for ( String version : versions )
- {
- assertTrue( it.hasNext() );
- assertEquals( version, it.next().toString() );
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/versions/ChainedVersionFilterTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/versions/ChainedVersionFilterTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/versions/ChainedVersionFilterTest.java
deleted file mode 100644
index 1e8a5bd..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/graph/versions/ChainedVersionFilterTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package org.eclipse.aether.util.graph.versions;
-
-/*
- * 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.DependencyCollectionContext;
-import org.eclipse.aether.collection.VersionFilter;
-import org.eclipse.aether.collection.VersionFilter.VersionFilterContext;
-import org.eclipse.aether.util.graph.version.ChainedVersionFilter;
-import org.eclipse.aether.util.graph.version.HighestVersionFilter;
-import org.eclipse.aether.util.graph.version.SnapshotVersionFilter;
-import org.junit.Test;
-
-public class ChainedVersionFilterTest
- extends AbstractVersionFilterTest
-{
-
- @Test
- public void testFilterVersions()
- throws Exception
- {
- VersionFilter filter =
- ChainedVersionFilter.newInstance( new SnapshotVersionFilter(), new HighestVersionFilter() );
- VersionFilterContext ctx = newContext( "g:a:[1,9]", "1", "2", "3-SNAPSHOT" );
- filter.filterVersions( ctx );
- assertVersions( ctx, "2" );
- }
-
- @Test
- public void testDeriveChildFilter()
- {
- VersionFilter filter1 = new HighestVersionFilter();
- VersionFilter filter2 = new VersionFilter()
- {
- public void filterVersions( VersionFilterContext context )
- {
- }
-
- public VersionFilter deriveChildFilter( DependencyCollectionContext context )
- {
- return null;
- }
- };
-
- VersionFilter filter = ChainedVersionFilter.newInstance( filter1 );
- assertSame( filter, derive( filter, "g:a:1" ) );
-
- filter = ChainedVersionFilter.newInstance( filter2 );
- assertSame( null, derive( filter, "g:a:1" ) );
-
- filter = ChainedVersionFilter.newInstance( filter1, filter2 );
- assertSame( filter1, derive( filter, "g:a:1" ) );
-
- filter = ChainedVersionFilter.newInstance( filter2, filter1 );
- assertSame( filter1, derive( filter, "g:a:1" ) );
- }
-
- @Test
- public void testEquals()
- {
- VersionFilter filter = ChainedVersionFilter.newInstance( new HighestVersionFilter() );
- assertFalse( filter.equals( null ) );
- assertTrue( filter.equals( filter ) );
- assertTrue( filter.equals( ChainedVersionFilter.newInstance( new HighestVersionFilter() ) ) );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/versions/ContextualSnapshotVersionFilterTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/versions/ContextualSnapshotVersionFilterTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/versions/ContextualSnapshotVersionFilterTest.java
deleted file mode 100644
index dd88a66..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/graph/versions/ContextualSnapshotVersionFilterTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.eclipse.aether.util.graph.versions;
-
-/*
- * 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.VersionFilter;
-import org.eclipse.aether.collection.VersionFilter.VersionFilterContext;
-import org.eclipse.aether.util.graph.version.ContextualSnapshotVersionFilter;
-import org.eclipse.aether.util.graph.version.SnapshotVersionFilter;
-import org.junit.Test;
-
-public class ContextualSnapshotVersionFilterTest
- extends AbstractVersionFilterTest
-{
-
- @Test
- public void testFilterVersions()
- throws Exception
- {
- VersionFilter filter = new ContextualSnapshotVersionFilter();
- VersionFilterContext ctx = newContext( "g:a:[1,9]", "1", "2-SNAPSHOT" );
- filter.filterVersions( ctx );
- assertVersions( ctx, "1", "2-SNAPSHOT" );
-
- ctx = newContext( "g:a:[1,9]", "1", "2-SNAPSHOT" );
- derive( filter, "g:a:1" ).filterVersions( ctx );
- assertVersions( ctx, "1" );
-
- ctx = newContext( "g:a:[1,9]", "1", "2-SNAPSHOT" );
- session.setConfigProperty( ContextualSnapshotVersionFilter.CONFIG_PROP_ENABLE, "true" );
- derive( filter, "g:a:1-SNAPSHOT" ).filterVersions( ctx );
- assertVersions( ctx, "1" );
- }
-
- @Test
- public void testDeriveChildFilter()
- {
- ContextualSnapshotVersionFilter filter = new ContextualSnapshotVersionFilter();
- assertTrue( derive( filter, "g:a:1" ) instanceof SnapshotVersionFilter );
- assertSame( null, derive( filter, "g:a:1-SNAPSHOT" ) );
- session.setConfigProperty( ContextualSnapshotVersionFilter.CONFIG_PROP_ENABLE, "true" );
- assertTrue( derive( filter, "g:a:1-SNAPSHOT" ) instanceof SnapshotVersionFilter );
- }
-
- @Test
- public void testEquals()
- {
- ContextualSnapshotVersionFilter filter = new ContextualSnapshotVersionFilter();
- assertFalse( filter.equals( null ) );
- assertTrue( filter.equals( filter ) );
- assertTrue( filter.equals( new ContextualSnapshotVersionFilter() ) );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/versions/HighestVersionFilterTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/versions/HighestVersionFilterTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/versions/HighestVersionFilterTest.java
deleted file mode 100644
index 3926c66..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/graph/versions/HighestVersionFilterTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.eclipse.aether.util.graph.versions;
-
-/*
- * 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.VersionFilter.VersionFilterContext;
-import org.eclipse.aether.util.graph.version.HighestVersionFilter;
-import org.junit.Test;
-
-public class HighestVersionFilterTest
- extends AbstractVersionFilterTest
-{
-
- @Test
- public void testFilterVersions()
- {
- HighestVersionFilter filter = new HighestVersionFilter();
- VersionFilterContext ctx = newContext( "g:a:[1,9]", "1", "2", "3", "4", "5", "6", "7", "8", "9" );
- filter.filterVersions( ctx );
- assertVersions( ctx, "9" );
- }
-
- @Test
- public void testDeriveChildFilter()
- {
- HighestVersionFilter filter = new HighestVersionFilter();
- assertSame( filter, derive( filter, "g:a:1" ) );
- }
-
- @Test
- public void testEquals()
- {
- HighestVersionFilter filter = new HighestVersionFilter();
- assertFalse( filter.equals( null ) );
- assertTrue( filter.equals( filter ) );
- assertTrue( filter.equals( new HighestVersionFilter() ) );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/versions/SnapshotVersionFilterTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/versions/SnapshotVersionFilterTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/versions/SnapshotVersionFilterTest.java
deleted file mode 100644
index 70c26f9..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/graph/versions/SnapshotVersionFilterTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.eclipse.aether.util.graph.versions;
-
-/*
- * 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.VersionFilter.VersionFilterContext;
-import org.eclipse.aether.util.graph.version.SnapshotVersionFilter;
-import org.junit.Test;
-
-public class SnapshotVersionFilterTest
- extends AbstractVersionFilterTest
-{
-
- @Test
- public void testFilterVersions()
- {
- SnapshotVersionFilter filter = new SnapshotVersionFilter();
- VersionFilterContext ctx = newContext( "g:a:[1,9]", "1", "2-SNAPSHOT", "3.1", "4.0-SNAPSHOT", "5.0.0" );
- filter.filterVersions( ctx );
- assertVersions( ctx, "1", "3.1", "5.0.0" );
- }
-
- @Test
- public void testDeriveChildFilter()
- {
- SnapshotVersionFilter filter = new SnapshotVersionFilter();
- assertSame( filter, derive( filter, "g:a:1" ) );
- }
-
- @Test
- public void testEquals()
- {
- SnapshotVersionFilter filter = new SnapshotVersionFilter();
- assertFalse( filter.equals( null ) );
- assertTrue( filter.equals( filter ) );
- assertTrue( filter.equals( new SnapshotVersionFilter() ) );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/visitor/FilteringDependencyVisitorTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/visitor/FilteringDependencyVisitorTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/visitor/FilteringDependencyVisitorTest.java
deleted file mode 100644
index 65a02a8..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/graph/visitor/FilteringDependencyVisitorTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.eclipse.aether.util.graph.visitor;
-
-/*
- * 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.graph.DependencyFilter;
-import org.eclipse.aether.graph.DependencyNode;
-import org.eclipse.aether.internal.test.util.DependencyGraphParser;
-import org.junit.Test;
-
-public class FilteringDependencyVisitorTest
-{
-
- private DependencyNode parse( String resource )
- throws Exception
- {
- return new DependencyGraphParser( "visitor/filtering/" ).parseResource( resource );
- }
-
- @Test
- public void testFilterCalledWithProperParentStack()
- throws Exception
- {
- DependencyNode root = parse( "parents.txt" );
-
- final StringBuilder buffer = new StringBuilder( 256 );
- DependencyFilter filter = new DependencyFilter()
- {
- public boolean accept( DependencyNode node, List<DependencyNode> parents )
- {
- for ( DependencyNode parent : parents )
- {
- buffer.append( parent.getDependency().getArtifact().getArtifactId() );
- }
- buffer.append( "," );
- return false;
- }
- };
-
- FilteringDependencyVisitor visitor = new FilteringDependencyVisitor( new PreorderNodeListGenerator(), filter );
- root.accept( visitor );
-
- assertEquals( ",a,ba,cba,a,ea,", buffer.toString() );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/visitor/PathRecordingDependencyVisitorTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/visitor/PathRecordingDependencyVisitorTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/visitor/PathRecordingDependencyVisitorTest.java
deleted file mode 100644
index cd766a0..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/graph/visitor/PathRecordingDependencyVisitorTest.java
+++ /dev/null
@@ -1,147 +0,0 @@
-package org.eclipse.aether.util.graph.visitor;
-
-/*
- * 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.graph.DependencyFilter;
-import org.eclipse.aether.graph.DependencyNode;
-import org.eclipse.aether.internal.test.util.DependencyGraphParser;
-import org.junit.Test;
-
-public class PathRecordingDependencyVisitorTest
-{
-
- private DependencyNode parse( String resource )
- throws Exception
- {
- return new DependencyGraphParser( "visitor/path-recorder/" ).parseResource( resource );
- }
-
- private void assertPath( List<DependencyNode> actual, String... expected )
- {
- assertEquals( actual.toString(), expected.length, actual.size() );
- for ( int i = 0; i < expected.length; i++ )
- {
- DependencyNode node = actual.get( i );
- assertEquals( actual.toString(), expected[i], node.getDependency().getArtifact().getArtifactId() );
- }
- }
-
- @Test
- public void testGetPaths_RecordsMatchesBeneathUnmatchedParents()
- throws Exception
- {
- DependencyNode root = parse( "simple.txt" );
-
- PathRecordingDependencyVisitor visitor = new PathRecordingDependencyVisitor( new ArtifactMatcher() );
- root.accept( visitor );
-
- List<List<DependencyNode>> paths = visitor.getPaths();
- assertEquals( paths.toString(), 2, paths.size() );
- assertPath( paths.get( 0 ), "a", "b", "x" );
- assertPath( paths.get( 1 ), "a", "x" );
- }
-
- @Test
- public void testGetPaths_DoesNotRecordMatchesBeneathMatchedParents()
- throws Exception
- {
- DependencyNode root = parse( "nested.txt" );
-
- PathRecordingDependencyVisitor visitor = new PathRecordingDependencyVisitor( new ArtifactMatcher() );
- root.accept( visitor );
-
- List<List<DependencyNode>> paths = visitor.getPaths();
- assertEquals( paths.toString(), 1, paths.size() );
- assertPath( paths.get( 0 ), "x" );
- }
-
- @Test
- public void testGetPaths_RecordsMatchesBeneathMatchedParentsIfRequested()
- throws Exception
- {
- DependencyNode root = parse( "nested.txt" );
-
- PathRecordingDependencyVisitor visitor = new PathRecordingDependencyVisitor( new ArtifactMatcher(), false );
- root.accept( visitor );
-
- List<List<DependencyNode>> paths = visitor.getPaths();
- assertEquals( paths.toString(), 3, paths.size() );
- assertPath( paths.get( 0 ), "x" );
- assertPath( paths.get( 1 ), "x", "a", "y" );
- assertPath( paths.get( 2 ), "x", "y" );
- }
-
- @Test
- public void testFilterCalledWithProperParentStack()
- throws Exception
- {
- DependencyNode root = parse( "parents.txt" );
-
- final StringBuilder buffer = new StringBuilder( 256 );
- DependencyFilter filter = new DependencyFilter()
- {
- public boolean accept( DependencyNode node, List<DependencyNode> parents )
- {
- for ( DependencyNode parent : parents )
- {
- buffer.append( parent.getDependency().getArtifact().getArtifactId() );
- }
- buffer.append( "," );
- return false;
- }
- };
-
- PathRecordingDependencyVisitor visitor = new PathRecordingDependencyVisitor( filter );
- root.accept( visitor );
-
- assertEquals( ",a,ba,cba,a,ea,", buffer.toString() );
- }
-
- @Test
- public void testGetPaths_HandlesCycles()
- throws Exception
- {
- DependencyNode root = parse( "cycle.txt" );
-
- PathRecordingDependencyVisitor visitor = new PathRecordingDependencyVisitor( new ArtifactMatcher(), false );
- root.accept( visitor );
-
- List<List<DependencyNode>> paths = visitor.getPaths();
- assertEquals( paths.toString(), 4, paths.size() );
- assertPath( paths.get( 0 ), "a", "b", "x" );
- assertPath( paths.get( 1 ), "a", "x" );
- assertPath( paths.get( 2 ), "a", "x", "b", "x" );
- assertPath( paths.get( 3 ), "a", "x", "x" );
- }
-
- private static class ArtifactMatcher
- implements DependencyFilter
- {
- public boolean accept( DependencyNode node, List<DependencyNode> parents )
- {
- return node.getDependency() != null && node.getDependency().getArtifact().getGroupId().equals( "match" );
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/visitor/PostorderNodeListGeneratorTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/visitor/PostorderNodeListGeneratorTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/visitor/PostorderNodeListGeneratorTest.java
deleted file mode 100644
index 8d6f525..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/graph/visitor/PostorderNodeListGeneratorTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.eclipse.aether.util.graph.visitor;
-
-/*
- * 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.graph.DependencyNode;
-import org.eclipse.aether.internal.test.util.DependencyGraphParser;
-import org.junit.Test;
-
-public class PostorderNodeListGeneratorTest
-{
-
- private DependencyNode parse( String resource )
- throws Exception
- {
- return new DependencyGraphParser( "visitor/ordered-list/" ).parseResource( resource );
- }
-
- private void assertSequence( List<DependencyNode> actual, String... expected )
- {
- assertEquals( actual.toString(), expected.length, actual.size() );
- for ( int i = 0; i < expected.length; i++ )
- {
- DependencyNode node = actual.get( i );
- assertEquals( actual.toString(), expected[i], node.getDependency().getArtifact().getArtifactId() );
- }
- }
-
- @Test
- public void testOrdering()
- throws Exception
- {
- DependencyNode root = parse( "simple.txt" );
-
- PostorderNodeListGenerator visitor = new PostorderNodeListGenerator();
- root.accept( visitor );
-
- assertSequence( visitor.getNodes(), "c", "b", "e", "d", "a" );
- }
-
- @Test
- public void testDuplicateSuppression()
- throws Exception
- {
- DependencyNode root = parse( "cycles.txt" );
-
- PostorderNodeListGenerator visitor = new PostorderNodeListGenerator();
- root.accept( visitor );
-
- assertSequence( visitor.getNodes(), "c", "b", "e", "d", "a" );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/visitor/PreorderNodeListGeneratorTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/visitor/PreorderNodeListGeneratorTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/visitor/PreorderNodeListGeneratorTest.java
deleted file mode 100644
index 200dd3b..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/graph/visitor/PreorderNodeListGeneratorTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.eclipse.aether.util.graph.visitor;
-
-/*
- * 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.graph.DependencyNode;
-import org.eclipse.aether.internal.test.util.DependencyGraphParser;
-import org.junit.Test;
-
-public class PreorderNodeListGeneratorTest
-{
-
- private DependencyNode parse( String resource )
- throws Exception
- {
- return new DependencyGraphParser( "visitor/ordered-list/" ).parseResource( resource );
- }
-
- private void assertSequence( List<DependencyNode> actual, String... expected )
- {
- assertEquals( actual.toString(), expected.length, actual.size() );
- for ( int i = 0; i < expected.length; i++ )
- {
- DependencyNode node = actual.get( i );
- assertEquals( actual.toString(), expected[i], node.getDependency().getArtifact().getArtifactId() );
- }
- }
-
- @Test
- public void testOrdering()
- throws Exception
- {
- DependencyNode root = parse( "simple.txt" );
-
- PreorderNodeListGenerator visitor = new PreorderNodeListGenerator();
- root.accept( visitor );
-
- assertSequence( visitor.getNodes(), "a", "b", "c", "d", "e" );
- }
-
- @Test
- public void testDuplicateSuppression()
- throws Exception
- {
- DependencyNode root = parse( "cycles.txt" );
-
- PreorderNodeListGenerator visitor = new PreorderNodeListGenerator();
- root.accept( visitor );
-
- assertSequence( visitor.getNodes(), "a", "b", "c", "d", "e" );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/graph/visitor/TreeDependencyVisitorTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/graph/visitor/TreeDependencyVisitorTest.java b/aether-util/src/test/java/org/eclipse/aether/util/graph/visitor/TreeDependencyVisitorTest.java
deleted file mode 100644
index 36cb6ac..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/graph/visitor/TreeDependencyVisitorTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package org.eclipse.aether.util.graph.visitor;
-
-/*
- * 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.graph.DependencyNode;
-import org.eclipse.aether.graph.DependencyVisitor;
-import org.eclipse.aether.internal.test.util.DependencyGraphParser;
-import org.junit.Test;
-
-public class TreeDependencyVisitorTest
-{
-
- private DependencyNode parse( String resource )
- throws Exception
- {
- return new DependencyGraphParser( "visitor/tree/" ).parseResource( resource );
- }
-
- @Test
- public void testDuplicateSuppression()
- throws Exception
- {
- DependencyNode root = parse( "cycles.txt" );
-
- RecordingVisitor rec = new RecordingVisitor();
- TreeDependencyVisitor visitor = new TreeDependencyVisitor( rec );
- root.accept( visitor );
-
- assertEquals( ">a >b >c <c <b >d <d <a ", rec.buffer.toString() );
- }
-
- private static class RecordingVisitor
- implements DependencyVisitor
- {
-
- StringBuilder buffer = new StringBuilder( 256 );
-
- public boolean visitEnter( DependencyNode node )
- {
- buffer.append( '>' ).append( node.getDependency().getArtifact().getArtifactId() ).append( ' ' );
- return true;
- }
-
- public boolean visitLeave( DependencyNode node )
- {
- buffer.append( '<' ).append( node.getDependency().getArtifact().getArtifactId() ).append( ' ' );
- return true;
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/listener/ChainedRepositoryListenerTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/listener/ChainedRepositoryListenerTest.java b/aether-util/src/test/java/org/eclipse/aether/util/listener/ChainedRepositoryListenerTest.java
deleted file mode 100644
index 6eaa25b..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/listener/ChainedRepositoryListenerTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.eclipse.aether.util.listener;
-
-/*
- * 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.lang.reflect.Method;
-
-import org.eclipse.aether.RepositoryListener;
-import org.eclipse.aether.util.listener.ChainedRepositoryListener;
-import org.junit.Test;
-
-/**
- */
-public class ChainedRepositoryListenerTest
-{
-
- @Test
- public void testAllEventTypesHandled()
- throws Exception
- {
- for ( Method method : RepositoryListener.class.getMethods() )
- {
- assertNotNull( ChainedRepositoryListener.class.getDeclaredMethod( method.getName(),
- method.getParameterTypes() ) );
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/listener/ChainedTransferListenerTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/listener/ChainedTransferListenerTest.java b/aether-util/src/test/java/org/eclipse/aether/util/listener/ChainedTransferListenerTest.java
deleted file mode 100644
index 7e7e969..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/listener/ChainedTransferListenerTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.eclipse.aether.util.listener;
-
-/*
- * 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.lang.reflect.Method;
-
-import org.eclipse.aether.transfer.TransferListener;
-import org.eclipse.aether.util.listener.ChainedTransferListener;
-import org.junit.Test;
-
-/**
- */
-public class ChainedTransferListenerTest
-{
-
- @Test
- public void testAllEventTypesHandled()
- throws Exception
- {
- for ( Method method : TransferListener.class.getMethods() )
- {
- assertNotNull( ChainedTransferListener.class.getDeclaredMethod( method.getName(),
- method.getParameterTypes() ) );
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/repository/ComponentAuthenticationTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/repository/ComponentAuthenticationTest.java b/aether-util/src/test/java/org/eclipse/aether/util/repository/ComponentAuthenticationTest.java
deleted file mode 100644
index 25d53f2..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/repository/ComponentAuthenticationTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.eclipse.aether.util.repository;
-
-/*
- * 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.DefaultRepositorySystemSession;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.repository.Authentication;
-import org.eclipse.aether.repository.AuthenticationContext;
-import org.eclipse.aether.repository.AuthenticationDigest;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.junit.Test;
-
-public class ComponentAuthenticationTest
-{
-
- private static class Component
- {
- }
-
- private RepositorySystemSession newSession()
- {
- return new DefaultRepositorySystemSession();
- }
-
- private RemoteRepository newRepo( Authentication auth )
- {
- return new RemoteRepository.Builder( "test", "default", "http://localhost" ).setAuthentication( auth ).build();
- }
-
- private AuthenticationContext newContext( Authentication auth )
- {
- return AuthenticationContext.forRepository( newSession(), newRepo( auth ) );
- }
-
- private String newDigest( Authentication auth )
- {
- return AuthenticationDigest.forRepository( newSession(), newRepo( auth ) );
- }
-
- @Test
- public void testFill()
- {
- Component comp = new Component();
- Authentication auth = new ComponentAuthentication( "key", comp );
- AuthenticationContext context = newContext( auth );
- assertEquals( null, context.get( "another-key" ) );
- assertSame( comp, context.get( "key", Component.class ) );
- }
-
- @Test
- public void testDigest()
- {
- Authentication auth1 = new ComponentAuthentication( "key", new Component() );
- Authentication auth2 = new ComponentAuthentication( "key", new Component() );
- String digest1 = newDigest( auth1 );
- String digest2 = newDigest( auth2 );
- assertEquals( digest1, digest2 );
-
- Authentication auth3 = new ComponentAuthentication( "key", new Object() );
- String digest3 = newDigest( auth3 );
- assertFalse( digest3.equals( digest1 ) );
-
- Authentication auth4 = new ComponentAuthentication( "Key", new Component() );
- String digest4 = newDigest( auth4 );
- assertFalse( digest4.equals( digest1 ) );
- }
-
- @Test
- public void testEquals()
- {
- Authentication auth1 = new ComponentAuthentication( "key", new Component() );
- Authentication auth2 = new ComponentAuthentication( "key", new Component() );
- Authentication auth3 = new ComponentAuthentication( "key", new Object() );
- assertEquals( auth1, auth2 );
- assertFalse( auth1.equals( auth3 ) );
- assertFalse( auth1.equals( null ) );
- }
-
- @Test
- public void testHashCode()
- {
- Authentication auth1 = new ComponentAuthentication( "key", new Component() );
- Authentication auth2 = new ComponentAuthentication( "key", new Component() );
- assertEquals( auth1.hashCode(), auth2.hashCode() );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/repository/DefaultProxySelectorTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/repository/DefaultProxySelectorTest.java b/aether-util/src/test/java/org/eclipse/aether/util/repository/DefaultProxySelectorTest.java
deleted file mode 100644
index 3eacbd5..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/repository/DefaultProxySelectorTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package org.eclipse.aether.util.repository;
-
-/*
- * 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.repository.DefaultProxySelector;
-import org.junit.Test;
-
-/**
- */
-public class DefaultProxySelectorTest
-{
-
- private boolean isNonProxyHost( String host, String nonProxyHosts )
- {
- return new DefaultProxySelector.NonProxyHosts( nonProxyHosts ).isNonProxyHost( host );
- }
-
- @Test
- public void testIsNonProxyHost_Blank()
- {
- assertFalse( isNonProxyHost( "www.eclipse.org", null ) );
- assertFalse( isNonProxyHost( "www.eclipse.org", "" ) );
- }
-
- @Test
- public void testIsNonProxyHost_Wildcard()
- {
- assertTrue( isNonProxyHost( "www.eclipse.org", "*" ) );
- assertTrue( isNonProxyHost( "www.eclipse.org", "*.org" ) );
- assertFalse( isNonProxyHost( "www.eclipse.org", "*.com" ) );
- assertTrue( isNonProxyHost( "www.eclipse.org", "www.*" ) );
- assertTrue( isNonProxyHost( "www.eclipse.org", "www.*.org" ) );
- }
-
- @Test
- public void testIsNonProxyHost_Multiple()
- {
- assertTrue( isNonProxyHost( "eclipse.org", "eclipse.org|host2" ) );
- assertTrue( isNonProxyHost( "eclipse.org", "host1|eclipse.org" ) );
- assertTrue( isNonProxyHost( "eclipse.org", "host1|eclipse.org|host2" ) );
- }
-
- @Test
- public void testIsNonProxyHost_Misc()
- {
- assertFalse( isNonProxyHost( "www.eclipse.org", "www.eclipse.com" ) );
- assertFalse( isNonProxyHost( "www.eclipse.org", "eclipse.org" ) );
- }
-
- @Test
- public void testIsNonProxyHost_CaseInsensitivity()
- {
- assertTrue( isNonProxyHost( "www.eclipse.org", "www.ECLIPSE.org" ) );
- assertTrue( isNonProxyHost( "www.ECLIPSE.org", "www.eclipse.org" ) );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/repository/JreProxySelectorTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/repository/JreProxySelectorTest.java b/aether-util/src/test/java/org/eclipse/aether/util/repository/JreProxySelectorTest.java
deleted file mode 100644
index 8eac55b..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/repository/JreProxySelectorTest.java
+++ /dev/null
@@ -1,184 +0,0 @@
-package org.eclipse.aether.util.repository;
-
-/*
- * 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.io.IOException;
-import java.net.Authenticator;
-import java.net.InetSocketAddress;
-import java.net.PasswordAuthentication;
-import java.net.SocketAddress;
-import java.net.URI;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.aether.DefaultRepositorySystemSession;
-import org.eclipse.aether.repository.Authentication;
-import org.eclipse.aether.repository.AuthenticationContext;
-import org.eclipse.aether.repository.Proxy;
-import org.eclipse.aether.repository.ProxySelector;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class JreProxySelectorTest
-{
-
- private abstract class AbstractProxySelector
- extends java.net.ProxySelector
- {
- @Override
- public void connectFailed( URI uri, SocketAddress sa, IOException ioe )
- {
- }
- }
-
- private ProxySelector selector = new JreProxySelector();
-
- private java.net.ProxySelector original;
-
- @Before
- public void init()
- {
- original = java.net.ProxySelector.getDefault();
- }
-
- @After
- public void exit()
- {
- java.net.ProxySelector.setDefault( original );
- Authenticator.setDefault( null );
- }
-
- @Test
- public void testGetProxy_InvalidUrl()
- throws Exception
- {
- RemoteRepository repo = new RemoteRepository.Builder( "test", "default", "http://host:invalid" ).build();
- assertNull( selector.getProxy( repo ) );
- }
-
- @Test
- public void testGetProxy_OpaqueUrl()
- throws Exception
- {
- RemoteRepository repo = new RemoteRepository.Builder( "test", "default", "classpath:base" ).build();
- assertNull( selector.getProxy( repo ) );
- }
-
- @Test
- public void testGetProxy_NullSelector()
- throws Exception
- {
- RemoteRepository repo = new RemoteRepository.Builder( "test", "default", "http://repo.eclipse.org/" ).build();
- java.net.ProxySelector.setDefault( null );
- assertNull( selector.getProxy( repo ) );
- }
-
- @Test
- public void testGetProxy_NoProxies()
- throws Exception
- {
- RemoteRepository repo = new RemoteRepository.Builder( "test", "default", "http://repo.eclipse.org/" ).build();
- java.net.ProxySelector.setDefault( new AbstractProxySelector()
- {
- @Override
- public List<java.net.Proxy> select( URI uri )
- {
- return Collections.emptyList();
- }
-
- } );
- assertNull( selector.getProxy( repo ) );
- }
-
- @Test
- public void testGetProxy_DirectProxy()
- throws Exception
- {
- RemoteRepository repo = new RemoteRepository.Builder( "test", "default", "http://repo.eclipse.org/" ).build();
- final InetSocketAddress addr = InetSocketAddress.createUnresolved( "proxy", 8080 );
- java.net.ProxySelector.setDefault( new AbstractProxySelector()
- {
- @Override
- public List<java.net.Proxy> select( URI uri )
- {
- return Arrays.asList( java.net.Proxy.NO_PROXY, new java.net.Proxy( java.net.Proxy.Type.HTTP, addr ) );
- }
-
- } );
- assertNull( selector.getProxy( repo ) );
- }
-
- @Test
- public void testGetProxy_HttpProxy()
- throws Exception
- {
- final RemoteRepository repo =
- new RemoteRepository.Builder( "test", "default", "http://repo.eclipse.org/" ).build();
- final URL url = new URL( repo.getUrl() );
- final InetSocketAddress addr = InetSocketAddress.createUnresolved( "proxy", 8080 );
- java.net.ProxySelector.setDefault( new AbstractProxySelector()
- {
- @Override
- public List<java.net.Proxy> select( URI uri )
- {
- if ( repo.getHost().equalsIgnoreCase( uri.getHost() ) )
- {
- return Arrays.asList( new java.net.Proxy( java.net.Proxy.Type.HTTP, addr ) );
- }
- return Collections.emptyList();
- }
-
- } );
- Authenticator.setDefault( new Authenticator()
- {
- @Override
- protected PasswordAuthentication getPasswordAuthentication()
- {
- if ( Authenticator.RequestorType.PROXY.equals( getRequestorType() )
- && addr.getHostName().equals( getRequestingHost() ) && addr.getPort() == getRequestingPort()
- && url.equals( getRequestingURL() ) )
- {
- return new PasswordAuthentication( "proxyuser", "proxypass".toCharArray() );
- }
- return super.getPasswordAuthentication();
- }
- } );
-
- Proxy proxy = selector.getProxy( repo );
- assertNotNull( proxy );
- assertEquals( addr.getHostName(), proxy.getHost() );
- assertEquals( addr.getPort(), proxy.getPort() );
- assertEquals( Proxy.TYPE_HTTP, proxy.getType() );
-
- RemoteRepository repo2 = new RemoteRepository.Builder( repo ).setProxy( proxy ).build();
- Authentication auth = proxy.getAuthentication();
- assertNotNull( auth );
- AuthenticationContext authCtx = AuthenticationContext.forProxy( new DefaultRepositorySystemSession(), repo2 );
- assertEquals( "proxyuser", authCtx.get( AuthenticationContext.USERNAME ) );
- assertEquals( "proxypass", authCtx.get( AuthenticationContext.PASSWORD ) );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/repository/SecretAuthenticationTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/repository/SecretAuthenticationTest.java b/aether-util/src/test/java/org/eclipse/aether/util/repository/SecretAuthenticationTest.java
deleted file mode 100644
index df4afaf..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/repository/SecretAuthenticationTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package org.eclipse.aether.util.repository;
-
-/*
- * 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.DefaultRepositorySystemSession;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.repository.Authentication;
-import org.eclipse.aether.repository.AuthenticationContext;
-import org.eclipse.aether.repository.AuthenticationDigest;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.junit.Test;
-
-public class SecretAuthenticationTest
-{
-
- private RepositorySystemSession newSession()
- {
- return new DefaultRepositorySystemSession();
- }
-
- private RemoteRepository newRepo( Authentication auth )
- {
- return new RemoteRepository.Builder( "test", "default", "http://localhost" ).setAuthentication( auth ).build();
- }
-
- private AuthenticationContext newContext( Authentication auth )
- {
- return AuthenticationContext.forRepository( newSession(), newRepo( auth ) );
- }
-
- private String newDigest( Authentication auth )
- {
- return AuthenticationDigest.forRepository( newSession(), newRepo( auth ) );
- }
-
- @Test
- public void testConstructor_CopyChars()
- {
- char[] value = { 'v', 'a', 'l' };
- new SecretAuthentication( "key", value );
- assertArrayEquals( new char[] { 'v', 'a', 'l' }, value );
- }
-
- @Test
- public void testFill()
- {
- Authentication auth = new SecretAuthentication( "key", "value" );
- AuthenticationContext context = newContext( auth );
- assertEquals( null, context.get( "another-key" ) );
- assertEquals( "value", context.get( "key" ) );
- }
-
- @Test
- public void testDigest()
- {
- Authentication auth1 = new SecretAuthentication( "key", "value" );
- Authentication auth2 = new SecretAuthentication( "key", "value" );
- String digest1 = newDigest( auth1 );
- String digest2 = newDigest( auth2 );
- assertEquals( digest1, digest2 );
-
- Authentication auth3 = new SecretAuthentication( "key", "Value" );
- String digest3 = newDigest( auth3 );
- assertFalse( digest3.equals( digest1 ) );
-
- Authentication auth4 = new SecretAuthentication( "Key", "value" );
- String digest4 = newDigest( auth4 );
- assertFalse( digest4.equals( digest1 ) );
- }
-
- @Test
- public void testEquals()
- {
- Authentication auth1 = new SecretAuthentication( "key", "value" );
- Authentication auth2 = new SecretAuthentication( "key", "value" );
- Authentication auth3 = new SecretAuthentication( "key", "Value" );
- assertEquals( auth1, auth2 );
- assertFalse( auth1.equals( auth3 ) );
- assertFalse( auth1.equals( null ) );
- }
-
- @Test
- public void testHashCode()
- {
- Authentication auth1 = new SecretAuthentication( "key", "value" );
- Authentication auth2 = new SecretAuthentication( "key", "value" );
- assertEquals( auth1.hashCode(), auth2.hashCode() );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/repository/StringAuthenticationTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/repository/StringAuthenticationTest.java b/aether-util/src/test/java/org/eclipse/aether/util/repository/StringAuthenticationTest.java
deleted file mode 100644
index 8f89299..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/repository/StringAuthenticationTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package org.eclipse.aether.util.repository;
-
-/*
- * 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.DefaultRepositorySystemSession;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.repository.Authentication;
-import org.eclipse.aether.repository.AuthenticationContext;
-import org.eclipse.aether.repository.AuthenticationDigest;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.junit.Test;
-
-public class StringAuthenticationTest
-{
-
- private RepositorySystemSession newSession()
- {
- return new DefaultRepositorySystemSession();
- }
-
- private RemoteRepository newRepo( Authentication auth )
- {
- return new RemoteRepository.Builder( "test", "default", "http://localhost" ).setAuthentication( auth ).build();
- }
-
- private AuthenticationContext newContext( Authentication auth )
- {
- return AuthenticationContext.forRepository( newSession(), newRepo( auth ) );
- }
-
- private String newDigest( Authentication auth )
- {
- return AuthenticationDigest.forRepository( newSession(), newRepo( auth ) );
- }
-
- @Test
- public void testFill()
- {
- Authentication auth = new StringAuthentication( "key", "value" );
- AuthenticationContext context = newContext( auth );
- assertEquals( null, context.get( "another-key" ) );
- assertEquals( "value", context.get( "key" ) );
- }
-
- @Test
- public void testDigest()
- {
- Authentication auth1 = new StringAuthentication( "key", "value" );
- Authentication auth2 = new StringAuthentication( "key", "value" );
- String digest1 = newDigest( auth1 );
- String digest2 = newDigest( auth2 );
- assertEquals( digest1, digest2 );
-
- Authentication auth3 = new StringAuthentication( "key", "Value" );
- String digest3 = newDigest( auth3 );
- assertFalse( digest3.equals( digest1 ) );
-
- Authentication auth4 = new StringAuthentication( "Key", "value" );
- String digest4 = newDigest( auth4 );
- assertFalse( digest4.equals( digest1 ) );
- }
-
- @Test
- public void testEquals()
- {
- Authentication auth1 = new StringAuthentication( "key", "value" );
- Authentication auth2 = new StringAuthentication( "key", "value" );
- Authentication auth3 = new StringAuthentication( "key", "Value" );
- assertEquals( auth1, auth2 );
- assertFalse( auth1.equals( auth3 ) );
- assertFalse( auth1.equals( null ) );
- }
-
- @Test
- public void testHashCode()
- {
- Authentication auth1 = new StringAuthentication( "key", "value" );
- Authentication auth2 = new StringAuthentication( "key", "value" );
- assertEquals( auth1.hashCode(), auth2.hashCode() );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/version/AbstractVersionTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/version/AbstractVersionTest.java b/aether-util/src/test/java/org/eclipse/aether/util/version/AbstractVersionTest.java
deleted file mode 100644
index 52541db..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/version/AbstractVersionTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package org.eclipse.aether.util.version;
-
-/*
- * 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.assertEquals;
-
-import org.eclipse.aether.version.Version;
-
-/**
- */
-abstract class AbstractVersionTest
-{
-
- protected static final int X_LT_Y = -1;
-
- protected static final int X_EQ_Y = 0;
-
- protected static final int X_GT_Y = 1;
-
- protected abstract Version newVersion( String version );
-
- protected void assertOrder( int expected, String version1, String version2 )
- {
- Version v1 = newVersion( version1 );
- Version v2 = newVersion( version2 );
-
- if ( expected > 0 )
- {
- assertEquals( "expected " + v1 + " > " + v2, 1, Integer.signum( v1.compareTo( v2 ) ) );
- assertEquals( "expected " + v2 + " < " + v1, -1, Integer.signum( v2.compareTo( v1 ) ) );
- assertEquals( "expected " + v1 + " != " + v2, false, v1.equals( v2 ) );
- assertEquals( "expected " + v2 + " != " + v1, false, v2.equals( v1 ) );
- }
- else if ( expected < 0 )
- {
- assertEquals( "expected " + v1 + " < " + v2, -1, Integer.signum( v1.compareTo( v2 ) ) );
- assertEquals( "expected " + v2 + " > " + v1, 1, Integer.signum( v2.compareTo( v1 ) ) );
- assertEquals( "expected " + v1 + " != " + v2, false, v1.equals( v2 ) );
- assertEquals( "expected " + v2 + " != " + v1, false, v2.equals( v1 ) );
- }
- else
- {
- assertEquals( "expected " + v1 + " == " + v2, 0, v1.compareTo( v2 ) );
- assertEquals( "expected " + v2 + " == " + v1, 0, v2.compareTo( v1 ) );
- assertEquals( "expected " + v1 + " == " + v2, true, v1.equals( v2 ) );
- assertEquals( "expected " + v2 + " == " + v1, true, v2.equals( v1 ) );
- assertEquals( "expected #(" + v1 + ") == #(" + v1 + ")", v1.hashCode(), v2.hashCode() );
- }
- }
-
- protected void assertSequence( String... versions )
- {
- for ( int i = 0; i < versions.length - 1; i++ )
- {
- for ( int j = i + 1; j < versions.length; j++ )
- {
- assertOrder( X_LT_Y, versions[i], versions[j] );
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/version/GenericVersionRangeTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/version/GenericVersionRangeTest.java b/aether-util/src/test/java/org/eclipse/aether/util/version/GenericVersionRangeTest.java
deleted file mode 100644
index 85d007f..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/version/GenericVersionRangeTest.java
+++ /dev/null
@@ -1,167 +0,0 @@
-package org.eclipse.aether.util.version;
-
-/*
- * 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.version.GenericVersion;
-import org.eclipse.aether.util.version.GenericVersionRange;
-import org.eclipse.aether.version.InvalidVersionSpecificationException;
-import org.eclipse.aether.version.Version;
-import org.eclipse.aether.version.VersionRange;
-import org.junit.Test;
-
-public class GenericVersionRangeTest
-{
-
- private Version newVersion( String version )
- {
- return new GenericVersion( version );
- }
-
- private VersionRange parseValid( String range )
- {
- try
- {
- return new GenericVersionRange( range );
- }
- catch ( InvalidVersionSpecificationException e )
- {
- AssertionError error =
- new AssertionError( range + " should be valid but failed to parse due to: " + e.getMessage() );
- error.initCause( e );
- throw error;
- }
- }
-
- private void parseInvalid( String range )
- {
- try
- {
- new GenericVersionRange( range );
- fail( range + " should be invalid" );
- }
- catch ( InvalidVersionSpecificationException e )
- {
- assertTrue( true );
- }
- }
-
- private void assertContains( VersionRange range, String version )
- {
- assertTrue( range + " should contain " + version, range.containsVersion( newVersion( version ) ) );
- }
-
- private void assertNotContains( VersionRange range, String version )
- {
- assertFalse( range + " should not contain " + version, range.containsVersion( newVersion( version ) ) );
- }
-
- @Test
- public void testLowerBoundInclusiveUpperBoundInclusive()
- {
- VersionRange range = parseValid( "[1,2]" );
- assertContains( range, "1" );
- assertContains( range, "1.1-SNAPSHOT" );
- assertContains( range, "2" );
- assertEquals( range, parseValid( range.toString() ) );
- }
-
- @Test
- public void testLowerBoundInclusiveUpperBoundExclusive()
- {
- VersionRange range = parseValid( "[1.2.3.4.5,1.2.3.4.6)" );
- assertContains( range, "1.2.3.4.5" );
- assertNotContains( range, "1.2.3.4.6" );
- assertEquals( range, parseValid( range.toString() ) );
- }
-
- @Test
- public void testLowerBoundExclusiveUpperBoundInclusive()
- {
- VersionRange range = parseValid( "(1a,1b]" );
- assertNotContains( range, "1a" );
- assertContains( range, "1b" );
- assertEquals( range, parseValid( range.toString() ) );
- }
-
- @Test
- public void testLowerBoundExclusiveUpperBoundExclusive()
- {
- VersionRange range = parseValid( "(1,3)" );
- assertNotContains( range, "1" );
- assertContains( range, "2-SNAPSHOT" );
- assertNotContains( range, "3" );
- assertEquals( range, parseValid( range.toString() ) );
- }
-
- @Test
- public void testSingleVersion()
- {
- VersionRange range = parseValid( "[1]" );
- assertContains( range, "1" );
- assertEquals( range, parseValid( range.toString() ) );
-
- range = parseValid( "[1,1]" );
- assertContains( range, "1" );
- assertEquals( range, parseValid( range.toString() ) );
- }
-
- @Test
- public void testSingleWildcardVersion()
- {
- VersionRange range = parseValid( "[1.2.*]" );
- assertContains( range, "1.2-alpha-1" );
- assertContains( range, "1.2-SNAPSHOT" );
- assertContains( range, "1.2" );
- assertContains( range, "1.2.9999999" );
- assertNotContains( range, "1.3-rc-1" );
- assertEquals( range, parseValid( range.toString() ) );
- }
-
- @Test
- public void testMissingOpenCloseDelimiter()
- {
- parseInvalid( "1.0" );
- }
-
- @Test
- public void testMissingOpenDelimiter()
- {
- parseInvalid( "1.0]" );
- parseInvalid( "1.0)" );
- }
-
- @Test
- public void testMissingCloseDelimiter()
- {
- parseInvalid( "[1.0" );
- parseInvalid( "(1.0" );
- }
-
- @Test
- public void testTooManyVersions()
- {
- parseInvalid( "[1,2,3]" );
- parseInvalid( "(1,2,3)" );
- parseInvalid( "[1,2,3)" );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/version/GenericVersionSchemeTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/version/GenericVersionSchemeTest.java b/aether-util/src/test/java/org/eclipse/aether/util/version/GenericVersionSchemeTest.java
deleted file mode 100644
index f52f73d..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/version/GenericVersionSchemeTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package org.eclipse.aether.util.version;
-
-/*
- * 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.version.GenericVersion;
-import org.eclipse.aether.util.version.GenericVersionScheme;
-import org.eclipse.aether.version.InvalidVersionSpecificationException;
-import org.eclipse.aether.version.VersionConstraint;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- */
-public class GenericVersionSchemeTest
-{
-
- private GenericVersionScheme scheme;
-
- @Before
- public void setUp()
- throws Exception
- {
- scheme = new GenericVersionScheme();
- }
-
- private InvalidVersionSpecificationException parseInvalid( String constraint )
- {
- try
- {
- scheme.parseVersionConstraint( constraint );
- fail( "expected exception for constraint " + constraint );
- return null;
- }
- catch ( InvalidVersionSpecificationException e )
- {
- return e;
- }
- }
-
- @Test
- public void testEnumeratedVersions()
- throws InvalidVersionSpecificationException
- {
- VersionConstraint c = scheme.parseVersionConstraint( "1.0" );
- assertEquals( "1.0", c.getVersion().toString() );
- assertTrue( c.containsVersion( new GenericVersion( "1.0" ) ) );
-
- c = scheme.parseVersionConstraint( "[1.0]" );
- assertEquals( null, c.getVersion() );
- assertTrue( c.containsVersion( new GenericVersion( "1.0" ) ) );
-
- c = scheme.parseVersionConstraint( "[1.0],[2.0]" );
- assertTrue( c.containsVersion( new GenericVersion( "1.0" ) ) );
- assertTrue( c.containsVersion( new GenericVersion( "2.0" ) ) );
-
- c = scheme.parseVersionConstraint( "[1.0],[2.0],[3.0]" );
- assertContains( c, "1.0", "2.0", "3.0" );
- assertNotContains( c, "1.5" );
-
- c = scheme.parseVersionConstraint( "[1,3),(3,5)" );
- assertContains( c, "1", "2", "4" );
- assertNotContains( c, "3", "5" );
-
- c = scheme.parseVersionConstraint( "[1,3),(3,)" );
- assertContains( c, "1", "2", "4" );
- assertNotContains( c, "3" );
- }
-
- private void assertNotContains( VersionConstraint c, String... versions )
- {
- assertContains( String.format( "%s: %%s should not be contained\n", c.toString() ), c, false, versions );
- }
-
- private void assertContains( String msg, VersionConstraint c, boolean b, String... versions )
- {
- for ( String v : versions )
- {
- assertEquals( String.format( msg, v ), b, c.containsVersion( new GenericVersion( v ) ) );
- }
- }
-
- private void assertContains( VersionConstraint c, String... versions )
- {
- assertContains( String.format( "%s: %%s should be contained\n", c.toString() ), c, true, versions );
- }
-
- @Test
- public void testInvalid()
- {
- parseInvalid( "[1," );
- parseInvalid( "[1,2],(3," );
- parseInvalid( "[1,2],3" );
- }
-}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-util/src/test/java/org/eclipse/aether/util/version/GenericVersionTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/version/GenericVersionTest.java b/aether-util/src/test/java/org/eclipse/aether/util/version/GenericVersionTest.java
deleted file mode 100644
index ae891af..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/version/GenericVersionTest.java
+++ /dev/null
@@ -1,345 +0,0 @@
-package org.eclipse.aether.util.version;
-
-/*
- * 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.Locale;
-
-import org.eclipse.aether.util.version.GenericVersion;
-import org.eclipse.aether.version.Version;
-import org.junit.Test;
-
-/**
- */
-public class GenericVersionTest
- extends AbstractVersionTest
-{
-
- protected Version newVersion( String version )
- {
- return new GenericVersion( version );
- }
-
- @Test
- public void testEmptyVersion()
- {
- assertOrder( X_EQ_Y, "0", "" );
- }
-
- @Test
- public void testNumericOrdering()
- {
- assertOrder( X_LT_Y, "2", "10" );
- assertOrder( X_LT_Y, "1.2", "1.10" );
- assertOrder( X_LT_Y, "1.0.2", "1.0.10" );
- assertOrder( X_LT_Y, "1.0.0.2", "1.0.0.10" );
- assertOrder( X_LT_Y, "1.0.20101206.111434.1", "1.0.20101206.111435.1" );
- assertOrder( X_LT_Y, "1.0.20101206.111434.2", "1.0.20101206.111434.10" );
- }
-
- @Test
- public void testDelimiters()
- {
- assertOrder( X_EQ_Y, "1.0", "1-0" );
- assertOrder( X_EQ_Y, "1.0", "1_0" );
- assertOrder( X_EQ_Y, "1.a", "1a" );
- }
-
- @Test
- public void testLeadingZerosAreSemanticallyIrrelevant()
- {
- assertOrder( X_EQ_Y, "1", "01" );
- assertOrder( X_EQ_Y, "1.2", "1.002" );
- assertOrder( X_EQ_Y, "1.2.3", "1.2.0003" );
- assertOrder( X_EQ_Y, "1.2.3.4", "1.2.3.00004" );
- }
-
- @Test
- public void testTrailingZerosAreSemanticallyIrrelevant()
- {
- assertOrder( X_EQ_Y, "1", "1.0.0.0.0.0.0.0.0.0.0.0.0.0" );
- assertOrder( X_EQ_Y, "1", "1-0-0-0-0-0-0-0-0-0-0-0-0-0" );
- assertOrder( X_EQ_Y, "1", "1.0-0.0-0.0-0.0-0.0-0.0-0.0" );
- assertOrder( X_EQ_Y, "1", "1.0000000000000" );
- assertOrder( X_EQ_Y, "1.0", "1.0.0" );
- }
-
- @Test
- public void testTrailingZerosBeforeQualifierAreSemanticallyIrrelevant()
- {
- assertOrder( X_EQ_Y, "1.0-ga", "1.0.0-ga" );
- assertOrder( X_EQ_Y, "1.0.ga", "1.0.0.ga" );
- assertOrder( X_EQ_Y, "1.0ga", "1.0.0ga" );
-
- assertOrder( X_EQ_Y, "1.0-alpha", "1.0.0-alpha" );
- assertOrder( X_EQ_Y, "1.0.alpha", "1.0.0.alpha" );
- assertOrder( X_EQ_Y, "1.0alpha", "1.0.0alpha" );
- assertOrder( X_EQ_Y, "1.0-alpha-snapshot", "1.0.0-alpha-snapshot" );
- assertOrder( X_EQ_Y, "1.0.alpha.snapshot", "1.0.0.alpha.snapshot" );
-
- assertOrder( X_EQ_Y, "1.x.0-alpha", "1.x.0.0-alpha" );
- assertOrder( X_EQ_Y, "1.x.0.alpha", "1.x.0.0.alpha" );
- assertOrder( X_EQ_Y, "1.x.0-alpha-snapshot", "1.x.0.0-alpha-snapshot" );
- assertOrder( X_EQ_Y, "1.x.0.alpha.snapshot", "1.x.0.0.alpha.snapshot" );
- }
-
- @Test
- public void testTrailingDelimitersAreSemanticallyIrrelevant()
- {
- assertOrder( X_EQ_Y, "1", "1............." );
- assertOrder( X_EQ_Y, "1", "1-------------" );
- assertOrder( X_EQ_Y, "1.0", "1............." );
- assertOrder( X_EQ_Y, "1.0", "1-------------" );
- }
-
- @Test
- public void testInitialDelimiters()
- {
- assertOrder( X_EQ_Y, "0.1", ".1" );
- assertOrder( X_EQ_Y, "0.0.1", "..1" );
- assertOrder( X_EQ_Y, "0.1", "-1" );
- assertOrder( X_EQ_Y, "0.0.1", "--1" );
- }
-
- @Test
- public void testConsecutiveDelimiters()
- {
- assertOrder( X_EQ_Y, "1.0.1", "1..1" );
- assertOrder( X_EQ_Y, "1.0.0.1", "1...1" );
- assertOrder( X_EQ_Y, "1.0.1", "1--1" );
- assertOrder( X_EQ_Y, "1.0.0.1", "1---1" );
- }
-
- @Test
- public void testUnlimitedNumberOfVersionComponents()
- {
- assertOrder( X_GT_Y, "1.0.1.2.3.4.5.6.7.8.9.0.1.2.10", "1.0.1.2.3.4.5.6.7.8.9.0.1.2.3" );
- }
-
- @Test
- public void testUnlimitedNumberOfDigitsInNumericComponent()
- {
- assertOrder( X_GT_Y, "1.1234567890123456789012345678901", "1.123456789012345678901234567891" );
- }
-
- @Test
- public void testTransitionFromDigitToLetterAndViceVersaIsEqualivantToDelimiter()
- {
- assertOrder( X_EQ_Y, "1alpha10", "1.alpha.10" );
- assertOrder( X_EQ_Y, "1alpha10", "1-alpha-10" );
-
- assertOrder( X_GT_Y, "1.alpha10", "1.alpha2" );
- assertOrder( X_GT_Y, "10alpha", "1alpha" );
- }
-
- @Test
- public void testWellKnownQualifierOrdering()
- {
- assertOrder( X_EQ_Y, "1-alpha1", "1-a1" );
- assertOrder( X_LT_Y, "1-alpha", "1-beta" );
- assertOrder( X_EQ_Y, "1-beta1", "1-b1" );
- assertOrder( X_LT_Y, "1-beta", "1-milestone" );
- assertOrder( X_EQ_Y, "1-milestone1", "1-m1" );
- assertOrder( X_LT_Y, "1-milestone", "1-rc" );
- assertOrder( X_EQ_Y, "1-rc", "1-cr" );
- assertOrder( X_LT_Y, "1-rc", "1-snapshot" );
- assertOrder( X_LT_Y, "1-snapshot", "1" );
- assertOrder( X_EQ_Y, "1", "1-ga" );
- assertOrder( X_EQ_Y, "1", "1.ga.0.ga" );
- assertOrder( X_EQ_Y, "1.0", "1-ga" );
- assertOrder( X_EQ_Y, "1", "1-ga.ga" );
- assertOrder( X_EQ_Y, "1", "1-ga-ga" );
- assertOrder( X_EQ_Y, "A", "A.ga.ga" );
- assertOrder( X_EQ_Y, "A", "A-ga-ga" );
- assertOrder( X_EQ_Y, "1", "1-final" );
- assertOrder( X_LT_Y, "1", "1-sp" );
-
- assertOrder( X_LT_Y, "A.rc.1", "A.ga.1" );
- assertOrder( X_GT_Y, "A.sp.1", "A.ga.1" );
- assertOrder( X_LT_Y, "A.rc.x", "A.ga.x" );
- assertOrder( X_GT_Y, "A.sp.x", "A.ga.x" );
- }
-
- @Test
- public void testWellKnownQualifierVersusUnknownQualifierOrdering()
- {
- assertOrder( X_GT_Y, "1-abc", "1-alpha" );
- assertOrder( X_GT_Y, "1-abc", "1-beta" );
- assertOrder( X_GT_Y, "1-abc", "1-milestone" );
- assertOrder( X_GT_Y, "1-abc", "1-rc" );
- assertOrder( X_GT_Y, "1-abc", "1-snapshot" );
- assertOrder( X_GT_Y, "1-abc", "1" );
- assertOrder( X_GT_Y, "1-abc", "1-sp" );
- }
-
- @Test
- public void testWellKnownSingleCharQualifiersOnlyRecognizedIfImmediatelyFollowedByNumber()
- {
- assertOrder( X_GT_Y, "1.0a", "1.0" );
- assertOrder( X_GT_Y, "1.0-a", "1.0" );
- assertOrder( X_GT_Y, "1.0.a", "1.0" );
- assertOrder( X_GT_Y, "1.0b", "1.0" );
- assertOrder( X_GT_Y, "1.0-b", "1.0" );
- assertOrder( X_GT_Y, "1.0.b", "1.0" );
- assertOrder( X_GT_Y, "1.0m", "1.0" );
- assertOrder( X_GT_Y, "1.0-m", "1.0" );
- assertOrder( X_GT_Y, "1.0.m", "1.0" );
-
- assertOrder( X_LT_Y, "1.0a1", "1.0" );
- assertOrder( X_LT_Y, "1.0-a1", "1.0" );
- assertOrder( X_LT_Y, "1.0.a1", "1.0" );
- assertOrder( X_LT_Y, "1.0b1", "1.0" );
- assertOrder( X_LT_Y, "1.0-b1", "1.0" );
- assertOrder( X_LT_Y, "1.0.b1", "1.0" );
- assertOrder( X_LT_Y, "1.0m1", "1.0" );
- assertOrder( X_LT_Y, "1.0-m1", "1.0" );
- assertOrder( X_LT_Y, "1.0.m1", "1.0" );
-
- assertOrder( X_GT_Y, "1.0a.1", "1.0" );
- assertOrder( X_GT_Y, "1.0a-1", "1.0" );
- assertOrder( X_GT_Y, "1.0b.1", "1.0" );
- assertOrder( X_GT_Y, "1.0b-1", "1.0" );
- assertOrder( X_GT_Y, "1.0m.1", "1.0" );
- assertOrder( X_GT_Y, "1.0m-1", "1.0" );
- }
-
- @Test
- public void testUnknownQualifierOrdering()
- {
- assertOrder( X_LT_Y, "1-abc", "1-abcd" );
- assertOrder( X_LT_Y, "1-abc", "1-bcd" );
- assertOrder( X_GT_Y, "1-abc", "1-aac" );
- }
-
- @Test
- public void testCaseInsensitiveOrderingOfQualifiers()
- {
- assertOrder( X_EQ_Y, "1.alpha", "1.ALPHA" );
- assertOrder( X_EQ_Y, "1.alpha", "1.Alpha" );
-
- assertOrder( X_EQ_Y, "1.beta", "1.BETA" );
- assertOrder( X_EQ_Y, "1.beta", "1.Beta" );
-
- assertOrder( X_EQ_Y, "1.milestone", "1.MILESTONE" );
- assertOrder( X_EQ_Y, "1.milestone", "1.Milestone" );
-
- assertOrder( X_EQ_Y, "1.rc", "1.RC" );
- assertOrder( X_EQ_Y, "1.rc", "1.Rc" );
- assertOrder( X_EQ_Y, "1.cr", "1.CR" );
- assertOrder( X_EQ_Y, "1.cr", "1.Cr" );
-
- assertOrder( X_EQ_Y, "1.snapshot", "1.SNAPSHOT" );
- assertOrder( X_EQ_Y, "1.snapshot", "1.Snapshot" );
-
- assertOrder( X_EQ_Y, "1.ga", "1.GA" );
- assertOrder( X_EQ_Y, "1.ga", "1.Ga" );
- assertOrder( X_EQ_Y, "1.final", "1.FINAL" );
- assertOrder( X_EQ_Y, "1.final", "1.Final" );
-
- assertOrder( X_EQ_Y, "1.sp", "1.SP" );
- assertOrder( X_EQ_Y, "1.sp", "1.Sp" );
-
- assertOrder( X_EQ_Y, "1.unknown", "1.UNKNOWN" );
- assertOrder( X_EQ_Y, "1.unknown", "1.Unknown" );
- }
-
- @Test
- public void testCaseInsensitiveOrderingOfQualifiersIsLocaleIndependent()
- {
- Locale orig = Locale.getDefault();
- try
- {
- Locale[] locales = { Locale.ENGLISH, new Locale( "tr" ) };
- for ( Locale locale : locales )
- {
- Locale.setDefault( locale );
- assertOrder( X_EQ_Y, "1-abcdefghijklmnopqrstuvwxyz", "1-ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
- }
- }
- finally
- {
- Locale.setDefault( orig );
- }
- }
-
- @Test
- public void testQualifierVersusNumberOrdering()
- {
- assertOrder( X_LT_Y, "1-ga", "1-1" );
- assertOrder( X_LT_Y, "1.ga", "1.1" );
- assertOrder( X_EQ_Y, "1-ga", "1.0" );
- assertOrder( X_EQ_Y, "1.ga", "1.0" );
-
- assertOrder( X_LT_Y, "1-ga-1", "1-0-1" );
- assertOrder( X_LT_Y, "1.ga.1", "1.0.1" );
-
- assertOrder( X_GT_Y, "1.sp", "1.0" );
- assertOrder( X_LT_Y, "1.sp", "1.1" );
-
- assertOrder( X_LT_Y, "1-abc", "1-1" );
- assertOrder( X_LT_Y, "1.abc", "1.1" );
-
- assertOrder( X_LT_Y, "1-xyz", "1-1" );
- assertOrder( X_LT_Y, "1.xyz", "1.1" );
- }
-
- @Test
- public void testVersionEvolution()
- {
- assertSequence( "0.9.9-SNAPSHOT", "0.9.9", "0.9.10-SNAPSHOT", "0.9.10", "1.0-alpha-2-SNAPSHOT", "1.0-alpha-2",
- "1.0-alpha-10-SNAPSHOT", "1.0-alpha-10", "1.0-beta-1-SNAPSHOT", "1.0-beta-1",
- "1.0-rc-1-SNAPSHOT", "1.0-rc-1", "1.0-SNAPSHOT", "1.0", "1.0-sp-1-SNAPSHOT", "1.0-sp-1",
- "1.0.1-alpha-1-SNAPSHOT", "1.0.1-alpha-1", "1.0.1-beta-1-SNAPSHOT", "1.0.1-beta-1",
- "1.0.1-rc-1-SNAPSHOT", "1.0.1-rc-1", "1.0.1-SNAPSHOT", "1.0.1", "1.1-SNAPSHOT", "1.1" );
-
- assertSequence( "1.0-alpha", "1.0", "1.0-1" );
- assertSequence( "1.0.alpha", "1.0", "1.0-1" );
- assertSequence( "1.0-alpha", "1.0", "1.0.1" );
- assertSequence( "1.0.alpha", "1.0", "1.0.1" );
- }
-
- @Test
- public void testMinimumSegment()
- {
- assertOrder( X_LT_Y, "1.min", "1.0-alpha-1" );
- assertOrder( X_LT_Y, "1.min", "1.0-SNAPSHOT" );
- assertOrder( X_LT_Y, "1.min", "1.0" );
- assertOrder( X_LT_Y, "1.min", "1.9999999999" );
-
- assertOrder( X_EQ_Y, "1.min", "1.MIN" );
-
- assertOrder( X_GT_Y, "1.min", "0.99999" );
- assertOrder( X_GT_Y, "1.min", "0.max" );
- }
-
- @Test
- public void testMaximumSegment()
- {
- assertOrder( X_GT_Y, "1.max", "1.0-alpha-1" );
- assertOrder( X_GT_Y, "1.max", "1.0-SNAPSHOT" );
- assertOrder( X_GT_Y, "1.max", "1.0" );
- assertOrder( X_GT_Y, "1.max", "1.9999999999" );
-
- assertOrder( X_EQ_Y, "1.max", "1.MAX" );
-
- assertOrder( X_LT_Y, "1.max", "2.0-alpha-1" );
- assertOrder( X_LT_Y, "1.max", "2.min" );
- }
-
-}