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.war;
20  
21  import java.io.File;
22  import java.text.SimpleDateFormat;
23  import java.util.LinkedList;
24  import java.util.Locale;
25  
26  import org.apache.maven.artifact.handler.ArtifactHandler;
27  import org.apache.maven.plugin.testing.stubs.ArtifactStub;
28  import org.apache.maven.plugins.war.stub.AarArtifactStub;
29  import org.apache.maven.plugins.war.stub.EJBArtifactStub;
30  import org.apache.maven.plugins.war.stub.EJBArtifactStubWithClassifier;
31  import org.apache.maven.plugins.war.stub.EJBClientArtifactStub;
32  import org.apache.maven.plugins.war.stub.IncludeExcludeWarArtifactStub;
33  import org.apache.maven.plugins.war.stub.JarArtifactStub;
34  import org.apache.maven.plugins.war.stub.MarArtifactStub;
35  import org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub;
36  import org.apache.maven.plugins.war.stub.MavenProjectBasicStub;
37  import org.apache.maven.plugins.war.stub.PARArtifactStub;
38  import org.apache.maven.plugins.war.stub.ResourceStub;
39  import org.apache.maven.plugins.war.stub.TLDArtifactStub;
40  import org.apache.maven.plugins.war.stub.WarArtifactStub;
41  import org.apache.maven.plugins.war.stub.XarArtifactStub;
42  import org.codehaus.plexus.util.FileUtils;
43  
44  import static org.junit.Assert.assertNotEquals;
45  
46  public class WarExplodedMojoTest extends AbstractWarExplodedMojoTest {
47  
48      protected File getPomFile() {
49          return new File(getBasedir(), "/target/test-classes/unit/warexplodedmojo/plugin-config.xml");
50      }
51  
52      protected File getTestDirectory() {
53          return new File(getBasedir(), "target/test-classes/unit/warexplodedmojo/test-dir");
54      }
55  
56      /**
57       * @throws Exception in case of an error.
58       */
59      public void testSimpleExplodedWar() throws Exception {
60          // setup test data
61          String testId = "SimpleExplodedWar";
62          MavenProjectBasicStub project = new MavenProjectBasicStub();
63          File webAppSource = createWebAppSource(testId);
64          File classesDir = createClassesDir(testId, false);
65          File webAppResource = new File(getTestDirectory(), testId + "-resources");
66          File webAppDirectory = new File(getTestDirectory(), testId);
67          File sampleResource = new File(webAppResource, "pix/panis_na.jpg");
68          ResourceStub[] resources = new ResourceStub[] {new ResourceStub()};
69  
70          createFile(sampleResource);
71  
72          assertTrue("sampeResource not found", sampleResource.exists());
73  
74          // configure mojo
75          resources[0].setDirectory(webAppResource.getAbsolutePath());
76          this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
77          setVariableValueToObject(mojo, "webResources", resources);
78          mojo.execute();
79  
80          // validate operation
81          File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
82          File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
83          File expectedWebResourceFile = new File(webAppDirectory, "pix/panis_na.jpg");
84          File expectedWEBINFDir = new File(webAppDirectory, "WEB-INF");
85          File expectedMETAINFDir = new File(webAppDirectory, "META-INF");
86  
87          assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
88          assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
89          assertTrue("resources doesn't exist: " + expectedWebResourceFile, expectedWebResourceFile.exists());
90          assertTrue("WEB-INF not found", expectedWEBINFDir.exists());
91          assertTrue("META-INF not found", expectedMETAINFDir.exists());
92  
93          // house keeping
94          expectedWebSourceFile.delete();
95          expectedWebSource2File.delete();
96          expectedWebResourceFile.delete();
97      }
98  
99      /**
100      * @throws Exception in case of an error.
101      */
102     public void testSimpleExplodedWarWTargetPath() throws Exception {
103         // setup test data
104         String testId = "SimpleExplodedWar";
105         MavenProjectBasicStub project = new MavenProjectBasicStub();
106         File webAppSource = createWebAppSource(testId);
107         File classesDir = createClassesDir(testId, false);
108         File webAppResource = new File(getTestDirectory(), "resources");
109         File webAppDirectory = new File(getTestDirectory(), testId);
110         File sampleResource = new File(webAppResource, "pix/panis_na.jpg");
111         ResourceStub[] resources = new ResourceStub[] {new ResourceStub()};
112 
113         createFile(sampleResource);
114 
115         // configure mojo
116         resources[0].setDirectory(webAppResource.getAbsolutePath());
117         resources[0].setTargetPath("targetPath");
118         this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
119         setVariableValueToObject(mojo, "webResources", resources);
120         mojo.execute();
121 
122         // validate operation
123         File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
124         File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
125         File expectedWebResourceFile = new File(webAppDirectory, "targetPath/pix/panis_na.jpg");
126         File expectedWEBINFDir = new File(webAppDirectory, "WEB-INF");
127         File expectedMETAINFDir = new File(webAppDirectory, "META-INF");
128 
129         assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
130         assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
131         assertTrue("resources doesn't exist: " + expectedWebResourceFile, expectedWebResourceFile.exists());
132         assertTrue("WEB-INF not found", expectedWEBINFDir.exists());
133         assertTrue("META-INF not found", expectedMETAINFDir.exists());
134 
135         // house keeping
136         expectedWebSourceFile.delete();
137         expectedWebSource2File.delete();
138         expectedWebResourceFile.delete();
139     }
140 
141     /**
142      * @throws Exception in case of an error.
143      */
144     public void testExplodedWar_WithCustomWebXML() throws Exception {
145         // setup test data
146         String testId = "ExplodedWar_WithCustomWebXML";
147         MavenProjectBasicStub project = new MavenProjectBasicStub();
148         File webAppSource = createWebAppSource(testId);
149         File classesDir = createClassesDir(testId, true);
150         File xmlSource = createXMLConfigDir(testId, new String[] {"web.xml"});
151         File webAppDirectory = new File(getTestDirectory(), testId);
152 
153         // configure mojo
154         this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
155         mojo.setWebXml(new File(xmlSource, "web.xml"));
156         mojo.execute();
157 
158         // validate operation
159         File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
160         File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
161         File expectedWEBXMLFile = new File(webAppDirectory, "WEB-INF/web.xml");
162         File expectedMETAINFDir = new File(webAppDirectory, "META-INF");
163 
164         assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
165         assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
166         assertTrue("WEB XML not found: " + expectedWEBXMLFile.toString(), expectedWEBXMLFile.exists());
167         assertTrue("META-INF not found", expectedMETAINFDir.exists());
168         assertEquals("WEB XML not correct", mojo.getWebXml().toString(), FileUtils.fileRead(expectedWEBXMLFile));
169 
170         // house keeping
171         expectedWebSourceFile.delete();
172         expectedWebSource2File.delete();
173         expectedWEBXMLFile.delete();
174         expectedMETAINFDir.delete();
175     }
176 
177     /**
178      * @throws Exception in case of an error.
179      */
180     public void testExplodedWar_WithContainerConfigXML() throws Exception {
181         // setup test data
182         String testId = "ExplodedWar_WithContainerConfigXML";
183         MavenProjectBasicStub project = new MavenProjectBasicStub();
184         File classesDir = createClassesDir(testId, true);
185         File webAppSource = createWebAppSource(testId);
186         File xmlSource = createXMLConfigDir(testId, new String[] {"config.xml"});
187         File webAppDirectory = new File(getTestDirectory(), testId);
188 
189         // configure mojo
190         this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
191         mojo.setContainerConfigXML(new File(xmlSource, "config.xml"));
192         mojo.execute();
193 
194         // validate operation
195         File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
196         File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
197         File expectedContainerConfigXMLFile = new File(webAppDirectory, "META-INF/config.xml");
198         File expectedWEBINFDir = new File(webAppDirectory, "WEB-INF");
199 
200         assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
201         assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
202         assertTrue("WEB-INF not found", expectedWEBINFDir.exists());
203         assertTrue(
204                 "Container Config XML not found:" + expectedContainerConfigXMLFile.toString(),
205                 expectedContainerConfigXMLFile.exists());
206 
207         // house keeping
208         expectedWebSourceFile.delete();
209         expectedWebSource2File.delete();
210         expectedContainerConfigXMLFile.delete();
211         expectedWEBINFDir.delete();
212     }
213 
214     /**
215      * @throws Exception in case of an error.
216      */
217     public void testExplodedWar_WithSimpleExternalWARFile() throws Exception {
218         // setup test data
219         MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
220         WarArtifactStub warArtifact = new WarArtifactStub(getBasedir());
221 
222         String testId = "ExplodedWar_WithSimpleExternalWARFile";
223         File webAppDirectory = new File(getTestDirectory(), testId);
224         File webAppSource = createWebAppSource(testId);
225         File classesDir = createClassesDir(testId, true);
226         File workDirectory = new File(getTestDirectory(), "/war/work-" + testId);
227         File simpleWarFile = warArtifact.getFile();
228 
229         assertTrue("simple war not found: " + simpleWarFile.toString(), simpleWarFile.exists());
230 
231         createDir(workDirectory);
232 
233         // configure mojo
234         project.addArtifact(warArtifact);
235         this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
236         setVariableValueToObject(mojo, "workDirectory", workDirectory);
237         mojo.execute();
238 
239         // validate operation - META-INF is automatically excluded so remove the file from the list
240         File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
241         File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
242         File expectedWEBXMLFile = new File(webAppDirectory, "WEB-INF/web.xml");
243         File expectedWARFile = new File(webAppDirectory, "/org/sample/company/test.jsp");
244 
245         assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
246         assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
247         // check simple.war in the unit test dir under resources to verify the list of files
248         assertTrue("web xml not found: " + expectedWEBXMLFile.toString(), expectedWEBXMLFile.exists());
249         assertTrue("war file not found: " + expectedWARFile.toString(), expectedWARFile.exists());
250 
251         // house keeping
252         expectedWebSourceFile.delete();
253         expectedWebSource2File.delete();
254         expectedWEBXMLFile.delete();
255         expectedWARFile.delete();
256     }
257 
258     /**
259      * Merge a dependent WAR when a file in the war source directory overrides one found in the WAR.
260      * @throws Exception in case of an error.
261      */
262     public void testExplodedWarMergeWarLocalFileOverride() throws Exception {
263         // setup test data
264         MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
265         WarArtifactStub warArtifact = new WarArtifactStub(getBasedir());
266 
267         String testId = "testExplodedWarMergeWarLocalFileOverride";
268         File webAppDirectory = new File(getTestDirectory(), testId);
269         File webAppSource = getWebAppSource(testId);
270         File simpleJSP = new File(webAppSource, "org/sample/company/test.jsp");
271         createFile(simpleJSP);
272 
273         File workDirectory = new File(getTestDirectory(), "/war/work-" + testId);
274         createDir(workDirectory);
275 
276         File classesDir = createClassesDir(testId, true);
277 
278         // configure mojo
279         project.addArtifact(warArtifact);
280         this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
281         setVariableValueToObject(mojo, "workDirectory", workDirectory);
282         mojo.execute();
283 
284         // validate operation
285         File expectedFile = new File(webAppDirectory, "/org/sample/company/test.jsp");
286 
287         assertTrue("file not found: " + expectedFile.toString(), expectedFile.exists());
288         assertEquals("file incorrect", simpleJSP.toString(), FileUtils.fileRead(expectedFile));
289 
290         // check when the merged war file is newer - so set an old time on the local file
291         long time =
292                 new SimpleDateFormat("yyyy-MM-dd", Locale.US).parse("2005-1-1").getTime();
293         simpleJSP.setLastModified(time);
294         expectedFile.setLastModified(time);
295 
296         project.addArtifact(warArtifact);
297         this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
298         setVariableValueToObject(mojo, "workDirectory", workDirectory);
299         mojo.execute();
300 
301         assertTrue("file not found: " + expectedFile.toString(), expectedFile.exists());
302         assertEquals("file incorrect", simpleJSP.toString(), FileUtils.fileRead(expectedFile));
303 
304         // house keeping
305         expectedFile.delete();
306     }
307 
308     // The last modified thingy behavior is not applicable anymore. This is the only test that
309     // has been removed.
310     // /**
311     // * Merge a dependent WAR that gets updated since the last run.
312     // */
313     // public void testExplodedWarMergeWarUpdated()
314     // throws Exception
315     // {
316     // // setup test data
317     // MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
318     // WarArtifactStub warArtifact = new WarArtifactStub( getBasedir() );
319     //
320     // String testId = "testExplodedWarMergeWarUpdated";
321     // File webAppDirectory = new File( getTestDirectory(), testId );
322     // FileUtils.deleteDirectory( webAppDirectory );
323     //
324     // File webAppSource = getWebAppSource( testId );
325     //
326     // File workDirectory = new File( getTestDirectory(), "/war/work-" + testId );
327     // createDir( workDirectory );
328     //
329     // File classesDir = createClassesDir( testId, true );
330     //
331     // // configure mojo
332     // project.addArtifact( warArtifact );
333     // this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
334     // setVariableValueToObject( mojo, "workDirectory", workDirectory );
335     // mojo.execute();
336     //
337     // // validate operation
338     // File expectedFile = new File( webAppDirectory, "/org/sample/company/test.jsp" );
339     //
340     // assertTrue( "file not found: " + expectedFile.toString(), expectedFile.exists() );
341     // assertEquals( "file incorrect", "", FileUtils.fileRead( expectedFile ) );
342     //
343     // // update file, so the local one is older
344     // warArtifact.setFile( new File( warArtifact.getFile().getParentFile(), "simple-updated.war" ) );
345     //
346     // mojo.execute();
347     //
348     // assertTrue( "file not found: " + expectedFile.toString(), expectedFile.exists() );
349     // assertEquals( "file incorrect", "updated\n", FileUtils.fileRead( expectedFile ) );
350     //
351     // // update file, so the local one is newer
352     // warArtifact.setFile( new File( warArtifact.getFile().getParentFile(), "simple.war" ) );
353     //
354     // mojo.execute();
355     //
356     // assertTrue( "file not found: " + expectedFile.toString(), expectedFile.exists() );
357     // assertEquals( "file incorrect", "updated\n", FileUtils.fileRead( expectedFile ) );
358     //
359     // // house keeping
360     // expectedFile.delete();
361     // }
362 
363     /**
364      * @throws Exception in case of an error.
365      */
366     public void testExplodedWar_WithEJB() throws Exception {
367         // setup test data
368         String testId = "ExplodedWar_WithEJB";
369         MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
370         File webAppDirectory = new File(getTestDirectory(), testId);
371         File webAppSource = createWebAppSource(testId);
372         File classesDir = createClassesDir(testId, true);
373         EJBArtifactStub ejbArtifact = new EJBArtifactStub(getBasedir());
374         File ejbFile = ejbArtifact.getFile();
375 
376         assertTrue("ejb jar not found: " + ejbFile.toString(), ejbFile.exists());
377 
378         // configure mojo
379         project.addArtifact(ejbArtifact);
380         this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
381         mojo.execute();
382 
383         // validate operation
384         File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
385         File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
386         // final name form is <artifactId>-<version>.<type>
387         File expectedEJBArtifact = new File(webAppDirectory, "WEB-INF/lib/ejbartifact-0.0-Test.jar");
388         // File expectedEJBArtifact = new File( webAppDirectory, "WEB-INF/lib/ejbartifact-0.0-Test.jar" );
389 
390         assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
391         assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
392         assertTrue("ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists());
393 
394         // house keeping
395         expectedWebSourceFile.delete();
396         expectedWebSource2File.delete();
397         expectedEJBArtifact.delete();
398     }
399 
400     public void testExplodedWarWithJar() throws Exception {
401         // setup test data
402         String testId = "ExplodedWarWithJar";
403         MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
404         File webAppDirectory = new File(getTestDirectory(), testId);
405         File webAppSource = createWebAppSource(testId);
406         File classesDir = createClassesDir(testId, true);
407         ArtifactHandler artifactHandler = (ArtifactHandler) lookup(ArtifactHandler.ROLE, "jar");
408         ArtifactStub jarArtifact = new JarArtifactStub(getBasedir(), artifactHandler);
409         File jarFile = jarArtifact.getFile();
410 
411         assertTrue("jar not found: " + jarFile.toString(), jarFile.exists());
412 
413         // configure mojo
414         project.addArtifact(jarArtifact);
415         this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
416         mojo.execute();
417 
418         // validate operation
419         File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
420         File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
421         // final name form is <artifactId>-<version>.<type>
422         File expectedJarArtifact = new File(webAppDirectory, "WEB-INF/lib/jarartifact-0.0-Test.jar");
423 
424         assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
425         assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
426         assertTrue("jar artifact not found: " + expectedJarArtifact.toString(), expectedJarArtifact.exists());
427 
428         // house keeping
429         expectedWebSourceFile.delete();
430         expectedWebSource2File.delete();
431         expectedJarArtifact.delete();
432     }
433 
434     /**
435      * @throws Exception in case of an error.
436      */
437     public void testExplodedWar_WithEJBClient() throws Exception {
438         // setup test data
439         String testId = "ExplodedWar_WithEJB";
440         MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
441         File webAppDirectory = new File(getTestDirectory(), testId);
442         File webAppSource = createWebAppSource(testId);
443         File classesDir = createClassesDir(testId, true);
444         EJBClientArtifactStub ejbArtifact = new EJBClientArtifactStub(getBasedir());
445         File ejbFile = ejbArtifact.getFile();
446 
447         assertTrue("ejb jar not found: " + ejbFile.toString(), ejbFile.exists());
448 
449         // configure mojo
450         project.addArtifact(ejbArtifact);
451         this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
452         mojo.execute();
453 
454         // validate operation
455         File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
456         File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
457         // final name form is <artifactId>-<version>.<type>
458         File expectedEJBArtifact = new File(webAppDirectory, "WEB-INF/lib/ejbclientartifact-0.0-Test-client.jar");
459 
460         assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
461         assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
462         assertTrue("ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists());
463 
464         // house keeping
465         expectedWebSourceFile.delete();
466         expectedWebSource2File.delete();
467         expectedEJBArtifact.delete();
468     }
469 
470     /**
471      * @throws Exception in case of an error.
472      */
473     public void testExplodedWar_WithTLD() throws Exception {
474         // setup test data
475         String testId = "ExplodedWar_WithTLD";
476         MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
477         File webAppDirectory = new File(getTestDirectory(), testId);
478         File webAppSource = createWebAppSource(testId);
479         File classesDir = createClassesDir(testId, true);
480         TLDArtifactStub tldArtifact = new TLDArtifactStub(getBasedir());
481         File tldFile = tldArtifact.getFile();
482 
483         assertTrue("tld jar not found: " + tldFile.getAbsolutePath(), tldFile.exists());
484 
485         // configure mojo
486         project.addArtifact(tldArtifact);
487         this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
488         mojo.execute();
489 
490         // validate operation
491         File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
492         File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
493         // final name form is <artifactId>-<version>.<type>
494         File expectedTLDArtifact = new File(webAppDirectory, "WEB-INF/tld/tldartifact-0.0-Test.tld");
495 
496         assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
497         assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
498         assertTrue("tld artifact not found: " + expectedTLDArtifact.toString(), expectedTLDArtifact.exists());
499 
500         // house keeping
501         expectedWebSourceFile.delete();
502         expectedWebSource2File.delete();
503         expectedTLDArtifact.delete();
504     }
505 
506     /**
507      * @throws Exception in case of an error.
508      */
509     public void testExplodedWar_WithPAR() throws Exception {
510         // setup test data
511         String testId = "ExplodedWar_WithPAR";
512         MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
513         File webAppDirectory = new File(getTestDirectory(), testId);
514         File webAppSource = createWebAppSource(testId);
515         File classesDir = createClassesDir(testId, true);
516         PARArtifactStub parartifact = new PARArtifactStub(getBasedir());
517         File parFile = parartifact.getFile();
518 
519         assertTrue("par not found: " + parFile.getAbsolutePath(), parFile.exists());
520 
521         // configure mojo
522         project.addArtifact(parartifact);
523         this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
524         mojo.execute();
525 
526         // validate operation
527         File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
528         File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
529         // final name form is <artifactId>-<version>.<type>
530         File expectedPARArtifact = new File(webAppDirectory, "WEB-INF/lib/parartifact-0.0-Test.jar");
531 
532         assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
533         assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
534         assertTrue("par artifact not found: " + expectedPARArtifact.toString(), expectedPARArtifact.exists());
535 
536         // house keeping
537         expectedWebSourceFile.delete();
538         expectedWebSource2File.delete();
539         expectedPARArtifact.delete();
540     }
541 
542     /**
543      * @throws Exception in case of an error.
544      */
545     public void testExplodedWarWithAar() throws Exception {
546         // setup test data
547         String testId = "ExplodedWarWithAar";
548         MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
549         File webAppDirectory = new File(getTestDirectory(), testId);
550         File webAppSource = createWebAppSource(testId);
551         File classesDir = createClassesDir(testId, true);
552         // Fake here since the aar artifact handler does not exist: no biggie
553         ArtifactHandler artifactHandler = (ArtifactHandler) lookup(ArtifactHandler.ROLE, "jar");
554         ArtifactStub aarArtifact = new AarArtifactStub(getBasedir(), artifactHandler);
555         File aarFile = aarArtifact.getFile();
556 
557         assertTrue("jar not found: " + aarFile.toString(), aarFile.exists());
558 
559         // configure mojo
560         project.addArtifact(aarArtifact);
561         this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
562         mojo.execute();
563 
564         // validate operation
565         File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
566         File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
567         // final name form is <artifactId>-<version>.<type>
568         File expectedJarArtifact = new File(webAppDirectory, "WEB-INF/services/aarartifact-0.0-Test.jar");
569 
570         assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
571         assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
572         assertTrue("jar artifact not found: " + expectedJarArtifact.toString(), expectedJarArtifact.exists());
573 
574         // house keeping
575         expectedWebSourceFile.delete();
576         expectedWebSource2File.delete();
577         expectedJarArtifact.delete();
578     }
579 
580     /**
581      * @throws Exception in case of an error.
582      */
583     public void testExplodedWarWithMar() throws Exception {
584         // setup test data
585         String testId = "ExplodedWarWithMar";
586         MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
587         File webAppDirectory = new File(getTestDirectory(), testId);
588         File webAppSource = createWebAppSource(testId);
589         File classesDir = createClassesDir(testId, true);
590         // Fake here since the mar artifact handler does not exist: no biggie
591         ArtifactHandler artifactHandler = (ArtifactHandler) lookup(ArtifactHandler.ROLE, "jar");
592         ArtifactStub marArtifact = new MarArtifactStub(getBasedir(), artifactHandler);
593         File marFile = marArtifact.getFile();
594 
595         assertTrue("jar not found: " + marFile.toString(), marFile.exists());
596 
597         // configure mojo
598         project.addArtifact(marArtifact);
599         this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
600         mojo.execute();
601 
602         // validate operation
603         File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
604         File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
605         // final name form is <artifactId>-<version>.<type>
606         File expectedJarArtifact = new File(webAppDirectory, "WEB-INF/modules/marartifact-0.0-Test.jar");
607 
608         assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
609         assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
610         assertTrue("jar artifact not found: " + expectedJarArtifact.toString(), expectedJarArtifact.exists());
611 
612         // house keeping
613         expectedWebSourceFile.delete();
614         expectedWebSource2File.delete();
615         expectedJarArtifact.delete();
616     }
617 
618     /**
619      * @throws Exception in case of an error.
620      */
621     public void testExplodedWarWithXar() throws Exception {
622         // setup test data
623         String testId = "ExplodedWarWithXar";
624         MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
625         File webAppDirectory = new File(getTestDirectory(), testId);
626         File webAppSource = createWebAppSource(testId);
627         File classesDir = createClassesDir(testId, true);
628         // Fake here since the xar artifact handler does not exist: no biggie
629         ArtifactHandler artifactHandler = (ArtifactHandler) lookup(ArtifactHandler.ROLE, "jar");
630         ArtifactStub xarArtifact = new XarArtifactStub(getBasedir(), artifactHandler);
631         File xarFile = xarArtifact.getFile();
632 
633         assertTrue("jar not found: " + xarFile.toString(), xarFile.exists());
634 
635         // configure mojo
636         project.addArtifact(xarArtifact);
637         this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
638         mojo.execute();
639 
640         // validate operation
641         File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
642         File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
643         // final name form is <artifactId>-<version>.<type>
644         File expectedJarArtifact = new File(webAppDirectory, "WEB-INF/extensions/xarartifact-0.0-Test.jar");
645 
646         assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
647         assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
648         assertTrue("jar artifact not found: " + expectedJarArtifact.toString(), expectedJarArtifact.exists());
649 
650         // house keeping
651         expectedWebSourceFile.delete();
652         expectedWebSource2File.delete();
653         expectedJarArtifact.delete();
654     }
655 
656     /**
657      * @throws Exception in case of an error.
658      */
659     public void testExplodedWar_WithDuplicateDependencies() throws Exception {
660         // setup test data
661         String testId = "ExplodedWar_WithDuplicateDependencies";
662         MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
663         File webAppDirectory = new File(getTestDirectory(), testId);
664         File webAppSource = createWebAppSource(testId);
665         File classesDir = createClassesDir(testId, true);
666         EJBArtifactStub ejbArtifact = new EJBArtifactStub(getBasedir());
667         EJBArtifactStub ejbArtifactDup = new EJBArtifactStub(getBasedir());
668         File ejbFile = ejbArtifact.getFile();
669 
670         // ejbArtifact has a hard coded file, only one assert is needed
671         assertTrue("ejb not found: " + ejbFile.getAbsolutePath(), ejbFile.exists());
672 
673         // configure mojo
674         ejbArtifact.setGroupId("org.sample.ejb");
675         ejbArtifactDup.setGroupId("org.dup.ejb");
676         project.addArtifact(ejbArtifact);
677         project.addArtifact(ejbArtifactDup);
678         this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
679         mojo.execute();
680 
681         // validate operation
682         File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
683         File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
684         // final name form is <artifactId>-<version>.<type>
685         File expectedEJBArtifact = new File(webAppDirectory, "WEB-INF/lib/org.sample.ejb-ejbartifact-0.0-Test.jar");
686         File expectedEJBDupArtifact = new File(webAppDirectory, "WEB-INF/lib/org.dup.ejb-ejbartifact-0.0-Test.jar");
687 
688         assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
689         assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
690         assertTrue("ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists());
691         assertTrue("ejb dup artifact not found: " + expectedEJBDupArtifact.toString(), expectedEJBDupArtifact.exists());
692 
693         // house keeping
694         expectedWebSourceFile.delete();
695         expectedWebSource2File.delete();
696         expectedEJBArtifact.delete();
697         expectedEJBDupArtifact.delete();
698     }
699 
700     /**
701      * @throws Exception in case of an error.
702      */
703     public void testExplodedWar_DuplicateWithClassifier() throws Exception {
704         // setup test data
705         String testId = "ExplodedWar_DuplicateWithClassifier";
706         MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
707         File webAppDirectory = new File(getTestDirectory(), testId);
708         File webAppSource = createWebAppSource(testId);
709         File classesDir = createClassesDir(testId, true);
710         EJBArtifactStub ejbArtifact = new EJBArtifactStub(getBasedir());
711         EJBArtifactStubWithClassifier ejbArtifactDup = new EJBArtifactStubWithClassifier(getBasedir());
712 
713         File ejbFile = ejbArtifact.getFile();
714 
715         // ejbArtifact has a hard coded file, only one assert is needed
716         assertTrue("ejb not found: " + ejbFile.getAbsolutePath(), ejbFile.exists());
717 
718         // configure mojo
719 
720         ejbArtifact.setGroupId("org.sample.ejb");
721         ejbArtifactDup.setGroupId("org.sample.ejb");
722 
723         ejbArtifactDup.setClassifier("classifier");
724 
725         project.addArtifact(ejbArtifact);
726         project.addArtifact(ejbArtifactDup);
727 
728         this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
729         mojo.execute();
730 
731         // validate operation
732         File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
733         File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
734         // final name form is <artifactId>-<version>.<type>
735         File expectedEJBArtifact = new File(webAppDirectory, "WEB-INF/lib/ejbartifact-0.0-Test.jar");
736         File expectedEJBDupArtifact = new File(webAppDirectory, "WEB-INF/lib/ejbartifact-0.0-Test-classifier.jar");
737 
738         assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
739         assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
740         assertTrue("ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists());
741         assertTrue("ejb dup artifact not found: " + expectedEJBDupArtifact.toString(), expectedEJBDupArtifact.exists());
742 
743         // house keeping
744         expectedWebSourceFile.delete();
745         expectedWebSource2File.delete();
746         expectedEJBArtifact.delete();
747         expectedEJBDupArtifact.delete();
748     }
749 
750     /**
751      * @throws Exception in case of an error.
752      */
753     public void testExplodedWar_WithClasses() throws Exception {
754         // setup test data
755         String testId = "ExplodedWar_WithClasses";
756         MavenProjectBasicStub project = new MavenProjectBasicStub();
757         File webAppDirectory = new File(getTestDirectory(), testId);
758         File webAppSource = createWebAppSource(testId);
759         File classesDir = createClassesDir(testId, false);
760 
761         // configure mojo
762         this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
763         mojo.execute();
764 
765         // validate operation
766         File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
767         File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
768         // final name form is <artifactId>-<version>.<type>
769         File expectedClass = new File(webAppDirectory, "WEB-INF/classes/sample-servlet.clazz");
770 
771         assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
772         assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
773         assertTrue("classes not found: " + expectedClass.toString(), expectedClass.exists());
774 
775         // house keeping
776         expectedWebSourceFile.delete();
777         expectedWebSource2File.delete();
778         expectedClass.delete();
779     }
780 
781     /**
782      * @throws Exception in case of an error.
783      */
784     public void testExplodedWar_WithSourceIncludeExclude() throws Exception {
785         // setup test data
786         String testId = "ExplodedWar_WithSourceIncludeExclude";
787         MavenProjectBasicStub project = new MavenProjectBasicStub();
788         File webAppSource = createWebAppSource(testId);
789         File classesDir = createClassesDir(testId, true);
790         File webAppDirectory = new File(getTestDirectory(), testId);
791 
792         // configure mojo
793         this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
794         setVariableValueToObject(mojo, "warSourceIncludes", "**/*sit.jsp");
795         setVariableValueToObject(mojo, "warSourceExcludes", "**/last*.*");
796         mojo.execute();
797 
798         // validate operation
799         File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
800         File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
801         File expectedWEBXMLDir = new File(webAppDirectory, "WEB-INF");
802         File expectedMETAINFDir = new File(webAppDirectory, "META-INF");
803 
804         assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
805         assertFalse("source files found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
806         assertTrue("WEB XML not found: " + expectedWEBXMLDir.toString(), expectedWEBXMLDir.exists());
807         assertTrue("META-INF not found", expectedMETAINFDir.exists());
808 
809         // house keeping
810         expectedWebSourceFile.delete();
811         expectedWebSource2File.delete();
812         expectedWEBXMLDir.delete();
813         expectedMETAINFDir.delete();
814     }
815 
816     /**
817      * @throws Exception in case of an error.
818      */
819     public void testExplodedWar_WithWarDependencyIncludeExclude() throws Exception {
820         // setup test data
821         String testId = "ExplodedWar_WithWarDependencyIncludeExclude";
822         MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
823         IncludeExcludeWarArtifactStub includeexcludeWarArtifact = new IncludeExcludeWarArtifactStub(getBasedir());
824         File webAppDirectory = new File(getTestDirectory(), testId);
825         File webAppSource = createWebAppSource(testId);
826         File classesDir = createClassesDir(testId, true);
827         File workDirectory = new File(getTestDirectory(), "/war/work-" + testId);
828         File includeExcludeWarFile = includeexcludeWarArtifact.getFile();
829 
830         assertTrue("war not found: " + includeExcludeWarFile.toString(), includeExcludeWarFile.exists());
831 
832         createDir(workDirectory);
833 
834         // configure mojo
835         project.addArtifact(includeexcludeWarArtifact);
836         this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
837         setVariableValueToObject(mojo, "dependentWarIncludes", "**/*Include.jsp,**/*.xml");
838         setVariableValueToObject(mojo, "dependentWarExcludes", "**/*Exclude*,**/MANIFEST.MF");
839         setVariableValueToObject(mojo, "workDirectory", workDirectory);
840         mojo.execute();
841 
842         // validate operation
843         File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
844         File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
845         File expectedManifestFile = new File(webAppDirectory, "META-INF/MANIFEST.MF");
846         File expectedWEBXMLFile = new File(webAppDirectory, "WEB-INF/web.xml");
847         File expectedIncludedWARFile = new File(webAppDirectory, "/org/sample/company/testInclude.jsp");
848         File expectedExcludedWarfile = new File(webAppDirectory, "/org/sample/companyExclude/test.jsp");
849 
850         assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
851         assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
852         // check include-exclude.war in the unit test dir under resources to verify the list of files
853         assertTrue("web xml not found: " + expectedWEBXMLFile.toString(), expectedWEBXMLFile.exists());
854         assertFalse("manifest file found: " + expectedManifestFile.toString(), expectedManifestFile.exists());
855         assertTrue("war file not found: " + expectedIncludedWARFile.toString(), expectedIncludedWARFile.exists());
856         assertFalse("war file not found: " + expectedExcludedWarfile.toString(), expectedExcludedWarfile.exists());
857 
858         // house keeping
859         expectedWebSourceFile.delete();
860         expectedWebSource2File.delete();
861         expectedManifestFile.delete();
862         expectedWEBXMLFile.delete();
863         expectedIncludedWARFile.delete();
864         expectedExcludedWarfile.delete();
865     }
866 
867     /**
868      * @throws Exception in case of an error.
869      */
870     public void testExplodedWarWithSourceModificationCheck() throws Exception {
871         // setup test data
872         String testId = "ExplodedWarWithSourceModificationCheck";
873         MavenProjectBasicStub project = new MavenProjectBasicStub();
874         File webAppSource = createWebAppSource(testId);
875         File classesDir = createClassesDir(testId, false);
876         File webAppDirectory = new File(getTestDirectory(), testId);
877 
878         // configure mojo
879         this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
880 
881         // destination file is already created manually containing an "error" string
882         // source is newer than the destination file
883         mojo.execute();
884 
885         // validate operation
886 
887         File expectedWEBINFDir = new File(webAppDirectory, "WEB-INF");
888         File expectedMETAINFDir = new File(webAppDirectory, "META-INF");
889         File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
890         File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
891 
892         assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
893         assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
894         assertTrue("WEB-INF not found", expectedWEBINFDir.exists());
895         assertTrue("META-INF not found", expectedMETAINFDir.exists());
896 
897         // 1st phase destination is older than source
898         // destination starts with a value of error replaced with a blank source
899         assertNotEquals(
900                 "source files not updated with new copy: " + expectedWebSourceFile.toString(),
901                 "error",
902                 FileUtils.fileRead(expectedWebSourceFile));
903 
904         // TODO: uncomment when lastModified problem is resolved
905         // FileWriter writer = new FileWriter(expectedWebSourceFile);
906         //
907         // // 2nd phase destination is newer than source
908         // // destination should not be replaced with an blank source
909         // writer.write("newdata");
910         // mojo.execute();
911         // reader = new FileReader(expectedWebSourceFile);
912         // reader.read(data);
913         // assertTrue("source file updated with old copy: "
914         // +expectedWebSourceFile.toString(),String.valueOf(data).equals("newdata") ); }
915 
916         // house keeping
917         expectedWEBINFDir.delete();
918         expectedMETAINFDir.delete();
919         expectedWebSourceFile.delete();
920         expectedWebSource2File.delete();
921     }
922 
923     /**
924      * @throws Exception in case of an error.
925      */
926     public void testExplodedWarWithOutputFileNameMapping() throws Exception {
927         // setup test data
928         String testId = "ExplodedWarWithFileNameMapping";
929         MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
930         File webAppDirectory = new File(getTestDirectory(), testId);
931         File webAppSource = createWebAppSource(testId);
932         File classesDir = createClassesDir(testId, true);
933         ArtifactHandler artifactHandler = (ArtifactHandler) lookup(ArtifactHandler.ROLE, "jar");
934         ArtifactStub jarArtifact = new JarArtifactStub(getBasedir(), artifactHandler);
935         File jarFile = jarArtifact.getFile();
936 
937         assertTrue("jar not found: " + jarFile.toString(), jarFile.exists());
938 
939         // configure mojo
940         project.addArtifact(jarArtifact);
941         mojo.setOutputFileNameMapping("@{artifactId}@.@{extension}@");
942         this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
943         mojo.execute();
944 
945         // validate operation
946         File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
947         File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
948         // final name form is <artifactId>-<version>.<type>
949         File expectedJarArtifact = new File(webAppDirectory, "WEB-INF/lib/jarartifact.jar");
950 
951         assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
952         assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
953         assertTrue("jar artifact not found: " + expectedJarArtifact.toString(), expectedJarArtifact.exists());
954 
955         // house keeping
956         expectedWebSourceFile.delete();
957         expectedWebSource2File.delete();
958         expectedJarArtifact.delete();
959     }
960 
961     /**
962      * @throws Exception in case of an error.
963      */
964     public void testExplodedWarWithOutputFileNameMappingAndDuplicateDependencies() throws Exception {
965         // setup test data
966         String testId = "ExplodedWarWithFileNameMappingAndDuplicateDependencies";
967         MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
968         File webAppDirectory = new File(getTestDirectory(), testId);
969         File webAppSource = createWebAppSource(testId);
970         File classesDir = createClassesDir(testId, true);
971         EJBArtifactStub ejbArtifact = new EJBArtifactStub(getBasedir());
972         EJBArtifactStub ejbArtifactDup = new EJBArtifactStub(getBasedir());
973         File ejbFile = ejbArtifact.getFile();
974 
975         // ejbArtifact has a hard coded file, only one assert is needed
976         assertTrue("ejb not found: " + ejbFile.getAbsolutePath(), ejbFile.exists());
977 
978         // configure mojo
979         ejbArtifact.setGroupId("org.sample.ejb");
980         ejbArtifactDup.setGroupId("org.dup.ejb");
981         project.addArtifact(ejbArtifact);
982         project.addArtifact(ejbArtifactDup);
983         mojo.setOutputFileNameMapping("@{artifactId}@.@{extension}@");
984         this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
985         mojo.execute();
986 
987         // validate operation
988         File expectedWebSourceFile = new File(webAppDirectory, "pansit.jsp");
989         File expectedWebSource2File = new File(webAppDirectory, "org/web/app/last-exile.jsp");
990         // final name form is <artifactId>-<version>.<type>
991         File expectedEJBArtifact = new File(webAppDirectory, "WEB-INF/lib/org.sample.ejb-ejbartifact.jar");
992         File expectedEJBDupArtifact = new File(webAppDirectory, "WEB-INF/lib/org.dup.ejb-ejbartifact.jar");
993 
994         assertTrue("source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists());
995         assertTrue("source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists());
996         assertTrue("ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists());
997         assertTrue("ejb dup artifact not found: " + expectedEJBDupArtifact.toString(), expectedEJBDupArtifact.exists());
998 
999         // house keeping
1000         expectedWebSourceFile.delete();
1001         expectedWebSource2File.delete();
1002         expectedEJBArtifact.delete();
1003         expectedEJBDupArtifact.delete();
1004     }
1005 
1006     /* --------------------- 2.1 Overlay tests ----------------------------------- */
1007 
1008     /*---------------------------*/
1009 
1010 }