Permalink
Browse files

[SHRINKWRAP-233] Added test case for addDefaultPackage

  • Loading branch information...
1 parent 46efdaa commit 2e5fef8d1e3ebe383caeff24bf57b367ebab2bff Ivan Pazmino committed Jul 10, 2011
Showing with 39 additions and 6 deletions.
  1. +39 −6 impl-base/src/test/java/DefaultPackageAddTestCase.java
@@ -4,7 +4,9 @@
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.After;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
/*
@@ -45,10 +47,33 @@
* Logger
*/
private static final Logger log = Logger.getLogger(DefaultPackageAddTestCase.class.getName());
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ private ArchivePath classInDefaultPackagePath;
+ private ArchivePath innerClassInDefaultPackagePath;
+
+ //-------------------------------------------------------------------------------------||
+ // Fixtures ---------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ @Before
+ public void setupPaths() {
+ classInDefaultPackagePath = ArchivePaths.create("/ClassInDefaultPackage.class");
+ innerClassInDefaultPackagePath = ArchivePaths.create("/ClassInDefaultPackage$InnerClassInDefaultPackage.class");
+ }
+
+ @After
+ public void cleanupPaths() {
+ classInDefaultPackagePath = null;
+ innerClassInDefaultPackagePath = null;
+ }
//-------------------------------------------------------------------------------------||
// Tests ------------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
/**
* Ensures that classes from the default package may be added
@@ -63,14 +88,22 @@ public void canAddClassFromDefaultPackage() throws Exception
.addClass(ClassInDefaultPackage.class);
log.info(archive.toString(true));
- // Ensure the classes were added in the paths expected
- final ArchivePath classInDefaultPackagePath = ArchivePaths.create("/ClassInDefaultPackage.class");
- final ArchivePath innerClassInDefaultPackagePath = ArchivePaths
- .create("/ClassInDefaultPackage$InnerClassInDefaultPackage.class");
+ assertClassesWereAdded(archive);
+ }
+
+ @Test
+ public void testAddDefaultPackage() {
+ JavaArchive archive = ShrinkWrap.create(JavaArchive.class);
+ archive.addDefaultPackage();
+
+ assertClassesWereAdded(archive);
+ }
+
+ private void assertClassesWereAdded(JavaArchive archive) {
Assert.assertTrue("Class in default package was not added to archive", archive
.contains(classInDefaultPackagePath));
Assert.assertTrue("Inner class in default package was not added to archive", archive
.contains(innerClassInDefaultPackagePath));
}
-
+
}

0 comments on commit 2e5fef8

Please sign in to comment.