]> source.dussan.org Git - archiva.git/blob
83874b7a04aed7bc5ea65e49d981ccf34b44e399
[archiva.git] /
1 package org.apache.archiva.configuration;
2
3 /*
4  * Licensed to the Apache Software Foundation (ASF) under one
5  * or more contributor license agreements.  See the NOTICE file
6  * distributed with this work for additional information
7  * regarding copyright ownership.  The ASF licenses this file
8  * to you under the Apache License, Version 2.0 (the
9  * "License"); you may not use this file except in compliance
10  * with the License.  You may obtain a copy of the License at
11  *
12  *   http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17  * KIND, either express or implied.  See the License for the
18  * specific language governing permissions and limitations
19  * under the License.
20  */
21
22 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
23 import org.junit.Test;
24 import org.junit.runner.RunWith;
25 import org.springframework.test.context.ContextConfiguration;
26
27 import javax.inject.Inject;
28
29 import static org.junit.Assert.assertFalse;
30 import static org.junit.Assert.assertTrue;
31
32 @RunWith( ArchivaSpringJUnit4ClassRunner.class )
33 @ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml" } )
34 public class FileTypesTest
35 {
36     @Inject
37     private FileTypes filetypes;
38
39     @Test
40     public void testIsArtifact()
41     {
42         assertTrue( filetypes.matchesArtifactPattern( "test.maven-arch/poms/test-arch-2.0.3-SNAPSHOT.pom" ) );
43         assertTrue( filetypes.matchesArtifactPattern(
44             "test/maven-arch/test-arch/2.0.3-SNAPSHOT/test-arch-2.0.3-SNAPSHOT.jar" ) );
45         assertTrue( filetypes.matchesArtifactPattern( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz" ) );
46
47         assertFalse(
48             filetypes.matchesArtifactPattern( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.sha1" ) );
49         assertFalse(
50             filetypes.matchesArtifactPattern( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.md5" ) );
51         assertFalse(
52             filetypes.matchesArtifactPattern( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.asc" ) );
53         assertFalse(
54             filetypes.matchesArtifactPattern( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.pgp" ) );
55         assertFalse( filetypes.matchesArtifactPattern( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml" ) );
56         assertFalse( filetypes.matchesArtifactPattern( "org/apache/derby/derby/maven-metadata.xml" ) );
57     }
58
59     @Test
60     public void testDefaultExclusions()
61     {
62         assertTrue( filetypes.matchesDefaultExclusions( "repository/test/.index/nexus-maven-repository-index.gz" ) );
63         assertTrue( filetypes.matchesDefaultExclusions( "repository/test/.index/nexus-maven-repository-index.zip" ) );
64         assertTrue( filetypes.matchesDefaultExclusions(
65             "repository/test/org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.sha1" ) );
66         assertTrue( filetypes.matchesDefaultExclusions(
67             "repository/test/org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.md5" ) );
68         assertTrue( filetypes.matchesDefaultExclusions(
69             "repository/test/org/apache/derby/derby/10.2.2.0/maven-metadata.xml" ) );
70         assertTrue( filetypes.matchesDefaultExclusions(
71             "repository/test/org/apache/derby/derby/10.2.2.0/maven-metadata.xml.sha1" ) );
72         assertTrue( filetypes.matchesDefaultExclusions(
73             "repository/test/org/apache/derby/derby/10.2.2.0/maven-metadata.xml.md5" ) );
74
75         assertFalse( filetypes.matchesDefaultExclusions(
76             "repository/test/org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.zip" ) );
77         assertFalse( filetypes.matchesDefaultExclusions(
78             "repository/test/org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz" ) );
79     }
80 }