Search in sources :

Example 1 with ArtifactTypeMappingService

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

the class ArtifactTypeMappingServiceTest method testGetStandardTypeForUknonwnType.

public void testGetStandardTypeForUknonwnType() {
    try {
        ArtifactTypeMappingService service = getDefaultService();
        service.getStandardType("MyKoolCustomType");
        fail("Should have failed to retrieve a unknwon custom type");
    } catch (UnknownArtifactTypeException e) {
    // That's good
    }
}
Also used : UnknownArtifactTypeException(org.apache.maven.plugins.ear.UnknownArtifactTypeException) ArtifactTypeMappingService(org.apache.maven.plugins.ear.util.ArtifactTypeMappingService)

Example 2 with ArtifactTypeMappingService

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

the class ArtifactTypeMappingServiceTest method getDefaultService.

protected ArtifactTypeMappingService getDefaultService() {
    try {
        ArtifactTypeMappingService service = new ArtifactTypeMappingService();
        service.configure(new XmlPlexusConfiguration("dummy"));
        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)

Example 3 with ArtifactTypeMappingService

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

the class ArtifactTypeMappingServiceTest method testConfigWithSameCustomType.

public void testConfigWithSameCustomType() {
    try {
        XmlPlexusConfiguration rootConfig = new XmlPlexusConfiguration("dummy");
        XmlPlexusConfiguration childConfig = new XmlPlexusConfiguration(ArtifactTypeMappingService.ARTIFACT_TYPE_MAPPING_ELEMENT);
        childConfig.setAttribute("type", "generic");
        childConfig.setAttribute("mapping", "rar");
        XmlPlexusConfiguration childConfig2 = new XmlPlexusConfiguration(ArtifactTypeMappingService.ARTIFACT_TYPE_MAPPING_ELEMENT);
        childConfig.setAttribute("type", "generic");
        childConfig.setAttribute("mapping", "ejb");
        rootConfig.addChild(childConfig);
        rootConfig.addChild(childConfig2);
        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 4 with ArtifactTypeMappingService

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

the class ArtifactRepositoryTest method testRepositoryWithOneUnclassifiedArtifact.

@Test
public void testRepositoryWithOneUnclassifiedArtifact() {
    ArtifactTypeMappingService artifactTypeMappingService = new ArtifactTypeMappingService();
    ArtifactRepository repo = new ArtifactRepository(createArtifacts(new String[] { "myartifact" }), MAIN_ARTIFACT_ID, artifactTypeMappingService);
    assertNotNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar"));
    assertNotNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar", null));
}
Also used : ArtifactRepository(org.apache.maven.plugins.ear.util.ArtifactRepository) ArtifactTypeMappingService(org.apache.maven.plugins.ear.util.ArtifactTypeMappingService) Test(org.junit.Test)

Example 5 with ArtifactTypeMappingService

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

the class ArtifactRepositoryTest method testRepositoryWithOneClassifiedArtifact.

@Test
public void testRepositoryWithOneClassifiedArtifact() {
    ArtifactTypeMappingService artifactTypeMappingService = new ArtifactTypeMappingService();
    ArtifactRepository repo = new ArtifactRepository(createArtifacts(new String[] { "myartifact" }, null, null, new String[] { "classified" }), MAIN_ARTIFACT_ID, artifactTypeMappingService);
    assertNotNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar"));
    assertNotNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar", "classified"));
    assertNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar", "wrong"));
}
Also used : ArtifactRepository(org.apache.maven.plugins.ear.util.ArtifactRepository) ArtifactTypeMappingService(org.apache.maven.plugins.ear.util.ArtifactTypeMappingService) Test(org.junit.Test)

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