http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-test-util/src/test/java/org/eclipse/aether/internal/test/util/IniArtifactDataReaderTest.java ---------------------------------------------------------------------- diff --git a/aether-test-util/src/test/java/org/eclipse/aether/internal/test/util/IniArtifactDataReaderTest.java b/aether-test-util/src/test/java/org/eclipse/aether/internal/test/util/IniArtifactDataReaderTest.java deleted file mode 100644 index 4864b32..0000000 --- a/aether-test-util/src/test/java/org/eclipse/aether/internal/test/util/IniArtifactDataReaderTest.java +++ /dev/null @@ -1,232 +0,0 @@ -package org.eclipse.aether.internal.test.util; - -/* - * 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.util.Collection; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.graph.Dependency; -import org.eclipse.aether.graph.Exclusion; -import org.eclipse.aether.internal.test.util.ArtifactDescription; -import org.eclipse.aether.internal.test.util.IniArtifactDataReader; -import org.eclipse.aether.repository.RemoteRepository; -import org.junit.Before; -import org.junit.Test; - -/** - */ -public class IniArtifactDataReaderTest -{ - - private IniArtifactDataReader parser; - - @Before - public void setup() - throws Exception - { - this.parser = new IniArtifactDataReader( "org/eclipse/aether/internal/test/util/" ); - } - - @Test - public void testRelocation() - throws IOException - { - String def = "[relocation]\ngid:aid:ext:ver"; - - ArtifactDescription description = parser.parseLiteral( def ); - - Artifact artifact = description.getRelocation(); - assertNotNull( artifact ); - assertEquals( "aid", artifact.getArtifactId() ); - assertEquals( "gid", artifact.getGroupId() ); - assertEquals( "ver", artifact.getVersion() ); - assertEquals( "ext", artifact.getExtension() ); - } - - @Test - public void testDependencies() - throws IOException - { - String def = "[dependencies]\ngid:aid:ext:ver\n-exclusion:aid\ngid2:aid2:ext2:ver2"; - - ArtifactDescription description = parser.parseLiteral( def ); - - List<Dependency> dependencies = description.getDependencies(); - assertNotNull( dependencies ); - assertEquals( 2, dependencies.size() ); - - Dependency dependency = dependencies.get( 0 ); - assertEquals( "compile", dependency.getScope() ); - - Artifact artifact = dependency.getArtifact(); - assertNotNull( artifact ); - assertEquals( "aid", artifact.getArtifactId() ); - assertEquals( "gid", artifact.getGroupId() ); - assertEquals( "ver", artifact.getVersion() ); - assertEquals( "ext", artifact.getExtension() ); - - Collection<Exclusion> exclusions = dependency.getExclusions(); - assertNotNull( exclusions ); - assertEquals( 1, exclusions.size() ); - Exclusion exclusion = exclusions.iterator().next(); - assertEquals( "exclusion", exclusion.getGroupId() ); - assertEquals( "aid", exclusion.getArtifactId() ); - assertEquals( "*", exclusion.getClassifier() ); - assertEquals( "*", exclusion.getExtension() ); - - dependency = dependencies.get( 1 ); - - artifact = dependency.getArtifact(); - assertNotNull( artifact ); - assertEquals( "aid2", artifact.getArtifactId() ); - assertEquals( "gid2", artifact.getGroupId() ); - assertEquals( "ver2", artifact.getVersion() ); - assertEquals( "ext2", artifact.getExtension() ); - } - - @Test - public void testManagedDependencies() - throws IOException - { - String def = "[managed-dependencies]\ngid:aid:ext:ver\n-exclusion:aid\ngid2:aid2:ext2:ver2:runtime"; - - ArtifactDescription description = parser.parseLiteral( def ); - - List<Dependency> dependencies = description.getManagedDependencies(); - assertNotNull( dependencies ); - assertEquals( 2, dependencies.size() ); - - Dependency dependency = dependencies.get( 0 ); - assertEquals( "", dependency.getScope() ); - - Artifact artifact = dependency.getArtifact(); - assertNotNull( artifact ); - assertEquals( "aid", artifact.getArtifactId() ); - assertEquals( "gid", artifact.getGroupId() ); - assertEquals( "ver", artifact.getVersion() ); - assertEquals( "ext", artifact.getExtension() ); - - Collection<Exclusion> exclusions = dependency.getExclusions(); - assertNotNull( exclusions ); - assertEquals( 1, exclusions.size() ); - Exclusion exclusion = exclusions.iterator().next(); - assertEquals( "exclusion", exclusion.getGroupId() ); - assertEquals( "aid", exclusion.getArtifactId() ); - assertEquals( "*", exclusion.getClassifier() ); - assertEquals( "*", exclusion.getExtension() ); - - dependency = dependencies.get( 1 ); - assertEquals( "runtime", dependency.getScope() ); - - artifact = dependency.getArtifact(); - assertNotNull( artifact ); - assertEquals( "aid2", artifact.getArtifactId() ); - assertEquals( "gid2", artifact.getGroupId() ); - assertEquals( "ver2", artifact.getVersion() ); - assertEquals( "ext2", artifact.getExtension() ); - - assertEquals( 0, dependency.getExclusions().size() ); - } - - @Test - public void testResource() - throws IOException - { - ArtifactDescription description = parser.parse( "ArtifactDataReaderTest.ini" ); - - Artifact artifact = description.getRelocation(); - assertEquals( "gid", artifact.getGroupId() ); - assertEquals( "aid", artifact.getArtifactId() ); - assertEquals( "ver", artifact.getVersion() ); - assertEquals( "ext", artifact.getExtension() ); - - assertEquals( 1, description.getRepositories().size() ); - RemoteRepository repo = description.getRepositories().get( 0 ); - assertEquals( "id", repo.getId() ); - assertEquals( "type", repo.getContentType() ); - assertEquals( "protocol://some/url?for=testing", repo.getUrl() ); - - assertDependencies( description.getDependencies() ); - assertDependencies( description.getManagedDependencies() ); - - } - - private void assertDependencies( List<Dependency> deps ) - { - assertEquals( 4, deps.size() ); - - Dependency dep = deps.get( 0 ); - assertEquals( "scope", dep.getScope() ); - assertEquals( false, dep.isOptional() ); - assertEquals( 2, dep.getExclusions().size() ); - Iterator<Exclusion> it = dep.getExclusions().iterator(); - Exclusion excl = it.next(); - assertEquals( "gid3", excl.getGroupId() ); - assertEquals( "aid", excl.getArtifactId() ); - excl = it.next(); - assertEquals( "gid2", excl.getGroupId() ); - assertEquals( "aid2", excl.getArtifactId() ); - - Artifact art = dep.getArtifact(); - assertEquals( "gid", art.getGroupId() ); - assertEquals( "aid", art.getArtifactId() ); - assertEquals( "ver", art.getVersion() ); - assertEquals( "ext", art.getExtension() ); - - dep = deps.get( 1 ); - assertEquals( "scope", dep.getScope() ); - assertEquals( true, dep.isOptional() ); - assertEquals( 0, dep.getExclusions().size() ); - - art = dep.getArtifact(); - assertEquals( "gid", art.getGroupId() ); - assertEquals( "aid2", art.getArtifactId() ); - assertEquals( "ver", art.getVersion() ); - assertEquals( "ext", art.getExtension() ); - - dep = deps.get( 2 ); - assertEquals( "scope", dep.getScope() ); - assertEquals( true, dep.isOptional() ); - assertEquals( 0, dep.getExclusions().size() ); - - art = dep.getArtifact(); - assertEquals( "gid", art.getGroupId() ); - assertEquals( "aid", art.getArtifactId() ); - assertEquals( "ver3", art.getVersion() ); - assertEquals( "ext", art.getExtension() ); - - dep = deps.get( 3 ); - assertEquals( "scope5", dep.getScope() ); - assertEquals( true, dep.isOptional() ); - assertEquals( 0, dep.getExclusions().size() ); - - art = dep.getArtifact(); - assertEquals( "gid1", art.getGroupId() ); - assertEquals( "aid", art.getArtifactId() ); - assertEquals( "ver", art.getVersion() ); - assertEquals( "ext", art.getExtension() ); - } - -}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-test-util/src/test/java/org/eclipse/aether/internal/test/util/IniArtifactDescriptorReaderTest.java ---------------------------------------------------------------------- diff --git a/aether-test-util/src/test/java/org/eclipse/aether/internal/test/util/IniArtifactDescriptorReaderTest.java b/aether-test-util/src/test/java/org/eclipse/aether/internal/test/util/IniArtifactDescriptorReaderTest.java deleted file mode 100644 index 8b6bfa4..0000000 --- a/aether-test-util/src/test/java/org/eclipse/aether/internal/test/util/IniArtifactDescriptorReaderTest.java +++ /dev/null @@ -1,152 +0,0 @@ -package org.eclipse.aether.internal.test.util; - -/* - * 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.util.Iterator; -import java.util.List; - -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.artifact.DefaultArtifact; -import org.eclipse.aether.graph.Dependency; -import org.eclipse.aether.graph.Exclusion; -import org.eclipse.aether.internal.test.util.IniArtifactDescriptorReader; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.resolution.ArtifactDescriptorException; -import org.eclipse.aether.resolution.ArtifactDescriptorRequest; -import org.eclipse.aether.resolution.ArtifactDescriptorResult; -import org.junit.Before; -import org.junit.Test; - -/** - */ -public class IniArtifactDescriptorReaderTest -{ - - private IniArtifactDescriptorReader reader; - - private RepositorySystemSession session; - - @Before - public void setup() - throws IOException - { - reader = new IniArtifactDescriptorReader( "org/eclipse/aether/internal/test/util/" ); - session = TestUtils.newSession(); - } - - @Test( expected = ArtifactDescriptorException.class ) - public void testMissingDescriptor() - throws ArtifactDescriptorException - { - Artifact art = new DefaultArtifact( "missing:aid:ver:ext" ); - ArtifactDescriptorRequest request = new ArtifactDescriptorRequest( art, null, "" ); - reader.readArtifactDescriptor( session, request ); - } - - @Test - public void testLookup() - throws ArtifactDescriptorException - { - Artifact art = new DefaultArtifact( "gid:aid:ext:ver" ); - ArtifactDescriptorRequest request = new ArtifactDescriptorRequest( art, null, "" ); - ArtifactDescriptorResult description = reader.readArtifactDescriptor( session, request ); - - assertEquals( request, description.getRequest() ); - assertEquals( art.setVersion( "1" ), description.getArtifact() ); - - assertEquals( 1, description.getRelocations().size() ); - Artifact artifact = description.getRelocations().get( 0 ); - assertEquals( "gid", artifact.getGroupId() ); - assertEquals( "aid", artifact.getArtifactId() ); - assertEquals( "ver", artifact.getVersion() ); - assertEquals( "ext", artifact.getExtension() ); - - assertEquals( 1, description.getRepositories().size() ); - RemoteRepository repo = description.getRepositories().get( 0 ); - assertEquals( "id", repo.getId() ); - assertEquals( "type", repo.getContentType() ); - assertEquals( "protocol://some/url?for=testing", repo.getUrl() ); - - assertDependencies( description.getDependencies() ); - assertDependencies( description.getManagedDependencies() ); - - } - - private void assertDependencies( List<Dependency> deps ) - { - assertEquals( 4, deps.size() ); - - Dependency dep = deps.get( 0 ); - assertEquals( "scope", dep.getScope() ); - assertEquals( false, dep.isOptional() ); - assertEquals( 2, dep.getExclusions().size() ); - Iterator<Exclusion> it = dep.getExclusions().iterator(); - Exclusion excl = it.next(); - assertEquals( "gid3", excl.getGroupId() ); - assertEquals( "aid", excl.getArtifactId() ); - excl = it.next(); - assertEquals( "gid2", excl.getGroupId() ); - assertEquals( "aid2", excl.getArtifactId() ); - - Artifact art = dep.getArtifact(); - assertEquals( "gid", art.getGroupId() ); - assertEquals( "aid", art.getArtifactId() ); - assertEquals( "ver", art.getVersion() ); - assertEquals( "ext", art.getExtension() ); - - dep = deps.get( 1 ); - assertEquals( "scope", dep.getScope() ); - assertEquals( true, dep.isOptional() ); - assertEquals( 0, dep.getExclusions().size() ); - - art = dep.getArtifact(); - assertEquals( "gid", art.getGroupId() ); - assertEquals( "aid2", art.getArtifactId() ); - assertEquals( "ver", art.getVersion() ); - assertEquals( "ext", art.getExtension() ); - - dep = deps.get( 2 ); - assertEquals( "scope", dep.getScope() ); - assertEquals( true, dep.isOptional() ); - assertEquals( 0, dep.getExclusions().size() ); - - art = dep.getArtifact(); - assertEquals( "gid", art.getGroupId() ); - assertEquals( "aid", art.getArtifactId() ); - assertEquals( "ver3", art.getVersion() ); - assertEquals( "ext", art.getExtension() ); - - dep = deps.get( 3 ); - assertEquals( "scope5", dep.getScope() ); - assertEquals( true, dep.isOptional() ); - assertEquals( 0, dep.getExclusions().size() ); - - art = dep.getArtifact(); - assertEquals( "gid1", art.getGroupId() ); - assertEquals( "aid", art.getArtifactId() ); - assertEquals( "ver", art.getVersion() ); - assertEquals( "ext", art.getExtension() ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-test-util/src/test/java/org/eclipse/aether/internal/test/util/NodeDefinitionTest.java ---------------------------------------------------------------------- diff --git a/aether-test-util/src/test/java/org/eclipse/aether/internal/test/util/NodeDefinitionTest.java b/aether-test-util/src/test/java/org/eclipse/aether/internal/test/util/NodeDefinitionTest.java deleted file mode 100644 index 8f41a5a..0000000 --- a/aether-test-util/src/test/java/org/eclipse/aether/internal/test/util/NodeDefinitionTest.java +++ /dev/null @@ -1,156 +0,0 @@ -package org.eclipse.aether.internal.test.util; - -/* - * 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.Collections; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.junit.Test; - -public class NodeDefinitionTest -{ - - private void assertMatch( String text, String regex, String... groups ) - { - Pattern pattern = Pattern.compile( regex ); - Matcher matcher = pattern.matcher( text ); - assertEquals( true, matcher.matches() ); - assertTrue( groups.length + " vs " + matcher.groupCount(), groups.length <= matcher.groupCount() ); - for ( int i = 1; i <= groups.length; i++ ) - { - assertEquals( "Mismatch for group " + i, groups[i - 1], matcher.group( i ) ); - } - } - - private void assertNoMatch( String text, String regex ) - { - Pattern pattern = Pattern.compile( regex ); - Matcher matcher = pattern.matcher( text ); - assertEquals( false, matcher.matches() ); - } - - @Test - public void testPatterns() - { - assertMatch( "(Example-ID_0123456789)", NodeDefinition.ID, "Example-ID_0123456789" ); - assertMatch( "^Example-ID_0123456789", NodeDefinition.IDREF, "Example-ID_0123456789" ); - - assertMatch( "gid:aid:1", NodeDefinition.COORDS, "gid", "aid", null, null, "1" ); - assertMatch( "gid:aid:jar:1", NodeDefinition.COORDS, "gid", "aid", "jar", null, "1" ); - assertMatch( "gid:aid:jar:cls:1", NodeDefinition.COORDS, "gid", "aid", "jar", "cls", "1" ); - - assertMatch( "[1]", NodeDefinition.RANGE, "[1]" ); - assertMatch( "[1,)", NodeDefinition.RANGE, "[1,)" ); - assertMatch( "(1,2)", NodeDefinition.RANGE, "(1,2)" ); - - assertMatch( "scope = compile", NodeDefinition.SCOPE, "compile", null ); - assertMatch( "scope=compile<runtime", NodeDefinition.SCOPE, "compile", "runtime" ); - assertMatch( "compile<runtime", NodeDefinition.SCOPE, "compile", "runtime" ); - assertNoMatch( "optional", NodeDefinition.SCOPE ); - assertNoMatch( "!optional", NodeDefinition.SCOPE ); - - assertMatch( "optional", NodeDefinition.OPTIONAL, "optional" ); - assertMatch( "!optional", NodeDefinition.OPTIONAL, "!optional" ); - - assertMatch( "relocations = g:a:1", NodeDefinition.RELOCATIONS, "g:a:1" ); - assertMatch( "relocations=g:a:1 , g:a:2", NodeDefinition.RELOCATIONS, "g:a:1 , g:a:2" ); - - assertMatch( "props = Key:Value", NodeDefinition.PROPS, "Key:Value" ); - assertMatch( "props=k:1 , k_2:v_2", NodeDefinition.PROPS, "k:1 , k_2:v_2" ); - - assertMatch( "gid:aid:1", NodeDefinition.COORDSX, "gid:aid:1", null, null ); - assertMatch( "gid:aid:1[1,2)", NodeDefinition.COORDSX, "gid:aid:1", "[1,2)", null ); - assertMatch( "gid:aid:1<2", NodeDefinition.COORDSX, "gid:aid:1", null, "2" ); - assertMatch( "gid:aid:1(, 2)<[1, 3]", NodeDefinition.COORDSX, "gid:aid:1", "(, 2)", "[1, 3]" ); - - assertMatch( "gid:aid:1(, 2)<[1, 3] props=k:v scope=c<r optional relocations=g:a:v (id)", NodeDefinition.NODE, - "gid:aid:1", "(, 2)", "[1, 3]", "k:v", "c", "r", "optional", "g:a:v", "id" ); - - assertMatch( "gid:aid:1(, 2)<[1, 3] props=k:v c<r optional relocations=g:a:v (id)", NodeDefinition.LINE, null, - "gid:aid:1", "(, 2)", "[1, 3]", "k:v", "c", "r", "optional", "g:a:v", "id" ); - assertMatch( "^id", NodeDefinition.LINE, "id", null, null, null ); - } - - @Test - public void testParsing_Reference() - { - NodeDefinition desc = new NodeDefinition( "^id" ); - assertEquals( "id", desc.reference ); - } - - @Test - public void testParsing_Node() - { - NodeDefinition desc = new NodeDefinition( "g:a:1" ); - assertEquals( null, desc.reference ); - assertEquals( "g:a:1", desc.coords ); - assertEquals( null, desc.range ); - assertEquals( null, desc.premanagedVersion ); - assertEquals( null, desc.scope ); - assertEquals( null, desc.premanagedScope ); - assertEquals( false, desc.optional ); - assertEquals( null, desc.properties ); - assertEquals( null, desc.relocations ); - assertEquals( null, desc.id ); - - desc = new NodeDefinition( "gid1:aid1:ext1:ver1 scope1 !optional" ); - assertEquals( null, desc.reference ); - assertEquals( "gid1:aid1:ext1:ver1", desc.coords ); - assertEquals( null, desc.range ); - assertEquals( null, desc.premanagedVersion ); - assertEquals( "scope1", desc.scope ); - assertEquals( null, desc.premanagedScope ); - assertEquals( false, desc.optional ); - assertEquals( null, desc.properties ); - assertEquals( null, desc.relocations ); - assertEquals( null, desc.id ); - - desc = new NodeDefinition( "g:a:1 optional" ); - assertEquals( null, desc.reference ); - assertEquals( "g:a:1", desc.coords ); - assertEquals( null, desc.range ); - assertEquals( null, desc.premanagedVersion ); - assertEquals( null, desc.scope ); - assertEquals( null, desc.premanagedScope ); - assertEquals( true, desc.optional ); - assertEquals( null, desc.properties ); - assertEquals( null, desc.relocations ); - assertEquals( null, desc.id ); - - desc = - new NodeDefinition( "gid:aid:1(, 2)<[1, 3]" + " props = k:v" + " scope=c<r" + " optional" - + " relocations = g:a:v , g:a:1" + " (id)" ); - assertEquals( null, desc.reference ); - assertEquals( "gid:aid:1", desc.coords ); - assertEquals( "(, 2)", desc.range ); - assertEquals( "[1, 3]", desc.premanagedVersion ); - assertEquals( "c", desc.scope ); - assertEquals( "r", desc.premanagedScope ); - assertEquals( true, desc.optional ); - assertEquals( Collections.singletonMap( "k", "v" ), desc.properties ); - assertEquals( Arrays.asList( "g:a:v", "g:a:1" ), desc.relocations ); - assertEquals( "id", desc.id ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-test-util/src/test/resources/org/eclipse/aether/internal/test/util/ArtifactDataReaderTest.ini ---------------------------------------------------------------------- diff --git a/aether-test-util/src/test/resources/org/eclipse/aether/internal/test/util/ArtifactDataReaderTest.ini b/aether-test-util/src/test/resources/org/eclipse/aether/internal/test/util/ArtifactDataReaderTest.ini deleted file mode 100644 index 28e3634..0000000 --- a/aether-test-util/src/test/resources/org/eclipse/aether/internal/test/util/ArtifactDataReaderTest.ini +++ /dev/null @@ -1,21 +0,0 @@ -[relocation] -gid:aid:ext:ver - -[dependencies] -gid:aid:ext:ver:scope --gid3:aid --gid2:aid2 -gid:aid2:ext:ver:scope:optional -gid:aid:ext:ver3:scope:optional -gid1:aid:ext:ver:scope5:optional - -[managedDependencies] -gid:aid:ext:ver:scope --gid3:aid --gid2:aid2 -gid:aid2:ext:ver:scope:optional -gid:aid:ext:ver3:scope:optional -gid1:aid:ext:ver:scope5:optional - -[repositories] -id:type:protocol://some/url?for=testing http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-test-util/src/test/resources/org/eclipse/aether/internal/test/util/gid_aid_1.ini ---------------------------------------------------------------------- diff --git a/aether-test-util/src/test/resources/org/eclipse/aether/internal/test/util/gid_aid_1.ini b/aether-test-util/src/test/resources/org/eclipse/aether/internal/test/util/gid_aid_1.ini deleted file mode 100644 index 1373b19..0000000 --- a/aether-test-util/src/test/resources/org/eclipse/aether/internal/test/util/gid_aid_1.ini +++ /dev/null @@ -1,18 +0,0 @@ -[dependencies] -gid:aid:ext:ver:scope --gid3:aid --gid2:aid2 -gid:aid2:ext:ver:scope:optional -gid:aid:ext:ver3:scope:optional -gid1:aid:ext:ver:scope5:optional - -[managedDependencies] -gid:aid:ext:ver:scope --gid3:aid --gid2:aid2 -gid:aid2:ext:ver:scope:optional -gid:aid:ext:ver3:scope:optional -gid1:aid:ext:ver:scope5:optional - -[repositories] -id:type:protocol://some/url?for=testing http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-test-util/src/test/resources/org/eclipse/aether/internal/test/util/gid_aid_ver.ini ---------------------------------------------------------------------- diff --git a/aether-test-util/src/test/resources/org/eclipse/aether/internal/test/util/gid_aid_ver.ini b/aether-test-util/src/test/resources/org/eclipse/aether/internal/test/util/gid_aid_ver.ini deleted file mode 100644 index 7f45908..0000000 --- a/aether-test-util/src/test/resources/org/eclipse/aether/internal/test/util/gid_aid_ver.ini +++ /dev/null @@ -1,2 +0,0 @@ -[relocation] -gid:aid:ext:1 http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-test-util/src/test/resources/org/eclipse/aether/internal/test/util/testResourceLoading.txt ---------------------------------------------------------------------- diff --git a/aether-test-util/src/test/resources/org/eclipse/aether/internal/test/util/testResourceLoading.txt b/aether-test-util/src/test/resources/org/eclipse/aether/internal/test/util/testResourceLoading.txt deleted file mode 100644 index 6c79ca5..0000000 --- a/aether-test-util/src/test/resources/org/eclipse/aether/internal/test/util/testResourceLoading.txt +++ /dev/null @@ -1,3 +0,0 @@ -gid:aid:ext:ver ---- -gid:aid2:ext:ver \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-classpath/pom.xml ---------------------------------------------------------------------- diff --git a/aether-transport-classpath/pom.xml b/aether-transport-classpath/pom.xml deleted file mode 100644 index eddd8db..0000000 --- a/aether-transport-classpath/pom.xml +++ /dev/null @@ -1,89 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- - 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. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.maven.aether</groupId> - <artifactId>aether</artifactId> - <version>1.0.3-SNAPSHOT</version> - </parent> - - <artifactId>aether-transport-classpath</artifactId> - - <name>Aether Transport Classpath</name> - <description> - A transport implementation for repositories using classpath:// URLs. - </description> - - <dependencies> - <dependency> - <groupId>org.apache.maven.aether</groupId> - <artifactId>aether-api</artifactId> - </dependency> - <dependency> - <groupId>org.apache.maven.aether</groupId> - <artifactId>aether-spi</artifactId> - </dependency> - <dependency> - <groupId>org.apache.maven.aether</groupId> - <artifactId>aether-util</artifactId> - </dependency> - <dependency> - <groupId>javax.inject</groupId> - <artifactId>javax.inject</artifactId> - <scope>provided</scope> - <optional>true</optional> - </dependency> - <dependency> - <groupId>org.sonatype.sisu</groupId> - <artifactId>sisu-guice</artifactId> - <classifier>no_aop</classifier> - <scope>test</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-library</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.maven.aether</groupId> - <artifactId>aether-test-util</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.eclipse.sisu</groupId> - <artifactId>sisu-maven-plugin</artifactId> - </plugin> - </plugins> - </build> -</project> http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/ClasspathTransporter.java ---------------------------------------------------------------------- diff --git a/aether-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/ClasspathTransporter.java b/aether-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/ClasspathTransporter.java deleted file mode 100644 index 493c907..0000000 --- a/aether-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/ClasspathTransporter.java +++ /dev/null @@ -1,149 +0,0 @@ -package org.eclipse.aether.transport.classpath; - -/* - * 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.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.net.URLConnection; - -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.spi.connector.transport.AbstractTransporter; -import org.eclipse.aether.spi.connector.transport.GetTask; -import org.eclipse.aether.spi.connector.transport.PeekTask; -import org.eclipse.aether.spi.connector.transport.PutTask; -import org.eclipse.aether.spi.connector.transport.TransportTask; -import org.eclipse.aether.spi.log.Logger; -import org.eclipse.aether.transfer.NoTransporterException; -import org.eclipse.aether.util.ConfigUtils; - -/** - * A transporter reading from the classpath. - */ -final class ClasspathTransporter - extends AbstractTransporter -{ - - private final String resourceBase; - - private final ClassLoader classLoader; - - public ClasspathTransporter( RepositorySystemSession session, RemoteRepository repository, Logger logger ) - throws NoTransporterException - { - if ( !"classpath".equalsIgnoreCase( repository.getProtocol() ) ) - { - throw new NoTransporterException( repository ); - } - - String base; - try - { - URI uri = new URI( repository.getUrl() ); - String ssp = uri.getSchemeSpecificPart(); - if ( ssp.startsWith( "/" ) ) - { - base = uri.getPath(); - if ( base == null ) - { - base = ""; - } - else if ( base.startsWith( "/" ) ) - { - base = base.substring( 1 ); - } - } - else - { - base = ssp; - } - if ( base.length() > 0 && !base.endsWith( "/" ) ) - { - base += '/'; - } - } - catch ( URISyntaxException e ) - { - throw new NoTransporterException( repository, e ); - } - resourceBase = base; - - Object cl = ConfigUtils.getObject( session, null, ClasspathTransporterFactory.CONFIG_PROP_CLASS_LOADER ); - if ( cl instanceof ClassLoader ) - { - classLoader = (ClassLoader) cl; - } - else - { - classLoader = Thread.currentThread().getContextClassLoader(); - } - } - - private URL getResource( TransportTask task ) - throws Exception - { - String resource = resourceBase + task.getLocation().getPath(); - URL url = classLoader.getResource( resource ); - if ( url == null ) - { - throw new ResourceNotFoundException( "Could not locate " + resource ); - } - return url; - } - - public int classify( Throwable error ) - { - if ( error instanceof ResourceNotFoundException ) - { - return ERROR_NOT_FOUND; - } - return ERROR_OTHER; - } - - @Override - protected void implPeek( PeekTask task ) - throws Exception - { - getResource( task ); - } - - @Override - protected void implGet( GetTask task ) - throws Exception - { - URL url = getResource( task ); - URLConnection conn = url.openConnection(); - utilGet( task, conn.getInputStream(), true, conn.getContentLength(), false ); - } - - @Override - protected void implPut( PutTask task ) - throws Exception - { - throw new UnsupportedOperationException( "Uploading to a classpath: repository is not supported" ); - } - - @Override - protected void implClose() - { - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/ClasspathTransporterFactory.java ---------------------------------------------------------------------- diff --git a/aether-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/ClasspathTransporterFactory.java b/aether-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/ClasspathTransporterFactory.java deleted file mode 100644 index 18db417..0000000 --- a/aether-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/ClasspathTransporterFactory.java +++ /dev/null @@ -1,116 +0,0 @@ -package org.eclipse.aether.transport.classpath; - -/* - * 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 javax.inject.Inject; -import javax.inject.Named; - -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.spi.connector.transport.Transporter; -import org.eclipse.aether.spi.connector.transport.TransporterFactory; -import org.eclipse.aether.spi.locator.Service; -import org.eclipse.aether.spi.locator.ServiceLocator; -import org.eclipse.aether.spi.log.Logger; -import org.eclipse.aether.spi.log.LoggerFactory; -import org.eclipse.aether.spi.log.NullLoggerFactory; -import org.eclipse.aether.transfer.NoTransporterException; - -/** - * A transporter factory for repositories using the {@code classpath:} protocol. As example, getting an item named - * {@code some/file.txt} from a repository with the URL {@code classpath:/base/dir} results in retrieving the resource - * {@code base/dir/some/file.txt} from the classpath. The classpath to load the resources from is given via a - * {@link ClassLoader} that can be configured via the configuration property {@link #CONFIG_PROP_CLASS_LOADER}. - * <p> - * <em>Note:</em> Such repositories are read-only and uploads to them are generally not supported. - */ -@Named( "classpath" ) -public final class ClasspathTransporterFactory - implements TransporterFactory, Service -{ - - /** - * The key in the repository session's {@link RepositorySystemSession#getConfigProperties() configuration - * properties} used to store a {@link ClassLoader} from which resources should be retrieved. If unspecified, the - * {@link Thread#getContextClassLoader() context class loader} of the current thread will be used. - */ - public static final String CONFIG_PROP_CLASS_LOADER = "aether.connector.classpath.loader"; - - private Logger logger = NullLoggerFactory.LOGGER; - - private float priority; - - /** - * Creates an (uninitialized) instance of this transporter factory. <em>Note:</em> In case of manual instantiation - * by clients, the new factory needs to be configured via its various mutators before first use or runtime errors - * will occur. - */ - public ClasspathTransporterFactory() - { - // enables default constructor - } - - @Inject - ClasspathTransporterFactory( LoggerFactory loggerFactory ) - { - setLoggerFactory( loggerFactory ); - } - - public void initService( ServiceLocator locator ) - { - setLoggerFactory( locator.getService( LoggerFactory.class ) ); - } - - /** - * Sets the logger factory to use for this component. - * - * @param loggerFactory The logger factory to use, may be {@code null} to disable logging. - * @return This component for chaining, never {@code null}. - */ - public ClasspathTransporterFactory setLoggerFactory( LoggerFactory loggerFactory ) - { - this.logger = NullLoggerFactory.getSafeLogger( loggerFactory, ClasspathTransporter.class ); - return this; - } - - public float getPriority() - { - return priority; - } - - /** - * Sets the priority of this component. - * - * @param priority The priority. - * @return This component for chaining, never {@code null}. - */ - public ClasspathTransporterFactory setPriority( float priority ) - { - this.priority = priority; - return this; - } - - public Transporter newInstance( RepositorySystemSession session, RemoteRepository repository ) - throws NoTransporterException - { - return new ClasspathTransporter( session, repository, logger ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/ResourceNotFoundException.java ---------------------------------------------------------------------- diff --git a/aether-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/ResourceNotFoundException.java b/aether-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/ResourceNotFoundException.java deleted file mode 100644 index d30a0ff..0000000 --- a/aether-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/ResourceNotFoundException.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.eclipse.aether.transport.classpath; - -/* - * 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.io.IOException; - -/** - * Special exception type used instead of {@code FileNotFoundException} to avoid misinterpretation of errors unrelated - * to the remote resource. - */ -class ResourceNotFoundException - extends IOException -{ - - public ResourceNotFoundException( String message ) - { - super( message ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/package-info.java ---------------------------------------------------------------------- diff --git a/aether-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/package-info.java b/aether-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/package-info.java deleted file mode 100644 index 8bcda93..0000000 --- a/aether-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -// CHECKSTYLE_OFF: RegexpHeader -/* - * 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. - */ -/** - * Support for downloads that utilize the classpath as "remote" storage. - */ -package org.eclipse.aether.transport.classpath; - http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-classpath/src/site/site.xml ---------------------------------------------------------------------- diff --git a/aether-transport-classpath/src/site/site.xml b/aether-transport-classpath/src/site/site.xml deleted file mode 100644 index abeaa3a..0000000 --- a/aether-transport-classpath/src/site/site.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- -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. ---> - -<project xmlns="http://maven.apache.org/DECORATION/1.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd" - name="Transport Classpath"> - <body> - <menu name="Overview"> - <item name="Introduction" href="index.html"/> - <item name="JavaDocs" href="apidocs/index.html"/> - <item name="Source Xref" href="xref/index.html"/> - <!--item name="FAQ" href="faq.html"/--> - </menu> - - <menu ref="parent"/> - <menu ref="reports"/> - </body> -</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-classpath/src/test/java/org/eclipse/aether/transport/classpath/ClasspathTransporterTest.java ---------------------------------------------------------------------- diff --git a/aether-transport-classpath/src/test/java/org/eclipse/aether/transport/classpath/ClasspathTransporterTest.java b/aether-transport-classpath/src/test/java/org/eclipse/aether/transport/classpath/ClasspathTransporterTest.java deleted file mode 100644 index 0c91685..0000000 --- a/aether-transport-classpath/src/test/java/org/eclipse/aether/transport/classpath/ClasspathTransporterTest.java +++ /dev/null @@ -1,411 +0,0 @@ -package org.eclipse.aether.transport.classpath; - -/* - * 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.File; -import java.io.FileNotFoundException; -import java.net.URI; - -import org.eclipse.aether.DefaultRepositorySystemSession; -import org.eclipse.aether.internal.test.util.TestFileUtils; -import org.eclipse.aether.internal.test.util.TestLoggerFactory; -import org.eclipse.aether.internal.test.util.TestUtils; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.spi.connector.transport.GetTask; -import org.eclipse.aether.spi.connector.transport.PeekTask; -import org.eclipse.aether.spi.connector.transport.PutTask; -import org.eclipse.aether.spi.connector.transport.Transporter; -import org.eclipse.aether.spi.connector.transport.TransporterFactory; -import org.eclipse.aether.transfer.NoTransporterException; -import org.eclipse.aether.transfer.TransferCancelledException; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - */ -public class ClasspathTransporterTest -{ - - private DefaultRepositorySystemSession session; - - private TransporterFactory factory; - - private Transporter transporter; - - private RemoteRepository newRepo( String url ) - { - return new RemoteRepository.Builder( "test", "default", url ).build(); - } - - private void newTransporter( String url ) - throws Exception - { - if ( transporter != null ) - { - transporter.close(); - transporter = null; - } - transporter = factory.newInstance( session, newRepo( url ) ); - } - - @Before - public void setUp() - throws Exception - { - session = TestUtils.newSession(); - factory = new ClasspathTransporterFactory( new TestLoggerFactory() ); - newTransporter( "classpath:/repository" ); - } - - @After - public void tearDown() - { - if ( transporter != null ) - { - transporter.close(); - transporter = null; - } - factory = null; - session = null; - } - - @Test - public void testClassify() - throws Exception - { - assertEquals( Transporter.ERROR_OTHER, transporter.classify( new FileNotFoundException() ) ); - assertEquals( Transporter.ERROR_NOT_FOUND, transporter.classify( new ResourceNotFoundException( "test" ) ) ); - } - - @Test - public void testPeek() - throws Exception - { - transporter.peek( new PeekTask( URI.create( "file.txt" ) ) ); - } - - @Test - public void testPeek_NotFound() - throws Exception - { - try - { - transporter.peek( new PeekTask( URI.create( "missing.txt" ) ) ); - fail( "Expected error" ); - } - catch ( ResourceNotFoundException e ) - { - assertEquals( Transporter.ERROR_NOT_FOUND, transporter.classify( e ) ); - } - } - - @Test - public void testPeek_Closed() - throws Exception - { - transporter.close(); - try - { - transporter.peek( new PeekTask( URI.create( "missing.txt" ) ) ); - fail( "Expected error" ); - } - catch ( IllegalStateException e ) - { - assertEquals( Transporter.ERROR_OTHER, transporter.classify( e ) ); - } - } - - @Test - public void testGet_ToMemory() - throws Exception - { - RecordingTransportListener listener = new RecordingTransportListener(); - GetTask task = new GetTask( URI.create( "file.txt" ) ).setListener( listener ); - transporter.get( task ); - assertEquals( "test", task.getDataString() ); - assertEquals( 0, listener.dataOffset ); - assertEquals( 4, listener.dataLength ); - assertEquals( 1, listener.startedCount ); - assertTrue( "Count: " + listener.progressedCount, listener.progressedCount > 0 ); - assertEquals( task.getDataString(), listener.baos.toString( "UTF-8" ) ); - } - - @Test - public void testGet_ToFile() - throws Exception - { - File file = TestFileUtils.createTempFile( "failure" ); - RecordingTransportListener listener = new RecordingTransportListener(); - GetTask task = new GetTask( URI.create( "file.txt" ) ).setDataFile( file ).setListener( listener ); - transporter.get( task ); - assertEquals( "test", TestFileUtils.readString( file ) ); - assertEquals( 0, listener.dataOffset ); - assertEquals( 4, listener.dataLength ); - assertEquals( 1, listener.startedCount ); - assertTrue( "Count: " + listener.progressedCount, listener.progressedCount > 0 ); - assertEquals( "test", listener.baos.toString( "UTF-8" ) ); - } - - @Test - public void testGet_EmptyResource() - throws Exception - { - File file = TestFileUtils.createTempFile( "failure" ); - RecordingTransportListener listener = new RecordingTransportListener(); - GetTask task = new GetTask( URI.create( "empty.txt" ) ).setDataFile( file ).setListener( listener ); - transporter.get( task ); - assertEquals( "", TestFileUtils.readString( file ) ); - assertEquals( 0, listener.dataOffset ); - assertEquals( 0, listener.dataLength ); - assertEquals( 1, listener.startedCount ); - assertEquals( 0, listener.progressedCount ); - assertEquals( "", listener.baos.toString( "UTF-8" ) ); - } - - @Test - public void testGet_EncodedResourcePath() - throws Exception - { - GetTask task = new GetTask( URI.create( "some%20space.txt" ) ); - transporter.get( task ); - assertEquals( "space", task.getDataString() ); - } - - @Test - public void testGet_Fragment() - throws Exception - { - GetTask task = new GetTask( URI.create( "file.txt#ignored" ) ); - transporter.get( task ); - assertEquals( "test", task.getDataString() ); - } - - @Test - public void testGet_Query() - throws Exception - { - GetTask task = new GetTask( URI.create( "file.txt?ignored" ) ); - transporter.get( task ); - assertEquals( "test", task.getDataString() ); - } - - @Test - public void testGet_FileHandleLeak() - throws Exception - { - for ( int i = 0; i < 100; i++ ) - { - File file = TestFileUtils.createTempFile( "failure" ); - transporter.get( new GetTask( URI.create( "file.txt" ) ).setDataFile( file ) ); - assertTrue( i + ", " + file.getAbsolutePath(), file.delete() ); - } - } - - @Test - public void testGet_NotFound() - throws Exception - { - try - { - transporter.get( new GetTask( URI.create( "missing.txt" ) ) ); - fail( "Expected error" ); - } - catch ( ResourceNotFoundException e ) - { - assertEquals( Transporter.ERROR_NOT_FOUND, transporter.classify( e ) ); - } - } - - @Test - public void testGet_Closed() - throws Exception - { - transporter.close(); - try - { - transporter.get( new GetTask( URI.create( "file.txt" ) ) ); - fail( "Expected error" ); - } - catch ( IllegalStateException e ) - { - assertEquals( Transporter.ERROR_OTHER, transporter.classify( e ) ); - } - } - - @Test - public void testGet_StartCancelled() - throws Exception - { - RecordingTransportListener listener = new RecordingTransportListener(); - listener.cancelStart = true; - GetTask task = new GetTask( URI.create( "file.txt" ) ).setListener( listener ); - try - { - transporter.get( task ); - fail( "Expected error" ); - } - catch ( TransferCancelledException e ) - { - assertEquals( Transporter.ERROR_OTHER, transporter.classify( e ) ); - } - assertEquals( 0, listener.dataOffset ); - assertEquals( 4, listener.dataLength ); - assertEquals( 1, listener.startedCount ); - assertEquals( 0, listener.progressedCount ); - } - - @Test - public void testGet_ProgressCancelled() - throws Exception - { - RecordingTransportListener listener = new RecordingTransportListener(); - listener.cancelProgress = true; - GetTask task = new GetTask( URI.create( "file.txt" ) ).setListener( listener ); - try - { - transporter.get( task ); - fail( "Expected error" ); - } - catch ( TransferCancelledException e ) - { - assertEquals( Transporter.ERROR_OTHER, transporter.classify( e ) ); - } - assertEquals( 0, listener.dataOffset ); - assertEquals( 4, listener.dataLength ); - assertEquals( 1, listener.startedCount ); - assertEquals( 1, listener.progressedCount ); - } - - @Test - public void testPut() - throws Exception - { - try - { - transporter.put( new PutTask( URI.create( "missing.txt" ) ) ); - fail( "Expected error" ); - } - catch ( UnsupportedOperationException e ) - { - assertEquals( Transporter.ERROR_OTHER, transporter.classify( e ) ); - } - } - - @Test - public void testPut_Closed() - throws Exception - { - transporter.close(); - try - { - transporter.put( new PutTask( URI.create( "missing.txt" ) ) ); - fail( "Expected error" ); - } - catch ( IllegalStateException e ) - { - assertEquals( Transporter.ERROR_OTHER, transporter.classify( e ) ); - } - } - - @Test( expected = NoTransporterException.class ) - public void testInit_BadProtocol() - throws Exception - { - newTransporter( "bad:/void" ); - } - - @Test - public void testInit_CaseInsensitiveProtocol() - throws Exception - { - newTransporter( "classpath:/void" ); - newTransporter( "CLASSPATH:/void" ); - newTransporter( "ClassPath:/void" ); - } - - @Test - public void testInit_OpaqueUrl() - throws Exception - { - testInit( "classpath:repository" ); - } - - @Test - public void testInit_OpaqueUrlTrailingSlash() - throws Exception - { - testInit( "classpath:repository/" ); - } - - @Test - public void testInit_OpaqueUrlSpaces() - throws Exception - { - testInit( "classpath:repo%20space" ); - } - - @Test - public void testInit_HierarchicalUrl() - throws Exception - { - testInit( "classpath:/repository" ); - } - - @Test - public void testInit_HierarchicalUrlTrailingSlash() - throws Exception - { - testInit( "classpath:/repository/" ); - } - - @Test - public void testInit_HierarchicalUrlSpaces() - throws Exception - { - testInit( "classpath:/repo%20space" ); - } - - @Test - public void testInit_HierarchicalUrlRoot() - throws Exception - { - testInit( "classpath:/" ); - } - - @Test - public void testInit_HierarchicalUrlNoPath() - throws Exception - { - testInit( "classpath://reserved" ); - } - - private void testInit( String base ) - throws Exception - { - newTransporter( base ); - GetTask task = new GetTask( URI.create( "file.txt" ) ); - transporter.get( task ); - assertEquals( "test", task.getDataString() ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-classpath/src/test/java/org/eclipse/aether/transport/classpath/RecordingTransportListener.java ---------------------------------------------------------------------- diff --git a/aether-transport-classpath/src/test/java/org/eclipse/aether/transport/classpath/RecordingTransportListener.java b/aether-transport-classpath/src/test/java/org/eclipse/aether/transport/classpath/RecordingTransportListener.java deleted file mode 100644 index 9447d39..0000000 --- a/aether-transport-classpath/src/test/java/org/eclipse/aether/transport/classpath/RecordingTransportListener.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.eclipse.aether.transport.classpath; - -/* - * 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.io.ByteArrayOutputStream; -import java.nio.ByteBuffer; - -import org.eclipse.aether.spi.connector.transport.TransportListener; -import org.eclipse.aether.transfer.TransferCancelledException; - -class RecordingTransportListener - extends TransportListener -{ - - public final ByteArrayOutputStream baos = new ByteArrayOutputStream( 1024 ); - - public long dataOffset; - - public long dataLength; - - public int startedCount; - - public int progressedCount; - - public boolean cancelStart; - - public boolean cancelProgress; - - @Override - public void transportStarted( long dataOffset, long dataLength ) - throws TransferCancelledException - { - startedCount++; - progressedCount = 0; - this.dataLength = dataLength; - this.dataOffset = dataOffset; - baos.reset(); - if ( cancelStart ) - { - throw new TransferCancelledException(); - } - } - - @Override - public void transportProgressed( ByteBuffer data ) - throws TransferCancelledException - { - progressedCount++; - baos.write( data.array(), data.arrayOffset() + data.position(), data.remaining() ); - if ( cancelProgress ) - { - throw new TransferCancelledException(); - } - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-classpath/src/test/resources/file.txt ---------------------------------------------------------------------- diff --git a/aether-transport-classpath/src/test/resources/file.txt b/aether-transport-classpath/src/test/resources/file.txt deleted file mode 100644 index 30d74d2..0000000 --- a/aether-transport-classpath/src/test/resources/file.txt +++ /dev/null @@ -1 +0,0 @@ -test \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-classpath/src/test/resources/repo space/file.txt ---------------------------------------------------------------------- diff --git a/aether-transport-classpath/src/test/resources/repo space/file.txt b/aether-transport-classpath/src/test/resources/repo space/file.txt deleted file mode 100644 index 30d74d2..0000000 --- a/aether-transport-classpath/src/test/resources/repo space/file.txt +++ /dev/null @@ -1 +0,0 @@ -test \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-classpath/src/test/resources/repository/empty.txt ---------------------------------------------------------------------- diff --git a/aether-transport-classpath/src/test/resources/repository/empty.txt b/aether-transport-classpath/src/test/resources/repository/empty.txt deleted file mode 100644 index e69de29..0000000 http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-classpath/src/test/resources/repository/file.txt ---------------------------------------------------------------------- diff --git a/aether-transport-classpath/src/test/resources/repository/file.txt b/aether-transport-classpath/src/test/resources/repository/file.txt deleted file mode 100644 index 30d74d2..0000000 --- a/aether-transport-classpath/src/test/resources/repository/file.txt +++ /dev/null @@ -1 +0,0 @@ -test \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-classpath/src/test/resources/repository/some space.txt ---------------------------------------------------------------------- diff --git a/aether-transport-classpath/src/test/resources/repository/some space.txt b/aether-transport-classpath/src/test/resources/repository/some space.txt deleted file mode 100644 index 82cbe04..0000000 --- a/aether-transport-classpath/src/test/resources/repository/some space.txt +++ /dev/null @@ -1 +0,0 @@ -space \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-file/pom.xml ---------------------------------------------------------------------- diff --git a/aether-transport-file/pom.xml b/aether-transport-file/pom.xml deleted file mode 100644 index ea4701a..0000000 --- a/aether-transport-file/pom.xml +++ /dev/null @@ -1,89 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- - 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. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.maven.aether</groupId> - <artifactId>aether</artifactId> - <version>1.0.3-SNAPSHOT</version> - </parent> - - <artifactId>aether-transport-file</artifactId> - - <name>Aether Transport File</name> - <description> - A transport implementation for repositories using file:// URLs. - </description> - - <dependencies> - <dependency> - <groupId>org.apache.maven.aether</groupId> - <artifactId>aether-api</artifactId> - </dependency> - <dependency> - <groupId>org.apache.maven.aether</groupId> - <artifactId>aether-spi</artifactId> - </dependency> - <dependency> - <groupId>org.apache.maven.aether</groupId> - <artifactId>aether-util</artifactId> - </dependency> - <dependency> - <groupId>javax.inject</groupId> - <artifactId>javax.inject</artifactId> - <scope>provided</scope> - <optional>true</optional> - </dependency> - <dependency> - <groupId>org.sonatype.sisu</groupId> - <artifactId>sisu-guice</artifactId> - <classifier>no_aop</classifier> - <scope>test</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-library</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.maven.aether</groupId> - <artifactId>aether-test-util</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.eclipse.sisu</groupId> - <artifactId>sisu-maven-plugin</artifactId> - </plugin> - </plugins> - </build> -</project> http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-file/src/main/java/org/eclipse/aether/transport/file/FileTransporter.java ---------------------------------------------------------------------- diff --git a/aether-transport-file/src/main/java/org/eclipse/aether/transport/file/FileTransporter.java b/aether-transport-file/src/main/java/org/eclipse/aether/transport/file/FileTransporter.java deleted file mode 100644 index 5c5cfa4..0000000 --- a/aether-transport-file/src/main/java/org/eclipse/aether/transport/file/FileTransporter.java +++ /dev/null @@ -1,127 +0,0 @@ -package org.eclipse.aether.transport.file; - -/* - * 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.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; - -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.spi.connector.transport.AbstractTransporter; -import org.eclipse.aether.spi.connector.transport.GetTask; -import org.eclipse.aether.spi.connector.transport.PeekTask; -import org.eclipse.aether.spi.connector.transport.PutTask; -import org.eclipse.aether.spi.connector.transport.TransportTask; -import org.eclipse.aether.spi.log.Logger; -import org.eclipse.aether.transfer.NoTransporterException; - -/** - * A transporter using {@link java.io.File}. - */ -final class FileTransporter - extends AbstractTransporter -{ - - private final Logger logger; - - private final File basedir; - - public FileTransporter( RemoteRepository repository, Logger logger ) - throws NoTransporterException - { - if ( !"file".equalsIgnoreCase( repository.getProtocol() ) ) - { - throw new NoTransporterException( repository ); - } - this.logger = logger; - basedir = new File( PathUtils.basedir( repository.getUrl() ) ).getAbsoluteFile(); - } - - File getBasedir() - { - return basedir; - } - - public int classify( Throwable error ) - { - if ( error instanceof ResourceNotFoundException ) - { - return ERROR_NOT_FOUND; - } - return ERROR_OTHER; - } - - @Override - protected void implPeek( PeekTask task ) - throws Exception - { - getFile( task, true ); - } - - @Override - protected void implGet( GetTask task ) - throws Exception - { - File file = getFile( task, true ); - utilGet( task, new FileInputStream( file ), true, file.length(), false ); - } - - @Override - protected void implPut( PutTask task ) - throws Exception - { - File file = getFile( task, false ); - file.getParentFile().mkdirs(); - try - { - utilPut( task, new FileOutputStream( file ), true ); - } - catch ( Exception e ) - { - if ( !file.delete() && file.exists() ) - { - logger.debug( "Could not delete partial file " + file ); - } - throw e; - } - } - - private File getFile( TransportTask task, boolean required ) - throws Exception - { - String path = task.getLocation().getPath(); - if ( path.contains( "../" ) ) - { - throw new IllegalArgumentException( "Illegal resource path: " + path ); - } - File file = new File( basedir, path ); - if ( required && !file.exists() ) - { - throw new ResourceNotFoundException( "Could not locate " + file ); - } - return file; - } - - @Override - protected void implClose() - { - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-file/src/main/java/org/eclipse/aether/transport/file/FileTransporterFactory.java ---------------------------------------------------------------------- diff --git a/aether-transport-file/src/main/java/org/eclipse/aether/transport/file/FileTransporterFactory.java b/aether-transport-file/src/main/java/org/eclipse/aether/transport/file/FileTransporterFactory.java deleted file mode 100644 index 86ae6fc..0000000 --- a/aether-transport-file/src/main/java/org/eclipse/aether/transport/file/FileTransporterFactory.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.eclipse.aether.transport.file; - -/* - * 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 javax.inject.Inject; -import javax.inject.Named; - -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.spi.connector.transport.Transporter; -import org.eclipse.aether.spi.connector.transport.TransporterFactory; -import org.eclipse.aether.spi.locator.Service; -import org.eclipse.aether.spi.locator.ServiceLocator; -import org.eclipse.aether.spi.log.Logger; -import org.eclipse.aether.spi.log.LoggerFactory; -import org.eclipse.aether.spi.log.NullLoggerFactory; -import org.eclipse.aether.transfer.NoTransporterException; - -/** - * A transporter factory for repositories using the {@code file:} protocol. - */ -@Named( "file" ) -public final class FileTransporterFactory - implements TransporterFactory, Service -{ - - private Logger logger = NullLoggerFactory.LOGGER; - - private float priority; - - /** - * Creates an (uninitialized) instance of this transporter factory. <em>Note:</em> In case of manual instantiation - * by clients, the new factory needs to be configured via its various mutators before first use or runtime errors - * will occur. - */ - public FileTransporterFactory() - { - // enables default constructor - } - - @Inject - FileTransporterFactory( LoggerFactory loggerFactory ) - { - setLoggerFactory( loggerFactory ); - } - - public void initService( ServiceLocator locator ) - { - setLoggerFactory( locator.getService( LoggerFactory.class ) ); - } - - /** - * Sets the logger factory to use for this component. - * - * @param loggerFactory The logger factory to use, may be {@code null} to disable logging. - * @return This component for chaining, never {@code null}. - */ - public FileTransporterFactory setLoggerFactory( LoggerFactory loggerFactory ) - { - this.logger = NullLoggerFactory.getSafeLogger( loggerFactory, FileTransporter.class ); - return this; - } - - public float getPriority() - { - return priority; - } - - /** - * Sets the priority of this component. - * - * @param priority The priority. - * @return This component for chaining, never {@code null}. - */ - public FileTransporterFactory setPriority( float priority ) - { - this.priority = priority; - return this; - } - - public Transporter newInstance( RepositorySystemSession session, RemoteRepository repository ) - throws NoTransporterException - { - return new FileTransporter( repository, logger ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-file/src/main/java/org/eclipse/aether/transport/file/PathUtils.java ---------------------------------------------------------------------- diff --git a/aether-transport-file/src/main/java/org/eclipse/aether/transport/file/PathUtils.java b/aether-transport-file/src/main/java/org/eclipse/aether/transport/file/PathUtils.java deleted file mode 100644 index ac3f8fd..0000000 --- a/aether-transport-file/src/main/java/org/eclipse/aether/transport/file/PathUtils.java +++ /dev/null @@ -1,138 +0,0 @@ -package org.eclipse.aether.transport.file; - -/* - * 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. - */ - -/** - * URL handling for file URLs. Based on org.apache.maven.wagon.PathUtils. - */ -final class PathUtils -{ - - private PathUtils() - { - } - - /** - * Return the protocol name. <br/> - * E.g: for input <code>http://www.codehause.org</code> this method will return <code>http</code> - * - * @param url the url - * @return the host name - */ - public static String protocol( final String url ) - { - final int pos = url.indexOf( ":" ); - - if ( pos == -1 ) - { - return ""; - } - return url.substring( 0, pos ).trim(); - } - - /** - * Derive the path portion of the given URL. - * - * @param url the file-repository URL - * @return the basedir of the repository - */ - public static String basedir( String url ) - { - String protocol = PathUtils.protocol( url ); - - String retValue = null; - - if ( protocol.length() > 0 ) - { - retValue = url.substring( protocol.length() + 1 ); - } - else - { - retValue = url; - } - retValue = decode( retValue ); - // special case: if omitted // on protocol, keep path as is - if ( retValue.startsWith( "//" ) ) - { - retValue = retValue.substring( 2 ); - - if ( retValue.length() >= 2 && ( retValue.charAt( 1 ) == '|' || retValue.charAt( 1 ) == ':' ) ) - { - // special case: if there is a windows drive letter, then keep the original return value - retValue = retValue.charAt( 0 ) + ":" + retValue.substring( 2 ); - } - else - { - // Now we expect the host - int index = retValue.indexOf( "/" ); - if ( index >= 0 ) - { - retValue = retValue.substring( index + 1 ); - } - - // special case: if there is a windows drive letter, then keep the original return value - if ( retValue.length() >= 2 && ( retValue.charAt( 1 ) == '|' || retValue.charAt( 1 ) == ':' ) ) - { - retValue = retValue.charAt( 0 ) + ":" + retValue.substring( 2 ); - } - else if ( index >= 0 ) - { - // leading / was previously stripped - retValue = "/" + retValue; - } - } - } - - // special case: if there is a windows drive letter using |, switch to : - if ( retValue.length() >= 2 && retValue.charAt( 1 ) == '|' ) - { - retValue = retValue.charAt( 0 ) + ":" + retValue.substring( 2 ); - } - - return retValue.trim(); - } - - /** - * Decodes the specified (portion of a) URL. <strong>Note:</strong> This decoder assumes that ISO-8859-1 is used to - * convert URL-encoded octets to characters. - * - * @param url The URL to decode, may be <code>null</code>. - * @return The decoded URL or <code>null</code> if the input was <code>null</code>. - */ - static String decode( String url ) - { - String decoded = url; - if ( url != null ) - { - int pos = -1; - while ( ( pos = decoded.indexOf( '%', pos + 1 ) ) >= 0 ) - { - if ( pos + 2 < decoded.length() ) - { - String hexStr = decoded.substring( pos + 1, pos + 3 ); - char ch = (char) Integer.parseInt( hexStr, 16 ); - decoded = decoded.substring( 0, pos ) + ch + decoded.substring( pos + 3 ); - } - } - } - return decoded; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-file/src/main/java/org/eclipse/aether/transport/file/ResourceNotFoundException.java ---------------------------------------------------------------------- diff --git a/aether-transport-file/src/main/java/org/eclipse/aether/transport/file/ResourceNotFoundException.java b/aether-transport-file/src/main/java/org/eclipse/aether/transport/file/ResourceNotFoundException.java deleted file mode 100644 index 462fa0a..0000000 --- a/aether-transport-file/src/main/java/org/eclipse/aether/transport/file/ResourceNotFoundException.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.eclipse.aether.transport.file; - -/* - * 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.io.IOException; - -/** - * Special exception type used instead of {@code FileNotFoundException} to avoid misinterpretation of errors unrelated - * to the remote resource. - */ -class ResourceNotFoundException - extends IOException -{ - - public ResourceNotFoundException( String message ) - { - super( message ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-file/src/main/java/org/eclipse/aether/transport/file/package-info.java ---------------------------------------------------------------------- diff --git a/aether-transport-file/src/main/java/org/eclipse/aether/transport/file/package-info.java b/aether-transport-file/src/main/java/org/eclipse/aether/transport/file/package-info.java deleted file mode 100644 index 8220bf4..0000000 --- a/aether-transport-file/src/main/java/org/eclipse/aether/transport/file/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -// CHECKSTYLE_OFF: RegexpHeader -/* - * 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. - */ -/** - * Support for downloads/uploads using the local filesystem as "remote" storage. - */ -package org.eclipse.aether.transport.file; - http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/3a1b8ae0/aether-transport-file/src/site/site.xml ---------------------------------------------------------------------- diff --git a/aether-transport-file/src/site/site.xml b/aether-transport-file/src/site/site.xml deleted file mode 100644 index 916ba7a..0000000 --- a/aether-transport-file/src/site/site.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- -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. ---> - -<project xmlns="http://maven.apache.org/DECORATION/1.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd" - name="Transport File"> - <body> - <menu name="Overview"> - <item name="Introduction" href="index.html"/> - <item name="JavaDocs" href="apidocs/index.html"/> - <item name="Source Xref" href="xref/index.html"/> - <!--item name="FAQ" href="faq.html"/--> - </menu> - - <menu ref="parent"/> - <menu ref="reports"/> - </body> -</project> \ No newline at end of file