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