View Javadoc

1   package org.apache.maven.index.artifact;
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.maven.index.artifact.M2ArtifactRecognizer;
23  
24  import junit.framework.TestCase;
25  
26  public class MavenArtifactRecognizerTest
27      extends TestCase
28  {
29  
30      public void testIsPom()
31      {
32          assertEquals( true, M2ArtifactRecognizer.isPom( "aaa.pom" ) );
33          assertEquals( true, M2ArtifactRecognizer.isPom( "zxc-1-2-3.pom" ) );
34          assertEquals( false, M2ArtifactRecognizer.isPom( "aaa.jar" ) );
35          assertEquals( false, M2ArtifactRecognizer.isPom( "aaa.pom-a" ) );
36      }
37  
38      public void testIsSnapshot1()
39      {
40          // NEXUS-3148
41          assertEquals( true, M2ArtifactRecognizer.isSnapshot( "/org/somewhere/aid/1.0SNAPSHOT/aid-1.0SNAPSHOT.jar" ) );
42  
43          assertEquals( true, M2ArtifactRecognizer.isSnapshot( "/org/somewhere/aid/1.0-SNAPSHOT/aid-1.0-SNAPSHOT.jar" ) );
44          assertEquals( true, M2ArtifactRecognizer.isSnapshot( "/org/somewhere/aid/1.0-SNAPSHOT/aid-1.0-SNAPSHOT.pom" ) );
45          assertEquals( true, M2ArtifactRecognizer.isSnapshot( "/org/somewhere/aid/1.0-SNAPSHOT/aid-1.2.3-.pom" ) );
46          assertEquals( false, M2ArtifactRecognizer.isSnapshot( "/org/somewhere/aid/1.0/xsd-SNAPsHOT.jar" ) );
47          assertEquals( false, M2ArtifactRecognizer.isSnapshot( "/org/somewhere/aid/1.0/xsd-SNAPHOT.pom" ) );
48          assertEquals( false, M2ArtifactRecognizer.isSnapshot( "/org/somewhere/aid/1.0/a/b/c/xsd-1.2.3NAPSHOT.pom" ) );
49          assertEquals( false, M2ArtifactRecognizer.isSnapshot( "/javax/mail/mail/1.4/mail-1.4.jar" ) );
50      }
51  
52      public void testIsSnapshot2()
53      {
54          assertEquals(
55              true,
56              M2ArtifactRecognizer.isSnapshot( "/org/somewhere/appassembler-maven-plugin/1.0-SNAPSHOT/appassembler-maven-plugin-1.0-20060714.142547-1.pom" ) );
57          assertEquals(
58              false,
59              M2ArtifactRecognizer.isSnapshot( "/org/somewhere/appassembler-maven-plugin/1.0/appassembler-maven-plugin-1.0-20060714.142547-1.pom" ) );
60      }
61  
62      public void testIsMetadata()
63      {
64          assertEquals( true, M2ArtifactRecognizer.isMetadata( "maven-metadata.xml" ) );
65          assertEquals( false, M2ArtifactRecognizer.isMetadata( "aven-metadata.xml" ) );
66          assertEquals( false, M2ArtifactRecognizer.isMetadata( "/javax/mail/mail/1.4/mail-1.4.jar" ) );
67      }
68  
69  }