Search in sources :

Example 11 with ArtifactTypeMappingService

use of org.apache.maven.plugins.ear.util.ArtifactTypeMappingService in project maven-plugins by apache.

the class ArtifactRepositoryTest method testEmptyRepository.

@Test
public void testEmptyRepository() {
    ArtifactTypeMappingService artifactTypeMappingService = new ArtifactTypeMappingService();
    ArtifactRepository repo = new ArtifactRepository(createArtifacts(null), MAIN_ARTIFACT_ID, artifactTypeMappingService);
    assertNull(repo.getUniqueArtifact("ear", "ar", "jar"));
    assertNull(repo.getUniqueArtifact("ear", "ar", "jar", null));
    assertNull(repo.getUniqueArtifact("ear", "ar", "jar", "class"));
}
Also used : ArtifactRepository(org.apache.maven.plugins.ear.util.ArtifactRepository) ArtifactTypeMappingService(org.apache.maven.plugins.ear.util.ArtifactTypeMappingService) Test(org.junit.Test)

Example 12 with ArtifactTypeMappingService

use of org.apache.maven.plugins.ear.util.ArtifactTypeMappingService in project maven-plugins by apache.

the class ArtifactTypeMappingServiceTest method testConfigWithNoType.

public void testConfigWithNoType() {
    try {
        XmlPlexusConfiguration rootConfig = new XmlPlexusConfiguration("dummy");
        XmlPlexusConfiguration childConfig = new XmlPlexusConfiguration(ArtifactTypeMappingService.ARTIFACT_TYPE_MAPPING_ELEMENT);
        childConfig.setAttribute("mapping", "ejb");
        rootConfig.addChild(childConfig);
        ArtifactTypeMappingService service = new ArtifactTypeMappingService();
        service.configure(rootConfig);
        fail("Should have failed");
    } catch (EarPluginException e) {
    // OK
    } catch (PlexusConfigurationException e) {
        e.printStackTrace();
        fail("Unexpected " + e.getMessage());
    }
}
Also used : PlexusConfigurationException(org.codehaus.plexus.configuration.PlexusConfigurationException) EarPluginException(org.apache.maven.plugins.ear.EarPluginException) XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) ArtifactTypeMappingService(org.apache.maven.plugins.ear.util.ArtifactTypeMappingService)

Example 13 with ArtifactTypeMappingService

use of org.apache.maven.plugins.ear.util.ArtifactTypeMappingService in project maven-plugins by apache.

the class ArtifactTypeMappingServiceTest method testConfigWithUnknownStandardType.

public void testConfigWithUnknownStandardType() {
    try {
        XmlPlexusConfiguration rootConfig = new XmlPlexusConfiguration("dummy");
        XmlPlexusConfiguration childConfig = new XmlPlexusConfiguration(ArtifactTypeMappingService.ARTIFACT_TYPE_MAPPING_ELEMENT);
        childConfig.setAttribute("type", "generic");
        childConfig.setAttribute("mapping", "notAStandardType");
        rootConfig.addChild(childConfig);
        ArtifactTypeMappingService service = new ArtifactTypeMappingService();
        service.configure(rootConfig);
        fail("Should have failed");
    } catch (EarPluginException e) {
    // OK
    } catch (PlexusConfigurationException e) {
        e.printStackTrace();
        fail("Unexpected " + e.getMessage());
    }
}
Also used : PlexusConfigurationException(org.codehaus.plexus.configuration.PlexusConfigurationException) EarPluginException(org.apache.maven.plugins.ear.EarPluginException) XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) ArtifactTypeMappingService(org.apache.maven.plugins.ear.util.ArtifactTypeMappingService)

Example 14 with ArtifactTypeMappingService

use of org.apache.maven.plugins.ear.util.ArtifactTypeMappingService in project maven-plugins by apache.

the class ArtifactTypeMappingServiceTest method testConfigWithNoMapping.

public void testConfigWithNoMapping() {
    try {
        XmlPlexusConfiguration rootConfig = new XmlPlexusConfiguration("dummy");
        XmlPlexusConfiguration childConfig = new XmlPlexusConfiguration(ArtifactTypeMappingService.ARTIFACT_TYPE_MAPPING_ELEMENT);
        childConfig.setAttribute("type", "generic");
        rootConfig.addChild(childConfig);
        ArtifactTypeMappingService service = new ArtifactTypeMappingService();
        service.configure(rootConfig);
        fail("Should have failed");
    } catch (EarPluginException e) {
    // OK
    } catch (PlexusConfigurationException e) {
        e.printStackTrace();
        fail("Unexpected " + e.getMessage());
    }
}
Also used : PlexusConfigurationException(org.codehaus.plexus.configuration.PlexusConfigurationException) EarPluginException(org.apache.maven.plugins.ear.EarPluginException) XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) ArtifactTypeMappingService(org.apache.maven.plugins.ear.util.ArtifactTypeMappingService)

Example 15 with ArtifactTypeMappingService

use of org.apache.maven.plugins.ear.util.ArtifactTypeMappingService in project maven-plugins by apache.

the class ArtifactTypeMappingServiceTest method getServiceWithRarMappingToMyRar.

// Utilities
protected ArtifactTypeMappingService getServiceWithRarMappingToMyRar() {
    try {
        XmlPlexusConfiguration rootConfig = new XmlPlexusConfiguration("artifact-type-mappings");
        XmlPlexusConfiguration childConfig = new XmlPlexusConfiguration(ArtifactTypeMappingService.ARTIFACT_TYPE_MAPPING_ELEMENT);
        childConfig.setAttribute("type", "MyRar");
        childConfig.setAttribute("mapping", "rar");
        rootConfig.addChild(childConfig);
        ArtifactTypeMappingService service = new ArtifactTypeMappingService();
        service.configure(rootConfig);
        return service;
    } catch (EarPluginException e) {
        e.printStackTrace();
        fail(e.getMessage());
    } catch (PlexusConfigurationException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    // Won't occur
    return null;
}
Also used : PlexusConfigurationException(org.codehaus.plexus.configuration.PlexusConfigurationException) EarPluginException(org.apache.maven.plugins.ear.EarPluginException) XmlPlexusConfiguration(org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration) ArtifactTypeMappingService(org.apache.maven.plugins.ear.util.ArtifactTypeMappingService)

Aggregations

ArtifactTypeMappingService (org.apache.maven.plugins.ear.util.ArtifactTypeMappingService)16 PlexusConfigurationException (org.codehaus.plexus.configuration.PlexusConfigurationException)7 EarPluginException (org.apache.maven.plugins.ear.EarPluginException)6 XmlPlexusConfiguration (org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration)6 ArtifactRepository (org.apache.maven.plugins.ear.util.ArtifactRepository)5 Test (org.junit.Test)5 UnknownArtifactTypeException (org.apache.maven.plugins.ear.UnknownArtifactTypeException)2 ArrayList (java.util.ArrayList)1 Artifact (org.apache.maven.artifact.Artifact)1 ScopeArtifactFilter (org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 JavaEEVersion (org.apache.maven.plugins.ear.util.JavaEEVersion)1