Added: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/ModuleIdentifierValidator.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/ModuleIdentifierValidator.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/ModuleIdentifierValidator.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/ModuleIdentifierValidator.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,139 @@
+package org.apache.maven.plugins.ear.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.plugins.ear.EarModule;
+
+/**
+ * This class will check the list of modules if there exist a duplicate 
artifactId. If we have such case it's necessary
+ * to create a warning to the user otherwise it can happen to overwrite 
existing artifacts during the EAR creation
+ * process. This is a temporary solution to keep backward compatibility with 
previous versions. For the next major
+ * release 3.X the creation of the EAR archive should be done based on unique 
identifiers like
+ * {@code groupId:artifactId:version}.
+ * 
+ * @author Karl Heinz Marbaise <[email protected]>
+ */
+public class ModuleIdentifierValidator
+{
+
+    private List<EarModule> earModules;
+
+    private Map<String, List<EarModule>> result;
+
+    /**
+     * @param earModules The list of {@link EarModule} which will be checked.
+     */
+    public ModuleIdentifierValidator( List<EarModule> earModules )
+    {
+        if ( earModules == null )
+        {
+            throw new IllegalArgumentException( "Not allowed to give null for 
earModules." );
+        }
+        this.earModules = earModules;
+        this.result = new HashMap<String, List<EarModule>>();
+    }
+
+    /**
+     * You have to call {@link #checkForDuplicateArtifacts()} before
+     * otherwise you will get always {@code false}.
+     * @return true in case of existing duplicates false otherwise.
+     */
+    public boolean existDuplicateArtifacts()
+    {
+        return !result.isEmpty();
+    }
+
+    /**
+     * Trigger the module list check.
+     * 
+     * @return this for fluent usage.
+     */
+    public ModuleIdentifierValidator checkForDuplicateArtifacts()
+    {
+        analyze();
+        return this;
+    }
+
+    private void analyze()
+    {
+        final Map<String, List<EarModule>> newList = new HashMap<String, 
List<EarModule>>();
+
+        for ( EarModule earModule : earModules )
+        {
+            String earId = earModule.getArtifact().getArtifactId() + ":" + 
earModule.getArtifact().getVersion();
+
+            if ( newList.containsKey( earId ) )
+            {
+                newList.get( earId ).add( earModule );
+            }
+            else
+            {
+                List<EarModule> list = new ArrayList<EarModule>();
+                list.add( earModule );
+                newList.put( earId, list );
+            }
+        }
+
+        result.clear();
+        for ( Map.Entry<String, List<EarModule>> item : newList.entrySet() )
+        {
+            if ( item.getValue().size() > 1 )
+            {
+                result.put( item.getKey(), item.getValue() );
+            }
+        }
+
+    }
+
+    /**
+     * @return A map of duplicate artifacts.
+     */
+    public Map<String, List<EarModule>> getDuplicateArtifacts()
+    {
+        return result;
+    }
+
+    /**
+     * @return The list of {@link EarModule}
+     */
+    public List<EarModule> getEarModules()
+    {
+        return earModules;
+    }
+
+    /**
+     * @param paramEarModules {@link EarModule}
+     * @return {@link ModuleIdentifierValidator}
+     */
+    public ModuleIdentifierValidator setEarModules( List<EarModule> 
paramEarModules )
+    {
+        if ( paramEarModules == null )
+        {
+            throw new IllegalArgumentException( "Not allowed to give null for 
earModules." );
+        }
+        this.earModules = paramEarModules;
+        return this;
+    }
+}
\ No newline at end of file

Added: 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/AbstractEarTestBase.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/AbstractEarTestBase.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/AbstractEarTestBase.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/AbstractEarTestBase.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,122 @@
+package org.apache.maven.plugins.ear;
+
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugins.ear.AbstractEarModule;
+import org.apache.maven.plugins.ear.EarModule;
+import org.apache.maven.plugins.ear.stub.ArtifactTestStub;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ */
+public abstract class AbstractEarTestBase
+{
+
+    public static final String DEFAULT_GROUPID = "eartest";
+
+    public static final String DEFAULT_TYPE = "jar";
+
+    protected void setUri( EarModule module, String uri )
+    {
+        ( (AbstractEarModule) module ).setUri( uri );
+    }
+
+    protected Set<Artifact> createArtifacts( String[] artifactsId )
+    {
+        return createArtifacts( artifactsId, null );
+    }
+
+    protected Set<Artifact> createArtifacts( String[] artifactsId, String[] 
types )
+    {
+        return createArtifacts( artifactsId, types, null );
+    }
+
+    protected Set<Artifact> createArtifacts( String[] artifactsId, String[] 
types, String[] groupsId )
+    {
+        return createArtifacts( artifactsId, types, groupsId, null );
+    }
+
+    protected Set<Artifact> createArtifacts( String[] artifactsId, String[] 
types, String[] groupsId,
+                                             String[] classifiers )
+    {
+        Set<Artifact> result = new TreeSet<Artifact>();
+        if ( artifactsId == null || artifactsId.length == 0 )
+        {
+            return result;
+        }
+        for ( int i = 0; i < artifactsId.length; i++ )
+        {
+            String artifactId = artifactsId[i];
+            String type = getData( types, i, DEFAULT_TYPE );
+            String groupId = getData( groupsId, i, DEFAULT_GROUPID );
+            String classifier = getData( classifiers, i, null );
+            result.add( new ArtifactTestStub( groupId, artifactId, type, 
classifier ) );
+
+        }
+        return result;
+    }
+
+    protected String getData( String[] data, int i, String defaultValue )
+    {
+        if ( data == null || data[i] == null )
+        {
+            return defaultValue;
+        }
+        else
+        {
+            return data[i];
+
+        }
+    }
+
+    protected String getDefaultValue( String t, String defaultValue )
+    {
+        if ( t == null )
+        {
+            return defaultValue;
+        }
+        else
+        {
+            return t;
+        }
+    }
+
+    protected Artifact createArtifact( String artifactId, String type, String 
groupId, String classifier )
+    {
+        return new ArtifactTestStub( getDefaultValue( groupId, DEFAULT_GROUPID 
), artifactId,
+                                     getDefaultValue( type, DEFAULT_TYPE ), 
classifier );
+    }
+
+    protected Artifact createArtifact( String artifactId, String type, String 
groupId )
+    {
+        return createArtifact( artifactId, type, groupId, null );
+
+    }
+
+    protected Artifact createArtifact( String artifactId, String type )
+    {
+        return createArtifact( artifactId, type, null );
+
+    }
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/EarModuleTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/EarModuleTest.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/EarModuleTest.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/EarModuleTest.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,45 @@
+package org.apache.maven.plugins.ear;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.maven.plugins.ear.AbstractEarModule;
+import org.junit.Test;
+
+/**
+ * Ear module test case.
+ * 
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: EarModuleTest.java 1648192 2014-12-28 12:39:04Z khmarbaise $
+ */
+public class EarModuleTest
+{
+
+    @Test
+    public void testCleanBuildDir()
+    {
+        assertEquals( "APP-INF/lib/", AbstractEarModule.cleanBundleDir( 
"APP-INF/lib" ) );
+        assertEquals( "APP-INF/lib/", AbstractEarModule.cleanBundleDir( 
"APP-INF/lib/" ) );
+        assertEquals( "APP-INF/lib/", AbstractEarModule.cleanBundleDir( 
"/APP-INF/lib" ) );
+        assertEquals( "APP-INF/lib/", AbstractEarModule.cleanBundleDir( 
"/APP-INF/lib/" ) );
+        assertEquals( "", AbstractEarModule.cleanBundleDir( "/" ) );
+    }
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/EnvEntryTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/EnvEntryTest.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/EnvEntryTest.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/EnvEntryTest.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,94 @@
+package org.apache.maven.plugins.ear;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.maven.plugins.ear.EnvEntry;
+
+/**
+ * @author Stephane Nicoll
+ */
+public class EnvEntryTest
+{
+
+    public static final String DESCRIPTION = "description";
+
+    public static final String NAME = "name";
+
+    public static final String TYPE = Integer.class.getName();
+
+    public static final String VALUE = "34";
+
+    @Test
+    public void createComplete()
+    {
+        final EnvEntry envEntry = new EnvEntry( DESCRIPTION, NAME, TYPE, VALUE 
);
+        assertEnvEntry( envEntry, DESCRIPTION, NAME, TYPE, VALUE );
+    }
+
+    @Test
+    public void createWithoutTypeButValue()
+    {
+        final EnvEntry envEntry = new EnvEntry( null, NAME, null, VALUE );
+        assertEnvEntry( envEntry, null, NAME, null, VALUE );
+    }
+
+    @Test( expected = IllegalArgumentException.class )
+    public void createWithoutName()
+    {
+        new EnvEntry( DESCRIPTION, null, TYPE, VALUE );
+
+    }
+
+    @Test( expected = IllegalArgumentException.class )
+    public void createWithEmptyName()
+    {
+        new EnvEntry( DESCRIPTION, "", TYPE, VALUE );
+    }
+
+    @Test( expected = IllegalArgumentException.class )
+    public void createWithNullTypeAndNoValue()
+    {
+        new EnvEntry( DESCRIPTION, NAME, null, null );
+
+    }
+
+    @Test( expected = IllegalArgumentException.class )
+    public void createWithEmptyTypeAndNoValue()
+    {
+        new EnvEntry( DESCRIPTION, NAME, "", null );
+
+    }
+
+    private void assertEnvEntry( EnvEntry actual, String description, String 
name, String type, String value )
+    {
+        assertNotNull( "Env entry could not be null", actual );
+        assertNotNull( "ToString could not be null", actual.toString() );
+        assertEquals( "Wrong env entry description for [" + actual + "]", 
description, actual.getDescription() );
+        assertEquals( "Wrong env entry name for [" + actual + "]", name, 
actual.getName() );
+        assertEquals( "Wrong env entry type for [" + actual + "]", type, 
actual.getType() );
+        assertEquals( "Wrong env entry value for [" + actual + "]", value, 
actual.getValue() );
+
+    }
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/it/AbstractEarPluginIT.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/it/AbstractEarPluginIT.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/it/AbstractEarPluginIT.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/it/AbstractEarPluginIT.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,413 @@
+package org.apache.maven.plugins.ear.it;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.maven.it.VerificationException;
+import org.apache.maven.it.Verifier;
+import org.apache.maven.it.util.ResourceExtractor;
+import org.apache.maven.plugins.ear.util.ResourceEntityResolver;
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * Base class for ear test cases.
+ * 
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: AbstractEarPluginIT.java 1630593 2014-10-09 20:40:31Z 
khmarbaise $
+ */
+public abstract class AbstractEarPluginIT
+    extends TestCase
+{
+
+    protected final String FINAL_NAME_PREFIX = "maven-ear-plugin-test-";
+
+    protected final String FINAL_NAME_SUFFIX = "-99.0";
+
+    /**
+     * The base directory.
+     */
+    private File basedir;
+
+    /**
+     * Test repository directory.
+     */
+    protected File localRepositoryDir = new File( 
getBasedir().getAbsolutePath(), "target/test-classes/m2repo" );
+
+    protected File settingsFile = new File( getBasedir().getAbsolutePath(), 
"target/test-classes/settings.xml" );
+
+    /**
+     * Execute the EAR plugin for the specified project.
+     * 
+     * @param projectName the name of the project
+     * @param properties extra properties to be used by the embedder
+     * @return the base directory of the project
+     * @throws Exception if an error occurred
+     */
+    @SuppressWarnings( "unchecked" )
+    protected File executeMojo( final String projectName, final Properties 
properties, boolean expectNoError )
+        throws Exception
+    {
+        System.out.println( "  Building: " + projectName );
+
+        File testDir = getTestDir( projectName );
+        Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+        // Let's add alternate settings.xml setting so that the latest 
dependencies are used
+        String localRepo = System.getProperty( "localRepositoryPath" );
+        verifier.setLocalRepo( localRepo );
+
+        verifier.getCliOptions().add( "-s \"" + settingsFile.getAbsolutePath() 
+ "\"" );//
+        verifier.getCliOptions().add( "-X" );
+        verifier.localRepo = localRepo;
+
+        // On linux and macOSX, an exception is thrown if a build failure 
occurs underneath
+        try
+        {
+            verifier.executeGoal( "package" );
+        }
+        catch ( VerificationException e )
+        {
+            // @TODO needs to be handled nicely in the verifier
+            if ( expectNoError || !e.getMessage().contains( "Exit code was 
non-zero" ) )
+            {
+                throw e;
+            }
+        }
+
+        // If no error is expected make sure that error logs are free
+        if ( expectNoError )
+        {
+            verifier.verifyErrorFreeLog();
+        }
+        verifier.resetStreams();
+        return testDir;
+    }
+
+    /**
+     * Execute the EAR plugin for the specified project.
+     * 
+     * @param projectName the name of the project
+     * @param properties extra properties to be used by the embedder
+     * @return the base directory of the project
+     * @throws Exception if an error occurred
+     */
+    protected File executeMojo( final String projectName, final Properties 
properties )
+        throws Exception
+    {
+        return executeMojo( projectName, properties, true );
+    }
+
+    /**
+     * Executes the specified projects and asserts the given artifacts.
+     * 
+     * @param projectName the project to test
+     * @param expectedArtifacts the list of artifacts to be found in the EAR 
archive
+     * @param artifactsDirectory whether the artifact is an exploded 
artifactsDirectory or not
+     * @param testDeploymentDescriptors whether we should test deployment 
descriptors
+     * @return the base directory of the project
+     * @throws Exception
+     */
+    protected File doTestProject( final String projectName, final String[] 
expectedArtifacts,
+                                  final boolean[] artifactsDirectory, boolean 
testDeploymentDescriptors )
+        throws Exception
+    {
+        final File baseDir = executeMojo( projectName, new Properties() );
+        assertEarArchive( baseDir, projectName );
+        assertEarDirectory( baseDir, projectName );
+
+        assertArchiveContent( baseDir, projectName, expectedArtifacts, 
artifactsDirectory );
+
+        if ( testDeploymentDescriptors )
+        {
+            assertDeploymentDescriptors( baseDir, projectName );
+        }
+
+        return baseDir;
+
+    }
+
+    /**
+     * Executes the specified projects and asserts the given artifacts. Assert 
the deployment descriptors are valid
+     * 
+     * @param projectName the project to test
+     * @param expectedArtifacts the list of artifacts to be found in the EAR 
archive
+     * @param artifactsDirectory whether the artifact is an exploded 
artifactsDirectory or not
+     * @return the base directory of the project
+     * @throws Exception
+     */
+    protected File doTestProject( final String projectName, final String[] 
expectedArtifacts,
+                                  final boolean[] artifactsDirectory )
+        throws Exception
+    {
+        return doTestProject( projectName, expectedArtifacts, 
artifactsDirectory, true );
+
+    }
+
+    /**
+     * Executes the specified projects and asserts the given artifacts as 
artifacts (non directory)
+     * 
+     * @param projectName the project to test
+     * @param expectedArtifacts the list of artifacts to be found in the EAR 
archive
+     * @param testDeploymentDescriptors whether we should test deployment 
descriptors
+     * @return the base directory of the project
+     * @throws Exception
+     */
+    protected File doTestProject( final String projectName, final String[] 
expectedArtifacts,
+                                  boolean testDeploymentDescriptors )
+        throws Exception
+    {
+        return doTestProject( projectName, expectedArtifacts, new 
boolean[expectedArtifacts.length] );
+    }
+
+    /**
+     * Executes the specified projects and asserts the given artifacts as 
artifacts (non directory). Assert the
+     * deployment descriptors are valid
+     * 
+     * @param projectName the project to test
+     * @param expectedArtifacts the list of artifacts to be found in the EAR 
archive
+     * @return the base directory of the project
+     * @throws Exception
+     */
+    protected File doTestProject( final String projectName, final String[] 
expectedArtifacts )
+        throws Exception
+    {
+        return doTestProject( projectName, expectedArtifacts, true );
+    }
+
+    protected void assertEarArchive( final File baseDir, final String 
projectName )
+    {
+        assertTrue( "EAR archive does not exist", getEarArchive( baseDir, 
projectName ).exists() );
+    }
+
+    protected void assertEarDirectory( final File baseDir, final String 
projectName )
+    {
+        assertTrue( "EAR archive directory does not exist", getEarDirectory( 
baseDir, projectName ).exists() );
+    }
+
+    protected File getTargetDirectory( final File basedir )
+    {
+        return new File( basedir, "target" );
+    }
+
+    protected File getEarArchive( final File baseDir, final String projectName 
)
+    {
+        return new File( getTargetDirectory( baseDir ), buildFinalName( 
projectName ) + ".ear" );
+    }
+
+    protected File getEarDirectory( final File baseDir, final String 
projectName )
+    {
+        return new File( getTargetDirectory( baseDir ), buildFinalName( 
projectName ) );
+    }
+
+    protected String buildFinalName( final String projectName )
+    {
+        return FINAL_NAME_PREFIX + projectName + FINAL_NAME_SUFFIX;
+    }
+
+    protected void assertArchiveContent( final File baseDir, final String 
projectName, final String[] artifactNames,
+                                         final boolean[] artifactsDirectory )
+    {
+        // sanity check
+        assertEquals( "Wrong parameter, artifacts mismatch directory flags", 
artifactNames.length,
+                      artifactsDirectory.length );
+
+        File dir = getEarDirectory( baseDir, projectName );
+
+        // Let's build the expected directories sort list
+        final List<File> expectedDirectories = new ArrayList<File>();
+        for ( int i = 0; i < artifactsDirectory.length; i++ )
+        {
+            if ( artifactsDirectory[i] )
+            {
+                expectedDirectories.add( new File( dir, artifactNames[i] ) );
+            }
+        }
+
+        final List<File> actualFiles = buildArchiveContentFiles( dir, 
expectedDirectories );
+        assertEquals( "Artifacts mismatch " + actualFiles, 
artifactNames.length, actualFiles.size() );
+        for ( int i = 0; i < artifactNames.length; i++ )
+        {
+            String artifactName = artifactNames[i];
+            final boolean isDirectory = artifactsDirectory[i];
+            File expectedFile = new File( dir, artifactName );
+
+            assertEquals( "Artifact[" + artifactName + "] not in the right 
form (exploded/archive", isDirectory,
+                          expectedFile.isDirectory() );
+            assertTrue( "Artifact[" + artifactName + "] not found in ear 
archive", actualFiles.contains( expectedFile ) );
+
+        }
+    }
+
+    protected List<File> buildArchiveContentFiles( final File baseDir, final 
List<File> expectedDirectories )
+    {
+        final List<File> result = new ArrayList<File>();
+        addFiles( baseDir, result, expectedDirectories );
+
+        return result;
+    }
+
+    private void addFiles( final File directory, final List<File> files, final 
List<File> expectedDirectories )
+    {
+        File[] result = directory.listFiles( new FilenameFilter()
+        {
+            public boolean accept( File dir, String name )
+            {
+                return !name.equals( "META-INF" );
+            }
+
+        } );
+
+        /*
+         * Kinda complex. If we found a file, we always add it to the list of 
files. If a directory is within the
+         * expectedDirectories short list we add it but we don't add it's 
content. Otherwise, we don't add the directory
+         * *BUT* we browse it's content
+         */
+        for ( File file : result )
+        {
+            if ( file.isFile() )
+            {
+                files.add( file );
+            }
+            else if ( expectedDirectories.contains( file ) )
+            {
+                files.add( file );
+            }
+            else
+            {
+                addFiles( file, files, expectedDirectories );
+            }
+        }
+    }
+
+    protected File getBasedir()
+    {
+        if ( basedir != null )
+        {
+            return basedir;
+        }
+
+        final String basedirString = System.getProperty( "basedir" );
+        if ( basedirString == null )
+        {
+            basedir = new File( "" );
+        }
+        else
+        {
+            basedir = new File( basedirString );
+        }
+        return basedir;
+    }
+
+    protected File getTestDir( String projectName )
+        throws IOException
+    {
+        return ResourceExtractor.simpleExtractResources( getClass(), 
"/projects/" + projectName );
+    }
+
+    // Generated application.xml stuff
+
+    /**
+     * Asserts that the deployment descriptors have been generated 
successfully.
+     * <p/>
+     * This test assumes that deployment descriptors are located in the 
<tt>expected-META-INF</tt> directory of the
+     * project. Note that the <tt>MANIFEST.mf</tt> file is ignored and is not 
tested.
+     * 
+     * @param baseDir the directory of the tested project
+     * @param projectName the name of the project
+     */
+    protected void assertDeploymentDescriptors( final File baseDir, final 
String projectName )
+        throws IOException
+    {
+        final File earDirectory = getEarDirectory( baseDir, projectName );
+        final File[] actualDeploymentDescriptors = getDeploymentDescriptors( 
new File( earDirectory, "META-INF" ) );
+        final File[] expectedDeploymentDescriptors =
+            getDeploymentDescriptors( new File( baseDir, "expected-META-INF" ) 
);
+
+        if ( expectedDeploymentDescriptors == null )
+        {
+            assertNull( "No deployment descriptor was expected", 
actualDeploymentDescriptors );
+        }
+        else
+        {
+            assertNotNull( "Missing deployment descriptor", 
actualDeploymentDescriptors );
+
+            // Make sure we have the same number of files
+            assertEquals( "Number of Deployment descriptor(s) mismatch", 
expectedDeploymentDescriptors.length,
+                          actualDeploymentDescriptors.length );
+
+            // Sort the files so that we have the same behavior here
+            Arrays.sort( expectedDeploymentDescriptors );
+            Arrays.sort( actualDeploymentDescriptors );
+
+            for ( int i = 0; i < expectedDeploymentDescriptors.length; i++ )
+            {
+                File expectedDeploymentDescriptor = 
expectedDeploymentDescriptors[i];
+                File actualDeploymentDescriptor = 
actualDeploymentDescriptors[i];
+
+                assertEquals( "File name mismatch", 
expectedDeploymentDescriptor.getName(),
+                              actualDeploymentDescriptor.getName() );
+
+                try
+                {
+                    DocumentBuilderFactory dbf = 
DocumentBuilderFactory.newInstance();
+                    dbf.setValidating( true );
+                    DocumentBuilder docBuilder = dbf.newDocumentBuilder();
+                    docBuilder.setEntityResolver( new ResourceEntityResolver() 
);
+                    docBuilder.setErrorHandler( new DefaultHandler() );
+
+                    final Diff myDiff =
+                        new Diff( docBuilder.parse( 
expectedDeploymentDescriptor ),
+                                  docBuilder.parse( actualDeploymentDescriptor 
) );
+                    XMLAssert.assertXMLEqual( "Wrong deployment descriptor 
generated for["
+                        + expectedDeploymentDescriptor.getName() + "]", 
myDiff, true );
+                }
+                catch ( Exception e )
+                {
+                    e.printStackTrace();
+                    fail( "Could not assert deployment descriptor " + 
e.getMessage() );
+                }
+            }
+        }
+    }
+
+    private File[] getDeploymentDescriptors( final File ddDirectory )
+    {
+        return ddDirectory.listFiles( new FilenameFilter()
+        {
+            public boolean accept( File dir, String name )
+            {
+                return !name.equalsIgnoreCase( "manifest.mf" );
+            }
+        } );
+    }
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/it/EarMojoIT.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/it/EarMojoIT.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/it/EarMojoIT.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/it/EarMojoIT.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,887 @@
+package org.apache.maven.plugins.ear.it;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.Properties;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.apache.maven.it.util.IOUtil;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.ReaderFactory;
+
+/**
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: EarMojoIT.java 1648055 2014-12-27 14:59:45Z khmarbaise $
+ * @noinspection JavaDoc
+ */
+public class EarMojoIT
+    extends AbstractEarPluginIT
+{
+
+    /**
+     * Builds an EAR with a single EJB and no configuration.
+     */
+    public void testProject001()
+        throws Exception
+    {
+        doTestProject( "project-001", new String[] { "ejb-sample-one-1.0.jar" 
} );
+    }
+
+    /**
+     * Builds an EAR with a customized artifact location and a customized 
artifact name.
+     */
+    public void testProject002()
+        throws Exception
+    {
+        doTestProject( "project-002", new String[] { 
"APP-INF/lib/ejb-sample-one-1.0.jar", "ejb-sample-two.jar" } );
+    }
+
+    /**
+     * Builds an EAR with a default bundle directory for <tt>java</tt> modules.
+     */
+    public void testProject003()
+        throws Exception
+    {
+        doTestProject( "project-003", new String[] { "ejb-sample-one-1.0.jar", 
"APP-INF/lib/jar-sample-one-1.0.jar",
+            "APP-INF/lib/jar-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with a default bundle directory for _java_ modules and a 
custom location overriding the default.
+     */
+    public void testProject004()
+        throws Exception
+    {
+        doTestProject( "project-004", new String[] { "ejb-sample-one-1.0.jar", 
"jar-sample-one-1.0.jar",
+            "APP-INF/lib/jar-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with a custom URI.
+     */
+    public void testProject005()
+        throws Exception
+    {
+        doTestProject( "project-005", new String[] { "ejb-sample-one-1.0.jar", 
"libs/another-name.jar" } );
+    }
+
+    /**
+     * Builds an EAR with an excluded module.
+     */
+    public void testProject006()
+        throws Exception
+    {
+        doTestProject( "project-006", new String[] { "ejb-sample-one-1.0.jar", 
"jar-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with a classified artifact and no extra configuration.
+     */
+    public void testProject007()
+        throws Exception
+    {
+        doTestProject( "project-007", new String[] { 
"ejb-sample-one-1.0-classified.jar" } );
+    }
+
+    /**
+     * Builds an EAR with deployment descriptor configuration for J2EE 1.3.
+     */
+    public void testProject008()
+        throws Exception
+    {
+        doTestProject( "project-008", new String[] { "ejb-sample-one-1.0.jar" 
} );
+    }
+
+    /**
+     * Builds an EAR with deployment descriptor configuration for J2EE 1.4.
+     */
+    public void testProject009()
+        throws Exception
+    {
+        doTestProject( "project-009", new String[] { "ejb-sample-one-1.0.jar" 
} );
+    }
+
+    /**
+     * Builds an EAR with deployment descriptor configuration for Java EE 5.
+     */
+    public void testProject010()
+        throws Exception
+    {
+        doTestProject( "project-010", new String[] { "ejb-sample-one-1.0.jar" 
} );
+    }
+
+    /**
+     * Builds an EAR and make sure that deployment descriptor default settings 
are applied.
+     */
+    public void testProject011()
+        throws Exception
+    {
+        doTestProject( "project-011", new String[] { "ejb-sample-one-1.0.jar" 
} );
+    }
+
+    /**
+     * Builds an EAR and make sure that EAR resources are bundled within the 
EAR.
+     */
+    public void testProject012()
+        throws Exception
+    {
+        doTestProject( "project-012", new String[] { "README.txt", 
"LICENSE.txt", "ejb-sample-one-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR and make sure that EAR resources in a customized 
resources directory are bundled within the EAR.
+     */
+    public void testProject013()
+        throws Exception
+    {
+        doTestProject( "project-013", new String[] { "README.txt", 
"LICENSE.txt", "ejb-sample-one-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR and make sure that EAR resources are bundled within the 
EAR using includes and excludes.
+     */
+    public void testProject014()
+        throws Exception
+    {
+        doTestProject( "project-014", new String[] { "LICENSE.txt", 
"ejb-sample-one-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR and make sure that default manifest is taken into account.
+     */
+    public void testProject015()
+        throws Exception
+    {
+        final File baseDir = doTestProject( "project-015", new String[] { 
"ejb-sample-one-1.0.jar" } );
+        final File expectedManifest = new File( baseDir, 
"src/main/application/META-INF/MANIFEST.MF" );
+        final File actualManifest = new File( getEarDirectory( baseDir, 
"project-015" ), "META-INF/MANIFEST.MF" );
+        assertTrue( "Manifest was not copied", actualManifest.exists() );
+        assertTrue( FileUtils.contentEquals( expectedManifest, actualManifest 
) );
+    }
+
+    /**
+     * Builds an EAR and make sure that custom manifest is taken into account.
+     */
+    public void testProject016()
+        throws Exception
+    {
+        final File baseDir = doTestProject( "project-016", new String[] { 
"ejb-sample-one-1.0.jar" } );
+
+        final File targetFolder = new File( baseDir, "target" );
+        final File createdEarFile = new File( targetFolder, 
"maven-ear-plugin-test-project-016-99.0.ear" );
+
+        final File sourceManifestFile = new File( baseDir, 
"src/main/ear/MANIFEST.MF" );
+
+        JarFile jarFile = new JarFile( createdEarFile );
+        Manifest manifestFromCreatedEARFile = jarFile.getManifest();
+        jarFile.close();
+
+        Manifest sourceManifest = new Manifest( new FileInputStream( 
sourceManifestFile ) );
+
+        assertTrue( "There are differences in the manifest.", 
sourceManifest.equals( manifestFromCreatedEARFile ) );
+    }
+
+    /**
+     * Builds an EAR and make sure that custom application.xml is taken into 
account.
+     */
+    public void testProject017()
+        throws Exception
+    {
+        doTestProject( "project-017", new String[] { "ejb-sample-one-1.0.jar" 
} );
+    }
+
+    /**
+     * Builds an EAR with a custom final name.
+     */
+    public void testProject018()
+        throws Exception
+    {
+        final File baseDir = executeMojo( "project-018", new Properties() );
+        final File expectedFile = new File( baseDir, 
"target/my-custom-file.ear" );
+        assertTrue( "EAR archive not found", expectedFile.exists() );
+    }
+
+    /**
+     * Builds an EAR with unpacked archives using the unpackTypes.
+     */
+    public void testProject019()
+        throws Exception
+    {
+        doTestProject( "project-019", new String[] { "ejb-sample-one-1.0.jar", 
"sar-sample-one-1.0.sar",
+            "jar-sample-one-1.0.jar" }, new boolean[] { false, true, true } );
+    }
+
+    /**
+     * Builds an EAR with unpacked archives using the unpack module attribute.
+     */
+    public void testProject020()
+        throws Exception
+    {
+        doTestProject( "project-020", new String[] { "ejb-sample-one-1.0.jar", 
"sar-sample-one-1.0.sar",
+            "jar-sample-one-1.0.jar" }, new boolean[] { true, false, false } );
+    }
+
+    /**
+     * Builds an EAR with unpacked archives using both unpackTypes and the 
unpack module attribute.
+     */
+    public void testProject021()
+        throws Exception
+    {
+        doTestProject( "project-021", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar",
+            "sar-sample-one-1.0.sar", "jar-sample-one-1.0.jar", 
"jar-sample-two-1.0.jar" }, new boolean[] { false,
+            true, false, false, true } );
+    }
+
+    /**
+     * Builds an EAR with a classifier.
+     */
+    public void testProject022()
+        throws Exception
+    {
+        final File baseDir = executeMojo( "project-022", new Properties() );
+        final File expectedFile = new File( baseDir, 
"target/maven-ear-plugin-test-project-022-99.0-myclassifier.ear" );
+        assertTrue( "EAR archive not found", expectedFile.exists() );
+    }
+
+    /**
+     * Builds an EAR and make sure that a single classified dependency is 
detected without specifying the classifier.
+     */
+    public void testProject023()
+        throws Exception
+    {
+        doTestProject( "project-023", new String[] { 
"ejb-sample-one-1.0-classified.jar", "ejb-sample-two-1.0.jar" },
+                       new boolean[] { true, false } );
+    }
+
+    /**
+     * Builds an EAR and make sure that a single classified dependency is 
detected when specifying the classifier.
+     */
+    public void testProject024()
+        throws Exception
+    {
+        doTestProject( "project-024", new String[] { 
"ejb-sample-one-1.0-classified.jar", "ejb-sample-two-1.0.jar" },
+                       new boolean[] { true, false } );
+    }
+
+    /**
+     * Builds an EAR and make sure that a classified dependency with mutiple 
candidates is detected when specifying the
+     * classifier.
+     */
+    public void testProject025()
+        throws Exception
+    {
+        doTestProject( "project-025", new String[] { 
"ejb-sample-one-1.0-classified.jar", "ejb-sample-one-1.0.jar" },
+                       new boolean[] { true, false } );
+    }
+
+    /**
+     * Builds an EAR and make sure that the build fails if a unclassifed 
module configuration with mutiple candidates is
+     * specified.
+     */
+    public void testProject026()
+        throws Exception
+    {
+        final File baseDir = executeMojo( "project-026", new Properties(), 
false );
+        // Stupido, checks that the ear archive is not there
+        assertFalse( "Execution should have failed", getEarArchive( baseDir, 
"project-026" ).exists() );
+    }
+
+    /**
+     * Builds an EAR and make sure that provided dependencies are not included 
in the EAR.
+     */
+    public void testProject027()
+        throws Exception
+    {
+        doTestProject( "project-027", new String[] { "ejb-sample-one-1.0.jar" 
} );
+    }
+
+    /**
+     * Builds an EAR and make sure that test dependencies are not included in 
the EAR.
+     */
+    public void testProject028()
+        throws Exception
+    {
+        doTestProject( "project-028", new String[] { "ejb-sample-one-1.0.jar" 
} );
+    }
+
+    /**
+     * Builds an EAR and make sure that system dependencies are not included 
in the EAR.
+     */
+    public void testProject029()
+        throws Exception
+    {
+        doTestProject( "project-029", new String[] { "ejb-sample-one-1.0.jar" 
} );
+    }
+
+    /**
+     * Builds an EAR and make sure that ejb-client dependencies are detected 
and not added by default in the generated
+     * application.xml.
+     */
+    public void testProject030()
+        throws Exception
+    {
+        doTestProject( "project-030", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0-client.jar" } );
+    }
+
+    /**
+     * Builds an EAR with a Jboss 4 configuration specifying the security 
domain and the unauthenticated-principal to
+     * use.
+     */
+    public void testProject031()
+        throws Exception
+    {
+        doTestProject( "project-031", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with a Jboss 3.2 configuration specifying the jmx-name to 
use.
+     */
+    public void testProject032()
+        throws Exception
+    {
+        doTestProject( "project-032", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with a Jboss 4 configuration and Jboss specific modules.
+     */
+    public void testProject033()
+        throws Exception
+    {
+        doTestProject( "project-033", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar",
+            "sar-sample-one-1.0.sar", "har-sample-one-1.0.har" } );
+    }
+
+    /**
+     * Builds an EAR with custom security settings.
+     */
+    public void testProject034()
+        throws Exception
+    {
+        doTestProject( "project-034", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with a full filename mapping and make sure that custom 
locations are not overridden.
+     */
+    public void testProject035()
+        throws Exception
+    {
+        doTestProject( "project-035", new String[] { 
"foo/eartest-ejb-sample-one-1.0.jar",
+            "eartest-ejb-sample-two-1.0.jar", 
"libs/eartest-jar-sample-one-1.0.jar",
+            "libs/eartest-jar-sample-two-1.0.jar", "sar-sample-one.sar" } );
+    }
+
+    /**
+     * Builds an EAR with a full filename mapping and make sure that groupIds 
with dots are replaced by dashes in
+     * filenames.
+     */
+    public void testProject036()
+        throws Exception
+    {
+        doTestProject( "project-036", new String[] { 
"foo/eartest-ejb-sample-one-1.0.jar",
+            "eartest-ejb-sample-two-1.0.jar", 
"com-foo-bar-ejb-sample-one-1.0.jar",
+            "com-foo-bar-ejb-sample-two-1.0.jar", 
"libs/eartest-jar-sample-one-1.0.jar",
+            "libs/eartest-jar-sample-two-1.0.jar", "sar-sample-one.sar" } );
+    }
+
+    /**
+     * Builds an EAR and make sure that ejb-client dependencies are detected 
and added in the generated application.xml
+     * if includeInApplicationXml is set.
+     */
+    public void testProject037()
+        throws Exception
+    {
+        doTestProject( "project-037", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0-client.jar" } );
+    }
+
+    /**
+     * Builds an EAR and make sure that a non-classified dependency with 
mutiple candidates is detected when specifying
+     * the mainArtifactId as classifier.
+     */
+    public void testProject038()
+        throws Exception
+    {
+        doTestProject( "project-038", new String[] { 
"ejb-sample-one-1.0-classified.jar", "ejb-sample-one-1.0.jar" },
+                       new boolean[] { false, true } );
+    }
+
+    /**
+     * Builds an EAR with a Jboss 4 configuration specifying specifying the 
loader repository to use.
+     */
+    public void testProject039()
+        throws Exception
+    {
+        doTestProject( "project-039", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with deployment descriptor configuration for Java EE 5 
and an alternative deployment descriptor.
+     */
+    public void testProject040()
+        throws Exception
+    {
+        doTestProject( "project-040", new String[] { "ejb-sample-one-1.0.jar" 
} );
+    }
+
+    /**
+     * Builds an EAR with a Jboss 4.2 configuration specifying the module 
order to use.
+     */
+    public void testProject041()
+        throws Exception
+    {
+        doTestProject( "project-041", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with a Jboss 4.2 configuration specifying a datasource to 
add.
+     */
+    public void testProject042()
+        throws Exception
+    {
+        doTestProject( "project-042", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with a custom descriptor location 
(generatedDescriptorLocation setting).
+     */
+    public void testProject043()
+        throws Exception
+    {
+        final File baseDir = doTestProject( "project-043", new String[] { 
"ejb-sample-one-1.0.jar" } );
+        final File expectedApplicationXml = new File( baseDir, 
"target/custom-descriptor-dir/application.xml" );
+        assertTrue( "Application.xml file not found", 
expectedApplicationXml.exists() );
+        assertFalse( "Application.xml file should not be empty", 
expectedApplicationXml.length() == 0 );
+    }
+
+    /**
+     * Builds an EAR with a custom library-directory.
+     */
+    public void testProject044()
+        throws Exception
+    {
+        doTestProject( "project-044", new String[] { "ejb-sample-one-1.0.jar", 
"myLibs/jar-sample-one-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR and filter the content of the sources directory.
+     */
+    public void testProject045()
+        throws Exception
+    {
+        final File baseDir = doTestProject( "project-045", new String[] { 
"README.txt", "ejb-sample-one-1.0.jar" } );
+        final File actualReadme = new File( getEarDirectory( baseDir, 
"project-045" ), "README.txt" );
+        final String content = IOUtil.toString( ReaderFactory.newReader( 
actualReadme, "UTF-8" ) );
+        assertTrue( "application name and version was not filtered properly", 
content.contains( "my-app 99.0" ) );
+        assertTrue( "Escaping did not work properly", content.contains( "will 
not be filtered ${application.name}." ) );
+    }
+
+    /**
+     * Builds an EAR and filter the content of the sources directory using a 
custom filter file.
+     */
+    public void testProject046()
+        throws Exception
+    {
+        final File baseDir = doTestProject( "project-046", new String[] { 
"README.txt", "ejb-sample-one-1.0.jar" } );
+        final File actualReadme = new File( getEarDirectory( baseDir, 
"project-046" ), "README.txt" );
+        final String content = IOUtil.toString( ReaderFactory.newReader( 
actualReadme, "UTF-8" ) );
+        assertTrue( "application name and version was not filtered properly", 
content.contains( "my-app 99.0" ) );
+        assertTrue( "application build was not filtered properly", 
content.contains( "(Build 2)" ) );
+        assertTrue( "Unknown property should not have been filtered",
+                    content.contains( "will not be filtered 
${application.unknown}." ) );
+    }
+
+    /**
+     * Builds an EAR and filter the content with a list of extensions.
+     */
+    public void testProject047()
+        throws Exception
+    {
+        final File baseDir = doTestProject( "project-047", new String[] { 
"README.txt", "ejb-sample-one-1.0.jar" } );
+        final File actualReadme = new File( getEarDirectory( baseDir, 
"project-047" ), "README.txt" );
+        final String content = IOUtil.toString( ReaderFactory.newReader( 
actualReadme, "UTF-8" ) );
+        assertTrue( "application name and version should not have been 
filtered", !content.contains( "my-app 99.0" ) );
+        assertTrue( "original properties not found", content.contains( 
"${application.name} ${project.version}" ) );
+    }
+
+    /**
+     * Builds an EAR with a Jboss 5 configuration containing library directory.
+     */
+    public void testProject048()
+        throws Exception
+    {
+        doTestProject( "project-048", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with a Jboss 4.2 configuration containing a library 
directory.
+     */
+    public void testProject049()
+        throws Exception
+    {
+        doTestProject( "project-049", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with a Jboss 5 configuration containing a loader 
repository configuration definition.
+     */
+    public void testProject050()
+        throws Exception
+    {
+        doTestProject( "project-050", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with a Jboss 5 configuration containing a loader 
repository class definition.
+     */
+    public void testProject051()
+        throws Exception
+    {
+        doTestProject( "project-051", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with a Jboss 5 configuration containing a configuration 
parser class definition.
+     */
+    public void testProject052()
+        throws Exception
+    {
+        doTestProject( "project-052", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with a Jboss 5 configuration containing only the loader 
repo configuration
+     */
+    public void testProject053()
+        throws Exception
+    {
+        doTestProject( "project-053", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with deployment descriptor configuration for Java EE 5 
and no application.xml
+     */
+    public void testProject054()
+        throws Exception
+    {
+        doTestProject( "project-054", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with jar dependencies added in application.xml.
+     */
+    public void testProject055()
+        throws Exception
+    {
+        doTestProject( "project-055", new String[] { "jar-sample-one-1.0.jar", 
"jar-sample-two-1.0.jar",
+            "jar-sample-three-with-deps-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with deployment descriptor configuration for J2EE 1.4 and 
an alternative deployment descriptor.
+     */
+    public void testProject056()
+        throws Exception
+    {
+        doTestProject( "project-056", new String[] { "ejb-sample-one-1.0.jar" 
} );
+    }
+
+    /**
+     * Builds an EAR with a complete JBoss 4.2 configuration and validate it 
matches the DTD (MEAR-104).
+     */
+    public void testProject057()
+        throws Exception
+    {
+        doTestProject( "project-057", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with deployment descriptor configuration for Java EE 6.
+     */
+    public void testProject058()
+        throws Exception
+    {
+        doTestProject( "project-058", new String[] { "ejb-sample-one-1.0.jar" 
} );
+    }
+
+    /**
+     * Builds an EAR with no display name entry at all.
+     */
+    public void testProject059()
+        throws Exception
+    {
+        doTestProject( "project-059", new String[] { "ejb-sample-one-1.0.jar" 
} );
+    }
+
+    /**
+     * Builds an EAR with ejb-client packaged for J2EE 1.3 (MEAR-85)
+     * 
+     * @throws Exception
+     */
+    public void testProject060()
+        throws Exception
+    {
+        doTestProject( "project-060", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0-client.jar" } );
+    }
+
+    /**
+     * Builds an EAR with ejb-client packaged for J2EE 1.4 (MEAR-85)
+     * 
+     * @throws Exception
+     */
+    public void testProject061()
+        throws Exception
+    {
+        doTestProject( "project-061", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0-client.jar" } );
+    }
+
+    /**
+     * Builds an EAR with ejb-client packaged for JavaEE 5 (MEAR-85)
+     * 
+     * @throws Exception
+     */
+    public void testProject062()
+        throws Exception
+    {
+        doTestProject( "project-062", new String[] { "ejb-sample-one-1.0.jar", 
"lib/ejb-sample-two-1.0-client.jar" } );
+    }
+
+    /**
+     * Builds an EAR with ejb-client packaged for JavaEE 6 (MEAR-85)
+     * 
+     * @throws Exception
+     */
+    public void testProject063()
+        throws Exception
+    {
+        doTestProject( "project-063", new String[] { 
"lib/ejb-sample-two-1.0-client.jar" } );
+    }
+
+    /**
+     * Builds an EAR with ejb-client packaged for JavaEE 5 and still put it in 
the root (MEAR-85)
+     * 
+     * @throws Exception
+     */
+    public void testProject064()
+        throws Exception
+    {
+        doTestProject( "project-064", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0-client.jar" } );
+    }
+
+    /**
+     * Builds an EAR with a custom moduleId.
+     */
+    public void testProject065()
+        throws Exception
+    {
+        doTestProject( "project-065", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with generateModuleId enabled.
+     */
+    public void testProject066()
+        throws Exception
+    {
+        doTestProject( "project-066", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with generateModuleId enabled and a custom module.
+     */
+    public void testProject067()
+        throws Exception
+    {
+        doTestProject( "project-067", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with the no-version file name mapping.
+     */
+    public void testProject068()
+        throws Exception
+    {
+        doTestProject( "project-068", new String[] { "ejb-sample-one.jar", 
"ejb-sample-two.jar" } );
+    }
+
+    /**
+     * Builds an EAR with a custom library-directory and JavaEE 6.
+     */
+    public void testProject069()
+        throws Exception
+    {
+        doTestProject( "project-069", new String[] { "ejb-sample-one-1.0.jar", 
"myLibs/jar-sample-one-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with application-name and initialize-in-order tags.
+     */
+    public void testProject070()
+        throws Exception
+    {
+        doTestProject( "project-070", new String[] { "ejb-sample-one-1.0.jar", 
"jar-sample-one-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with application-name and initialize-in-order tags for 
unsupported version.
+     */
+    public void testProject071()
+        throws Exception
+    {
+        doTestProject( "project-071", new String[] { "ejb-sample-one-1.0.jar", 
"jar-sample-one-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with an application client module (app-client).
+     */
+    public void testProject072()
+        throws Exception
+    {
+        doTestProject( "project-072", new String[] { "ejb-sample-one-1.0.jar", 
"app-client-sample-one-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with an application client module (app-client) and a 
default bundle directory for _java_ modules.
+     */
+    public void testProject073()
+        throws Exception
+    {
+        doTestProject( "project-073", new String[] { "ejb-sample-one-1.0.jar", 
"app-client-sample-one-1.0.jar",
+            "APP-INF/lib/jar-sample-one-1.0.jar", 
"APP-INF/lib/jar-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with custom env entries settings and J2EE 1.3. Not 
supported by the specification so this should be
+     * ignored.
+     */
+    public void testProject074()
+        throws Exception
+    {
+        doTestProject( "project-074", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with custom env entries settings and J2EE 1.4. Not 
supported by the specification so this should be
+     * ignored.
+     */
+    public void testProject075()
+        throws Exception
+    {
+        doTestProject( "project-075", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with custom env entries settings and JavaEE 5. Not 
supported by the specification so this should be
+     * ignored.
+     */
+    public void testProject076()
+        throws Exception
+    {
+        doTestProject( "project-076", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with custom env entries settings and JavaEE 6.
+     */
+    public void testProject077()
+        throws Exception
+    {
+        doTestProject( "project-077", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with the no version for ejb file name mapping.
+     */
+    public void testProject078()
+        throws Exception
+    {
+        doTestProject( "project-078", new String[] { "ejb-sample-one.jar", 
"war-sample-one-1.0.war",
+            "jar-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with the 'default' library directory mode. Uses the value 
of the defaultLibBundleDir.
+     */
+    public void testProject079()
+        throws Exception
+    {
+        doTestProject( "project-079", new String[] { "ejb-sample-one-1.0.jar", 
"myLibs/jar-sample-one-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with the 'empty' library directory mode. Generate an 
empty library-directory element.
+     */
+    public void testProject080()
+        throws Exception
+    {
+        doTestProject( "project-080", new String[] { "ejb-sample-one-1.0.jar", 
"myLibs/jar-sample-one-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with the 'none' library directory mode. Does not generate 
an library-directory element.
+     */
+    public void testProject081()
+        throws Exception
+    {
+        doTestProject( "project-081", new String[] { "ejb-sample-one-1.0.jar", 
"myLibs/jar-sample-one-1.0.jar" } );
+    }
+
+    /**
+     * Builds an EAR with deployment descriptor configuration for JavaEE 7.
+     */
+    public void testProject082()
+        throws Exception
+    {
+        doTestProject( "project-082", new String[] { "ejb-sample-one-1.0.jar" 
} );
+    }
+
+    /**
+     * Builds an EAR with a library directory and custom env entries. The 
library-directory element must come first
+     * (MEAR-158).
+     */
+    public void testProject083()
+        throws Exception
+    {
+        doTestProject( "project-083", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+    /**
+     * Support of an application id (MEAR-174).
+     */
+    public void testProject084()
+        throws Exception
+    {
+        doTestProject( "project-084", new String[] { "ejb-sample-one-1.0.jar" 
} );
+    }
+    
+    /**
+     * Builds an EAR with custom ejbRef entries settings and JavaEE 6.
+     */
+    public void testProject085()
+        throws Exception
+    {
+        doTestProject( "project-085", new String[] { "ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar" } );
+    }
+
+
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/AbstractFileNameMappingTestBase.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/AbstractFileNameMappingTestBase.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/AbstractFileNameMappingTestBase.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/AbstractFileNameMappingTestBase.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,53 @@
+package org.apache.maven.plugins.ear.output;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugins.ear.AbstractEarTestBase;
+import org.apache.maven.plugins.ear.stub.ArtifactTestStub;
+
+/**
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ */
+public abstract class AbstractFileNameMappingTestBase
+    extends AbstractEarTestBase
+{
+
+    protected Artifact createArtifactWithGroupId( String groupId, String 
artifactId, String version, String type,
+                                                  String classifier )
+    {
+        return new ArtifactTestStub( groupId, artifactId, type, classifier, 
version );
+    }
+
+    protected Artifact createArtifactWithGroupId( String groupId, String 
artifactId, String version, String type )
+    {
+        return createArtifactWithGroupId( groupId, artifactId, version, type, 
null );
+    }
+
+    protected Artifact createArtifact( String artifactId, String version, 
String type, String classifier )
+    {
+        return new ArtifactTestStub( DEFAULT_GROUPID, artifactId, type, 
classifier, version );
+    }
+
+    protected Artifact createArtifact( String artifactId, String version, 
String type )
+    {
+        return createArtifact( artifactId, version, type, null );
+    }
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/FileNameMappingFactoryTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/FileNameMappingFactoryTest.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/FileNameMappingFactoryTest.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/FileNameMappingFactoryTest.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,105 @@
+package org.apache.maven.plugins.ear.output;
+
+import org.apache.maven.plugins.ear.output.FileNameMapping;
+import org.apache.maven.plugins.ear.output.FileNameMappingFactory;
+import org.apache.maven.plugins.ear.output.FullFileNameMapping;
+import org.apache.maven.plugins.ear.output.NoVersionFileNameMapping;
+import org.apache.maven.plugins.ear.output.NoVersionForEjbFileNameMapping;
+import org.apache.maven.plugins.ear.output.StandardFileNameMapping;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: FileNameMappingFactoryTest.java 1368659 2012-08-02 19:28:23Z 
snicoll $
+ */
+public class FileNameMappingFactoryTest
+    extends TestCase
+{
+
+    public void testDefaultFileNameMapping()
+    {
+        final FileNameMapping actual = 
FileNameMappingFactory.getDefaultFileNameMapping();
+        assertNotNull( actual );
+        assertEquals( StandardFileNameMapping.class, actual.getClass() );
+    }
+
+    public void testGetFileNameMappingByName()
+    {
+        final FileNameMapping actual =
+            FileNameMappingFactory.getFileNameMapping( 
FileNameMappingFactory.STANDARD_FILE_NAME_MAPPING );
+        assertNotNull( actual );
+        assertEquals( StandardFileNameMapping.class, actual.getClass() );
+    }
+
+    public void testGetFileNameMappingByName2()
+    {
+        final FileNameMapping actual =
+            FileNameMappingFactory.getFileNameMapping( 
FileNameMappingFactory.FULL_FILE_NAME_MAPPING );
+        assertNotNull( actual );
+        assertEquals( FullFileNameMapping.class, actual.getClass() );
+    }
+
+    public void testGetFileNameMappingByName3()
+    {
+        final FileNameMapping actual =
+            FileNameMappingFactory.getFileNameMapping( 
FileNameMappingFactory.NO_VERSION_FILE_NAME_MAPPING );
+        assertNotNull( actual );
+        assertEquals( NoVersionFileNameMapping.class, actual.getClass() );
+    }
+
+    public void testGetFileNameMappingByName4()
+    {
+        final FileNameMapping actual =
+            FileNameMappingFactory.getFileNameMapping( 
FileNameMappingFactory.NO_VERSION_FOR_EJB_FILE_NAME_MAPPING );
+        assertNotNull( actual );
+        assertEquals( NoVersionForEjbFileNameMapping.class, actual.getClass() 
);
+    }
+
+    public void testGetFileNameMappingByClass()
+    {
+        final FileNameMapping actual =
+            FileNameMappingFactory.getFileNameMapping( 
StandardFileNameMapping.class.getName() );
+        assertNotNull( actual );
+        assertEquals( StandardFileNameMapping.class, actual.getClass() );
+    }
+
+    public void testGetFileNameMappingByClass2()
+    {
+        final FileNameMapping actual = 
FileNameMappingFactory.getFileNameMapping( FullFileNameMapping.class.getName() 
);
+        assertNotNull( actual );
+        assertEquals( FullFileNameMapping.class, actual.getClass() );
+    }
+
+    public void testGetFileNameMappingByUnknownClass()
+    {
+        try
+        {
+            FileNameMappingFactory.getFileNameMapping( "com.foo.bar" );
+            fail( "Should have failed" );
+        }
+        catch ( IllegalStateException e )
+        {
+            // OK
+        }
+    }
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/FullFileNameMappingTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/FullFileNameMappingTest.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/FullFileNameMappingTest.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/FullFileNameMappingTest.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,50 @@
+package org.apache.maven.plugins.ear.output;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.maven.plugins.ear.output.FullFileNameMapping;
+import org.junit.Test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ */
+public class FullFileNameMappingTest
+    extends AbstractFileNameMappingTestBase
+{
+
+    private final FullFileNameMapping instance = new FullFileNameMapping();
+
+    @Test
+    public void testSimpleArtifact()
+    {
+        assertEquals( "org-apache-foo-1.0-SNAPSHOT.jar",
+                      instance.mapFileName( createArtifactWithGroupId( 
"org.apache", "foo", "1.0-SNAPSHOT", "jar" ) ) );
+    }
+
+    @Test
+    public void testArtifactWithClassifier()
+    {
+        assertEquals( "org-apache-foo-1.0-SNAPSHOT-sources.jar",
+                      instance.mapFileName( createArtifactWithGroupId( 
"org.apache", "foo", "1.0-SNAPSHOT", "jar",
+                                                                       
"sources" ) ) );
+    }
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/NoVersionFileNameMappingTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/NoVersionFileNameMappingTest.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/NoVersionFileNameMappingTest.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/NoVersionFileNameMappingTest.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,48 @@
+package org.apache.maven.plugins.ear.output;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.maven.plugins.ear.output.NoVersionFileNameMapping;
+import org.junit.Test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Stephane Nicoll
+ */
+public class NoVersionFileNameMappingTest
+    extends AbstractFileNameMappingTestBase
+{
+    private final NoVersionFileNameMapping instance = new 
NoVersionFileNameMapping();
+
+    @Test
+    public void testSimpleArtifact()
+    {
+        assertEquals( "foo.jar", instance.mapFileName( createArtifact( "foo", 
"1.0-SNAPSHOT", "jar" ) ) );
+    }
+
+    @Test
+    public void testArtifactWithClassifier()
+    {
+        assertEquals( "foo-sources.jar",
+                      instance.mapFileName( createArtifact( "foo", 
"1.0-SNAPSHOT", "jar", "sources" ) ) );
+    }
+
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/NoVersionForEjbFileNameMappingTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/NoVersionForEjbFileNameMappingTest.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/NoVersionForEjbFileNameMappingTest.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/NoVersionForEjbFileNameMappingTest.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,46 @@
+package org.apache.maven.plugins.ear.output;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.maven.plugins.ear.output.NoVersionForEjbFileNameMapping;
+import org.junit.Test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Philippe Marschall
+ */
+public class NoVersionForEjbFileNameMappingTest
+    extends AbstractFileNameMappingTestBase
+{
+    private final NoVersionForEjbFileNameMapping instance = new 
NoVersionForEjbFileNameMapping();
+
+    @Test
+    public void testJarArtifact()
+    {
+        assertEquals( "foo-1.0-SNAPSHOT.jar", instance.mapFileName( 
createArtifact( "foo", "1.0-SNAPSHOT", "jar" ) ) );
+    }
+
+    @Test
+    public void testEjbArtifact()
+    {
+        assertEquals( "foo.jar", instance.mapFileName( createArtifact( "foo", 
"1.0-SNAPSHOT", "ejb" ) ) );
+    }
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/StandardFileNameMappingTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/StandardFileNameMappingTest.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/StandardFileNameMappingTest.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/StandardFileNameMappingTest.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,49 @@
+package org.apache.maven.plugins.ear.output;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.maven.plugins.ear.output.StandardFileNameMapping;
+import org.junit.Test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ */
+public class StandardFileNameMappingTest
+    extends AbstractFileNameMappingTestBase
+{
+
+    private final StandardFileNameMapping instance = new 
StandardFileNameMapping();
+
+    @Test
+    public void testSimpleArtifact()
+    {
+        assertEquals( "foo-1.0-SNAPSHOT.jar", instance.mapFileName( 
createArtifact( "foo", "1.0-SNAPSHOT", "jar" ) ) );
+    }
+
+    @Test
+    public void testArtifactWithClassifier()
+    {
+        assertEquals( "foo-1.0-SNAPSHOT-sources.jar",
+                      instance.mapFileName( createArtifact( "foo", 
"1.0-SNAPSHOT", "jar", "sources" ) ) );
+    }
+
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/TestAbstractFileNameMapping.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/TestAbstractFileNameMapping.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/TestAbstractFileNameMapping.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/TestAbstractFileNameMapping.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,60 @@
+package org.apache.maven.plugins.ear.output;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.plugins.ear.output.AbstractFileNameMapping;
+import org.junit.Test;
+
+public class TestAbstractFileNameMapping
+{
+    private AbstractFileNameMapping abstractFileNameMapping = new 
AbstractFileNameMapping()
+    {
+        public String mapFileName( Artifact a )
+        {
+            return null;
+        }
+    };
+
+    @Test
+    public void test()
+    {
+        ArtifactHandler handler = mock( ArtifactHandler.class );
+        when( handler.getExtension() ).thenReturn( "jar" );
+
+        Artifact artifact = mock( Artifact.class );
+        when( artifact.getArtifactHandler() ).thenReturn( handler );
+        when( artifact.getArtifactId() ).thenReturn( "mear149" );
+        when( artifact.getVersion() ).thenReturn( "1.0-SNAPSHOT" );
+        when( artifact.getBaseVersion() ).thenReturn( "1.0-20130423.042904" );
+
+        // default behavior: use -SNAPSHOT
+        assertEquals( "mear149-1.0-SNAPSHOT.jar", 
abstractFileNameMapping.generateFileName( artifact, true ) );
+        abstractFileNameMapping.setUseBaseVersion( true );
+        assertEquals( "mear149-1.0-20130423.042904.jar", 
abstractFileNameMapping.generateFileName( artifact, true ) );
+        abstractFileNameMapping.setUseBaseVersion( false );
+        assertEquals( "mear149-1.0-SNAPSHOT.jar", 
abstractFileNameMapping.generateFileName( artifact, true ) );
+    }
+
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/stub/ArtifactHandlerTestStub.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/stub/ArtifactHandlerTestStub.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/stub/ArtifactHandlerTestStub.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/stub/ArtifactHandlerTestStub.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,72 @@
+package org.apache.maven.plugins.ear.stub;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+
+/**
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ */
+public class ArtifactHandlerTestStub
+    implements ArtifactHandler
+{
+
+    private final String extension;
+
+    public ArtifactHandlerTestStub( String extension )
+    {
+        this.extension = extension;
+    }
+
+    public String getExtension()
+    {
+        return extension;
+    }
+
+    public String getDirectory()
+    {
+        throw new UnsupportedOperationException( "not implemented ; fake 
artifact stub" );
+    }
+
+    public String getClassifier()
+    {
+        throw new UnsupportedOperationException( "not implemented ; fake 
artifact stub" );
+    }
+
+    public String getPackaging()
+    {
+        throw new UnsupportedOperationException( "not implemented ; fake 
artifact stub" );
+    }
+
+    public boolean isIncludesDependencies()
+    {
+        throw new UnsupportedOperationException( "not implemented ; fake 
artifact stub" );
+    }
+
+    public String getLanguage()
+    {
+        throw new UnsupportedOperationException( "not implemented ; fake 
artifact stub" );
+    }
+
+    public boolean isAddedToClasspath()
+    {
+        throw new UnsupportedOperationException( "not implemented ; fake 
artifact stub" );
+    }
+}


Reply via email to