View Javadoc
1   package org.apache.maven.plugins.ear.util;
2   
3   import static org.junit.Assert.assertEquals;
4   
5   import java.util.ArrayList;
6   import java.util.List;
7   
8   import org.apache.maven.plugins.ear.AbstractEarTestBase;
9   import org.apache.maven.plugins.ear.EarModule;
10  import org.apache.maven.plugins.ear.EjbModule;
11  import org.junit.Test;
12  
13  /*
14   * Licensed to the Apache Software Foundation (ASF) under one
15   * or more contributor license agreements.  See the NOTICE file
16   * distributed with this work for additional information
17   * regarding copyright ownership.  The ASF licenses this file
18   * to you under the Apache License, Version 2.0 (the
19   * "License"); you may not use this file except in compliance
20   * with the License.  You may obtain a copy of the License at
21   *
22   *  http://www.apache.org/licenses/LICENSE-2.0
23   *
24   * Unless required by applicable law or agreed to in writing,
25   * software distributed under the License is distributed on an
26   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
27   * KIND, either express or implied.  See the License for the
28   * specific language governing permissions and limitations
29   * under the License.
30   */
31  
32  /**
33   * @author <a href="snicoll@apache.org">Stephane Nicoll</a>
34   */
35  public class EarMavenArchiverTest
36      extends AbstractEarTestBase
37  {
38  
39      private List<EarModule> modules = new ArrayList<EarModule>();
40  
41      @Test
42      public void testSimpleEjbModule()
43      {
44          final EarModule module = new EjbModule( createArtifact( "foo", "ejb" ) );
45          setUri( module, "foo-1.0.jar" );
46          modules.add( module );
47  
48          final EarMavenArchiver archiver = new EarMavenArchiver( modules );
49          assertEquals( "foo-1.0.jar", archiver.generateClassPathEntry( "" ) );
50  
51      }
52  
53      @Test
54      public void testSimpleJarModuleWithCustomBundleDir()
55      {
56          final EarModule module = new EjbModule( createArtifact( "foo", "jar" ) );
57          setUri( module, "libs/foo-1.0.jar" );
58          modules.add( module );
59  
60          final EarMavenArchiver archiver = new EarMavenArchiver( modules );
61          assertEquals( "libs/foo-1.0.jar", archiver.generateClassPathEntry( "" ) );
62  
63      }
64  
65      @Test
66      public void testTwoModules()
67      {
68          final EarModule module = new EjbModule( createArtifact( "foo", "ejb" ) );
69          setUri( module, "foo-1.0.jar" );
70          modules.add( module );
71  
72          final EarModule module2 = new EjbModule( createArtifact( "bar", "war" ) );
73          setUri( module2, "bar-2.0.1.war" );
74          modules.add( module2 );
75  
76          final EarMavenArchiver archiver = new EarMavenArchiver( modules );
77          assertEquals( "foo-1.0.jar bar-2.0.1.war", archiver.generateClassPathEntry( "" ) );
78  
79      }
80  
81  }