View Javadoc
1   package org.apache.maven.index;
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 java.io.File;
23  import java.util.Collection;
24  
25  import org.junit.Test;
26  
27  import static org.junit.Assert.assertEquals;
28  import static org.junit.Assert.assertNotNull;
29  
30  /** http://issues.sonatype.org/browse/NEXUS-3233 */
31  public class Nexus3233NexusIndexerTest
32      extends AbstractNexusIndexerTest
33  {
34      protected File repo = new File( getBasedir(), "src/test/nexus-3233" );
35  
36      @Override
37      protected void prepareNexusIndexer( NexusIndexer nexusIndexer )
38          throws Exception
39      {
40          context =
41              nexusIndexer.addIndexingContext( "nexus-3233", "nexus-3233", repo, indexDir, null, null, FULL_CREATORS );
42          nexusIndexer.scan( context );
43      }
44  
45      @Test
46      public void testIdentifyPomPackagingArtifacts()
47          throws Exception
48      {
49          // POM1
50          Collection<ArtifactInfo> ais = nexusIndexer.identify( MAVEN.SHA1, "741ea3998e6db3ce202d8b88aa53889543f050cc" );
51  
52          assertEquals( 1, ais.size() );
53  
54          ArtifactInfo ai = ais.iterator().next();
55  
56          assertNotNull( ai );
57  
58          assertEquals( "cisco.infra.dft", ai.getGroupId() );
59  
60          assertEquals( "dma.maven.plugins", ai.getArtifactId() );
61  
62          assertEquals( "1.0-SNAPSHOT", ai.getVersion() );
63  
64          // POM2
65          ais = nexusIndexer.identify( MAVEN.SHA1, "efb52d4ef65452b4e575fc2e7709595915775857" );
66  
67          assertEquals( 1, ais.size() );
68  
69          ai = ais.iterator().next();
70  
71          assertNotNull( ai );
72  
73          assertEquals( "cisco.infra.dft", ai.getGroupId() );
74  
75          assertEquals( "parent.pom", ai.getArtifactId() );
76  
77          assertEquals( "1.0-SNAPSHOT", ai.getVersion() );
78      }
79  }