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