1 package org.apache.archiva.repository.content;
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
22 import org.apache.archiva.metadata.model.ArtifactMetadata;
23 import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
24 import org.apache.archiva.metadata.repository.storage.maven2.ArtifactMappingProvider;
25 import org.apache.archiva.metadata.repository.storage.maven2.Maven2RepositoryPathTranslator;
26 import org.apache.archiva.metadata.repository.storage.maven2.MavenArtifactFacet;
27 import org.apache.archiva.repository.AbstractRepositoryLayerTestCase;
28 import org.junit.Test;
30 import java.util.Collections;
32 import static org.junit.Assert.*;
35 * ArtifactExtensionMappingTest
39 public class ArtifactExtensionMappingTest
40 extends AbstractRepositoryLayerTestCase
42 private RepositoryPathTranslator pathTranslator = new Maven2RepositoryPathTranslator(
43 Collections.<ArtifactMappingProvider>emptyList() );
46 public void testIsMavenPlugin()
48 assertMavenPlugin( "maven-test-plugin" );
49 assertMavenPlugin( "maven-clean-plugin" );
50 assertMavenPlugin( "cobertura-maven-plugin" );
51 assertMavenPlugin( "maven-project-info-reports-plugin" );
52 assertMavenPlugin( "silly-name-for-a-maven-plugin" );
54 assertNotMavenPlugin( "maven-plugin-api" );
55 assertNotMavenPlugin( "foo-lib" );
56 assertNotMavenPlugin( "another-maven-plugin-api" );
57 assertNotMavenPlugin( "secret-maven-plugin-2" );
60 private void assertMavenPlugin( String artifactId )
62 assertEquals( "Should be detected as maven plugin: <" + artifactId + ">", "maven-plugin", getTypeFromArtifactId(
66 private String getTypeFromArtifactId( String artifactId )
68 ArtifactMetadata artifact = pathTranslator.getArtifactFromId( null, "groupId", artifactId, "1.0",
69 artifactId + "-1.0.jar" );
70 MavenArtifactFacet facet = (MavenArtifactFacet) artifact.getFacet( MavenArtifactFacet.FACET_ID );
71 return facet.getType();
74 private void assertNotMavenPlugin( String artifactId )
76 assertFalse( "Should NOT be detected as maven plugin: <" + artifactId + ">", "maven-plugin".equals(
77 getTypeFromArtifactId( artifactId ) ) );