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