View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
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  package org.apache.maven.index.artifact;
20  
21  import org.junit.Test;
22  
23  import static org.junit.Assert.assertEquals;
24  
25  public class MavenArtifactRecognizerTest {
26  
27      @Test
28      public void testIsPom() {
29          assertEquals(true, M2ArtifactRecognizer.isPom("aaa.pom"));
30          assertEquals(true, M2ArtifactRecognizer.isPom("zxc-1-2-3.pom"));
31          assertEquals(false, M2ArtifactRecognizer.isPom("aaa.jar"));
32          assertEquals(false, M2ArtifactRecognizer.isPom("aaa.pom-a"));
33      }
34  
35      @Test
36      public void testIsSnapshot1() {
37          // NEXUS-3148
38          assertEquals(true, M2ArtifactRecognizer.isSnapshot("/org/somewhere/aid/1.0SNAPSHOT/aid-1.0SNAPSHOT.jar"));
39  
40          assertEquals(true, M2ArtifactRecognizer.isSnapshot("/org/somewhere/aid/1.0-SNAPSHOT/aid-1.0-SNAPSHOT.jar"));
41          assertEquals(true, M2ArtifactRecognizer.isSnapshot("/org/somewhere/aid/1.0-SNAPSHOT/aid-1.0-SNAPSHOT.pom"));
42          assertEquals(true, M2ArtifactRecognizer.isSnapshot("/org/somewhere/aid/1.0-SNAPSHOT/aid-1.2.3-.pom"));
43          assertEquals(false, M2ArtifactRecognizer.isSnapshot("/org/somewhere/aid/1.0/xsd-SNAPsHOT.jar"));
44          assertEquals(false, M2ArtifactRecognizer.isSnapshot("/org/somewhere/aid/1.0/xsd-SNAPHOT.pom"));
45          assertEquals(false, M2ArtifactRecognizer.isSnapshot("/org/somewhere/aid/1.0/a/b/c/xsd-1.2.3NAPSHOT.pom"));
46          assertEquals(false, M2ArtifactRecognizer.isSnapshot("/javax/mail/mail/1.4/mail-1.4.jar"));
47      }
48  
49      @Test
50      public void testIsSnapshot2() {
51          assertEquals(
52                  true,
53                  M2ArtifactRecognizer.isSnapshot(
54                          "/org/somewhere/appassembler-maven-plugin/1.0-SNAPSHOT/appassembler-maven-plugin-1.0-20060714.142547-1.pom"));
55          assertEquals(
56                  false,
57                  M2ArtifactRecognizer.isSnapshot(
58                          "/org/somewhere/appassembler-maven-plugin/1.0/appassembler-maven-plugin-1.0-20060714.142547-1.pom"));
59      }
60  
61      @Test
62      public void testIsMetadata() {
63          assertEquals(true, M2ArtifactRecognizer.isMetadata("maven-metadata.xml"));
64          assertEquals(false, M2ArtifactRecognizer.isMetadata("aven-metadata.xml"));
65          assertEquals(false, M2ArtifactRecognizer.isMetadata("/javax/mail/mail/1.4/mail-1.4.jar"));
66      }
67  }