Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Maven2RepositoryStorageTest.java 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package org.apache.archiva.repository.maven.metadata;
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. import org.apache.archiva.metadata.repository.storage.RepositoryStorage;
  20. import org.apache.archiva.repository.maven.MavenManagedRepository;
  21. import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
  22. import org.junit.Assert;
  23. import org.junit.Test;
  24. import org.junit.runner.RunWith;
  25. import org.springframework.test.context.ContextConfiguration;
  26. import javax.inject.Inject;
  27. import javax.inject.Named;
  28. import java.io.IOException;
  29. import java.nio.file.Paths;
  30. /**
  31. * @author Olivier Lamy
  32. */
  33. @RunWith( ArchivaSpringJUnit4ClassRunner.class )
  34. @ContextConfiguration( { "classpath*:/spring-context-storage.xml", "classpath*:META-INF/spring-context.xml" } )
  35. public class Maven2RepositoryStorageTest
  36. {
  37. @Inject
  38. @Named( "repositoryStorage#maven2" )
  39. RepositoryStorage repositoryStorage;
  40. @Test
  41. public void testGetLogicalPath() throws IOException {
  42. String href = "/repository/internal/org/apache/maven/someartifact.jar";
  43. Assert.assertEquals( "/org/apache/maven/someartifact.jar",
  44. repositoryStorage.getFilePath( href, MavenManagedRepository.newLocalInstance( "repo01", "repo01", Paths.get("target/repositories")) ) );
  45. href = "repository/internal/org/apache/maven/someartifact.jar";
  46. Assert.assertEquals( "/org/apache/maven/someartifact.jar",
  47. repositoryStorage.getFilePath( href, MavenManagedRepository.newLocalInstance( "repo01", "repo01", Paths.get("target/repositories") ) ) );
  48. href = "repository/internal/org/apache/maven/";
  49. Assert.assertEquals( "/org/apache/maven/", repositoryStorage.getFilePath( href, MavenManagedRepository.newLocalInstance("repo01", "repo01", Paths.get("target/repositories")) ) );
  50. href = "mypath";
  51. Assert.assertEquals( "/", repositoryStorage.getFilePath( href, MavenManagedRepository.newLocalInstance("repo01", "repo01", Paths.get("target/repositories")) ) );
  52. }
  53. }