View Javadoc
1   package org.apache.maven.plugins.ejb;
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 java.io.File;
23  import java.io.IOException;
24  import java.util.LinkedList;
25  import java.util.List;
26  import java.util.jar.JarFile;
27  
28  import org.apache.maven.plugin.MojoExecutionException;
29  import org.apache.maven.plugin.testing.AbstractMojoTestCase;
30  import org.apache.maven.plugins.ejb.stub.MavenProjectResourcesStub;
31  import org.apache.maven.plugins.ejb.utils.JarContentChecker;
32  import org.apache.maven.project.MavenProject;
33  import org.codehaus.plexus.util.FileUtils;
34  
35  /**
36   * EJB plugin Test Case
37   */
38  public class EjbMojoTest
39      extends AbstractMojoTestCase
40  {
41      static final String DEFAULT_POM_PATH = "target/test-classes/unit/ejbmojotest/plugin-config.xml";
42  
43      static final String DEFAULT_JAR_NAME = "testJar";
44  
45      /**
46       * check test environment
47       *
48       * @throws Exception if any exception occurs
49       */
50      public void testTestEnvironment()
51          throws Exception
52      {
53          // Perform lookup on the Mojo to make sure everything is ok
54          lookupMojo();
55      }
56  
57      /**
58       * Basic jar creation test.
59       *
60       * @throws Exception if any exception occurs
61       */
62      public void testDefaultWithoutClientJar()
63          throws Exception
64      {
65          final MavenProjectResourcesStub project = createTestProject( "default-noclient" );
66          final EjbMojo mojo = lookupMojoWithDefaultSettings( project );
67  
68          setupDefaultProject( project );
69  
70          setVariableValueToObject( mojo, "generateClient", Boolean.FALSE );
71          setVariableValueToObject( mojo, "ejbVersion", "2.1" );
72  
73          mojo.execute();
74  
75          assertJarCreation( project, true, false );
76      }
77  
78      /**
79       * Classified jar creation test.
80       *
81       * @throws Exception if any exception occurs
82       */
83      public void testClassifiedJarWithoutClientJar()
84          throws Exception
85      {
86          final MavenProjectResourcesStub project = createTestProject( "classified-noclient" );
87          final EjbMojo mojo = lookupMojoWithDefaultSettings( project );
88  
89          setupDefaultProject( project );
90  
91          setVariableValueToObject( mojo, "generateClient", Boolean.FALSE );
92          setVariableValueToObject( mojo, "ejbVersion", "2.1" );
93          setVariableValueToObject( mojo, "classifier", "classified" );
94  
95          mojo.execute();
96  
97          assertJarCreation( project, true, false, "classified" );
98      }
99  
100     /**
101      * Basic jar creation test with client jar.
102      *
103      * @throws Exception if any exception occurs
104      */
105     public void testDefaultWithClientJar()
106         throws Exception
107     {
108         final MavenProjectResourcesStub project = createTestProject( "default-client" );
109         final EjbMojo mojo = lookupMojoWithDefaultSettings( project );
110 
111         setupDefaultProject( project );
112 
113         setVariableValueToObject( mojo, "generateClient", Boolean.TRUE );
114         setVariableValueToObject( mojo, "ejbVersion", "2.1" );
115 
116         mojo.execute();
117 
118         assertJarCreation( project, true, true );
119     }
120 
121     /**
122      * Classified jar creation test with client jar.
123      *
124      * @throws Exception if any exception occurs
125      */
126     public void testClassifiedJarWithClientJar()
127         throws Exception
128     {
129         final MavenProjectResourcesStub project = createTestProject( "classified-client" );
130         final EjbMojo mojo = lookupMojoWithDefaultSettings( project );
131 
132         setupDefaultProject( project );
133 
134         setVariableValueToObject( mojo, "generateClient", Boolean.TRUE );
135         setVariableValueToObject( mojo, "ejbVersion", "2.1" );
136         setVariableValueToObject( mojo, "classifier", "classified" );
137         setVariableValueToObject( mojo, "clientClassifier", "classified-client" );
138 
139         mojo.execute();
140 
141         assertJarCreation( project, true, true, "classified" );
142     }
143 
144     /**
145      * Default ejb jar inclusion and exclusion test.
146      *
147      * @throws Exception if any exception occurs
148      */
149     public void testDefaultInclusionsExclusions()
150         throws Exception
151     {
152 
153         final MavenProjectResourcesStub project = createTestProject( "includes-excludes-default" );
154         final EjbMojo mojo = lookupMojoWithDefaultSettings( project );
155 
156         // put this on the target output dir
157         project.addFile( "META-INF/ejb-jar.xml", MavenProjectResourcesStub.OUTPUT_FILE );
158         project.addFile( "org/sample/ejb/AppBean.class", MavenProjectResourcesStub.OUTPUT_FILE );
159         project.addFile( "org/sample/ejb/AppCMP.class", MavenProjectResourcesStub.OUTPUT_FILE );
160         project.addFile( "org/sample/ejb/AppSession.class", MavenProjectResourcesStub.OUTPUT_FILE );
161 
162         // put this on the root dir
163         project.addFile( "pom.xml", MavenProjectResourcesStub.ROOT_FILE );
164 
165         // start creating the environment
166         project.setupBuildEnvironment();
167 
168         setVariableValueToObject( mojo, "generateClient", Boolean.FALSE );
169         setVariableValueToObject( mojo, "ejbVersion", "2.1" );
170 
171         mojo.execute();
172 
173         assertJarCreation( project, true, false );
174         assertJarContent( project,
175                           new String[] { "META-INF/MANIFEST.MF", "META-INF/ejb-jar.xml",
176                               "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
177                               "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties",
178                               "org/sample/ejb/AppBean.class", "org/sample/ejb/AppCMP.class",
179                               "org/sample/ejb/AppSession.class" },
180                           null );
181     }
182 
183     /**
184      * Client jar default inclusion and exclusion test.
185      *
186      * @throws Exception if any exception occurs
187      */
188     public void testClientJarDefaultInclusionsExclusions()
189         throws Exception
190     {
191 
192         final MavenProjectResourcesStub project = createTestProject( "includes-excludes-client" );
193         final EjbMojo mojo = lookupMojoWithDefaultSettings( project );
194 
195         // put this on the target output dir
196         project.addFile( "META-INF/ejb-jar.xml", MavenProjectResourcesStub.OUTPUT_FILE );
197         project.addFile( "org/sample/ejb/AppBean.class", MavenProjectResourcesStub.OUTPUT_FILE );
198         project.addFile( "org/sample/ejb/AppCMP.class", MavenProjectResourcesStub.OUTPUT_FILE );
199         project.addFile( "org/sample/ejb/AppSession.class", MavenProjectResourcesStub.OUTPUT_FILE );
200         project.addFile( "org/sample/ejb/AppStub.class", MavenProjectResourcesStub.OUTPUT_FILE );
201 
202         // put this on the root dir
203         project.addFile( "pom.xml", MavenProjectResourcesStub.ROOT_FILE );
204 
205         // start creating the environment
206         project.setupBuildEnvironment();
207 
208         setVariableValueToObject( mojo, "generateClient", Boolean.TRUE );
209         setVariableValueToObject( mojo, "ejbVersion", "2.1" );
210 
211         mojo.execute();
212 
213         assertJarCreation( project, true, true );
214         assertClientJarContent( project,
215                                 new String[] { "META-INF/MANIFEST.MF",
216                                     "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
217                                     "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties",
218                                     "org/sample/ejb/AppStub.class" },
219                                 new String[] { "META-INF/ejb-jar.xml", "org/sample/ejb/AppBean.class",
220                                     "org/sample/ejb/AppCMP.class", "org/sample/ejb/AppSession.class" } );
221     }
222 
223     /**
224      * Client jar inclusion test.
225      *
226      * @throws Exception if any exception occurs
227      */
228     public void testClientJarInclusions()
229         throws Exception
230     {
231         final List<String> inclusions = new LinkedList<String>();
232         inclusions.add( "**/*Include.class" );
233 
234         final MavenProjectResourcesStub project = createTestProject( "client-includes" );
235         final EjbMojo mojo = lookupMojoWithSettings( project, inclusions, new LinkedList<String>(), null );
236 
237         // put this on the target output dir
238         project.addFile( "META-INF/ejb-jar.xml", MavenProjectResourcesStub.OUTPUT_FILE );
239         project.addFile( "org/sample/ejb/AppInclude.class", MavenProjectResourcesStub.OUTPUT_FILE );
240         project.addFile( "org/sample/ejb/AppExclude.class", MavenProjectResourcesStub.OUTPUT_FILE );
241 
242         // put this on the root dir
243         project.addFile( "pom.xml", MavenProjectResourcesStub.ROOT_FILE );
244 
245         // start creating the environment
246         project.setupBuildEnvironment();
247 
248         setVariableValueToObject( mojo, "generateClient", Boolean.TRUE );
249         setVariableValueToObject( mojo, "ejbVersion", "2.1" );
250 
251         mojo.execute();
252 
253         assertJarCreation( project, true, true );
254         assertClientJarContent( project,
255                                 new String[] { "META-INF/MANIFEST.MF",
256                                     "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
257                                     "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties",
258                                     "org/sample/ejb/AppInclude.class" },
259                                 new String[] { "META-INF/ejb-jar.xml", "org/sample/ejb/AppExclude.class" } );
260     }
261 
262     /**
263      * Client jar exclusions test.
264      *
265      * @throws Exception if any exception occurs
266      */
267     public void testClientJarExclusions()
268         throws Exception
269     {
270 
271         final List<String> exclusions = new LinkedList<String>();
272         exclusions.add( "**/*Exclude.class" );
273 
274         final MavenProjectResourcesStub project = createTestProject( "client-excludes" );
275         final EjbMojo mojo = lookupMojoWithSettings( project, new LinkedList<String>(), exclusions, null );
276 
277         // put this on the target output dir
278         project.addFile( "META-INF/ejb-jar.xml", MavenProjectResourcesStub.OUTPUT_FILE );
279         project.addFile( "org/sample/ejb/AppInclude.class", MavenProjectResourcesStub.OUTPUT_FILE );
280         project.addFile( "org/sample/ejb/AppExclude.class", MavenProjectResourcesStub.OUTPUT_FILE );
281 
282         // put this on the root dir
283         project.addFile( "pom.xml", MavenProjectResourcesStub.ROOT_FILE );
284 
285         // start creating the environment
286         project.setupBuildEnvironment();
287 
288         setVariableValueToObject( mojo, "generateClient", Boolean.TRUE );
289         setVariableValueToObject( mojo, "ejbVersion", "2.1" );
290 
291         mojo.execute();
292 
293         assertJarCreation( project, true, true );
294         assertClientJarContent( project,
295                                 new String[] { "META-INF/MANIFEST.MF",
296                                     "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
297                                     "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties",
298                                     "org/sample/ejb/AppInclude.class" },
299                                 new String[] { "META-INF/ejb-jar.xml", "org/sample/ejb/AppExclude.class" } );
300 
301     }
302 
303     /**
304      * Main jar exclusions test.
305      *
306      * @throws Exception if any exception occurs
307      */
308     public void testMainJarExclusions()
309         throws Exception
310     {
311         final List<String> exclusions = new LinkedList<String>();
312         exclusions.add( "**/*Exclude.class" );
313 
314         final MavenProjectResourcesStub project = createTestProject( "main-excludes" );
315         final EjbMojo mojo =
316             lookupMojoWithSettings( project, new LinkedList<String>(), new LinkedList<String>(), exclusions );
317 
318         // put this on the target output dir
319         project.addFile( "META-INF/ejb-jar.xml", MavenProjectResourcesStub.OUTPUT_FILE );
320         project.addFile( "org/sample/ejb/AppInclude.class", MavenProjectResourcesStub.OUTPUT_FILE );
321         project.addFile( "org/sample/ejb/AppExclude.class", MavenProjectResourcesStub.OUTPUT_FILE );
322 
323         // put this on the root dir
324         project.addFile( "pom.xml", MavenProjectResourcesStub.ROOT_FILE );
325 
326         // start creating the environment
327         project.setupBuildEnvironment();
328 
329         setVariableValueToObject( mojo, "generateClient", Boolean.TRUE );
330         setVariableValueToObject( mojo, "ejbVersion", "2.1" );
331 
332         mojo.execute();
333 
334         assertJarCreation( project, true, true );
335         assertJarContent( project,
336                           new String[] { "META-INF/MANIFEST.MF",
337                               "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
338                               "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties",
339                               "org/sample/ejb/AppInclude.class" },
340                           new String[] { "META-INF/ejb-jar.xml", "org/sample/ejb/AppExclude.class" } );
341 
342     }
343 
344     /**
345      * Client jar inclusion test with a sub-package.
346      *
347      * @throws Exception if any exception occurs
348      */
349     public void testClientJarInclusionsWithSubPackage()
350         throws Exception
351     {
352         final List<String> inclusions = new LinkedList<String>();
353         inclusions.add( "org/sample/ejb/*.class" );
354 
355         final MavenProjectResourcesStub project = createTestProject( "client-includes-subpackage" );
356 
357         final EjbMojo mojo = lookupMojoWithSettings( project, inclusions, new LinkedList<String>(), null );
358 
359         // put this on the target output dir
360         project.addFile( "META-INF/ejb-jar.xml", MavenProjectResourcesStub.OUTPUT_FILE );
361         project.addFile( "org/sample/ejb/App.class", MavenProjectResourcesStub.OUTPUT_FILE );
362         project.addFile( "org/sample/ejb/impl/AppImpl.class", MavenProjectResourcesStub.OUTPUT_FILE );
363 
364         // put this on the root dir
365         project.addFile( "pom.xml", MavenProjectResourcesStub.ROOT_FILE );
366 
367         // start creating the environment
368         project.setupBuildEnvironment();
369 
370         setVariableValueToObject( mojo, "generateClient", Boolean.TRUE );
371         setVariableValueToObject( mojo, "ejbVersion", "2.1" );
372 
373         mojo.execute();
374 
375         assertJarCreation( project, true, true );
376         assertClientJarContent( project,
377                                 new String[] { "META-INF/MANIFEST.MF",
378                                     "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
379                                     "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties",
380                                     "org/sample/ejb/App.class" },
381                                 new String[] { "META-INF/ejb-jar.xml", "org/sample/ejb/impl/AppImpl.class",
382                                     "org/sample/ejb/impl" } );
383     }
384 
385     /**
386      * Client jar exclusions test that leaves an empty package.
387      *
388      * @throws Exception if any exception occurs
389      */
390     public void testClientJarExclusionsWithEmptyPackage()
391         throws Exception
392     {
393 
394         final LinkedList<String> exclusions = new LinkedList<String>();
395         exclusions.add( "org/sample/ejb/**" );
396 
397         final MavenProjectResourcesStub project = createTestProject( "client-excludes-emptypackage" );
398         final EjbMojo mojo = lookupMojoWithSettings( project, new LinkedList<String>(), exclusions, null );
399 
400         // put this on the target output dir
401         project.addFile( "META-INF/ejb-jar.xml", MavenProjectResourcesStub.OUTPUT_FILE );
402         project.addFile( "org/sample/ejb/AppOne.class", MavenProjectResourcesStub.OUTPUT_FILE );
403         project.addFile( "org/sample/ejb2/AppTwo.class", MavenProjectResourcesStub.OUTPUT_FILE );
404 
405         // put this on the root dir
406         project.addFile( "pom.xml", MavenProjectResourcesStub.ROOT_FILE );
407 
408         // start creating the environment
409         project.setupBuildEnvironment();
410 
411         setVariableValueToObject( mojo, "generateClient", Boolean.TRUE );
412         setVariableValueToObject( mojo, "ejbVersion", "2.1" );
413 
414         mojo.execute();
415 
416         assertJarCreation( project, true, true );
417 
418         // We check that the created jar does not contain the org/sample/ejb package empty
419         assertClientJarContent( project,
420                                 new String[] { "META-INF/MANIFEST.MF",
421                                     "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
422                                     "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties",
423                                     "org/sample/ejb2/AppTwo.class" },
424                                 new String[] { "META-INF/ejb-jar.xml", "org/sample/ejb/AppOne.class",
425                                     "org/sample/ejb" } );
426 
427     }
428 
429     /**
430      * Tests if the mojo throws an exception when the EJB version is &lt; 3.0 and no deployment descriptor is present.
431      * The case with deployment descriptor present is covered by previous tests.
432      *
433      * @throws Exception if any exception occurs
434      */
435     public void testEjbComplianceVersionTwoDotOneWithoutDescriptor()
436         throws Exception
437     {
438         final MavenProjectResourcesStub project = createTestProject( "compliance-nodescriptor-2.1" );
439         final EjbMojo mojo = lookupMojoWithDefaultSettings( project );
440 
441         // put this on the root dir
442         project.addFile( "pom.xml", MavenProjectResourcesStub.ROOT_FILE );
443 
444         // start creating the environment
445         project.setupBuildEnvironment();
446 
447         setVariableValueToObject( mojo, "generateClient", Boolean.FALSE );
448         setVariableValueToObject( mojo, "ejbVersion", "2.1" );
449 
450         try
451         {
452             mojo.execute();
453             fail( "Exception should be thrown: No deployment descriptor present." );
454         }
455         catch ( MojoExecutionException e )
456         {
457             // OK
458         }
459     }
460 
461     /**
462      * Tests if the jar is created under EJB version 3.0 with deployment descriptor present.
463      *
464      * @throws Exception if any exception occurs
465      */
466     public void testEjbComplianceVersionThreeWithDescriptor()
467         throws Exception
468     {
469 
470         final MavenProjectResourcesStub project = createTestProject( "compliance-descriptor-3" );
471         final EjbMojo mojo = lookupMojoWithDefaultSettings( project );
472 
473         // put this on the target dir
474         project.addFile( "META-INF/ejb-jar.xml", MavenProjectResourcesStub.OUTPUT_FILE );
475 
476         // put this on the root dir
477         project.addFile( "pom.xml", MavenProjectResourcesStub.ROOT_FILE );
478 
479         // start creating the environment
480         project.setupBuildEnvironment();
481 
482         setVariableValueToObject( mojo, "generateClient", Boolean.FALSE );
483         setVariableValueToObject( mojo, "ejbVersion", "3.0" );
484 
485         mojo.execute();
486 
487         assertJarCreation( project, true, false );
488 
489     }
490 
491     /**
492      * Tests if the jar is created under EJB version 3.0 without deployment descriptor present.
493      *
494      * @throws Exception if any exception occurs
495      */
496     public void testEjbCompliance_3_0_WithoutDescriptor()
497         throws Exception
498     {
499         final MavenProjectResourcesStub project = createTestProject( "compliance-nodescriptor-3" );
500         final EjbMojo mojo = lookupMojoWithDefaultSettings( project );
501 
502         // put this on the root dir
503         project.addFile( "pom.xml", MavenProjectResourcesStub.ROOT_FILE );
504 
505         // start creating the environment
506         project.setupBuildEnvironment();
507 
508         setVariableValueToObject( mojo, "generateClient", Boolean.FALSE );
509         setVariableValueToObject( mojo, "ejbVersion", "3.0" );
510 
511         mojo.execute();
512 
513         assertJarCreation( project, true, false );
514     }
515 
516     public void testEjb1VersionValidation()
517     {
518         try
519         {
520             EjbMojo.validateEjbVersion( "1.1" );
521             fail( "MojoException is expected" );
522         }
523         catch ( MojoExecutionException mex )
524         {
525         }
526     }
527 
528     public void testEjb2VersionValidation()
529         throws MojoExecutionException
530     {
531         EjbMojo.validateEjbVersion( "2.1" );
532     }
533 
534     public void testEjb3VersionValidation()
535         throws MojoExecutionException
536     {
537         EjbMojo.validateEjbVersion( "3.2" );
538     }
539 
540     public void testEjb4VersionValidation()
541         throws MojoExecutionException
542     {
543         EjbMojo.validateEjbVersion( "4.0" );
544     }
545 
546     protected EjbMojo lookupMojo()
547         throws Exception
548     {
549         File pomFile = new File( getBasedir(), DEFAULT_POM_PATH );
550         EjbMojo mojo = (EjbMojo) lookupMojo( "ejb", pomFile );
551 
552         assertNotNull( mojo );
553 
554         return mojo;
555     }
556 
557     protected MavenProjectResourcesStub createTestProject( final String testName )
558         throws Exception
559     {
560         // this will automatically create the isolated
561         // test environment
562         return new MavenProjectResourcesStub( testName );
563     }
564 
565     protected void setupDefaultProject( final MavenProjectResourcesStub project )
566         throws Exception
567     {
568         // put this on the target dir
569         project.addFile( "META-INF/ejb-jar.xml", MavenProjectResourcesStub.OUTPUT_FILE );
570         // put this on the root dir
571         project.addFile( "pom.xml", MavenProjectResourcesStub.ROOT_FILE );
572         // start creating the environment
573         project.setupBuildEnvironment();
574 
575     }
576 
577     protected EjbMojo lookupMojoWithSettings( final MavenProject project, List<String> clientIncludes,
578                                               List<String> clientExcludes, List<String> excludes )
579                                                   throws Exception
580     {
581         final EjbMojo mojo = lookupMojo();
582         setVariableValueToObject( mojo, "project", project );
583         setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getDirectory() ) );
584         setVariableValueToObject( mojo, "sourceDirectory", new File( project.getBuild().getOutputDirectory() ) );
585         setVariableValueToObject( mojo, "jarName", DEFAULT_JAR_NAME );
586         setVariableValueToObject( mojo, "ejbJar", EjbMojo.DEFAULT_EJBJAR );
587         setVariableValueToObject( mojo, "clientExcludes", clientExcludes );
588         setVariableValueToObject( mojo, "clientIncludes", clientIncludes );
589         setVariableValueToObject( mojo, "excludes", excludes );
590         setVariableValueToObject( mojo, "clientClassifier", EjbMojo.DEFAULT_CLIENT_CLASSIFIER );
591 
592         return mojo;
593     }
594 
595     protected EjbMojo lookupMojoWithDefaultSettings( final MavenProject project )
596         throws Exception
597     {
598         return lookupMojoWithSettings( project, new LinkedList<String>(), new LinkedList<String>(), null );
599     }
600 
601     protected void assertJarCreation( final MavenProject project, boolean ejbJarCreated, boolean ejbClientJarCreated,
602                                       String classifier )
603     {
604         String checkedJarFile;
605         String checkedClientJarFile;
606 
607         if ( classifier == null )
608         {
609             checkedJarFile = project.getBuild().getDirectory() + "/" + DEFAULT_JAR_NAME + ".jar";
610             checkedClientJarFile = project.getBuild().getDirectory() + "/" + DEFAULT_JAR_NAME + "-client.jar";
611         }
612         else
613         {
614             checkedJarFile = project.getBuild().getDirectory() + "/" + DEFAULT_JAR_NAME + "-" + classifier + ".jar";
615             checkedClientJarFile =
616                 project.getBuild().getDirectory() + "/" + DEFAULT_JAR_NAME + "-" + classifier + "-client.jar";
617         }
618 
619         assertEquals( "Invalid value for ejb-jar creation", ejbJarCreated, FileUtils.fileExists( checkedJarFile ) );
620         assertEquals( "Invalid value for ejb-jar client creation", ejbClientJarCreated,
621                       FileUtils.fileExists( checkedClientJarFile ) );
622 
623     }
624 
625     protected void assertJarCreation( final MavenProject project, boolean ejbJarCreated, boolean ejbClientJarCreated )
626     {
627         assertJarCreation( project, ejbJarCreated, ejbClientJarCreated, null );
628 
629     }
630 
631     private void doAssertJarContent( final MavenProject project, final String fileName, final String[] expectedFiles,
632                                      final String[] unexpectedFiles )
633                                          throws IOException
634     {
635         String checkedJarFile = project.getBuild().getDirectory() + "/" + fileName;
636         if ( expectedFiles != null )
637         {
638             final JarContentChecker inclusionChecker = new JarContentChecker();
639 
640             // set expected jar contents
641             for ( String expectedFile : expectedFiles )
642             {
643                 inclusionChecker.addFile( new File( expectedFile ) );
644             }
645             assertTrue( inclusionChecker.isOK( new JarFile( checkedJarFile ) ) );
646         }
647         if ( unexpectedFiles != null )
648         {
649             final JarContentChecker exclusionChecker = new JarContentChecker();
650             for ( String unexpectedFile : unexpectedFiles )
651             {
652                 exclusionChecker.addFile( new File( unexpectedFile ) );
653             }
654             assertFalse( exclusionChecker.isOK( new JarFile( checkedJarFile ) ) );
655         }
656 
657     }
658 
659     protected void assertJarContent( final MavenProject project, final String[] expectedFiles,
660                                      final String[] unexpectedFiles )
661                                          throws IOException
662     {
663 
664         doAssertJarContent( project, DEFAULT_JAR_NAME + ".jar", expectedFiles, unexpectedFiles );
665     }
666 
667     protected void assertClientJarContent( final MavenProject project, final String[] expectedFiles,
668                                            final String[] unexpectedFiles )
669                                                throws IOException
670     {
671 
672         doAssertJarContent( project, DEFAULT_JAR_NAME + "-client.jar", expectedFiles, unexpectedFiles );
673 
674     }
675 }