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