You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FileTypesTest.java 3.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package org.apache.archiva.configuration;
  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. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
  21. import org.junit.Test;
  22. import org.junit.runner.RunWith;
  23. import org.springframework.test.context.ContextConfiguration;
  24. import javax.inject.Inject;
  25. import static org.junit.Assert.assertFalse;
  26. import static org.junit.Assert.assertTrue;
  27. @RunWith( ArchivaSpringJUnit4ClassRunner.class )
  28. @ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml" } )
  29. public class FileTypesTest
  30. {
  31. @Inject
  32. private FileTypes filetypes;
  33. @Test
  34. public void testIsArtifact()
  35. {
  36. assertTrue( filetypes.matchesArtifactPattern( "test.maven-arch/poms/test-arch-2.0.3-SNAPSHOT.pom" ) );
  37. assertTrue( filetypes.matchesArtifactPattern(
  38. "test/maven-arch/test-arch/2.0.3-SNAPSHOT/test-arch-2.0.3-SNAPSHOT.jar" ) );
  39. assertTrue( filetypes.matchesArtifactPattern( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz" ) );
  40. assertFalse(
  41. filetypes.matchesArtifactPattern( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.sha1" ) );
  42. assertFalse(
  43. filetypes.matchesArtifactPattern( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.md5" ) );
  44. assertFalse(
  45. filetypes.matchesArtifactPattern( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.asc" ) );
  46. assertFalse(
  47. filetypes.matchesArtifactPattern( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.pgp" ) );
  48. assertFalse( filetypes.matchesArtifactPattern( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml" ) );
  49. assertFalse( filetypes.matchesArtifactPattern( "org/apache/derby/derby/maven-metadata.xml" ) );
  50. }
  51. @Test
  52. public void testDefaultExclusions()
  53. {
  54. assertTrue( filetypes.matchesDefaultExclusions( "repository/test/.index/nexus-maven-repository-index.gz" ) );
  55. assertTrue( filetypes.matchesDefaultExclusions( "repository/test/.index/nexus-maven-repository-index.zip" ) );
  56. assertTrue( filetypes.matchesDefaultExclusions(
  57. "repository/test/org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.sha1" ) );
  58. assertTrue( filetypes.matchesDefaultExclusions(
  59. "repository/test/org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.md5" ) );
  60. assertTrue( filetypes.matchesDefaultExclusions(
  61. "repository/test/org/apache/derby/derby/10.2.2.0/maven-metadata.xml" ) );
  62. assertTrue( filetypes.matchesDefaultExclusions(
  63. "repository/test/org/apache/derby/derby/10.2.2.0/maven-metadata.xml.sha1" ) );
  64. assertTrue( filetypes.matchesDefaultExclusions(
  65. "repository/test/org/apache/derby/derby/10.2.2.0/maven-metadata.xml.md5" ) );
  66. assertFalse( filetypes.matchesDefaultExclusions(
  67. "repository/test/org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.zip" ) );
  68. assertFalse( filetypes.matchesDefaultExclusions(
  69. "repository/test/org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz" ) );
  70. }
  71. }