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(), 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(), 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(), 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(), 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(), 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(), 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(), 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(), 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(), 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(), 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(), 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(), 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(), 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(), 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(), 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(), 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(),
713                     expectedEJBDupArtifact.exists() );
714 
715         // house keeping
716         expectedWebSourceFile.delete();
717         expectedWebSource2File.delete();
718         expectedEJBArtifact.delete();
719         expectedEJBDupArtifact.delete();
720     }
721 
722     /**
723      * @throws Exception
724      */
725     public void testExplodedWar_DuplicateWithClassifier()
726         throws Exception
727     {
728         // setup test data
729         String testId = "ExplodedWar_DuplicateWithClassifier";
730         MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
731         File webAppDirectory = new File( getTestDirectory(), testId );
732         File webAppSource = createWebAppSource( testId );
733         File classesDir = createClassesDir( testId, true );
734         EJBArtifactStub ejbArtifact = new EJBArtifactStub( getBasedir() );
735         EJBArtifactStubWithClassifier ejbArtifactDup = new EJBArtifactStubWithClassifier( getBasedir() );
736 
737         File ejbFile = ejbArtifact.getFile();
738 
739         // ejbArtifact has a hard coded file, only one assert is needed
740         assertTrue( "ejb not found: " + ejbFile.getAbsolutePath(), ejbFile.exists() );
741 
742         // configure mojo
743 
744         ejbArtifact.setGroupId( "org.sample.ejb" );
745         ejbArtifactDup.setGroupId( "org.sample.ejb" );
746 
747         ejbArtifactDup.setClassifier( "classifier" );
748 
749         project.addArtifact( ejbArtifact );
750         project.addArtifact( ejbArtifactDup );
751 
752         this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
753         mojo.execute();
754 
755         // validate operation
756         File expectedWebSourceFile = new File( webAppDirectory, "pansit.jsp" );
757         File expectedWebSource2File = new File( webAppDirectory, "org/web/app/last-exile.jsp" );
758         // final name form is <artifactId>-<version>.<type>
759         File expectedEJBArtifact = new File( webAppDirectory, "WEB-INF/lib/ejbartifact-0.0-Test.jar" );
760         File expectedEJBDupArtifact = new File( webAppDirectory, "WEB-INF/lib/ejbartifact-0.0-Test-classifier.jar" );
761 
762         assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
763         assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
764         assertTrue( "ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists() );
765         assertTrue( "ejb dup artifact not found: " + expectedEJBDupArtifact.toString(),
766                     expectedEJBDupArtifact.exists() );
767 
768         // house keeping
769         expectedWebSourceFile.delete();
770         expectedWebSource2File.delete();
771         expectedEJBArtifact.delete();
772         expectedEJBDupArtifact.delete();
773     }
774 
775     /**
776      * @throws Exception
777      */
778     public void testExplodedWar_WithClasses()
779         throws Exception
780     {
781         // setup test data
782         String testId = "ExplodedWar_WithClasses";
783         MavenProjectBasicStub project = new MavenProjectBasicStub();
784         File webAppDirectory = new File( getTestDirectory(), testId );
785         File webAppSource = createWebAppSource( testId );
786         File classesDir = createClassesDir( testId, false );
787 
788         // configure mojo
789         this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
790         mojo.execute();
791 
792         // validate operation
793         File expectedWebSourceFile = new File( webAppDirectory, "pansit.jsp" );
794         File expectedWebSource2File = new File( webAppDirectory, "org/web/app/last-exile.jsp" );
795         // final name form is <artifactId>-<version>.<type>
796         File expectedClass = new File( webAppDirectory, "WEB-INF/classes/sample-servlet.class" );
797 
798         assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
799         assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
800         assertTrue( "classes not found: " + expectedClass.toString(), expectedClass.exists() );
801 
802         // house keeping
803         expectedWebSourceFile.delete();
804         expectedWebSource2File.delete();
805         expectedClass.delete();
806     }
807 
808     public void testExplodedWar_WithSourceIncludeExclude()
809         throws Exception
810     {
811         // setup test data
812         String testId = "ExplodedWar_WithSourceIncludeExclude";
813         MavenProjectBasicStub project = new MavenProjectBasicStub();
814         File webAppSource = createWebAppSource( testId );
815         File classesDir = createClassesDir( testId, true );
816         File webAppDirectory = new File( getTestDirectory(), testId );
817 
818         // configure mojo
819         this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
820         setVariableValueToObject( mojo, "warSourceIncludes", "**/*sit.jsp" );
821         setVariableValueToObject( mojo, "warSourceExcludes", "**/last*.*" );
822         mojo.execute();
823 
824         // validate operation
825         File expectedWebSourceFile = new File( webAppDirectory, "pansit.jsp" );
826         File expectedWebSource2File = new File( webAppDirectory, "org/web/app/last-exile.jsp" );
827         File expectedWEBXMLDir = new File( webAppDirectory, "WEB-INF" );
828         File expectedMETAINFDir = new File( webAppDirectory, "META-INF" );
829 
830         assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
831         assertFalse( "source files found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
832         assertTrue( "WEB XML not found: " + expectedWEBXMLDir.toString(), expectedWEBXMLDir.exists() );
833         assertTrue( "META-INF not found", expectedMETAINFDir.exists() );
834 
835         // house keeping
836         expectedWebSourceFile.delete();
837         expectedWebSource2File.delete();
838         expectedWEBXMLDir.delete();
839         expectedMETAINFDir.delete();
840     }
841 
842     public void testExplodedWar_WithWarDependencyIncludeExclude()
843         throws Exception
844     {
845         // setup test data
846         String testId = "ExplodedWar_WithWarDependencyIncludeExclude";
847         MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
848         IncludeExcludeWarArtifactStub includeexcludeWarArtifact = new IncludeExcludeWarArtifactStub( getBasedir() );
849         File webAppDirectory = new File( getTestDirectory(), testId );
850         File webAppSource = createWebAppSource( testId );
851         File classesDir = createClassesDir( testId, true );
852         File workDirectory = new File( getTestDirectory(), "/war/work-" + testId );
853         File includeExcludeWarFile = includeexcludeWarArtifact.getFile();
854 
855         assertTrue( "war not found: " + includeExcludeWarFile.toString(), includeExcludeWarFile.exists() );
856 
857         createDir( workDirectory );
858 
859         // configure mojo
860         project.addArtifact( includeexcludeWarArtifact );
861         this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
862         setVariableValueToObject( mojo, "dependentWarIncludes", "**/*Include.jsp,**/*.xml" );
863         setVariableValueToObject( mojo, "dependentWarExcludes", "**/*Exclude*,**/MANIFEST.MF" );
864         setVariableValueToObject( mojo, "workDirectory", workDirectory );
865         mojo.execute();
866 
867         // validate operation
868         File expectedWebSourceFile = new File( webAppDirectory, "pansit.jsp" );
869         File expectedWebSource2File = new File( webAppDirectory, "org/web/app/last-exile.jsp" );
870         File expectedManifestFile = new File( webAppDirectory, "META-INF/MANIFEST.MF" );
871         File expectedWEBXMLFile = new File( webAppDirectory, "WEB-INF/web.xml" );
872         File expectedIncludedWARFile = new File( webAppDirectory, "/org/sample/company/testInclude.jsp" );
873         File expectedExcludedWarfile = new File( webAppDirectory, "/org/sample/companyExclude/test.jsp" );
874 
875         assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
876         assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
877         // check include-exclude.war in the unit test dir under resources to verify the list of files
878         assertTrue( "web xml not found: " + expectedWEBXMLFile.toString(), expectedWEBXMLFile.exists() );
879         assertFalse( "manifest file found: " + expectedManifestFile.toString(), expectedManifestFile.exists() );
880         assertTrue( "war file not found: " + expectedIncludedWARFile.toString(), expectedIncludedWARFile.exists() );
881         assertFalse( "war file not found: " + expectedExcludedWarfile.toString(), expectedExcludedWarfile.exists() );
882 
883         // house keeping
884         expectedWebSourceFile.delete();
885         expectedWebSource2File.delete();
886         expectedManifestFile.delete();
887         expectedWEBXMLFile.delete();
888         expectedIncludedWARFile.delete();
889         expectedExcludedWarfile.delete();
890     }
891 
892     public void testExplodedWarWithSourceModificationCheck()
893         throws Exception
894     {
895         // setup test data
896         String testId = "ExplodedWarWithSourceModificationCheck";
897         MavenProjectBasicStub project = new MavenProjectBasicStub();
898         File webAppSource = createWebAppSource( testId );
899         File classesDir = createClassesDir( testId, false );
900         File webAppDirectory = new File( getTestDirectory(), testId );
901 
902         // configure mojo
903         this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
904 
905         // destination file is already created manually containing an "error" string
906         // source is newer than the destination file
907         mojo.execute();
908 
909         // validate operation
910 
911         File expectedWEBINFDir = new File( webAppDirectory, "WEB-INF" );
912         File expectedMETAINFDir = new File( webAppDirectory, "META-INF" );
913         File expectedWebSourceFile = new File( webAppDirectory, "pansit.jsp" );
914         File expectedWebSource2File = new File( webAppDirectory, "org/web/app/last-exile.jsp" );
915 
916         assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
917         assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
918         assertTrue( "WEB-INF not found", expectedWEBINFDir.exists() );
919         assertTrue( "META-INF not found", expectedMETAINFDir.exists() );
920 
921         // 1st phase destination is older than source
922         // destination starts with a value of error replaced with a blank source
923         assertFalse( "source files not updated with new copy: " + expectedWebSourceFile.toString(),
924                      "error".equals( FileUtils.fileRead( expectedWebSourceFile ) ) );
925 
926         // TODO: uncomment when lastModified problem is resolved
927         // FileWriter writer = new FileWriter(expectedWebSourceFile);
928         //
929         // // 2nd phase destination is newer than source
930         // // destination should not be replaced with an blank source
931         // writer.write("newdata");
932         // mojo.execute();
933         // reader = new FileReader(expectedWebSourceFile);
934         // reader.read(data);
935         // assertTrue("source file updated with old copy: "
936         // +expectedWebSourceFile.toString(),String.valueOf(data).equals("newdata") ); }
937 
938         // house keeping
939         expectedWEBINFDir.delete();
940         expectedMETAINFDir.delete();
941         expectedWebSourceFile.delete();
942         expectedWebSource2File.delete();
943     }
944 
945     public void testExplodedWarWithOutputFileNameMapping()
946         throws Exception
947     {
948         // setup test data
949         String testId = "ExplodedWarWithFileNameMapping";
950         MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
951         File webAppDirectory = new File( getTestDirectory(), testId );
952         File webAppSource = createWebAppSource( testId );
953         File classesDir = createClassesDir( testId, true );
954         ArtifactHandler artifactHandler = (ArtifactHandler) lookup( ArtifactHandler.ROLE, "jar" );
955         ArtifactStub jarArtifact = new JarArtifactStub( getBasedir(), artifactHandler );
956         File jarFile = jarArtifact.getFile();
957 
958         assertTrue( "jar not found: " + jarFile.toString(), jarFile.exists() );
959 
960         // configure mojo
961         project.addArtifact( jarArtifact );
962         mojo.setOutputFileNameMapping( "@{artifactId}@.@{extension}@" );
963         this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
964         mojo.execute();
965 
966         // validate operation
967         File expectedWebSourceFile = new File( webAppDirectory, "pansit.jsp" );
968         File expectedWebSource2File = new File( webAppDirectory, "org/web/app/last-exile.jsp" );
969         // final name form is <artifactId>-<version>.<type>
970         File expectedJarArtifact = new File( webAppDirectory, "WEB-INF/lib/jarartifact.jar" );
971 
972         assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
973         assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
974         assertTrue( "jar artifact not found: " + expectedJarArtifact.toString(), expectedJarArtifact.exists() );
975 
976         // house keeping
977         expectedWebSourceFile.delete();
978         expectedWebSource2File.delete();
979         expectedJarArtifact.delete();
980     }
981 
982     /**
983      * @throws Exception
984      */
985     public void testExplodedWarWithOutputFileNameMappingAndDuplicateDependencies()
986         throws Exception
987     {
988         // setup test data
989         String testId = "ExplodedWarWithFileNameMappingAndDuplicateDependencies";
990         MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
991         File webAppDirectory = new File( getTestDirectory(), testId );
992         File webAppSource = createWebAppSource( testId );
993         File classesDir = createClassesDir( testId, true );
994         EJBArtifactStub ejbArtifact = new EJBArtifactStub( getBasedir() );
995         EJBArtifactStub ejbArtifactDup = new EJBArtifactStub( getBasedir() );
996         File ejbFile = ejbArtifact.getFile();
997 
998         // ejbArtifact has a hard coded file, only one assert is needed
999         assertTrue( "ejb not found: " + ejbFile.getAbsolutePath(), ejbFile.exists() );
1000 
1001         // configure mojo
1002         ejbArtifact.setGroupId( "org.sample.ejb" );
1003         ejbArtifactDup.setGroupId( "org.dup.ejb" );
1004         project.addArtifact( ejbArtifact );
1005         project.addArtifact( ejbArtifactDup );
1006         mojo.setOutputFileNameMapping( "@{artifactId}@.@{extension}@" );
1007         this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
1008         mojo.execute();
1009 
1010         // validate operation
1011         File expectedWebSourceFile = new File( webAppDirectory, "pansit.jsp" );
1012         File expectedWebSource2File = new File( webAppDirectory, "org/web/app/last-exile.jsp" );
1013         // final name form is <artifactId>-<version>.<type>
1014         File expectedEJBArtifact = new File( webAppDirectory, "WEB-INF/lib/org.sample.ejb-ejbartifact.jar" );
1015         File expectedEJBDupArtifact = new File( webAppDirectory, "WEB-INF/lib/org.dup.ejb-ejbartifact.jar" );
1016 
1017         assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
1018         assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
1019         assertTrue( "ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists() );
1020         assertTrue( "ejb dup artifact not found: " + expectedEJBDupArtifact.toString(),
1021                     expectedEJBDupArtifact.exists() );
1022 
1023         // house keeping
1024         expectedWebSourceFile.delete();
1025         expectedWebSource2File.delete();
1026         expectedEJBArtifact.delete();
1027         expectedEJBDupArtifact.delete();
1028     }
1029 
1030     /* --------------------- 2.1 Overlay tests ----------------------------------- */
1031 
1032     /*---------------------------*/
1033 
1034 
1035 }