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