Search in sources :

Example 6 with EarModule

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

the class ModuleIdentifierValidatorTest method createMockEarModule.

private EarModule createMockEarModule(String groupId, String artifactId, String classifier, String version) {
    EarModule earModule = mock(EarModule.class);
    Artifact artifact = mock(Artifact.class);
    when(earModule.getArtifact()).thenReturn(artifact);
    when(earModule.getArtifact().getGroupId()).thenReturn(groupId);
    when(earModule.getArtifact().getArtifactId()).thenReturn(artifactId);
    when(earModule.getArtifact().getClassifier()).thenReturn(classifier);
    when(earModule.getArtifact().getVersion()).thenReturn(version);
    when(earModule.getArtifact().getId()).thenReturn(groupId + ":" + artifactId + ":" + classifier + ":" + version);
    return earModule;
}
Also used : EarModule(org.apache.maven.plugins.ear.EarModule) Artifact(org.apache.maven.artifact.Artifact)

Example 7 with EarModule

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

the class EarMavenArchiverTest method testTwoModules.

@Test
public void testTwoModules() {
    final List<EarModule> modules = new ArrayList<EarModule>();
    final EarModule module = new EjbModule(createArtifact("foo", "ejb"));
    setUri(module, "foo-1.0.jar");
    modules.add(module);
    final EarModule module2 = new EjbModule(createArtifact("bar", "war"));
    setUri(module2, "bar-2.0.1.war");
    modules.add(module2);
    final EarMavenArchiver archiver = new EarMavenArchiver(modules);
    assertEquals("foo-1.0.jar bar-2.0.1.war", archiver.generateClassPathEntry(""));
}
Also used : ArrayList(java.util.ArrayList) EarModule(org.apache.maven.plugins.ear.EarModule) EjbModule(org.apache.maven.plugins.ear.EjbModule) EarMavenArchiver(org.apache.maven.plugins.ear.util.EarMavenArchiver) Test(org.junit.Test)

Example 8 with EarModule

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

the class ModuleIdentifierValidatorTest method shouldFailCauseTheArtifactIdsAreIdenticalWithClassifiers.

@Test
public void shouldFailCauseTheArtifactIdsAreIdenticalWithClassifiers() {
    EarModule earModule1 = createMockEarModule("org.apache.maven.test", "result-artifact", "first", "1.0.0");
    EarModule earModule2 = createMockEarModule("org.apache.maven", "result-artifact", "second", "1.0.0");
    earModules.add(earModule1);
    earModules.add(earModule2);
    miv.checkForDuplicateArtifacts();
    Map<String, List<EarModule>> result = miv.getDuplicateArtifacts();
    assertFalse(result.isEmpty());
    assertEquals(1, result.size());
    assertTrue(result.containsKey("result-artifact:1.0.0"));
    assertEquals(2, result.get("result-artifact:1.0.0").size());
}
Also used : EarModule(org.apache.maven.plugins.ear.EarModule) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 9 with EarModule

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

the class ModuleIdentifierValidatorTest method shouldFailWithAppropriateInformationAboutTheIdenticalArtifactIds.

@Test
public void shouldFailWithAppropriateInformationAboutTheIdenticalArtifactIds() {
    EarModule earModule_1 = createMockEarModule("org.apache", "artifact-2", "1.0.0");
    EarModule earModule_2 = createMockEarModule("org.apache.maven", "artifact-2", "1.0.0");
    earModules.add(createMockEarModule("org.apache", "artifact-1", "1.0.0"));
    earModules.add(earModule_1);
    earModules.add(createMockEarModule("org.apache.maven", "aid-1", "1.0.0"));
    earModules.add(earModule_2);
    earModules.add(createMockEarModule("org.apache.maven.test", "result-artifact-a", "1.0.0"));
    earModules.add(createMockEarModule("org.apache.maven.test", "result-artifact-b", "1.0.0"));
    miv.checkForDuplicateArtifacts();
    Map<String, List<EarModule>> result = miv.getDuplicateArtifacts();
    assertFalse(result.isEmpty());
    assertEquals(1, result.size());
    assertTrue(result.containsKey("artifact-2:1.0.0"));
    List<EarModule> list = result.get("artifact-2:1.0.0");
    assertEquals(2, list.size());
    assertTrue(list.contains(earModule_1));
    assertTrue(list.contains(earModule_2));
}
Also used : EarModule(org.apache.maven.plugins.ear.EarModule) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Aggregations

EarModule (org.apache.maven.plugins.ear.EarModule)9 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)6 List (java.util.List)4 EjbModule (org.apache.maven.plugins.ear.EjbModule)3 EarMavenArchiver (org.apache.maven.plugins.ear.util.EarMavenArchiver)3 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Artifact (org.apache.maven.artifact.Artifact)1 ModuleIdentifierValidator (org.apache.maven.plugins.ear.util.ModuleIdentifierValidator)1 Before (org.junit.Before)1