View Javadoc
1   package org.apache.maven.plugins.ear.it;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  import java.io.FileInputStream;
24  import java.util.Properties;
25  import java.util.jar.JarFile;
26  import java.util.jar.Manifest;
27  
28  import org.apache.commons.io.IOUtils;
29  import org.codehaus.plexus.util.FileUtils;
30  import org.codehaus.plexus.util.ReaderFactory;
31  
32  /**
33   * @author <a href="snicoll@apache.org">Stephane Nicoll</a>
34   */
35  public class EarMojoIT
36      extends AbstractEarPluginIT
37  {
38  
39      /**
40       * Builds an EAR with a single EJB and no configuration.
41       */
42      public void testProject001()
43          throws Exception
44      {
45          doTestProject( "project-001", new String[] { "eartest-ejb-sample-one-1.0.jar" } );
46      }
47  
48      /**
49       * Builds an EAR with a customized artifact location and a customized artifact name.
50       */
51      public void testProject002()
52          throws Exception
53      {
54          doTestProject( "project-002",
55                         new String[] { "APP-INF/lib/eartest-ejb-sample-one-1.0.jar", "ejb-sample-two.jar" } );
56      }
57  
58      /**
59       * Builds an EAR with a default bundle directory for {@code java} modules.
60       */
61      public void testProject003()
62          throws Exception
63      {
64          doTestProject( "project-003", new String[] { "eartest-ejb-sample-one-1.0.jar",
65              "APP-INF/lib/eartest-jar-sample-one-1.0.jar", "APP-INF/lib/eartest-jar-sample-two-1.0.jar" } );
66      }
67  
68      /**
69       * Builds an EAR with a default bundle directory for _java_ modules and a custom location overriding the default.
70       */
71      public void testProject004()
72          throws Exception
73      {
74          doTestProject( "project-004", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-jar-sample-one-1.0.jar",
75              "APP-INF/lib/eartest-jar-sample-two-1.0.jar" } );
76      }
77  
78      /**
79       * Builds an EAR with a custom URI.
80       */
81      public void testProject005()
82          throws Exception
83      {
84          doTestProject( "project-005", new String[] { "eartest-ejb-sample-one-1.0.jar", "libs/another-name.jar" } );
85      }
86  
87      /**
88       * Builds an EAR with an excluded module.
89       */
90      public void testProject006()
91          throws Exception
92      {
93          doTestProject( "project-006",
94                         new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-jar-sample-two-1.0.jar" } );
95      }
96  
97      /**
98       * Builds an EAR with a classified artifact and no extra configuration.
99       */
100     public void testProject007()
101         throws Exception
102     {
103         doTestProject( "project-007", new String[] { "eartest-ejb-sample-one-1.0-classified.jar" } );
104     }
105 
106     /**
107      * Builds an EAR with deployment descriptor configuration for J2EE 1.3.
108      */
109     public void testProject008()
110         throws Exception
111     {
112         doTestProject( "project-008", new String[] { "eartest-ejb-sample-one-1.0.jar" } );
113     }
114 
115     /**
116      * Builds an EAR with deployment descriptor configuration for J2EE 1.4.
117      */
118     public void testProject009()
119         throws Exception
120     {
121         doTestProject( "project-009", new String[] { "eartest-ejb-sample-one-1.0.jar" } );
122     }
123 
124     /**
125      * Builds an EAR with deployment descriptor configuration for Java EE 5.
126      */
127     public void testProject010()
128         throws Exception
129     {
130         doTestProject( "project-010", new String[] { "eartest-ejb-sample-one-1.0.jar" } );
131     }
132 
133     /**
134      * Builds an EAR and make sure that deployment descriptor default settings are applied.
135      */
136     public void testProject011()
137         throws Exception
138     {
139         doTestProject( "project-011", new String[] { "eartest-ejb-sample-one-1.0.jar" } );
140     }
141 
142     /**
143      * Builds an EAR and make sure that EAR resources are bundled within the EAR.
144      */
145     public void testProject012()
146         throws Exception
147     {
148         doTestProject( "project-012", new String[] { "README.txt", "LICENSE.txt", "eartest-ejb-sample-one-1.0.jar" } );
149     }
150 
151     /**
152      * Builds an EAR and make sure that EAR resources in a customized resources directory are bundled within the EAR.
153      */
154     public void testProject013()
155         throws Exception
156     {
157         doTestProject( "project-013", new String[] { "README.txt", "LICENSE.txt", "eartest-ejb-sample-one-1.0.jar" } );
158     }
159 
160     /**
161      * Builds an EAR and make sure that EAR resources are bundled within the EAR using includes and excludes.
162      */
163     public void testProject014()
164         throws Exception
165     {
166         doTestProject( "project-014", new String[] { "LICENSE.txt", "eartest-ejb-sample-one-1.0.jar" } );
167     }
168 
169     /**
170      * Builds an EAR and make sure that default manifest is taken into account.
171      */
172     public void testProject015()
173         throws Exception
174     {
175         final File baseDir = doTestProject( "project-015", new String[] { "eartest-ejb-sample-one-1.0.jar" } );
176         final File expectedManifest = new File( baseDir, "src/main/application/META-INF/MANIFEST.MF" );
177         final File actualManifest = new File( getEarDirectory( baseDir, "project-015" ), "META-INF/MANIFEST.MF" );
178         assertTrue( "Manifest was not copied", actualManifest.exists() );
179         assertTrue( FileUtils.contentEquals( expectedManifest, actualManifest ) );
180     }
181 
182     /**
183      * Builds an EAR and make sure that custom manifest is taken into account.
184      */
185     public void testProject016()
186         throws Exception
187     {
188         final File baseDir = doTestProject( "project-016", new String[] { "eartest-ejb-sample-one-1.0.jar" } );
189 
190         final File createdEarFile = getEarArchive( baseDir, "project-016" );
191 
192         final File sourceManifestFile = new File( baseDir, "src/main/ear/MANIFEST.MF" );
193 
194         try ( JarFile jarFile = new JarFile( createdEarFile );
195               FileInputStream in = new FileInputStream( sourceManifestFile ) )
196         {    
197             Manifest manifestFromCreatedEARFile = jarFile.getManifest();
198             Manifest sourceManifest = new Manifest( in );
199             assertEquals( "There are differences in the manifest.", sourceManifest, manifestFromCreatedEARFile );
200         }
201      }
202 
203     /**
204      * Builds an EAR and make sure that custom application.xml is taken into account.
205      */
206     public void testProject017()
207         throws Exception
208     {
209         doTestProject( "project-017", new String[] { "eartest-ejb-sample-one-1.0.jar" } );
210     }
211 
212     /**
213      * Builds an EAR with a custom final name.
214      */
215     public void testProject018()
216         throws Exception
217     {
218         final File baseDir = executeMojo( "project-018" );
219         final File expectedFile = new File( baseDir, "target/my-custom-file.ear" );
220         assertTrue( "EAR archive not found", expectedFile.exists() );
221     }
222 
223     /**
224      * Builds an EAR with unpacked archives using the unpackTypes.
225      */
226     public void testProject019()
227         throws Exception
228     {
229         doTestProject( "project-019", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-sar-sample-one-1.0.sar",
230             "eartest-jar-sample-one-1.0.jar" }, new boolean[] { false, true, true } );
231     }
232 
233     /**
234      * Builds an EAR with unpacked archives using the unpack module attribute.
235      */
236     public void testProject020()
237         throws Exception
238     {
239         doTestProject( "project-020", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-sar-sample-one-1.0.sar",
240             "eartest-jar-sample-one-1.0.jar" }, new boolean[] { true, false, false } );
241     }
242 
243     /**
244      * Builds an EAR with unpacked archives using both unpackTypes and the unpack module attribute.
245      */
246     public void testProject021()
247         throws Exception
248     {
249         doTestProject( "project-021",
250                        new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar",
251                            "eartest-sar-sample-one-1.0.sar", "eartest-jar-sample-one-1.0.jar",
252                            "eartest-jar-sample-two-1.0.jar" },
253                        new boolean[] { false, true, false, false, true } );
254     }
255 
256     /**
257      * Builds an EAR with a classifier.
258      */
259     public void testProject022()
260         throws Exception
261     {
262         final File baseDir = executeMojo( "project-022" );
263         final File expectedFile = new File( baseDir, "target/maven-ear-plugin-test-project-022-99.0-myclassifier.ear" );
264         assertTrue( "EAR archive not found", expectedFile.exists() );
265     }
266 
267     /**
268      * Builds an EAR and make sure that a single classified dependency is detected without specifying the classifier.
269      */
270     public void testProject023()
271         throws Exception
272     {
273         doTestProject( "project-023",
274                        new String[] { "eartest-ejb-sample-one-1.0-classified.jar", "eartest-ejb-sample-two-1.0.jar" },
275                        new boolean[] { true, false } );
276     }
277 
278     /**
279      * Builds an EAR and make sure that a single classified dependency is detected when specifying the classifier.
280      */
281     public void testProject024()
282         throws Exception
283     {
284         doTestProject( "project-024",
285                        new String[] { "eartest-ejb-sample-one-1.0-classified.jar", "eartest-ejb-sample-two-1.0.jar" },
286                        new boolean[] { true, false } );
287     }
288 
289     /**
290      * Builds an EAR and make sure that a classified dependency with multiple candidates is detected when specifying the
291      * classifier.
292      */
293     public void testProject025()
294         throws Exception
295     {
296         doTestProject( "project-025",
297                        new String[] { "eartest-ejb-sample-one-1.0-classified.jar", "eartest-ejb-sample-one-1.0.jar" },
298                        new boolean[] { true, false } );
299     }
300 
301     /**
302      * Builds an EAR and make sure that the build fails if a unclassifed module configuration with multiple candidates is
303      * specified.
304      */
305     public void testProject026()
306         throws Exception
307     {
308         final File baseDir = executeMojo( "project-026", false, true );
309         // Stupido, checks that the ear archive is not there
310         assertFalse( "Execution should have failed", getEarArchive( baseDir, "project-026" ).exists() );
311     }
312 
313     /**
314      * Builds an EAR and make sure that provided dependencies are not included in the EAR.
315      */
316     public void testProject027()
317         throws Exception
318     {
319         doTestProject( "project-027", new String[] { "eartest-ejb-sample-one-1.0.jar" } );
320     }
321 
322     /**
323      * Builds an EAR and make sure that test dependencies are not included in the EAR.
324      */
325     public void testProject028()
326         throws Exception
327     {
328         doTestProject( "project-028", new String[] { "eartest-ejb-sample-one-1.0.jar" } );
329     }
330 
331     /**
332      * Builds an EAR and make sure that system dependencies are not included in the EAR.
333      */
334     public void testProject029()
335         throws Exception
336     {
337         doTestProject( "project-029", new String[] { "eartest-ejb-sample-one-1.0.jar" } );
338     }
339 
340     /**
341      * Builds an EAR and make sure that ejb-client dependencies are detected and not added by default in the generated
342      * application.xml.
343      */
344     public void testProject030()
345         throws Exception
346     {
347         doTestProject( "project-030",
348                        new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0-client.jar" } );
349     }
350 
351     /**
352      * Builds an EAR with a Jboss 4 configuration specifying the security domain and the unauthenticated-principal to
353      * use.
354      */
355     public void testProject031()
356         throws Exception
357     {
358         doTestProject( "project-031",
359                        new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
360     }
361 
362     /**
363      * Builds an EAR with a Jboss 3.2 configuration specifying the jmx-name to use.
364      */
365     public void testProject032()
366         throws Exception
367     {
368         doTestProject( "project-032",
369                        new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
370     }
371 
372     /**
373      * Builds an EAR with a Jboss 4 configuration and Jboss specific modules.
374      */
375     public void testProject033()
376         throws Exception
377     {
378         doTestProject( "project-033", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar",
379             "eartest-sar-sample-one-1.0.sar", "eartest-har-sample-one-1.0.har" } );
380     }
381 
382     /**
383      * Builds an EAR with custom security settings.
384      */
385     public void testProject034()
386         throws Exception
387     {
388         doTestProject( "project-034",
389                        new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
390     }
391 
392     /**
393      * Builds an EAR with a full filename mapping and make sure that custom locations are not overridden.
394      */
395     public void testProject035()
396         throws Exception
397     {
398         doTestProject( "project-035",
399                        new String[] { "foo/eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar",
400                            "libs/eartest-jar-sample-one-1.0.jar", "libs/eartest-jar-sample-two-1.0.jar",
401                            "sar-sample-one.sar" } );
402     }
403 
404     /**
405      * Builds an EAR with a full filename mapping and make sure that groupIds with dots are replaced by dashes in
406      * filenames.
407      */
408     public void testProject036()
409         throws Exception
410     {
411         doTestProject( "project-036",
412                        new String[] { "foo/eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar",
413                            "com.foo.bar-ejb-sample-one-1.0.jar", "com.foo.bar-ejb-sample-two-1.0.jar",
414                            "libs/eartest-jar-sample-one-1.0.jar", "libs/eartest-jar-sample-two-1.0.jar",
415                            "sar-sample-one.sar" } );
416     }
417 
418     /**
419      * Builds an EAR and make sure that ejb-client dependencies are detected and added in the generated application.xml
420      * if includeInApplicationXml is set.
421      */
422     public void testProject037()
423         throws Exception
424     {
425         doTestProject( "project-037", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0-client.jar" } );
426     }
427 
428     /**
429      * Builds an EAR and make sure that a non-classified dependency with multiple candidates is detected when specifying
430      * the mainArtifactId as classifier.
431      */
432     public void testProject038()
433         throws Exception
434     {
435         doTestProject( "project-038", new String[] { "eartest-ejb-sample-one-1.0-classified.jar", "eartest-ejb-sample-one-1.0.jar" },
436                        new boolean[] { false, true } );
437     }
438 
439     /**
440      * Builds an EAR with a Jboss 4 configuration specifying specifying the loader repository to use.
441      */
442     public void testProject039()
443         throws Exception
444     {
445         doTestProject( "project-039", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
446     }
447 
448     /**
449      * Builds an EAR with deployment descriptor configuration for Java EE 5 and an alternative deployment descriptor.
450      */
451     public void testProject040()
452         throws Exception
453     {
454         doTestProject( "project-040", new String[] { "eartest-ejb-sample-one-1.0.jar" } );
455     }
456 
457     /**
458      * Builds an EAR with a Jboss 4.2 configuration specifying the module order to use.
459      */
460     public void testProject041()
461         throws Exception
462     {
463         doTestProject( "project-041", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
464     }
465 
466     /**
467      * Builds an EAR with a Jboss 4.2 configuration specifying a datasource to add.
468      */
469     public void testProject042()
470         throws Exception
471     {
472         doTestProject( "project-042", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
473     }
474 
475     /**
476      * Builds an EAR with a custom descriptor location (generatedDescriptorLocation setting).
477      */
478     public void testProject043()
479         throws Exception
480     {
481         final File baseDir = doTestProject( "project-043", new String[] { "eartest-ejb-sample-one-1.0.jar" } );
482         final File expectedApplicationXml = new File( baseDir, "target/custom-descriptor-dir/application.xml" );
483         assertTrue( "Application.xml file not found", expectedApplicationXml.exists() );
484         assertFalse( "Application.xml file should not be empty", expectedApplicationXml.length() == 0 );
485     }
486 
487     /**
488      * Builds an EAR with a custom library-directory.
489      */
490     public void testProject044()
491         throws Exception
492     {
493         doTestProject( "project-044", new String[] { "eartest-ejb-sample-one-1.0.jar", "myLibs/eartest-jar-sample-one-1.0.jar" } );
494     }
495 
496     /**
497      * Builds an EAR and filter the content of the sources directory.
498      */
499     public void testProject045()
500         throws Exception
501     {
502         final File baseDir = doTestProject( "project-045", new String[] { "README.txt", "eartest-ejb-sample-one-1.0.jar" } );
503         final File actualReadme = new File( getEarDirectory( baseDir, "project-045" ), "README.txt" );
504         final String content = IOUtils.toString( ReaderFactory.newReader( actualReadme, "UTF-8" ) );
505         assertTrue( "application name and version was not filtered properly", content.contains( "my-app 99.0" ) );
506         assertTrue( "Escaping did not work properly", content.contains( "will not be filtered ${application.name}." ) );
507     }
508 
509     /**
510      * Builds an EAR and filter the content of the sources directory using a custom filter file.
511      */
512     public void testProject046()
513         throws Exception
514     {
515         final File baseDir = doTestProject( "project-046", new String[] { "README.txt", "eartest-ejb-sample-one-1.0.jar" } );
516         final File actualReadme = new File( getEarDirectory( baseDir, "project-046" ), "README.txt" );
517         final String content = IOUtils.toString( ReaderFactory.newReader( actualReadme, "UTF-8" ) );
518         assertTrue( "application name and version was not filtered properly", content.contains( "my-app 99.0" ) );
519         assertTrue( "application build was not filtered properly", content.contains( "(Build 2)" ) );
520         assertTrue( "Unknown property should not have been filtered",
521                     content.contains( "will not be filtered ${application.unknown}." ) );
522     }
523 
524     /**
525      * Builds an EAR and filter the content with a list of extensions.
526      */
527     public void testProject047()
528         throws Exception
529     {
530         final File baseDir = doTestProject( "project-047", new String[] { "README.txt", "eartest-ejb-sample-one-1.0.jar" } );
531         final File actualReadme = new File( getEarDirectory( baseDir, "project-047" ), "README.txt" );
532         final String content = IOUtils.toString( ReaderFactory.newReader( actualReadme, "UTF-8" ) );
533         assertTrue( "application name and version should not have been filtered", !content.contains( "my-app 99.0" ) );
534         assertTrue( "original properties not found", content.contains( "${application.name} ${project.version}" ) );
535     }
536 
537     /**
538      * Builds an EAR with a JBoss 5 configuration containing library directory.
539      */
540     public void testProject048()
541         throws Exception
542     {
543         doTestProject( "project-048", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
544     }
545 
546     /**
547      * Builds an EAR with a JBoss 4.2 configuration containing a library directory.
548      */
549     public void testProject049()
550         throws Exception
551     {
552         doTestProject( "project-049", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
553     }
554 
555     /**
556      * Builds an EAR with a Jboss 5 configuration containing a loader repository configuration definition.
557      */
558     public void testProject050()
559         throws Exception
560     {
561         doTestProject( "project-050", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
562     }
563 
564     /**
565      * Builds an EAR with a Jboss 5 configuration containing a loader repository class definition.
566      */
567     public void testProject051()
568         throws Exception
569     {
570         doTestProject( "project-051", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
571     }
572 
573     /**
574      * Builds an EAR with a Jboss 5 configuration containing a configuration parser class definition.
575      */
576     public void testProject052()
577         throws Exception
578     {
579         doTestProject( "project-052", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
580     }
581 
582     /**
583      * Builds an EAR with a Jboss 5 configuration containing only the loader repo configuration
584      */
585     public void testProject053()
586         throws Exception
587     {
588         doTestProject( "project-053", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
589     }
590 
591     /**
592      * Builds an EAR with deployment descriptor configuration for Java EE 5 and no application.xml
593      */
594     public void testProject054()
595         throws Exception
596     {
597         doTestProject( "project-054", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
598     }
599 
600     /**
601      * Builds an EAR with jar dependencies added in application.xml.
602      */
603     public void testProject055()
604         throws Exception
605     {
606         doTestProject( "project-055", new String[] { "eartest-jar-sample-one-1.0.jar", "eartest-jar-sample-two-1.0.jar",
607             "eartest-jar-sample-three-with-deps-1.0.jar" } );
608     }
609 
610     /**
611      * Builds an EAR with deployment descriptor configuration for J2EE 1.4 and an alternative deployment descriptor.
612      */
613     public void testProject056()
614         throws Exception
615     {
616         doTestProject( "project-056", new String[] { "eartest-ejb-sample-one-1.0.jar" } );
617     }
618 
619     /**
620      * Builds an EAR with a complete JBoss 4.2 configuration and validate it matches the DTD (MEAR-104).
621      */
622     public void testProject057()
623         throws Exception
624     {
625         doTestProject( "project-057", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
626     }
627 
628     /**
629      * Builds an EAR with deployment descriptor configuration for Java EE 6.
630      */
631     public void testProject058()
632         throws Exception
633     {
634         doTestProject( "project-058", new String[] { "eartest-ejb-sample-one-1.0.jar" } );
635     }
636 
637     /**
638      * Builds an EAR with no display name entry at all.
639      */
640     public void testProject059()
641         throws Exception
642     {
643         doTestProject( "project-059", new String[] { "eartest-ejb-sample-one-1.0.jar" } );
644     }
645 
646     /**
647      * Builds an EAR with ejb-client packaged for J2EE 1.3 (MEAR-85)
648      */
649     public void testProject060()
650         throws Exception
651     {
652         doTestProject( "project-060", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0-client.jar" } );
653     }
654 
655     /**
656      * Builds an EAR with ejb-client packaged for J2EE 1.4 (MEAR-85)
657      */
658     public void testProject061()
659         throws Exception
660     {
661         doTestProject( "project-061", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0-client.jar" } );
662     }
663 
664     /**
665      * Builds an EAR with ejb-client packaged for JavaEE 5 (MEAR-85)
666      */
667     public void testProject062()
668         throws Exception
669     {
670         doTestProject( "project-062", new String[] { "eartest-ejb-sample-one-1.0.jar", "lib/eartest-ejb-sample-two-1.0-client.jar" } );
671     }
672 
673     /**
674      * Builds an EAR with ejb-client packaged for JavaEE 6 (MEAR-85)
675      */
676     public void testProject063()
677         throws Exception
678     {
679         doTestProject( "project-063", new String[] { "lib/eartest-ejb-sample-two-1.0-client.jar" } );
680     }
681 
682     /**
683      * Builds an EAR with ejb-client packaged for JavaEE 5 and still put it in the root (MEAR-85)
684      */
685     public void testProject064()
686         throws Exception
687     {
688         doTestProject( "project-064", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0-client.jar" } );
689     }
690 
691     /**
692      * Builds an EAR with a custom moduleId.
693      */
694     public void testProject065()
695         throws Exception
696     {
697         doTestProject( "project-065", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
698     }
699 
700     /**
701      * Builds an EAR with generateModuleId enabled.
702      */
703     public void testProject066()
704         throws Exception
705     {
706         doTestProject( "project-066", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
707     }
708 
709     /**
710      * Builds an EAR with generateModuleId enabled and a custom module.
711      */
712     public void testProject067()
713         throws Exception
714     {
715         doTestProject( "project-067", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
716     }
717 
718     /**
719      * Builds an EAR with the no-version file name mapping.
720      */
721     public void testProject068()
722         throws Exception
723     {
724         doTestProject( "project-068", new String[] { "eartest-ejb-sample-one.jar", "eartest-ejb-sample-two.jar" } );
725     }
726 
727     /**
728      * Builds an EAR with a custom library-directory and JavaEE 6.
729      */
730     public void testProject069()
731         throws Exception
732     {
733         doTestProject( "project-069", new String[] { "eartest-ejb-sample-one-1.0.jar", "myLibs/eartest-jar-sample-one-1.0.jar" } );
734     }
735 
736     /**
737      * Builds an EAR with application-name and initialize-in-order tags.
738      */
739     public void testProject070()
740         throws Exception
741     {
742         doTestProject( "project-070", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-jar-sample-one-1.0.jar" } );
743     }
744 
745     /**
746      * Builds an EAR with application-name and initialize-in-order tags for unsupported version.
747      */
748     public void testProject071()
749         throws Exception
750     {
751         doTestProject( "project-071", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-jar-sample-one-1.0.jar" } );
752     }
753 
754     /**
755      * Builds an EAR with an application client module (app-client).
756      */
757     public void testProject072()
758         throws Exception
759     {
760         doTestProject( "project-072", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-app-client-sample-one-1.0.jar" } );
761     }
762 
763     /**
764      * Builds an EAR with an application client module (app-client) and a default bundle directory for _java_ modules.
765      */
766     public void testProject073()
767         throws Exception
768     {
769         doTestProject( "project-073", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-app-client-sample-one-1.0.jar",
770             "APP-INF/lib/eartest-jar-sample-one-1.0.jar", "APP-INF/lib/eartest-jar-sample-two-1.0.jar" } );
771     }
772 
773     /**
774      * Builds an EAR with custom env entries settings and J2EE 1.3. Not supported by the specification so this should be
775      * ignored.
776      */
777     public void testProject074()
778         throws Exception
779     {
780         doTestProject( "project-074", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
781     }
782 
783     /**
784      * Builds an EAR with custom env entries settings and J2EE 1.4. Not supported by the specification so this should be
785      * ignored.
786      */
787     public void testProject075()
788         throws Exception
789     {
790         doTestProject( "project-075", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
791     }
792 
793     /**
794      * Builds an EAR with custom env entries settings and JavaEE 5. Not supported by the specification so this should be
795      * ignored.
796      */
797     public void testProject076()
798         throws Exception
799     {
800         doTestProject( "project-076", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
801     }
802 
803     /**
804      * Builds an EAR with custom env entries settings and JavaEE 6.
805      */
806     public void testProject077()
807         throws Exception
808     {
809         doTestProject( "project-077", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
810     }
811 
812     /**
813      * Builds an EAR with the no version for ejb file name mapping.
814      */
815     public void testProject078()
816         throws Exception
817     {
818         doTestProject( "project-078",
819                        new String[] { "ejb-sample-one.jar", "war-sample-one.war", "jar-sample-two.jar" } );
820     }
821 
822     /**
823      * Builds an EAR with the 'default' library directory mode. Uses the value of the defaultLibBundleDir.
824      */
825     public void testProject079()
826         throws Exception
827     {
828         doTestProject( "project-079", new String[] { "eartest-ejb-sample-one-1.0.jar", "myLibs/eartest-jar-sample-one-1.0.jar" } );
829     }
830 
831     /**
832      * Builds an EAR with the 'empty' library directory mode. Generate an empty library-directory element.
833      */
834     public void testProject080()
835         throws Exception
836     {
837         doTestProject( "project-080", new String[] { "eartest-ejb-sample-one-1.0.jar", "myLibs/eartest-jar-sample-one-1.0.jar" } );
838     }
839 
840     /**
841      * Builds an EAR with the 'none' library directory mode. Does not generate an library-directory element.
842      */
843     public void testProject081()
844         throws Exception
845     {
846         doTestProject( "project-081", new String[] { "eartest-ejb-sample-one-1.0.jar", "myLibs/eartest-jar-sample-one-1.0.jar" } );
847     }
848 
849     /**
850      * Builds an EAR with deployment descriptor configuration for JavaEE 7.
851      */
852     public void testProject082()
853         throws Exception
854     {
855         doTestProject( "project-082", new String[] { "eartest-ejb-sample-one-1.0.jar" } );
856     }
857 
858     /**
859      * Builds an EAR with a library directory and custom env entries. The library-directory element must come first
860      * (MEAR-158).
861      */
862     public void testProject083()
863         throws Exception
864     {
865         doTestProject( "project-083", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
866     }
867 
868     /**
869      * Support of an application id (MEAR-174).
870      */
871     public void testProject084()
872         throws Exception
873     {
874         doTestProject( "project-084", new String[] { "eartest-ejb-sample-one-1.0.jar" } );
875     }
876 
877     /**
878      * Builds an EAR with custom ejbRef entries settings and JavaEE 6.
879      */
880     public void testProject085()
881         throws Exception
882     {
883         doTestProject( "project-085", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
884     }
885 
886     /**
887      * Builds an EAR with custom ejbRef entries plus lookup-name entry.
888      */
889     public void testProject086()
890         throws Exception
891     {
892         doTestProject( "project-086", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
893     }
894 
895     /**
896      * Builds an EAR with resource-ref entries.
897      */
898     public void testProject087()
899         throws Exception
900     {
901         doTestProject( "project-087", new String[] { "eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar" } );
902     }
903 
904     /**
905      * Builds WAR and EAR as part of multi-module project twice so that the 2nd build is guaranteed to be performed when
906      * target directories and files exist.
907      */
908     public void testProject088()
909         throws Exception
910     {
911         final String warModule = "eartest-war-sample-two-1.0.war";
912         final String ejbModule = "eartest-ejb-sample-one-1.0.jar";
913         final String jarSampleTwoLibrary = "lib/eartest-jar-sample-two-1.0.jar";
914         final String[] expectedArtifacts = { warModule, ejbModule, jarSampleTwoLibrary };
915         final boolean[] artifactsDirectory = { false, true, false };
916         final String[] artifactsToValidateManifest = { warModule, ejbModule };
917         final boolean[] artifactsToValidateManifestDirectory = { false, true };
918         final String[][] expectedClassPathElements = { { jarSampleTwoLibrary }, { jarSampleTwoLibrary } };
919 
920         // "Clean" build - target directories and files do not exist
921         // Pass cleanBeforeExecute parameter to ensure that target location is cleaned before Mojo execution
922         doTestProject( "project-088", "ear", expectedArtifacts, artifactsDirectory,
923             artifactsToValidateManifest, artifactsToValidateManifestDirectory, expectedClassPathElements, true );
924         // "Dirty" build - target directories and files exist
925         doTestProject( "project-088", "ear", expectedArtifacts, artifactsDirectory,
926             artifactsToValidateManifest, artifactsToValidateManifestDirectory, expectedClassPathElements, false );
927     }
928 
929     /**
930      * Validates modification of Class-Path entry of EAR modules manifest when
931      * <ul>
932      * <li>skinnyWars option is turned on</li>
933      * <li>skipClassPathModification option is turned off</li>
934      * </ul>
935      */
936     public void testProject089()
937         throws Exception
938     {
939         final String warModule = "eartest-war-sample-three-1.0.war";
940         final String ejbModule = "eartest-ejb-sample-three-1.0.jar";
941         final String jarSampleTwoLibrary = "lib/eartest-jar-sample-two-1.0.jar";
942         final String jarSampleThreeLibrary = "lib/eartest-jar-sample-three-with-deps-1.0.jar";
943         doTestProject( "project-089", "ear",
944             new String[] { warModule, ejbModule, jarSampleTwoLibrary, jarSampleThreeLibrary },
945             new boolean[] { false, false, false, false},
946             new String[] { warModule, ejbModule },
947             new boolean[] { false, false },
948             new String[][] { { jarSampleTwoLibrary, jarSampleThreeLibrary }, { jarSampleThreeLibrary, jarSampleTwoLibrary } },
949             true );
950     }
951 
952     /**
953      * Validates modification of Class-Path entry of EAR modules manifest when
954      * <ul>
955      * <li>skinnyWars option is turned on</li>
956      * <li>skipClassPathModification option is turned on</li>
957      * </ul>
958      */
959     public void testProject090()
960         throws Exception
961     {
962         final String warModule = "eartest-war-sample-three-1.0.war";
963         final String ejbModule = "eartest-ejb-sample-three-1.0.jar";
964         final String jarSampleTwoLibrary = "lib/eartest-jar-sample-two-1.0.jar";
965         final String jarSampleThreeLibrary = "lib/eartest-jar-sample-three-with-deps-1.0.jar";
966         doTestProject( "project-090", "ear",
967             new String[] { warModule, ejbModule, jarSampleTwoLibrary, jarSampleThreeLibrary },
968             new boolean[] { false, false, false, false },
969             new String[] { warModule, ejbModule },
970             new boolean[] { false, false },
971             new String[][] { { jarSampleTwoLibrary }, { jarSampleThreeLibrary, jarSampleTwoLibrary } },
972             true );
973     }
974 
975     /**
976      * Validates modification of Class-Path entry of EAR modules manifest when
977      * <ul>
978      * <li>skinnyWars option is turned off</li>
979      * <li>skipClassPathModification option is turned off</li>
980      * <li>unpacking of EJB JARs is turned on</li>
981      * </ul>
982      */
983     public void testProject091()
984         throws Exception
985     {
986         final String warModule = "eartest-war-sample-three-1.0.war";
987         final String ejbModule = "eartest-ejb-sample-three-1.0.jar";
988         final String jarSampleTwoLibrary = "eartest-jar-sample-two-1.0.jar";
989         final String jarSampleThreeLibrary = "eartest-jar-sample-three-with-deps-1.0.jar";
990         doTestProject( "project-091", "ear",
991             new String[] { warModule, ejbModule, jarSampleTwoLibrary, jarSampleThreeLibrary },
992             new boolean[] { false, true, false, false },
993             new String[] { warModule, ejbModule },
994             new boolean[] { false, true },
995             new String[][] { { "jar-sample-two-1.0.jar" }, { jarSampleThreeLibrary, jarSampleTwoLibrary } },
996             true );
997     }
998 
999     /**
1000      * Ensures that when
1001      * <ul>
1002      * <li>skinnyWars option is turned off (has default value)</li>
1003      * <li>skinnyModules options is turned on</li>
1004      * </ul>
1005      * then movement of JARs and modification of manifest Class-Path entry is performed for WAR, SAR, HAR and RAR
1006      * modules. Additionally this test ensures that
1007      * <ul>
1008      * <li>movement of JARs is not performed for modules whose libDirectory property doesn't point to the correct module
1009      * entry containing JAR libraries packaged into the module</li>
1010      * <li>JAR with provided scope is removed from modules and from Class-Path entries</li>
1011      * </ul>
1012      */
1013     public void testProject092()
1014         throws Exception
1015     {
1016         final String projectName = "project-092";
1017         final String earModuleName = "ear";
1018         final String jarSampleOneLibrary = "jar-sample-one-1.0.jar";
1019         final String jarSampleTwoLibrary = "jar-sample-two-1.0.jar";
1020         final String jarSampleThreeLibrary = "jar-sample-three-with-deps-1.0.jar";
1021         final String jarSampleOneEarLibrary = "libs/eartest-" + jarSampleOneLibrary;
1022         final String jarSampleTwoEarLibrary = "libs/eartest-" + jarSampleTwoLibrary;
1023         final String jarSampleThreeEarLibrary = "libs/eartest-" + jarSampleThreeLibrary;
1024         final String warModule = "eartest-war-sample-three-1.0.war";
1025         final String sarModuleTwo = "eartest-sar-sample-two-1.0.sar";
1026         final String sarModuleThree = "eartest-sar-sample-three-1.0.sar";
1027         final String sarModuleFour = "eartest-sar-sample-four-1.0.sar";
1028         final String harModule = "eartest-har-sample-two-1.0.har";
1029         final String rarModule = "eartest-rar-sample-one-1.0.rar";
1030         final String[] earModules = { warModule, sarModuleTwo, sarModuleThree, sarModuleFour, harModule, rarModule };
1031         final boolean[] earModuleDirectory = { false, false, false, false, false, false };
1032         final String warModuleLibDir = "WEB-INF/lib/";
1033         final String sarModuleTwoLibDir = "libraries/";
1034         final String sarModuleThreeLibDir = "";
1035         final String sarModuleFourLibDir = "lib/";
1036         final String harModuleLibDir = "lib/";
1037         final String rarModuleLibDir = "";
1038 
1039         final File baseDir = doTestProject( projectName, earModuleName,
1040             new String[] { warModule, sarModuleTwo, sarModuleThree, sarModuleFour, harModule, rarModule,
1041                 jarSampleOneEarLibrary, jarSampleTwoEarLibrary, jarSampleThreeEarLibrary },
1042             new boolean[] { false, false, false, false, false, false, false, false, false },
1043             earModules, earModuleDirectory,
1044             new String[][] {
1045                 { jarSampleTwoEarLibrary, jarSampleOneEarLibrary, jarSampleThreeEarLibrary },
1046                 { jarSampleThreeEarLibrary, jarSampleTwoEarLibrary, jarSampleOneEarLibrary },
1047                 { jarSampleThreeEarLibrary, jarSampleTwoEarLibrary, jarSampleOneEarLibrary },
1048                 { jarSampleOneEarLibrary, jarSampleTwoEarLibrary, jarSampleThreeEarLibrary },
1049                 { jarSampleOneEarLibrary, jarSampleThreeEarLibrary, jarSampleTwoEarLibrary },
1050                 { jarSampleThreeEarLibrary, jarSampleTwoEarLibrary, jarSampleOneEarLibrary } },
1051             true );
1052 
1053         assertEarModulesContent( baseDir, projectName, earModuleName, earModules, earModuleDirectory,
1054             new String[][] {
1055                 { warModuleLibDir },
1056                 { sarModuleTwoLibDir },
1057                 { sarModuleThreeLibDir },
1058                 { sarModuleFourLibDir + jarSampleOneLibrary },
1059                 { harModuleLibDir },
1060                 { rarModuleLibDir } },
1061             new String[][] {
1062                 { warModuleLibDir + jarSampleTwoLibrary },
1063                 { sarModuleTwoLibDir + jarSampleTwoLibrary, sarModuleTwoLibDir + jarSampleThreeLibrary },
1064                 { sarModuleThreeLibDir + jarSampleTwoLibrary, sarModuleThreeLibDir + jarSampleThreeLibrary },
1065                 { },
1066                 { harModuleLibDir + jarSampleOneLibrary, harModuleLibDir + jarSampleTwoLibrary, harModuleLibDir + jarSampleThreeLibrary },
1067                 { rarModuleLibDir + jarSampleTwoLibrary, rarModuleLibDir + jarSampleThreeLibrary } } );
1068     }
1069 
1070     /**
1071      * Ensures that when
1072      * <ul>
1073      * <li>skinnyWars option is turned on</li>
1074      * <li>skinnyModules options is turned off (has default value)</li>
1075      * </ul>
1076      * then movement of JARs and modification of manifest Class-Path entry is performed only for WAR module and not for
1077      * SAR, HAR and RAR modules.
1078      */
1079     public void testProject093()
1080         throws Exception
1081     {
1082         final String projectName = "project-093";
1083         final String earModuleName = "ear";
1084         final String jarSampleOneLibrary = "jar-sample-one-1.0.jar";
1085         final String jarSampleTwoLibrary = "jar-sample-two-1.0.jar";
1086         final String jarSampleThreeLibrary = "jar-sample-three-with-deps-1.0.jar";
1087         final String jarSampleTwoEarLibrary = "lib/eartest-" + jarSampleTwoLibrary;
1088         final String jarSampleThreeEarLibrary = "lib/eartest-" + jarSampleThreeLibrary;
1089         final String warModule = "eartest-war-sample-three-1.0.war";
1090         final String sarModule = "eartest-sar-sample-two-1.0.sar";
1091         final String harModule = "eartest-har-sample-two-1.0.har";
1092         final String rarModule = "eartest-rar-sample-one-1.0.rar";
1093         final String[] earModules = { warModule, sarModule, harModule, rarModule };
1094         final boolean[] earModuleDirectory = { false, false, false, false };
1095         final String warModuleLibDir = "WEB-INF/lib/";
1096         final String sarModuleLibDir = "lib/";
1097         final String harModuleLibDir = "lib/";
1098         final String rarModuleLibDir = "";
1099 
1100         final File baseDir = doTestProject( projectName, earModuleName,
1101             new String[] { warModule, sarModule, harModule, rarModule, jarSampleTwoEarLibrary, jarSampleThreeEarLibrary },
1102             new boolean[] { false, false, false, false, false, false },
1103             earModules, earModuleDirectory,
1104             new String[][] {
1105                 { jarSampleThreeEarLibrary, jarSampleTwoEarLibrary },
1106                 { jarSampleThreeLibrary, jarSampleTwoLibrary, jarSampleOneLibrary },
1107                 null,
1108                 { jarSampleOneLibrary, jarSampleThreeLibrary, jarSampleTwoLibrary } },
1109             true );
1110 
1111         assertEarModulesContent( baseDir, projectName, earModuleName, earModules, earModuleDirectory,
1112             new String[][] {
1113                 { warModuleLibDir },
1114                 { sarModuleLibDir + jarSampleOneLibrary, sarModuleLibDir + jarSampleTwoLibrary, sarModuleLibDir + jarSampleThreeLibrary },
1115                 { harModuleLibDir + jarSampleOneLibrary, harModuleLibDir + jarSampleTwoLibrary, harModuleLibDir + jarSampleThreeLibrary },
1116                 { rarModuleLibDir + jarSampleOneLibrary, rarModuleLibDir + jarSampleTwoLibrary, rarModuleLibDir + jarSampleThreeLibrary } } ,
1117             new String[][] {
1118                 { warModuleLibDir + jarSampleTwoLibrary, warModuleLibDir + jarSampleThreeLibrary },
1119                 { },
1120                 { },
1121                 { } } );
1122     }
1123 
1124     /**
1125      * Ensures that when
1126      * <ul>
1127      * <li>skinnyWars option is turned off (has default value)</li>
1128      * <li>skinnyModules options is turned off (has default value)</li>
1129      * </ul>
1130      * then
1131      * <ul>
1132      * <li>movement of JARs and modification of the manifest Class-Path entry is not performed for WAR, SAR, HAR and
1133      * RAR modules</li>
1134      * <li>modification of the manifest Class-Path entry is performed for EJB module</li>
1135      * <li>provided JAR is removed from the manifest Class-Path entry of EJB module</li>
1136      * </ul>
1137      */
1138     public void testProject094()
1139         throws Exception
1140     {
1141         final String projectName = "project-094";
1142         final String earModuleName = "ear";
1143         final String jarSampleOneLibrary = "jar-sample-one-1.0.jar";
1144         final String jarSampleTwoLibrary = "jar-sample-two-1.0.jar";
1145         final String jarSampleThreeLibrary = "jar-sample-three-with-deps-1.0.jar";
1146         final String jarSampleTwoEarLibrary = "lib/eartest-" + jarSampleTwoLibrary;
1147         final String jarSampleThreeEarLibrary = "lib/eartest-" + jarSampleThreeLibrary;
1148         final String warModule = "eartest-war-sample-three-1.0.war";
1149         final String sarModule = "eartest-sar-sample-two-1.0.sar";
1150         final String harModule = "eartest-har-sample-two-1.0.har";
1151         final String rarModule = "eartest-rar-sample-one-1.0.rar";
1152         final String ejbModule = "eartest-ejb-sample-three-1.0.jar";
1153         final String[] earModules = { warModule, sarModule, harModule, rarModule, ejbModule };
1154         final boolean[] earModuleDirectory = { false, false, false, false, false };
1155         final String warModuleLibDir = "WEB-INF/lib/";
1156         final String sarModuleLibDir = "lib/";
1157         final String harModuleLibDir = "lib/";
1158         final String rarModuleLibDir = "";
1159 
1160         final File baseDir = doTestProject( projectName, earModuleName,
1161             new String[] { warModule, sarModule, harModule, rarModule, ejbModule, jarSampleTwoEarLibrary,
1162                 jarSampleThreeEarLibrary },
1163             new boolean[] { false, false, false, false, false, false, false },
1164             earModules, earModuleDirectory,
1165             new String[][] { null, null, null, null,
1166                 new String[] { jarSampleThreeEarLibrary, jarSampleTwoEarLibrary } },
1167             true );
1168 
1169         assertEarModulesContent( baseDir, projectName, earModuleName, earModules, earModuleDirectory,
1170             new String[][] {
1171                 { warModuleLibDir + jarSampleTwoLibrary, warModuleLibDir + jarSampleThreeLibrary },
1172                 { sarModuleLibDir + jarSampleOneLibrary, sarModuleLibDir + jarSampleTwoLibrary, sarModuleLibDir + jarSampleThreeLibrary },
1173                 { harModuleLibDir + jarSampleOneLibrary, harModuleLibDir + jarSampleTwoLibrary, harModuleLibDir + jarSampleThreeLibrary },
1174                 { rarModuleLibDir + jarSampleOneLibrary, rarModuleLibDir + jarSampleTwoLibrary, rarModuleLibDir + jarSampleThreeLibrary },
1175                 null } ,
1176             null );
1177     }
1178 
1179     /**
1180      * Ensures that test JAR dependency of WAR is handled as regular JAR in terms of packaging and manifest modification
1181      * when skinnyWars option is turned on.
1182      */
1183     public void testProject095()
1184         throws Exception
1185     {
1186         final String warModule = "eartest-war-sample-two-1.0.war";
1187         final String jarSampleTwoLibrary = "lib/eartest-jar-sample-two-1.0.jar";
1188         final String jarSampleThreeLibrary = "lib/eartest-jar-sample-three-with-deps-1.0.jar";
1189         final String jarSampleFourTestLibrary = "lib/eartest-jar-sample-four-1.0-tests.jar";
1190         doTestProject( "project-095", "ear",
1191             new String[] { warModule, jarSampleTwoLibrary, jarSampleThreeLibrary, jarSampleFourTestLibrary },
1192             new boolean[] { false, false, false, false },
1193             new String[] { warModule },
1194             new boolean[] { false },
1195             new String[][] { { jarSampleFourTestLibrary, jarSampleThreeLibrary, jarSampleTwoLibrary } },
1196             true );
1197     }
1198 
1199     /**
1200      * Ensures that test JAR dependency representing Java module is described in deployment descriptor
1201      * if includeInApplicationXml property of module is {@code true}.
1202      */
1203     public void testProject096()
1204         throws Exception
1205     {
1206         final String warModule = "eartest-war-sample-two-1.0.war";
1207         final String jarSampleTwoLibrary = "eartest-jar-sample-two-1.0.jar";
1208         final String jarSampleThreeLibrary = "eartest-jar-sample-three-with-deps-1.0.jar";
1209         final String jarSampleFourTestLibrary = "eartest-jar-sample-four-1.0-tests.jar";
1210         final String jarSampleFiveLibrary = "eartest-jar-sample-five-1.0.jar";
1211         doTestProject( "project-096", "ear",
1212             new String[] { warModule, jarSampleTwoLibrary, jarSampleThreeLibrary, jarSampleFourTestLibrary, jarSampleFiveLibrary },
1213             new boolean[] { false, false, false, false, false },
1214             new String[] { warModule },
1215             new boolean[] { false },
1216             new String[][] { { jarSampleFourTestLibrary, jarSampleFiveLibrary, jarSampleThreeLibrary, jarSampleTwoLibrary } },
1217             true );
1218     }
1219 
1220     /**
1221      * Ensures that artifacts with jboss-sar, jboss-har and jboss-par types are packaged in EAR and
1222      * described in deployment descriptor when respective types are configured for EAR modules.
1223      */
1224     public void testProject097()
1225         throws Exception
1226     {
1227         final String warModule = "eartest-war-sample-three-1.0.war";
1228         final String sarSampleTwo = "eartest-sar-sample-two-1.0.sar";
1229         final String harSampleTwo = "eartest-har-sample-two-1.0.har";
1230         final String parSampleTwo = "eartest-par-sample-one-1.0.par";
1231         final String[] artifacts = { warModule, sarSampleTwo, harSampleTwo, parSampleTwo };
1232         final boolean[] artifactsDirectory = { false, false, false, false };
1233         doTestProject( "project-097", "ear", artifacts, artifactsDirectory, null, null, null , true );
1234     }
1235 
1236     /**
1237      * Ensures that when skinnyModules option is turned on then
1238      * <ul>
1239      * <li>EAR module whose classPathItem property is {@code false} is removed from the Class-Path entry of
1240      * MANIFEST.mf of other modules</li>
1241      * <li>EAR module whose classPathItem property is {@code true} is added into the Class-Path entry of MANIFEST.mf
1242      * or existing reference is updated to match location of the module</li>
1243      * <li>EAR module is removed from WARs and RARs (from modules which include their dependencies)</li>
1244      * </ul>
1245      */
1246     public void testProject098()
1247         throws Exception
1248     {
1249         final String projectName = "project-098";
1250         final String earModuleName = "ear";
1251         final String jarSampleOneLibrary = "jar-sample-one-1.0.jar";
1252         final String jarSampleTwoLibrary = "jar-sample-two-1.0.jar";
1253         final String jarSampleThreeLibrary = "jar-sample-three-with-deps-1.0.jar";
1254         final String ejbFourClientLibrary = "ejb-sample-four-1.0-client.jar";
1255         final String jarSampleOneEarLibrary = "lib/eartest-" + jarSampleOneLibrary;
1256         final String jarSampleTwoEarLibrary = "lib/eartest-" + jarSampleTwoLibrary;
1257         final String jarSampleThreeEarLibrary = "lib/eartest-" + jarSampleThreeLibrary;
1258         final String ejbFourClientEarLibrary = "lib/eartest-" + ejbFourClientLibrary;
1259         final String ejbThreeLibrary = "ejb-sample-three-1.0.jar";
1260         final String ejbFourLibrary = "ejb-sample-four-1.0.jar";
1261         final String ejbThreeModule = "eartest-" + ejbThreeLibrary;
1262         final String ejbFourModule = "eartest-" + ejbFourLibrary;
1263         final String rarLibrary = "rar-sample-one-1.0.rar";
1264         final String rarModule = "eartest-" + rarLibrary;
1265         final String warModule = "eartest-war-sample-three-1.0.war";
1266         final String[] earModules = { ejbThreeModule, ejbFourModule, rarModule, warModule };
1267         final boolean[] earModuleDirectory = { false, false, false, false };
1268         final String warModuleLibDir = "WEB-INF/lib/";
1269         final String rarModuleLibDir = "";
1270 
1271         final File baseDir = doTestProject( projectName, earModuleName,
1272             new String[] { ejbThreeModule, ejbFourModule, rarModule, warModule,
1273                 jarSampleOneEarLibrary, jarSampleTwoEarLibrary, jarSampleThreeEarLibrary, ejbFourClientEarLibrary },
1274             new boolean[] { false, false, false, false, false, false, false, false },
1275             earModules, earModuleDirectory,
1276             new String[][] {
1277                 { jarSampleThreeEarLibrary, jarSampleTwoEarLibrary, ejbFourClientEarLibrary, jarSampleOneEarLibrary },
1278                 { jarSampleOneEarLibrary, jarSampleTwoEarLibrary, jarSampleThreeEarLibrary, ejbFourClientEarLibrary },
1279                 { jarSampleThreeEarLibrary, jarSampleTwoEarLibrary, jarSampleOneEarLibrary, ejbFourClientEarLibrary },
1280                 { jarSampleOneEarLibrary, jarSampleThreeEarLibrary, jarSampleTwoEarLibrary, ejbFourClientEarLibrary } },
1281             true );
1282 
1283         assertEarModulesContent( baseDir, projectName, earModuleName, earModules, earModuleDirectory,
1284             new String[][] { null, null, null, { warModuleLibDir } },
1285             new String[][] { null, null,
1286                 {
1287                     rarModuleLibDir + jarSampleTwoLibrary,
1288                     rarModuleLibDir + jarSampleThreeLibrary,
1289                     rarModuleLibDir + ejbFourLibrary,
1290                     rarModuleLibDir + ejbFourClientLibrary,
1291                 },
1292                 {
1293                     warModuleLibDir + jarSampleOneLibrary,
1294                     rarModuleLibDir + jarSampleThreeLibrary,
1295                     rarModuleLibDir + jarSampleTwoLibrary,
1296                     warModuleLibDir + ejbThreeLibrary,
1297                     warModuleLibDir + ejbFourLibrary,
1298                     warModuleLibDir + ejbFourClientLibrary,
1299                     warModuleLibDir + rarLibrary,
1300                     warModuleLibDir + rarLibrary
1301                 } } );
1302     }
1303 
1304     /**
1305      * Builds an EAR with deployment descriptor configuration for JakartaEE 9.
1306      */
1307     public void testProject099()
1308             throws Exception
1309     {
1310         doTestProject( "project-099", new String[] { "eartest-ejb-sample-one-1.0.jar" } );
1311     }
1312 
1313     /**
1314      * Builds an EAR with deployment descriptor configuration for JakartaEE 10.
1315      */
1316     public void testProject100()
1317             throws Exception
1318     {
1319         doTestProject( "project-100", new String[] { "eartest-ejb-sample-one-1.0.jar" } );
1320     }
1321 
1322     /**
1323      * Ensure that {@code defaultLibBundleDir} with dot at begin don't remove artifacts during second execution.
1324      */
1325     public void testProject101() throws Exception
1326     {
1327         String[] expectedArtifacts = new String[] {
1328             "eartest-jar-sample-one-1.0.jar", "eartest-jar-sample-two-1.0.jar", "eartest-jar-sample-three-with-deps-1.0.jar" };
1329 
1330         boolean[] artifactsDirectory = new boolean[expectedArtifacts.length];
1331 
1332         doTestProject( "project-101", expectedArtifacts, true );
1333         doTestProject( "project-101", expectedArtifacts, false );
1334     }
1335 }