View Javadoc
1   /**
2    * The MIT License
3    *
4    * Copyright 2006-2012 The Codehaus.
5    *
6    * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
7    * associated documentation files (the "Software"), to deal in the Software without restriction,
8    * including without limitation the rights to use, copy, modify, merge, publish, distribute,
9    * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
10   * furnished to do so, subject to the following conditions:
11   *
12   * The above copyright notice and this permission notice shall be included in all copies or
13   * substantial portions of the Software.
14   *
15   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
16   * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17   * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18   * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20   */
21  package org.codehaus.mojo.appassembler.daemon.jsw;
22  
23  import java.io.File;
24  import java.io.IOException;
25  
26  import org.codehaus.mojo.appassembler.daemon.AbstractDaemonGeneratorTest;
27  import org.codehaus.mojo.appassembler.daemon.DaemonGeneratorException;
28  import org.codehaus.plexus.util.FileUtils;
29  import org.codehaus.plexus.util.StringUtils;
30  
31  /**
32   * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
33   * @version $Id$
34   * @todo test could be improved - there are other conditions like
35   *       "check if extra properties can override those from template"
36   * @todo reading POM/model should not be necessary?
37   */
38  public class JavaServiceWrapperDaemonGeneratorTest
39      extends AbstractDaemonGeneratorTest
40  {
41      public void testGenerationWithAllInfoInDescriptor()
42          throws Exception
43      {
44          runTest( "jsw", "src/test/resources/project-1/pom.xml", "src/test/resources/project-1/descriptor.xml",
45                   "target/output-1-jsw" );
46  
47          File jswDir = getTestFile( "target/output-1-jsw/app" );
48          File wrapper = new File( jswDir, "conf/wrapper.conf" );
49  
50          assertTrue( "Wrapper file is missing: " + wrapper.getAbsolutePath(), wrapper.isFile() );
51  
52          assertEquals( normalizedLineEndingRead( "src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/wrapper-1.conf" ),
53                        FileUtils.fileRead( wrapper ) );
54  
55          File shellScript = new File( jswDir, "bin/app" );
56  
57          assertTrue( "Shell script file is missing: " + shellScript.getAbsolutePath(), shellScript.isFile() );
58  
59          assertEquals( FileUtils.fileRead( getTestFile( "src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/run-1.sh" ) ),
60                        FileUtils.fileRead( shellScript ) );
61  
62          File batchFile = new File( jswDir, "bin/app.bat" );
63  
64          assertTrue( "Batch file is missing: " + batchFile.getAbsolutePath(), batchFile.isFile() );
65  
66          assertEquals( FileUtils.fileRead( getTestFile( "src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/run-1.bat" ) ),
67                        FileUtils.fileRead( batchFile ) );
68  
69          assertEquals( ( new File( getBasedir()
70                            + "/target/classes/org/codehaus/mojo/appassembler/daemon/jsw/bin/wrapper-linux-x86-32" ) ).length(),
71                        ( new File( jswDir, "bin/wrapper-linux-x86-32" ) ).length() );
72  
73          assertFileExists( jswDir, "lib/wrapper.jar" );
74          assertFileExists( jswDir, "lib/wrapper-windows-x86-32.dll" );
75          assertFileExists( jswDir, "lib/libwrapper-macosx-universal-32.jnilib" );
76          assertFileExists( jswDir, "lib/libwrapper-linux-x86-32.so" );
77          assertFileExists( jswDir, "lib/libwrapper-solaris-x86-32.so" );
78  
79          assertFileExists( jswDir, "bin/wrapper-windows-x86-32.exe" );
80          assertFileExists( jswDir, "bin/wrapper-macosx-universal-32" );
81          assertFileExists( jswDir, "bin/wrapper-solaris-x86-32" );
82          assertFileExists( jswDir, "bin/wrapper-linux-x86-32" );
83  
84          assertFileNotExists( jswDir, "lib/libwrapper-macosx-ppc-32.jnilib" );
85          assertFileNotExists( jswDir, "lib/libwrapper-linux-ppc-64.so" );
86          assertFileNotExists( jswDir, "lib/libwrapper-linux-x86-64.so" );
87          assertFileNotExists( jswDir, "lib/libwrapper-solaris-sparc-32.so" );
88          assertFileNotExists( jswDir, "lib/libwrapper-solaris-sparc-64.so" );
89          assertFileNotExists( jswDir, "bin/wrapper-macosx-ppc-32" );
90          assertFileNotExists( jswDir, "bin/wrapper-linux-ppc-64" );
91          assertFileNotExists( jswDir, "bin/wrapper-linux-x86-64" );
92          assertFileNotExists( jswDir, "bin/wrapper-solaris-sparc-32" );
93          assertFileNotExists( jswDir, "bin/wrapper-solaris-sparc-64" );
94      }
95  
96      public void testGenerateWithCustomJSWPlatforms()
97          throws Exception
98      {
99          runTest( "jsw", "src/test/resources/project-4/pom.xml", "src/test/resources/project-4/descriptor.xml",
100                  "target/output-4-jsw" );
101 
102         File jswDir = getTestFile( "target/output-4-jsw/app" );
103         File wrapper = new File( jswDir, "conf/wrapper.conf" );
104 
105         assertTrue( "Wrapper file is missing: " + wrapper.getAbsolutePath(), wrapper.isFile() );
106 
107         assertEquals( normalizedLineEndingRead( "src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/wrapper-1.conf" ),
108                       FileUtils.fileRead( wrapper ) );
109 
110         File shellScript = new File( jswDir, "bin/app" );
111 
112         assertTrue( "Shell script file is missing: " + shellScript.getAbsolutePath(), shellScript.isFile() );
113 
114         assertEquals( FileUtils.fileRead( getTestFile( "src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/run-1.sh" ) ),
115                       FileUtils.fileRead( shellScript ) );
116 
117         File batchFile = new File( jswDir, "bin/app.bat" );
118 
119         assertTrue( "Batch file is missing: " + batchFile.getAbsolutePath(), batchFile.isFile() );
120 
121         assertEquals( FileUtils.fileRead( getTestFile( "src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/run-1.bat" ) ),
122                       FileUtils.fileRead( batchFile ) );
123 
124         assertEquals( ( new File( getBasedir()
125                           + "/target/classes/org/codehaus/mojo/appassembler/daemon/jsw/bin/wrapper-linux-x86-32" ) ).length(),
126                       ( new File( jswDir, "bin/wrapper-linux-x86-32" ) ).length() );
127 
128         assertFileExists( jswDir, "lib/wrapper.jar" );
129         assertFileExists( jswDir, "lib/wrapper-windows-x86-32.dll" );
130         assertFileExists( jswDir, "lib/libwrapper-macosx-universal-32.jnilib" );
131         assertFileNotExists( jswDir, "lib/libwrapper-macosx-ppc-32.jnilib" );
132         assertFileNotExists( jswDir, "lib/libwrapper-linux-ppc-64.so" );
133         assertFileExists( jswDir, "lib/libwrapper-linux-x86-32.so" );
134         assertFileNotExists( jswDir, "lib/libwrapper-linux-x86-64.so" );
135         assertFileNotExists( jswDir, "lib/libwrapper-solaris-x86-32.so" );
136         assertFileExists( jswDir, "lib/libwrapper-solaris-sparc-64.so" );
137 
138         assertFileExists( jswDir, "bin/wrapper-windows-x86-32.exe" );
139         assertFileExists( jswDir, "bin/wrapper-macosx-universal-32" );
140         assertFileNotExists( jswDir, "bin/wrapper-macosx-ppc-32" );
141         assertFileNotExists( jswDir, "bin/wrapper-linux-ppc-64" );
142         assertFileExists( jswDir, "bin/wrapper-linux-x86-32" );
143         assertFileNotExists( jswDir, "bin/wrapper-linux-x86-64" );
144         assertFileNotExists( jswDir, "bin/wrapper-solaris-x86-32" );
145         assertFileExists( jswDir, "bin/wrapper-solaris-sparc-64" );
146     }
147 
148     public void testDefaultJSWFilesIfNoGeneratorConfigurationsIsSet()
149         throws Exception
150     {
151         runTest( "jsw", "src/test/resources/project-5/pom.xml", "src/test/resources/project-5/descriptor.xml",
152                  "target/output-5-jsw" );
153 
154         File jswDir = getTestFile( "target/output-5-jsw/app" );
155         File wrapper = new File( jswDir, "conf/wrapper.conf" );
156 
157         assertTrue( "Wrapper file is missing: " + wrapper.getAbsolutePath(), wrapper.isFile() );
158 
159         assertEquals( normalizedLineEndingRead( "src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/no-generator-configurations-wrapper.conf" ),
160                       FileUtils.fileRead( wrapper ) );
161 
162         File shellScript = new File( jswDir, "bin/app" );
163 
164         assertTrue( "Shell script file is missing: " + shellScript.getAbsolutePath(), shellScript.isFile() );
165 
166         assertEquals( FileUtils.fileRead( getTestFile( "src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/no-generator-configurations-run.sh" ) ),
167                       FileUtils.fileRead( shellScript ) );
168 
169         File batchFile = new File( jswDir, "bin/app.bat" );
170 
171         assertTrue( "Batch file is missing: " + batchFile.getAbsolutePath(), batchFile.isFile() );
172 
173         assertEquals( FileUtils.fileRead( getTestFile( "src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/no-generator-configurations-run.bat" ) ),
174                       FileUtils.fileRead( batchFile ) );
175 
176         assertEquals( ( new File( getBasedir()
177                           + "/target/classes/org/codehaus/mojo/appassembler/daemon/jsw/bin/wrapper-linux-x86-32" ) ).length(),
178                       ( new File( jswDir, "bin/wrapper-linux-x86-32" ) ).length() );
179 
180         assertFileExists( jswDir, "lib/wrapper.jar" );
181         assertFileExists( jswDir, "lib/wrapper-windows-x86-32.dll" );
182         assertFileExists( jswDir, "lib/libwrapper-macosx-universal-32.jnilib" );
183         assertFileExists( jswDir, "lib/libwrapper-linux-x86-32.so" );
184         assertFileExists( jswDir, "lib/libwrapper-solaris-x86-32.so" );
185         assertFileNotExists( jswDir, "lib/libwrapper-macosx-ppc-32.jnilib" );
186         assertFileNotExists( jswDir, "lib/libwrapper-linux-ppc-64.so" );
187         assertFileNotExists( jswDir, "lib/libwrapper-linux-x86-64.so" );
188         assertFileNotExists( jswDir, "lib/libwrapper-solaris-sparc-32.so" );
189         assertFileNotExists( jswDir, "lib/libwrapper-solaris-sparc-64.so" );
190 
191         assertFileExists( jswDir, "bin/wrapper-windows-x86-32.exe" );
192         assertFileExists( jswDir, "bin/wrapper-macosx-universal-32" );
193         assertFileExists( jswDir, "bin/wrapper-linux-x86-32" );
194         assertFileExists( jswDir, "bin/wrapper-solaris-x86-32" );
195         assertFileNotExists( jswDir, "bin/wrapper-macosx-ppc-32" );
196         assertFileNotExists( jswDir, "bin/wrapper-linux-ppc-64" );
197         assertFileNotExists( jswDir, "bin/wrapper-linux-x86-64" );
198         assertFileNotExists( jswDir, "bin/wrapper-solaris-sparc-32" );
199         assertFileNotExists( jswDir, "bin/wrapper-solaris-sparc-64" );
200     }
201 
202     public void testGenerateWithConfigurationDirectoriesAddedFromGeneratorConfiguration()
203         throws Exception
204     {
205         runTest( "jsw", "src/test/resources/project-6/pom.xml", "src/test/resources/project-6/descriptor.xml",
206                  "target/output-6-jsw" );
207 
208         File jswDir = getTestFile( "target/output-6-jsw/app" );
209         File wrapper = new File( jswDir, "conf/wrapper.conf" );
210 
211         assertTrue( "Wrapper file is missing: " + wrapper.getAbsolutePath(), wrapper.isFile() );
212 
213         assertEquals( normalizedLineEndingRead( "src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/wrapper-6.conf" ),
214                       FileUtils.fileRead( wrapper ) );
215     }
216 
217     private String normalizedLineEndingRead( String file )
218         throws IOException
219     {
220         String expected = FileUtils.fileRead( getTestFile( file ) );
221         return StringUtils.unifyLineSeparators( expected );
222     }
223 
224     public void testGenerateWithAllKnownPlatforms()
225         throws Exception
226     {
227         runTest( "jsw", "src/test/resources/project-7/pom.xml", "src/test/resources/project-7/descriptor.xml",
228                  "target/output-7-jsw" );
229 
230         File jswDir = getTestFile( "target/output-7-jsw/app" );
231         File wrapper = new File( jswDir, "conf/wrapper.conf" );
232 
233         assertTrue( "Wrapper file is missing: " + wrapper.getAbsolutePath(), wrapper.isFile() );
234 
235         assertEquals( normalizedLineEndingRead( "src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/wrapper-7.conf" ),
236                       FileUtils.fileRead( wrapper ) );
237 
238         assertFileExists( jswDir, "lib/wrapper.jar" );
239         assertFileExists( jswDir, "lib/libwrapper-aix-ppc-32.a" );
240         assertFileExists( jswDir, "lib/libwrapper-aix-ppc-64.a" );
241         assertFileExists( jswDir, "lib/libwrapper-hpux-parisc-64.sl" );
242         assertFileExists( jswDir, "lib/libwrapper-macosx-universal-32.jnilib" );
243         assertFileExists( jswDir, "lib/libwrapper-macosx-universal-64.jnilib" );
244         assertFileExists( jswDir, "lib/libwrapper-linux-ppc-64.so" );
245         assertFileExists( jswDir, "lib/libwrapper-linux-x86-32.so" );
246         assertFileExists( jswDir, "lib/libwrapper-linux-x86-64.so" );
247         assertFileExists( jswDir, "lib/libwrapper-solaris-x86-32.so" );
248         assertFileExists( jswDir, "lib/libwrapper-solaris-sparc-32.so" );
249         assertFileExists( jswDir, "lib/libwrapper-solaris-sparc-64.so" );
250         assertFileExists( jswDir, "lib/wrapper-windows-x86-32.dll" );
251         assertFileExists( jswDir, "lib/wrapper-windows-x86-64.dll" );
252 
253         assertFileExists( jswDir, "bin/wrapper-aix-ppc-32" );
254         assertFileExists( jswDir, "bin/wrapper-aix-ppc-64" );
255         assertFileExists( jswDir, "bin/wrapper-hpux-parisc-64" );
256         assertFileExists( jswDir, "bin/wrapper-macosx-universal-32" );
257         assertFileExists( jswDir, "bin/wrapper-macosx-universal-64" );
258         assertFileExists( jswDir, "bin/wrapper-linux-ppc-64" );
259         assertFileExists( jswDir, "bin/wrapper-linux-x86-32" );
260         assertFileExists( jswDir, "bin/wrapper-linux-x86-64" );
261         assertFileExists( jswDir, "bin/wrapper-solaris-x86-32" );
262         assertFileExists( jswDir, "bin/wrapper-solaris-sparc-32" );
263         assertFileExists( jswDir, "bin/wrapper-solaris-sparc-64" );
264         assertFileExists( jswDir, "bin/wrapper-windows-x86-32.exe" );
265         assertFileExists( jswDir, "bin/wrapper-windows-x86-64.exe" );
266     }
267 
268     public void testGenerationWithRunAsUserEnvVar()
269         throws Exception
270     {
271         runTest( "jsw", "src/test/resources/project-8/pom.xml", "src/test/resources/project-8/descriptor.xml",
272                  "target/output-8-jsw" );
273 
274         File jswDir = getTestFile( "target/output-8-jsw/app" );
275         File wrapper = new File( jswDir, "conf/wrapper.conf" );
276 
277         assertTrue( "Wrapper file is missing: " + wrapper.getAbsolutePath(), wrapper.isFile() );
278 
279         String dir = "src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw";
280 
281         String testFile = dir + "/wrapper-8.conf";
282         assertEquals( "Comparing " + testFile + " to " + wrapper,
283                       normalizeLineTerminators( FileUtils.fileRead( getTestFile( testFile ) ) ),
284                       normalizeLineTerminators( FileUtils.fileRead( wrapper ) ) );
285 
286         File shellScript = new File( jswDir, "bin/app" );
287 
288         assertTrue( "Shell script file is missing: " + shellScript.getAbsolutePath(), shellScript.isFile() );
289 
290         testFile = dir + "/run-8.sh";
291         assertEquals( "Comparing " + testFile + " to " + shellScript,
292                       normalizeLineTerminators( FileUtils.fileRead( getTestFile( testFile ) ) ),
293                       normalizeLineTerminators( FileUtils.fileRead( shellScript ) ) );
294 
295         File batchFile = new File( jswDir, "bin/app.bat" );
296 
297         assertTrue( "Batch file is missing: " + batchFile.getAbsolutePath(), batchFile.isFile() );
298 
299         testFile = dir + "/run-8.bat";
300         assertEquals( "Comparing " + testFile + " to " + batchFile, FileUtils.fileRead( getTestFile( testFile ) ),
301                       FileUtils.fileRead( batchFile ) );
302     }
303 
304     public void testGenerationWithChkConfig()
305         throws Exception
306     {
307         runTest( "jsw", "src/test/resources/project-12/pom.xml", "src/test/resources/project-12/descriptor.xml",
308                  "target/output-12-jsw" );
309 
310         File jswDir = getTestFile( "target/output-12-jsw/app" );
311         File wrapper = new File( jswDir, "conf/wrapper.conf" );
312 
313         String wrapperContents = FileUtils.fileRead( wrapper );
314 
315         assertFalse( "Wrapper conf contains chkconfig.start", wrapperContents.contains( "chkconfig.start" ) );
316         assertFalse( "Wrapper conf contains chkconfig.stop", wrapperContents.contains( "chkconfig.stop" ) );
317 
318         File script = new File( jswDir, "bin/app" );
319         String scriptContents = FileUtils.fileRead( script );
320 
321         assertTrue( "Chkconfig replace did not work", scriptContents.contains( "chkconfig: 3 21 81" ) );
322     }
323 
324     public void testGenerationWithWrapperPidFile()
325         throws Exception
326     {
327         runTest( "jsw", "src/test/resources/project-9/pom.xml", "src/test/resources/project-9/descriptor.xml",
328                  "target/output-9-jsw" );
329 
330         File jswDir = getTestFile( "target/output-9-jsw/app" );
331         File wrapper = new File( jswDir, "conf/wrapper.conf" );
332 
333         assertTrue( "Wrapper file is missing: " + wrapper.getAbsolutePath(), wrapper.isFile() );
334 
335         String dir = "src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw";
336 
337         String testFile = dir + "/wrapper-9.conf";
338         assertEquals( "Comparing " + testFile + " to " + wrapper,
339                       normalizeLineTerminators( FileUtils.fileRead( getTestFile( testFile ) ) ),
340                       normalizeLineTerminators( FileUtils.fileRead( wrapper ) ) );
341 
342         File shellScript = new File( jswDir, "bin/app" );
343 
344         assertTrue( "Shell script file is missing: " + shellScript.getAbsolutePath(), shellScript.isFile() );
345 
346         testFile = dir + "/run-9.sh";
347         assertEquals( "Comparing " + testFile + " to " + shellScript,
348                       normalizeLineTerminators( FileUtils.fileRead( getTestFile( testFile ) ) ),
349                       normalizeLineTerminators( FileUtils.fileRead( shellScript ) ) );
350 
351         // there are no changes in batch file so we don't check it here
352     }
353 
354     public void testGenerationWithGoodExternalDeltaPack()
355         throws Exception
356     {
357         runTest( "jsw", "src/test/resources/project-10/pom.xml", "src/test/resources/project-10/descriptor.xml",
358                  "target/output-10-jsw" );
359 
360         File jswDir = getTestFile( "target/output-10-jsw/app" );
361 
362         // just enough to prove we see the external files
363         assertFileExists( jswDir, "lib/wrapper.jar" );
364         assertFileExists( jswDir, "lib/libwrapper-aix-ppc-32.a" );
365         assertFileExists( jswDir, "lib/libwrapper-aix-ppc-64.a" );
366 
367         // just enough to prove we see the external files
368         assertFileExists( jswDir, "bin/wrapper-aix-ppc-32" );
369         assertFileExists( jswDir, "bin/wrapper-aix-ppc-64" );
370     }
371 
372     public void testGenerationWithBadExternalDeltaPack()
373         throws Exception
374     {
375         try
376         {
377             runTest( "jsw", "src/test/resources/project-10/pom.xml", "src/test/resources/project-11/descriptor.xml",
378                      "target/output-11-jsw" );
379 
380             fail( "Invalid external delta pack passed thru!!." );
381         }
382         catch ( DaemonGeneratorException e )
383         {
384             assertTrue( "Invalid external delta pack does not get correct exceptoin",
385                         e.getMessage().startsWith( "Could not copy external file" ) );
386         }
387     }
388 
389     public void testGenerationWithRepositoryName()
390         throws Exception
391     {
392         runTest( "jsw", "src/test/resources/project-13/pom.xml", "src/test/resources/project-13/descriptor.xml",
393                  "target/output-13-jsw" );
394 
395         File jswDir = getTestFile( "target/output-13-jsw/app" );
396         File wrapper = new File( jswDir, "conf/wrapper.conf" );
397 
398         assertTrue( "Wrapper file is missing: " + wrapper.getAbsolutePath(), wrapper.isFile() );
399 
400         String dir = "src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw";
401 
402         String testFile = dir + "/wrapper-13.conf";
403         assertEquals( "Comparing " + testFile + " to " + wrapper,
404                       normalizeLineTerminators( FileUtils.fileRead( getTestFile( testFile ) ) ),
405                       normalizeLineTerminators( FileUtils.fileRead( wrapper ) ) );
406 
407         assertFileExists( jswDir, "repo/wrapper.jar" );
408         assertFileExists( jswDir, "repo/wrapper-windows-x86-32.dll" );
409         assertFileExists( jswDir, "repo/wrapper-windows-x86-64.dll" );
410         assertFileExists( jswDir, "repo/libwrapper-macosx-universal-32.jnilib" );
411         assertFileExists( jswDir, "repo/libwrapper-linux-x86-32.so" );
412         assertFileExists( jswDir, "repo/libwrapper-solaris-sparc-64.so" );
413         assertFileNotExists( jswDir, "lib/wrapper.jar" );
414         assertFileNotExists( jswDir, "lib/wrapper-windows-x86-32.dll" );
415         assertFileNotExists( jswDir, "lib/wrapper-windows-x86-64.dll" );
416         assertFileNotExists( jswDir, "lib/libwrapper-macosx-universal-32.jnilib" );
417         assertFileNotExists( jswDir, "lib/libwrapper-linux-x86-32.so" );
418         assertFileNotExists( jswDir, "lib/libwrapper-solaris-sparc-64.so" );
419     }
420 
421     public void testGenerationWithConfigurationDirectory()
422         throws Exception
423     {
424         runTest( "jsw", "src/test/resources/project-14/pom.xml", "src/test/resources/project-14/descriptor.xml",
425                  "target/output-14-jsw" );
426 
427         File jswDir = getTestFile( "target/output-14-jsw/app" );
428         assertFileExists( jswDir, "etc/wrapper.conf" );
429 
430         File shellScript = new File( jswDir, "bin/app" );
431         assertTrue( "Shell script file is missing: " + shellScript.getAbsolutePath(), shellScript.isFile() );
432         assertEquals( FileUtils.fileRead( getTestFile( "src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/run-14.sh" ) ),
433                       FileUtils.fileRead( shellScript ) );
434 
435         File batchFile = new File( jswDir, "bin/app.bat" );
436         assertTrue( "Batch file is missing: " + batchFile.getAbsolutePath(), batchFile.isFile() );
437         assertEquals( FileUtils.fileRead( getTestFile( "src/test/resources/org/codehaus/mojo/appassembler/daemon/jsw/run-14.bat" ) ),
438                       FileUtils.fileRead( batchFile ) );
439     }
440 
441     public void testGenerationWithEndorsedDirectory()
442         throws Exception
443     {
444         runTest( "jsw", "src/test/resources/project-15/pom.xml", "src/test/resources/project-15/descriptor.xml",
445                  "target/output-15-jsw" );
446 
447         File jswDir = getTestFile( "target/output-15-jsw/app" );
448         assertFileExists( jswDir, "conf/wrapper.conf" );
449 
450         File wrapper = new File( jswDir, "conf/wrapper.conf" );
451 
452         String wrapperContents = FileUtils.fileRead( wrapper );
453 
454         assertTrue( "Wrapper conf does not contain lib-endorsed", wrapperContents.contains( "lib-endorsed" ) );
455     }
456 
457     private static void assertFileExists( File jswDir, String file )
458     {
459         File wrapperJar = new File( jswDir, file );
460 
461         assertTrue( "File is missing: " + wrapperJar.getAbsolutePath(), wrapperJar.isFile() );
462     }
463 
464     private static void assertFileNotExists( File jswDir, String file )
465     {
466         File wrapperJar = new File( jswDir, file );
467 
468         assertFalse( "File should be missing: " + wrapperJar.getAbsolutePath(), wrapperJar.isFile() );
469     }
470 }