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