View Javadoc
1   package org.apache.maven.plugin.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.ejb.stub.MavenProjectResourcesStub;
30  import org.apache.maven.plugin.ejb.utils.JarContentChecker;
31  import org.apache.maven.plugin.testing.AbstractMojoTestCase;
32  import org.apache.maven.project.MavenProject;
33  import org.codehaus.plexus.util.FileUtils;
34  
35  /**
36   * EJB plugin Test Case
37   */
38  
39  public class EjbMojoTest
40      extends AbstractMojoTestCase
41  {
42      static final String DEFAULT_POM_PATH = "target/test-classes/unit/ejbmojotest/plugin-config.xml";
43  
44      static final String DEFAULT_JAR_NAME = "testJar";
45  
46      public void setUp()
47          throws Exception
48      {
49          super.setUp();
50      }
51  
52      public void tearDown()
53          throws Exception
54      {
55  
56      }
57  
58      /**
59       * check test environment
60       *
61       * @throws Exception if any exception occurs
62       */
63      public void testTestEnvironment()
64          throws Exception
65      {
66          // Perform lookup on the Mojo to make sure everything is ok
67          lookupMojo();
68      }
69  
70      /**
71       * Basic jar creation test.
72       *
73       * @throws Exception if any exception occurs
74       */
75      public void testDefaultWithoutClientJar()
76          throws Exception
77      {
78          final MavenProjectResourcesStub project = createTestProject( "default-noclient" );
79          final EjbMojo mojo = lookupMojoWithDefaultSettings( project );
80  
81          setupDefaultProject( project );
82  
83          setVariableValueToObject( mojo, "generateClient", Boolean.FALSE );
84          setVariableValueToObject( mojo, "ejbVersion", "2.1" );
85  
86          mojo.execute();
87  
88          assertJarCreation( project, true, false );
89      }
90  
91      /**
92       * Classified jar creation test.
93       *
94       * @throws Exception if any exception occurs
95       */
96      public void testClassifiedJarWithoutClientJar()
97          throws Exception
98      {
99          final MavenProjectResourcesStub project = createTestProject( "classified-noclient" );
100         final EjbMojo mojo = lookupMojoWithDefaultSettings( project );
101 
102         setupDefaultProject( project );
103 
104         setVariableValueToObject( mojo, "generateClient", Boolean.FALSE );
105         setVariableValueToObject( mojo, "ejbVersion", "2.1" );
106         setVariableValueToObject( mojo, "classifier", "classified" );
107 
108         mojo.execute();
109 
110         assertJarCreation( project, true, false, "classified" );
111     }
112 
113     /**
114      * Basic jar creation test with client jar.
115      *
116      * @throws Exception if any exception occurs
117      */
118     public void testDefaultWithClientJar()
119         throws Exception
120     {
121         final MavenProjectResourcesStub project = createTestProject( "default-client" );
122         final EjbMojo mojo = lookupMojoWithDefaultSettings( project );
123 
124         setupDefaultProject( project );
125 
126         setVariableValueToObject( mojo, "generateClient", Boolean.TRUE );
127         setVariableValueToObject( mojo, "ejbVersion", "2.1" );
128 
129         mojo.execute();
130 
131         assertJarCreation( project, true, true );
132     }
133 
134     /**
135      * Classified jar creation test with client jar.
136      *
137      * @throws Exception if any exception occurs
138      */
139     public void testClassifiedJarWithClientJar()
140         throws Exception
141     {
142         final MavenProjectResourcesStub project = createTestProject( "classified-client" );
143         final EjbMojo mojo = lookupMojoWithDefaultSettings( project );
144 
145         setupDefaultProject( project );
146 
147         setVariableValueToObject( mojo, "generateClient", Boolean.TRUE );
148         setVariableValueToObject( mojo, "ejbVersion", "2.1" );
149         setVariableValueToObject( mojo, "classifier", "classified" );
150 
151         mojo.execute();
152 
153         assertJarCreation( project, true, true, "classified" );
154     }
155 
156     /**
157      * Default ejb jar inclusion and exclusion test.
158      *
159      * @throws Exception if any exception occurs
160      */
161     public void testDefaultInclusionsExclusions()
162         throws Exception
163     {
164 
165         final MavenProjectResourcesStub project = createTestProject( "includes-excludes-default" );
166         final EjbMojo mojo = lookupMojoWithDefaultSettings( project );
167 
168         // put this on the target output dir
169         project.addFile( "META-INF/ejb-jar.xml", MavenProjectResourcesStub.OUTPUT_FILE );
170         project.addFile( "org/sample/ejb/AppBean.class", MavenProjectResourcesStub.OUTPUT_FILE );
171         project.addFile( "org/sample/ejb/AppCMP.class", MavenProjectResourcesStub.OUTPUT_FILE );
172         project.addFile( "org/sample/ejb/AppSession.class", MavenProjectResourcesStub.OUTPUT_FILE );
173 
174         // put this on the root dir
175         project.addFile( "pom.xml", MavenProjectResourcesStub.ROOT_FILE );
176 
177         // start creating the environment
178         project.setupBuildEnvironment();
179 
180         setVariableValueToObject( mojo, "generateClient", Boolean.FALSE );
181         setVariableValueToObject( mojo, "ejbVersion", "2.1" );
182 
183         mojo.execute();
184 
185         assertJarCreation( project, true, false );
186         assertJarContent( project, new String[] { "META-INF/MANIFEST.MF", "META-INF/ejb-jar.xml",
187             "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
188             "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties", "org/sample/ejb/AppBean.class",
189             "org/sample/ejb/AppCMP.class", "org/sample/ejb/AppSession.class" }, null );
190     }
191 
192     /**
193      * Client jar default inclusion and exclusion test.
194      *
195      * @throws Exception if any exception occurs
196      */
197     public void testClientJarDefaultInclusionsExclusions()
198         throws Exception
199     {
200 
201         final MavenProjectResourcesStub project = createTestProject( "includes-excludes-client" );
202         final EjbMojo mojo = lookupMojoWithDefaultSettings( project );
203 
204         // put this on the target output dir
205         project.addFile( "META-INF/ejb-jar.xml", MavenProjectResourcesStub.OUTPUT_FILE );
206         project.addFile( "org/sample/ejb/AppBean.class", MavenProjectResourcesStub.OUTPUT_FILE );
207         project.addFile( "org/sample/ejb/AppCMP.class", MavenProjectResourcesStub.OUTPUT_FILE );
208         project.addFile( "org/sample/ejb/AppSession.class", MavenProjectResourcesStub.OUTPUT_FILE );
209         project.addFile( "org/sample/ejb/AppStub.class", MavenProjectResourcesStub.OUTPUT_FILE );
210 
211         // put this on the root dir
212         project.addFile( "pom.xml", MavenProjectResourcesStub.ROOT_FILE );
213 
214         // start creating the environment
215         project.setupBuildEnvironment();
216 
217         setVariableValueToObject( mojo, "generateClient", Boolean.TRUE );
218         setVariableValueToObject( mojo, "ejbVersion", "2.1" );
219 
220         mojo.execute();
221 
222         assertJarCreation( project, true, true );
223         assertClientJarContent( project, 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" }, new String[] { "META-INF/ejb-jar.xml",
267                                     "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" }, new String[] { "META-INF/ejb-jar.xml",
307                                     "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" }, new String[] { "META-INF/ejb-jar.xml",
348                               "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, new String[] { "META-INF/MANIFEST.MF",
385                                     "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
386                                     "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties",
387                                     "org/sample/ejb/App.class" },
388                                 new String[] { "META-INF/ejb-jar.xml", "org/sample/ejb/impl/AppImpl.class",
389                                     "org/sample/ejb/impl" } );
390     }
391 
392     /**
393      * Client jar exclusions test that leaves an empty package.
394      *
395      * @throws Exception if any exception occurs
396      */
397     public void testClientJarExclusionsWithEmptyPackage()
398         throws Exception
399     {
400 
401         final LinkedList<String> exclusions = new LinkedList<String>();
402         exclusions.add( "org/sample/ejb/**" );
403 
404         final MavenProjectResourcesStub project = createTestProject( "client-excludes-emptypackage" );
405         final EjbMojo mojo = lookupMojoWithSettings( project, new LinkedList<String>(), exclusions, null );
406 
407         // put this on the target output dir
408         project.addFile( "META-INF/ejb-jar.xml", MavenProjectResourcesStub.OUTPUT_FILE );
409         project.addFile( "org/sample/ejb/AppOne.class", MavenProjectResourcesStub.OUTPUT_FILE );
410         project.addFile( "org/sample/ejb2/AppTwo.class", MavenProjectResourcesStub.OUTPUT_FILE );
411 
412         // put this on the root dir
413         project.addFile( "pom.xml", MavenProjectResourcesStub.ROOT_FILE );
414 
415         // start creating the environment
416         project.setupBuildEnvironment();
417 
418         setVariableValueToObject( mojo, "generateClient", Boolean.TRUE );
419         setVariableValueToObject( mojo, "ejbVersion", "2.1" );
420 
421         mojo.execute();
422 
423         assertJarCreation( project, true, true );
424 
425         // We check that the created jar does not contain the org/sample/ejb package empty
426         assertClientJarContent( project,
427                                 new String[] { "META-INF/MANIFEST.MF",
428                                     "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
429                                     "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties",
430                                     "org/sample/ejb2/AppTwo.class" },
431                                 new String[] { "META-INF/ejb-jar.xml", "org/sample/ejb/AppOne.class", "org/sample/ejb" } );
432 
433     }
434 
435     /**
436      * Tests if the mojo throws an exception when the EJB version is < 3.0 and no deployment descriptor is present. The
437      * case with deployment descriptor present is covered by previous tests.
438      *
439      * @throws Exception if any exception occurs
440      */
441     public void testEjbComplianceVersionTwoDotOneWithoutDescriptor()
442         throws Exception
443     {
444         final MavenProjectResourcesStub project = createTestProject( "compliance-nodescriptor-2.1" );
445         final EjbMojo mojo = lookupMojoWithDefaultSettings( project );
446 
447         // put this on the root dir
448         project.addFile( "pom.xml", MavenProjectResourcesStub.ROOT_FILE );
449 
450         // start creating the environment
451         project.setupBuildEnvironment();
452 
453         setVariableValueToObject( mojo, "generateClient", Boolean.FALSE );
454         setVariableValueToObject( mojo, "ejbVersion", "2.1" );
455 
456         try
457         {
458             mojo.execute();
459             fail( "Exception should be thrown: No deployment descriptor present." );
460         }
461         catch ( MojoExecutionException e )
462         {
463             // OK
464         }
465     }
466 
467     /**
468      * Tests if the jar is created under EJB version 3.0 with deployment descriptor present.
469      *
470      * @throws Exception if any exception occurs
471      */
472     public void testEjbComplianceVersionThreeWithDescriptor()
473         throws Exception
474     {
475 
476         final MavenProjectResourcesStub project = createTestProject( "compliance-descriptor-3" );
477         final EjbMojo mojo = lookupMojoWithDefaultSettings( project );
478 
479         // put this on the target dir
480         project.addFile( "META-INF/ejb-jar.xml", MavenProjectResourcesStub.OUTPUT_FILE );
481 
482         // put this on the root dir
483         project.addFile( "pom.xml", MavenProjectResourcesStub.ROOT_FILE );
484 
485         // start creating the environment
486         project.setupBuildEnvironment();
487 
488         setVariableValueToObject( mojo, "generateClient", Boolean.FALSE );
489         setVariableValueToObject( mojo, "ejbVersion", "3.0" );
490 
491         mojo.execute();
492 
493         assertJarCreation( project, true, false );
494 
495     }
496 
497     /**
498      * Tests if the jar is created under EJB version 3.0 without deployment descriptor present.
499      *
500      * @throws Exception if any exception occurs
501      */
502     public void testEjbCompliance_3_0_WithoutDescriptor()
503         throws Exception
504     {
505         final MavenProjectResourcesStub project = createTestProject( "compliance-nodescriptor-3" );
506         final EjbMojo mojo = lookupMojoWithDefaultSettings( project );
507 
508         // put this on the root dir
509         project.addFile( "pom.xml", MavenProjectResourcesStub.ROOT_FILE );
510 
511         // start creating the environment
512         project.setupBuildEnvironment();
513 
514         setVariableValueToObject( mojo, "generateClient", Boolean.FALSE );
515         setVariableValueToObject( mojo, "ejbVersion", "3.0" );
516 
517         mojo.execute();
518 
519         assertJarCreation( project, true, false );
520     }
521 
522     protected EjbMojo lookupMojo()
523         throws Exception
524     {
525         File pomFile = new File( getBasedir(), DEFAULT_POM_PATH );
526         EjbMojo mojo = (EjbMojo) lookupMojo( "ejb", pomFile );
527 
528         assertNotNull( mojo );
529 
530         return mojo;
531     }
532 
533     protected MavenProjectResourcesStub createTestProject( final String testName )
534         throws Exception
535     {
536         // this will automatically create the isolated
537         // test environment
538         return new MavenProjectResourcesStub( testName );
539     }
540 
541     protected void setupDefaultProject( final MavenProjectResourcesStub project )
542         throws Exception
543     {
544         // put this on the target dir
545         project.addFile( "META-INF/ejb-jar.xml", MavenProjectResourcesStub.OUTPUT_FILE );
546         // put this on the root dir
547         project.addFile( "pom.xml", MavenProjectResourcesStub.ROOT_FILE );
548         // start creating the environment
549         project.setupBuildEnvironment();
550 
551     }
552 
553     protected EjbMojo lookupMojoWithSettings( final MavenProject project, List<String> clientIncludes,
554                                               List<String> clientExcludes, List<String> excludes )
555         throws Exception
556     {
557         final EjbMojo mojo = lookupMojo();
558         setVariableValueToObject( mojo, "project", project );
559         setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getDirectory() ) );
560         setVariableValueToObject( mojo, "sourceDirectory", new File( project.getBuild().getOutputDirectory() ) );
561         setVariableValueToObject( mojo, "jarName", DEFAULT_JAR_NAME );
562         setVariableValueToObject( mojo, "clientExcludes", clientExcludes );
563         setVariableValueToObject( mojo, "clientIncludes", clientIncludes );
564         setVariableValueToObject( mojo, "excludes", excludes );
565 
566         return mojo;
567     }
568 
569     protected EjbMojo lookupMojoWithDefaultSettings( final MavenProject project )
570         throws Exception
571     {
572         return lookupMojoWithSettings( project, new LinkedList<String>(), new LinkedList<String>(), null );
573     }
574 
575     protected void assertJarCreation( final MavenProject project, boolean ejbJarCreated, boolean ejbClientJarCreated,
576                                       String classifier )
577     {
578         String checkedJarFile;
579         String checkedClientJarFile;
580 
581         if ( classifier == null )
582         {
583             checkedJarFile = project.getBuild().getDirectory() + "/" + DEFAULT_JAR_NAME + ".jar";
584             checkedClientJarFile = project.getBuild().getDirectory() + "/" + DEFAULT_JAR_NAME + "-client.jar";
585         }
586         else
587         {
588             checkedJarFile = project.getBuild().getDirectory() + "/" + DEFAULT_JAR_NAME + "-" + classifier + ".jar";
589             checkedClientJarFile =
590                 project.getBuild().getDirectory() + "/" + DEFAULT_JAR_NAME + "-" + classifier + "-client.jar";
591         }
592 
593         assertEquals( "Invalid value for ejb-jar creation", ejbJarCreated, FileUtils.fileExists( checkedJarFile ) );
594         assertEquals( "Invalid value for ejb-jar client creation", ejbClientJarCreated,
595                       FileUtils.fileExists( checkedClientJarFile ) );
596 
597     }
598 
599     protected void assertJarCreation( final MavenProject project, boolean ejbJarCreated, boolean ejbClientJarCreated )
600     {
601         assertJarCreation( project, ejbJarCreated, ejbClientJarCreated, null );
602 
603     }
604 
605     private void doAssertJarContent( final MavenProject project, final String fileName, final String[] expectedFiles,
606                                      final String[] unexpectedFiles )
607         throws IOException
608     {
609         String checkedJarFile = project.getBuild().getDirectory() + "/" + fileName;
610         if ( expectedFiles != null )
611         {
612             final JarContentChecker inclusionChecker = new JarContentChecker();
613 
614             // set expected jar contents
615             for ( String expectedFile : expectedFiles )
616             {
617                 inclusionChecker.addFile( new File( expectedFile ) );
618             }
619             assertTrue( inclusionChecker.isOK( new JarFile( checkedJarFile ) ) );
620         }
621         if ( unexpectedFiles != null )
622         {
623             final JarContentChecker exclusionChecker = new JarContentChecker();
624             for ( String unexpectedFile : unexpectedFiles )
625             {
626                 exclusionChecker.addFile( new File( unexpectedFile ) );
627             }
628             assertFalse( exclusionChecker.isOK( new JarFile( checkedJarFile ) ) );
629         }
630 
631     }
632 
633     protected void assertJarContent( final MavenProject project, final String[] expectedFiles,
634                                      final String[] unexpectedFiles )
635         throws IOException
636     {
637 
638         doAssertJarContent( project, DEFAULT_JAR_NAME + ".jar", expectedFiles, unexpectedFiles );
639     }
640 
641     protected void assertClientJarContent( final MavenProject project, final String[] expectedFiles,
642                                            final String[] unexpectedFiles )
643         throws IOException
644     {
645 
646         doAssertJarContent( project, DEFAULT_JAR_NAME + "-client.jar", expectedFiles, unexpectedFiles );
647 
648     }
649 }