Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[SHRINKWRAP-233] Added test case for addDefaultPackage

  • Loading branch information...
commit 2e5fef8d1e3ebe383caeff24bf57b367ebab2bff 1 parent 46efdaa
Ivan Pazmino authored

Showing 1 changed file with 39 additions and 6 deletions. Show diff stats Hide diff stats

  1. +39 6 impl-base/src/test/java/DefaultPackageAddTestCase.java
45 impl-base/src/test/java/DefaultPackageAddTestCase.java
@@ -4,7 +4,9 @@
4 4 import org.jboss.shrinkwrap.api.ArchivePaths;
5 5 import org.jboss.shrinkwrap.api.ShrinkWrap;
6 6 import org.jboss.shrinkwrap.api.spec.JavaArchive;
  7 +import org.junit.After;
7 8 import org.junit.Assert;
  9 +import org.junit.Before;
8 10 import org.junit.Test;
9 11
10 12 /*
@@ -45,10 +47,33 @@
45 47 * Logger
46 48 */
47 49 private static final Logger log = Logger.getLogger(DefaultPackageAddTestCase.class.getName());
  50 +
  51 + //-------------------------------------------------------------------------------------||
  52 + // Instance Members -------------------------------------------------------------------||
  53 + //-------------------------------------------------------------------------------------||
  54 +
  55 + private ArchivePath classInDefaultPackagePath;
  56 + private ArchivePath innerClassInDefaultPackagePath;
  57 +
  58 + //-------------------------------------------------------------------------------------||
  59 + // Fixtures ---------------------------------------------------------------------------||
  60 + //-------------------------------------------------------------------------------------||
  61 +
  62 + @Before
  63 + public void setupPaths() {
  64 + classInDefaultPackagePath = ArchivePaths.create("/ClassInDefaultPackage.class");
  65 + innerClassInDefaultPackagePath = ArchivePaths.create("/ClassInDefaultPackage$InnerClassInDefaultPackage.class");
  66 + }
  67 +
  68 + @After
  69 + public void cleanupPaths() {
  70 + classInDefaultPackagePath = null;
  71 + innerClassInDefaultPackagePath = null;
  72 + }
48 73
49 74 //-------------------------------------------------------------------------------------||
50 75 // Tests ------------------------------------------------------------------------------||
51   - //-------------------------------------------------------------------------------------||
  76 + //-------------------------------------------------------------------------------------||
52 77
53 78 /**
54 79 * Ensures that classes from the default package may be added
@@ -63,14 +88,22 @@ public void canAddClassFromDefaultPackage() throws Exception
63 88 .addClass(ClassInDefaultPackage.class);
64 89 log.info(archive.toString(true));
65 90
66   - // Ensure the classes were added in the paths expected
67   - final ArchivePath classInDefaultPackagePath = ArchivePaths.create("/ClassInDefaultPackage.class");
68   - final ArchivePath innerClassInDefaultPackagePath = ArchivePaths
69   - .create("/ClassInDefaultPackage$InnerClassInDefaultPackage.class");
  91 + assertClassesWereAdded(archive);
  92 + }
  93 +
  94 + @Test
  95 + public void testAddDefaultPackage() {
  96 + JavaArchive archive = ShrinkWrap.create(JavaArchive.class);
  97 + archive.addDefaultPackage();
  98 +
  99 + assertClassesWereAdded(archive);
  100 + }
  101 +
  102 + private void assertClassesWereAdded(JavaArchive archive) {
70 103 Assert.assertTrue("Class in default package was not added to archive", archive
71 104 .contains(classInDefaultPackagePath));
72 105 Assert.assertTrue("Inner class in default package was not added to archive", archive
73 106 .contains(innerClassInDefaultPackagePath));
74 107 }
75   -
  108 +
76 109 }

0 comments on commit 2e5fef8

Please sign in to comment.
Something went wrong with that request. Please try again.