[jboss-svn-commits] JBoss Common SVN: r3536 - in shrinkwrap/trunk/impl-base/src: test/java/org/jboss/shrinkwrap/impl/base/spec and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Sep 22 00:12:43 EDT 2009
Author: johnbailey
Date: 2009-09-22 00:12:40 -0400 (Tue, 22 Sep 2009)
New Revision: 3536
Added:
shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/ContainerTestBase.java
Removed:
shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ResourceNotFoundException.java
shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/SecurityActions.java
Modified:
shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ContainerBase.java
shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/EnterpriseArchiveImplTestCase.java
shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/JavaArchiveImplTestCase.java
shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/WebArchiveImplTestCase.java
shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/ArchiveTestBase.java
shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/unit/MemoryMapArchiveTestCase.java
Log:
[SHRINKWRAP-40] - Made a pass through the org.jboss.shrinkwrap.impl.base package to improve coverage
Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ContainerBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ContainerBase.java 2009-09-18 18:45:44 UTC (rev 3535)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ContainerBase.java 2009-09-22 04:12:40 UTC (rev 3536)
@@ -192,7 +192,7 @@
@Override
public Asset get(String path) throws AssetNotFoundException, IllegalArgumentException
{
- return get(new BasicPath(path));
+ return archive.get(path);
}
/* (non-Javadoc)
@@ -461,13 +461,7 @@
{
Validate.notNull(archive, "Archive must be specified");
- Map<Path, Asset> content = archive.getContent();
- for(Map.Entry<Path, Asset> entry : content.entrySet())
- {
- Path location = new BasicPath(getLibraryPath(), entry.getKey());
- add(location, entry.getValue());
- }
- return covarientReturn();
+ return add(getLibraryPath(), archive);
};
/* (non-Javadoc)
Deleted: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ResourceNotFoundException.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ResourceNotFoundException.java 2009-09-18 18:45:44 UTC (rev 3535)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ResourceNotFoundException.java 2009-09-22 04:12:40 UTC (rev 3536)
@@ -1,63 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.shrinkwrap.impl.base;
-
-/**
- * ResourceNotFoundException
- *
- * Thrown when a resource is requested, but could not be found
- * within the context of the given ClassLoader
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class ResourceNotFoundException extends IllegalArgumentException
-{
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * serialVersionUID
- */
- private static final long serialVersionUID = 1L;
-
- //-------------------------------------------------------------------------------------||
- // Constructors -----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- public ResourceNotFoundException()
- {
- super();
- }
-
- public ResourceNotFoundException(final String message, final Throwable cause)
- {
- super(message, cause);
- }
-
- public ResourceNotFoundException(final String s)
- {
- super(s);
- }
-
- public ResourceNotFoundException(final Throwable cause)
- {
- super(cause);
- }
-
-}
Deleted: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/SecurityActions.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/SecurityActions.java 2009-09-18 18:45:44 UTC (rev 3535)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/SecurityActions.java 2009-09-22 04:12:40 UTC (rev 3536)
@@ -1,63 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.shrinkwrap.impl.base;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-/**
- * SecurityActions
- *
- * A set of privileged actions that are not to leak out
- * of this package
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-final class SecurityActions
-{
-
- //-------------------------------------------------------------------------------||
- // Constructor ------------------------------------------------------------------||
- //-------------------------------------------------------------------------------||
-
- /**
- * No external instanciation
- */
- private SecurityActions()
- {
-
- }
-
- //-------------------------------------------------------------------------------||
- // Utility Methods --------------------------------------------------------------||
- //-------------------------------------------------------------------------------||
-
- /**
- * Obtains the Thread Context ClassLoader
- */
- static ClassLoader getThreadContextClassLoader()
- {
- return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
- {
- public ClassLoader run()
- {
- return Thread.currentThread().getContextClassLoader();
- }
- });
- }
-}
Modified: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/EnterpriseArchiveImplTestCase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/EnterpriseArchiveImplTestCase.java 2009-09-18 18:45:44 UTC (rev 3535)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/EnterpriseArchiveImplTestCase.java 2009-09-22 04:12:40 UTC (rev 3536)
@@ -17,132 +17,224 @@
package org.jboss.shrinkwrap.impl.base.spec;
import org.jboss.shrinkwrap.api.Path;
+import org.jboss.shrinkwrap.api.container.ClassContainer;
+import org.jboss.shrinkwrap.api.container.LibraryContainer;
+import org.jboss.shrinkwrap.api.container.ManifestContainer;
+import org.jboss.shrinkwrap.api.container.ResourceContainer;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.impl.base.MemoryMapArchiveImpl;
import org.jboss.shrinkwrap.impl.base.asset.AssetUtil;
import org.jboss.shrinkwrap.impl.base.path.BasicPath;
-import org.jboss.shrinkwrap.impl.base.spec.EnterpriseArchiveImpl;
-import org.jboss.shrinkwrap.impl.base.spec.JavaArchiveImpl;
+import org.jboss.shrinkwrap.impl.base.test.ContainerTestBase;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
-
/**
* EnterpriseArchiveImplTest
*
* Test to ensure that EnterpriseArchiveImpl follow to java ear spec.
*
* @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
* @version $Revision: $
*/
-public class EnterpriseArchiveImplTestCase
+public class EnterpriseArchiveImplTestCase extends ContainerTestBase<EnterpriseArchive>
{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
private static final String TEST_RESOURCE = "org/jboss/shrinkwrap/impl/base/asset/Test.properties";
-
+
private static final Path PATH_APPLICATION = new BasicPath("META-INF");
-
+
private static final Path PATH_LIBRARY = new BasicPath("lib");
private static final Path PATH_MODULE = new BasicPath("/");
-
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
private EnterpriseArchive archive;
+ //-------------------------------------------------------------------------------------||
+ // Lifecycle Methods ------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
@Before
- public void createWebArchive() throws Exception
+ public void createEnterpriseArchive() throws Exception
{
- archive = new EnterpriseArchiveImpl(new MemoryMapArchiveImpl());
+ archive = createNewArchive();
}
-
+
@After
public void ls()
{
System.out.println("test at jboss:/$ ls -l " + archive.getName());
System.out.println(archive.toString(true));
}
-
+
+ //-------------------------------------------------------------------------------------||
+ // Required Impls - ArchiveTestBase ---------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Return the current EnterpriseArchive
+ */
+ @Override
+ protected EnterpriseArchive getArchive()
+ {
+ return archive;
+ }
+
+ /**
+ * Create a new instance of a EnterpriseArchive
+ */
+ @Override
+ protected EnterpriseArchive createNewArchive()
+ {
+ return new EnterpriseArchiveImpl(new MemoryMapArchiveImpl());
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Impls - ContainerTestBase -------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ @Override
+ protected ClassContainer<EnterpriseArchive> getClassContainer()
+ {
+ throw new UnsupportedOperationException("EnterpriseArchives do not support classes");
+ }
+
+ @Override
+ protected Path getClassesPath()
+ {
+ throw new UnsupportedOperationException("EnterpriseArchives do not support classes");
+ }
+
+ @Override
+ protected LibraryContainer<EnterpriseArchive> getLibraryContainer()
+ {
+ return archive;
+ }
+
+ @Override
+ protected Path getManifestPath()
+ {
+ return PATH_APPLICATION;
+ }
+
+ @Override
+ protected Path getResourcePath()
+ {
+ return PATH_APPLICATION;
+ }
+
+ @Override
+ protected Path getLibraryPath()
+ {
+ return PATH_LIBRARY;
+ }
+
+ @Override
+ protected ManifestContainer<EnterpriseArchive> getManifestContainer()
+ {
+ return getArchive();
+ }
+
+ @Override
+ protected ResourceContainer<EnterpriseArchive> getResourceContainer()
+ {
+ return getArchive();
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
@Test
- public void shouldBeAbleToAddApplicationXML() throws Exception
+ public void shouldBeAbleToAddApplicationXML() throws Exception
{
archive.setApplicationXML(TEST_RESOURCE);
-
+
Path expectedPath = new BasicPath(PATH_APPLICATION, "application.xml");
-
- Assert.assertTrue(
- "applicaton.xml should be located in /META-INF/application.xml",
- archive.contains(expectedPath));
+
+ Assert
+ .assertTrue("applicaton.xml should be located in /META-INF/application.xml", archive.contains(expectedPath));
}
@Test
- public void shouldBeAbleToAddApplicationResource() throws Exception
+ public void shouldBeAbleToAddApplicationResource() throws Exception
{
archive.addApplicationResource(TEST_RESOURCE);
-
+
Path expectedPath = new BasicPath(PATH_APPLICATION, TEST_RESOURCE);
-
- Assert.assertTrue(
- "A application resource should be located in /META-INF/",
- archive.contains(expectedPath));
+
+ Assert.assertTrue("A application resource should be located in /META-INF/", archive.contains(expectedPath));
}
@Test
- public void shouldBeAbleToAddApplicationResourceWithNewName() throws Exception
+ public void shouldBeAbleToAddApplicationResourceWithNewName() throws Exception
{
String newName = "test.txt";
archive.addApplicationResource(new BasicPath(newName), TEST_RESOURCE);
-
+
Path expectedPath = new BasicPath(PATH_APPLICATION, newName);
-
- Assert.assertTrue(
- "A application resource should be located in /META-INF/",
- archive.contains(expectedPath));
+
+ Assert.assertTrue("A application resource should be located in /META-INF/", archive.contains(expectedPath));
}
-
- @Test
- public void shouldBeAbleToAddLibrary() throws Exception
- {
- archive.addLibrary(TEST_RESOURCE);
- Path expectedPath = new BasicPath(PATH_LIBRARY, TEST_RESOURCE);
-
- Assert.assertTrue(
- "A library should be located in /lib/",
- archive.contains(expectedPath));
- }
-
@Test
- public void shouldBeAbleToAddModule() throws Exception
+ public void shouldBeAbleToAddModule() throws Exception
{
archive.addModule(TEST_RESOURCE);
- Path expectedPath = new BasicPath(
- PATH_MODULE,
- AssetUtil.getNameForClassloaderResource(TEST_RESOURCE));
-
- Assert.assertTrue(
- "A application module should be located in /",
- archive.contains(expectedPath));
+ Path expectedPath = new BasicPath(PATH_MODULE, AssetUtil.getNameForClassloaderResource(TEST_RESOURCE));
+
+ Assert.assertTrue("A application module should be located in /", archive.contains(expectedPath));
}
-
- //@Test
- // TODO: should we be able to add a ArchiveAsset, to add aarchive as a single jar not a exploded jar?
- public void shouldBeAbleToAddArchiveModule() throws Exception
+
+ @Test
+ public void shouldBeAbleToAddArchiveModule() throws Exception
{
JavaArchive moduleArchive = new JavaArchiveImpl(new MemoryMapArchiveImpl("test.jar"));
moduleArchive.addResource(TEST_RESOURCE);
moduleArchive.addResource(new BasicPath("test.txt"), TEST_RESOURCE);
-
+
archive.addModule(moduleArchive);
- Path expectedPath = new BasicPath(
- PATH_MODULE,
- moduleArchive.getName());
-
- Assert.assertTrue(
- "A application module should be located in /",
- archive.contains(expectedPath));
+ Path expectedPath = new BasicPath(PATH_MODULE, moduleArchive.getName());
+
+ Assert.assertTrue("A application module should be located in /", archive.contains(expectedPath));
}
-
+
+ @Ignore
+ @Override
+ public void testAddClass() throws Exception
+ {
+ }
+
+ @Ignore
+ @Override
+ public void testAddClasses() throws Exception
+ {
+ }
+
+ @Ignore
+ @Override
+ public void testAddPackage() throws Exception
+ {
+ }
+
+ @Ignore
+ @Override
+ public void testAddPackageNonRecursive() throws Exception
+ {
+ }
+
}
Modified: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/JavaArchiveImplTestCase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/JavaArchiveImplTestCase.java 2009-09-18 18:45:44 UTC (rev 3535)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/JavaArchiveImplTestCase.java 2009-09-22 04:12:40 UTC (rev 3536)
@@ -19,15 +19,18 @@
import java.util.logging.Logger;
import org.jboss.shrinkwrap.api.Path;
+import org.jboss.shrinkwrap.api.container.ClassContainer;
+import org.jboss.shrinkwrap.api.container.LibraryContainer;
+import org.jboss.shrinkwrap.api.container.ManifestContainer;
+import org.jboss.shrinkwrap.api.container.ResourceContainer;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.impl.base.MemoryMapArchiveImpl;
-import org.jboss.shrinkwrap.impl.base.asset.AssetUtil;
import org.jboss.shrinkwrap.impl.base.path.BasicPath;
-import org.jboss.shrinkwrap.impl.base.spec.JavaArchiveImpl;
-import org.jboss.shrinkwrap.impl.base.spec.donotchange.DummyClassUsedForClassResourceTest;
+import org.jboss.shrinkwrap.impl.base.test.ContainerTestBase;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -36,26 +39,39 @@
* Test case to ensure that the JavaArchive follows the Jar spec.
*
* @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
* @version $Revision: $
*/
-public class JavaArchiveImplTestCase
+public class JavaArchiveImplTestCase extends ContainerTestBase<JavaArchive>
{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
private static final Logger log = Logger.getLogger(JavaArchiveImplTestCase.class.getName());
-
+
private static final String TEST_RESOURCE = "org/jboss/shrinkwrap/impl/base/asset/Test.properties";
private static final Path PATH_MANIFEST = new BasicPath("META-INF");
- private static final Path PATH_RESOURCE = new BasicPath("/");
-
private static final Path PATH_CLASS = new BasicPath("/");
+ private static final Path PATH_RESOURCE = new BasicPath();
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
private JavaArchive archive;
+ //-------------------------------------------------------------------------------------||
+ // Lifecycle Methods ------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
@Before
public void createArchive()
{
- archive = new JavaArchiveImpl(new MemoryMapArchiveImpl());
+ archive = createNewArchive();
}
@After
@@ -65,96 +81,111 @@
System.out.println(archive.toString(true));
}
- @Test
- public void shouldBeAbleToSetManifestFile() throws Exception
+ //-------------------------------------------------------------------------------------||
+ // Required Impls - ArchiveTestBase ---------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Return the archive to super class
+ */
+ @Override
+ protected JavaArchive getArchive()
{
- archive.setManifest(TEST_RESOURCE);
-
- Path expectedPath = new BasicPath(PATH_MANIFEST, "MANIFEST.MF");
-
- Assert.assertTrue(
- "The MANIFEST.MF file should be located under /META-INF/MANIFEST.MF",
- archive.contains(expectedPath));
+ return archive;
}
- @Test
- public void shouldBeAbleToAddManifestResource() throws Exception
+ /**
+ * Create a new JavaArchive instance
+ */
+ @Override
+ protected JavaArchive createNewArchive()
{
- archive.addManifestResource(TEST_RESOURCE);
-
- Path expectedPath = new BasicPath(PATH_MANIFEST, TEST_RESOURCE);
-
- Assert.assertTrue(
- "A manifest resource should be located under /META-INF/",
- archive.contains(expectedPath));
+ return new JavaArchiveImpl(new MemoryMapArchiveImpl());
}
- @Test
- public void shouldBeAbleToAddManifestResourceWithNewName() throws Exception
+ //-------------------------------------------------------------------------------------||
+ // Required Impls - ContainerTestBase ---------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ @Override
+ protected ManifestContainer<JavaArchive> getManifestContainer()
{
- String newName = "test.txt";
- archive.addManifestResource(new BasicPath(newName), TEST_RESOURCE);
-
- Path expectedPath = new BasicPath(PATH_MANIFEST, newName);
-
- Assert.assertTrue(
- "A manifest resoruce should be located under /META-INF/",
- archive.contains(expectedPath));
+ return getArchive();
}
- @Test
- public void shouldBeAbleToAddResource() throws Exception
+ @Override
+ protected ResourceContainer<JavaArchive> getResourceContainer()
{
- archive.addResource(TEST_RESOURCE);
-
- Path expectedPath = new BasicPath(PATH_RESOURCE, TEST_RESOURCE);
-
- Assert.assertTrue(
- "A resoruce should be located under /",
- archive.contains(expectedPath));
+ return getArchive();
}
- @Test
- public void shouldBeAbleToAddResourceWithNewName() throws Exception
+ @Override
+ protected ClassContainer<JavaArchive> getClassContainer()
{
- String newName = "test.txt";
- archive.addResource(TEST_RESOURCE, newName);
-
- Path expectedPath = new BasicPath(
- PATH_RESOURCE,
- "/org/jboss/shrinkwrap/impl/base/asset/" + newName);
-
- Assert.assertTrue(
- "A resoruce should be located under /",
- archive.contains(expectedPath));
+ return archive;
}
- @Test
- public void shouldBeAbleToAddClass() throws Exception
+ @Override
+ protected LibraryContainer<JavaArchive> getLibraryContainer()
{
- archive.addClasses(DummyClassUsedForClassResourceTest.class);
+ throw new UnsupportedOperationException("JavaArchive does not support libraries");
+ }
- Path expectedPath = new BasicPath(
- PATH_CLASS,
- AssetUtil.getFullPathForClassResource(DummyClassUsedForClassResourceTest.class));
-
- Assert.assertTrue(
- "A class should be located under /",
- archive.contains(expectedPath));
+ @Override
+ protected Path getManifestPath()
+ {
+ return PATH_MANIFEST;
}
+ @Override
+ protected Path getResourcePath()
+ {
+ return PATH_RESOURCE;
+ }
+
+ @Override
+ protected Path getClassesPath()
+ {
+ return PATH_CLASS;
+ }
+
+ @Override
+ protected Path getLibraryPath()
+ {
+ throw new UnsupportedOperationException("JavaArchive does not support libraries");
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
@Test
- public void shouldBeAbleToAddPackage() throws Exception
+ public void shouldBeAbleToSetManifestFile() throws Exception
{
- archive.addPackages(false, DummyClassUsedForClassResourceTest.class.getPackage());
+ archive.setManifest(TEST_RESOURCE);
- Path expectedPath = new BasicPath(
- PATH_CLASS,
- AssetUtil.getFullPathForClassResource(DummyClassUsedForClassResourceTest.class));
-
- Assert.assertTrue(
- "A class should be located under /",
- archive.contains(expectedPath));
+ Path expectedPath = new BasicPath(PATH_MANIFEST, "MANIFEST.MF");
+
+ Assert.assertTrue("The MANIFEST.MF file should be located under /META-INF/MANIFEST.MF", archive
+ .contains(expectedPath));
}
+ @Ignore
+ @Override
+ public void testAddLibrary() throws Exception
+ {
+ }
+
+ @Ignore
+ @Override
+ public void testAddLibraryToPath() throws Exception
+ {
+ }
+
+ @Ignore
+ @Override
+ public void testAddArchiveAsLibrary() throws Exception
+ {
+ }
+
}
Modified: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/WebArchiveImplTestCase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/WebArchiveImplTestCase.java 2009-09-18 18:45:44 UTC (rev 3535)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/WebArchiveImplTestCase.java 2009-09-22 04:12:40 UTC (rev 3536)
@@ -17,12 +17,14 @@
package org.jboss.shrinkwrap.impl.base.spec;
import org.jboss.shrinkwrap.api.Path;
+import org.jboss.shrinkwrap.api.container.ClassContainer;
+import org.jboss.shrinkwrap.api.container.LibraryContainer;
+import org.jboss.shrinkwrap.api.container.ManifestContainer;
+import org.jboss.shrinkwrap.api.container.ResourceContainer;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.impl.base.MemoryMapArchiveImpl;
-import org.jboss.shrinkwrap.impl.base.asset.AssetUtil;
import org.jboss.shrinkwrap.impl.base.path.BasicPath;
-import org.jboss.shrinkwrap.impl.base.spec.WebArchiveImpl;
-import org.jboss.shrinkwrap.impl.base.spec.donotchange.DummyClassUsedForClassResourceTest;
+import org.jboss.shrinkwrap.impl.base.test.ContainerTestBase;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -34,28 +36,41 @@
* Test case to ensure that the WebArchive follows the War spec.
*
* @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
* @version $Revision: $
*/
-public class WebArchiveImplTestCase
+public class WebArchiveImplTestCase extends ContainerTestBase<WebArchive>
{
- private static final String TEST_RESOURCE = "org/jboss/shrinkwrap/impl/base/asset/Test.properties";
-
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
private static final Path PATH_WEBINF = new BasicPath("WEB-INF");
private static final Path PATH_LIBRARY = new BasicPath(PATH_WEBINF, "lib");
private static final Path PATH_CLASSES = new BasicPath(PATH_WEBINF, "classes");
+ private static final Path PATH_MANIFEST = new BasicPath("META-INF");
+
private static final Path PATH_RESOURCE = new BasicPath();
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
private WebArchive archive;
+ //-------------------------------------------------------------------------------------||
+ // Lifecycle Methods ------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
@Before
public void createWebArchive() throws Exception
{
- archive = new WebArchiveImpl(new MemoryMapArchiveImpl());
+ archive = createNewArchive();
}
-
+
@After
public void ls()
{
@@ -63,94 +78,123 @@
System.out.println(archive.toString(true));
}
+ //-------------------------------------------------------------------------------------||
+ // Required Impls - ArchiveTestBase ---------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ @Override
+ protected WebArchive getArchive()
+ {
+ return archive;
+ }
+
+ /**
+ * Create a new instance of a WebArchive
+ */
+ @Override
+ protected WebArchive createNewArchive()
+ {
+ return new WebArchiveImpl(new MemoryMapArchiveImpl());
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Impls - ContainerTestBase -------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ @Override
+ protected ManifestContainer<WebArchive> getManifestContainer()
+ {
+ return getArchive();
+ }
+
+ @Override
+ protected ResourceContainer<WebArchive> getResourceContainer()
+ {
+ return getArchive();
+ }
+
+ @Override
+ protected ClassContainer<WebArchive> getClassContainer()
+ {
+ return archive;
+ }
+
+ @Override
+ protected LibraryContainer<WebArchive> getLibraryContainer()
+ {
+ return archive;
+ }
+
+ @Override
+ protected Path getManifestPath()
+ {
+ return PATH_MANIFEST;
+ }
+
+ @Override
+ protected Path getResourcePath()
+ {
+ return PATH_RESOURCE;
+ }
+
+ @Override
+ protected Path getClassesPath()
+ {
+ return PATH_CLASSES;
+ }
+
+ @Override
+ protected Path getLibraryPath()
+ {
+ return PATH_LIBRARY;
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+
@Test
public void shouldBeAbleToSetWebXML() throws Exception
{
archive.setWebXML(TEST_RESOURCE);
-
+
Path expectedPath = new BasicPath(PATH_WEBINF, "web.xml");
-
- Assert.assertTrue(
- "web.xml should be located in /WEB-INF/web.xml",
- archive.contains(expectedPath));
+
+ Assert.assertTrue("web.xml should be located in /WEB-INF/web.xml", archive.contains(expectedPath));
}
-
+
@Test
- public void shouldBeAbleToAddWebResource() throws Exception {
+ public void shouldBeAbleToAddWebResource() throws Exception
+ {
archive.addWebResource(TEST_RESOURCE);
-
+
Path expectedPath = new BasicPath(PATH_WEBINF, TEST_RESOURCE);
-
- Assert.assertTrue(
- "A resource should be located in /WEB-INF/",
- archive.contains(expectedPath));
+
+ Assert.assertTrue("A resource should be located in /WEB-INF/", archive.contains(expectedPath));
}
@Test
- public void shouldBeAbleToAddWebResourceWithNewName() throws Exception {
+ public void shouldBeAbleToAddWebResourceWithNewName() throws Exception
+ {
String newName = "test.txt";
archive.addWebResource(new BasicPath(newName), TEST_RESOURCE);
-
+
Path expectedPath = new BasicPath(PATH_WEBINF, newName);
-
- Assert.assertTrue(
- "A resource should be located in /WEB-INF/",
- archive.contains(expectedPath));
+
+ Assert.assertTrue("A resource should be located in /WEB-INF/", archive.contains(expectedPath));
}
-
+
@Test
public void shouldBeAbleToAddLibrary() throws Exception
{
archive.addLibrary(TEST_RESOURCE);
-
+
Path expectedPath = new BasicPath(PATH_LIBRARY, TEST_RESOURCE);
-
- Assert.assertTrue(
- "A library should be located in /WEB-INF/lib/",
- archive.contains(expectedPath));
- }
- @Test
- public void shouldBeAbleToAddClasses() throws Exception
- {
- archive.addClasses(DummyClassUsedForClassResourceTest.class);
-
- Path expectedPath = new BasicPath(
- PATH_CLASSES,
- AssetUtil.getFullPathForClassResource(
- DummyClassUsedForClassResourceTest.class));
-
- Assert.assertTrue(
- "A class should be located in /WEB-INF/classes/",
- archive.contains(expectedPath));
+ Assert.assertTrue("A library should be located in /WEB-INF/lib/", archive.contains(expectedPath));
}
- @Test
- public void shouldBeAbleToAddPackages() throws Exception
- {
- archive.addPackages(true, DummyClassUsedForClassResourceTest.class.getPackage());
-
- Path expectedPath = new BasicPath(
- PATH_CLASSES,
- AssetUtil.getFullPathForClassResource(
- DummyClassUsedForClassResourceTest.class));
-
- Assert.assertTrue(
- "A class should be located in /WEB-INF/classes/",
- archive.contains(expectedPath));
- }
-
- @Test
- public void shouldBeAbleToAddResource() throws Exception
- {
- archive.addResource(TEST_RESOURCE);
-
- Path expectedPath = new BasicPath(PATH_RESOURCE, TEST_RESOURCE);
-
- Assert.assertTrue(
- "A resource should be located in /",
- archive.contains(expectedPath));
- }
}
Modified: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/ArchiveTestBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/ArchiveTestBase.java 2009-09-18 18:45:44 UTC (rev 3535)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/ArchiveTestBase.java 2009-09-22 04:12:40 UTC (rev 3536)
@@ -67,7 +67,7 @@
*
* @return A Archive<T> instance.
*/
- protected abstract Archive<T> getArchive();
+ protected abstract T getArchive();
/**
* Create a new {@link Archive} instance.
@@ -146,7 +146,61 @@
{
}
}
+
+ /**
+ * Ensure adding an asset to a string path results in successful storage.
+ * @throws Exception
+ */
+ @Test
+ public void testAddWithStringPath() throws Exception
+ {
+ Archive<T> archive = getArchive();
+ Asset asset = new ClassLoaderAsset(NAME_TEST_PROPERTIES);
+ Path location = new BasicPath("/", "test.properties");
+ archive.add(location.get(), asset);
+
+ Assert.assertTrue("Asset should be placed on " + new BasicPath("/", "test.properties"), archive.contains(location));
+ }
+
+ /**
+ * Ensure adding an asset to a string path requires path.
+ * @throws Exception
+ */
+ @Test
+ public void testAddWithStringPathRequiresPath() throws Exception
+ {
+ Archive<T> archive = getArchive();
+ Asset asset = new ClassLoaderAsset(NAME_TEST_PROPERTIES);
+
+ try
+ {
+ archive.add((String) null, asset);
+ Assert.fail("Should have throw an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expectedException)
+ {
+ }
+ }
+
+ /**
+ * Ensure adding an asset to the path string requires an asset.
+ * @throws Exception
+ */
+ @Test
+ public void testAddWithStringPathRequiresAssets() throws Exception
+ {
+ Archive<T> archive = getArchive();
+ try
+ {
+ archive.add("/Test.properties", (Asset) null);
+ Assert.fail("Should have throw an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expectedException)
+ {
+ }
+ }
+
/**
* Ensure adding an asset with a name results in successful storage
* @throws Exception
@@ -310,8 +364,43 @@
{
}
}
+
+ /**
+ * Ensure an asset can be retrieved by a string path
+ * @throws Exception
+ */
+ @Test
+ public void testGetAssetWithString() throws Exception
+ {
+ Archive<T> archive = getArchive();
+ Path location = new BasicPath("/", "test.properties");
+ Asset asset = new ClassLoaderAsset(NAME_TEST_PROPERTIES);
+ archive.add(location, asset);
+ Asset fetchedAsset = archive.get(location.get());
+
+ Assert.assertTrue("Asset should be returned from path: " + location.get(), compareAssets(asset, fetchedAsset));
+ }
+
/**
+ * Ensure get asset by string requires a path
+ * @throws Exception
+ */
+ @Test
+ public void testGetAssetWithStringRequiresPath() throws Exception
+ {
+ Archive<T> archive = getArchive();
+ try
+ {
+ archive.get((String) null);
+ Assert.fail("Should have throw an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expectedException)
+ {
+ }
+ }
+
+ /**
* Ensure get content returns the correct map of content
* @throws Exception
*/
Added: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/ContainerTestBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/ContainerTestBase.java (rev 0)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/ContainerTestBase.java 2009-09-22 04:12:40 UTC (rev 3536)
@@ -0,0 +1,377 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.shrinkwrap.impl.base.test;
+
+import java.net.URL;
+
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.Path;
+import org.jboss.shrinkwrap.api.container.ClassContainer;
+import org.jboss.shrinkwrap.api.container.LibraryContainer;
+import org.jboss.shrinkwrap.api.container.ManifestContainer;
+import org.jboss.shrinkwrap.api.container.ResourceContainer;
+import org.jboss.shrinkwrap.impl.base.asset.AssetUtil;
+import org.jboss.shrinkwrap.impl.base.path.BasicPath;
+import org.jboss.shrinkwrap.impl.base.spec.donotchange.DummyClassUsedForClassResourceTest;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * ContainerTestBase
+ *
+ * Base test for all Container providers to help ensure consistency between implementations.
+ *
+ * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: $
+ */
+public abstract class ContainerTestBase<T extends Archive<T>> extends ArchiveTestBase<T>
+{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ protected static final String TEST_RESOURCE = "org/jboss/shrinkwrap/impl/base/asset/Test.properties";
+
+ protected static final Path NESTED_PATH = new BasicPath("nested");
+
+ //-------------------------------------------------------------------------------------||
+ // Contracts --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Return the archive as a ResourceContainer
+ */
+ protected abstract ResourceContainer<T> getResourceContainer();
+
+ /**
+ * Get the resource path for the container
+ */
+ protected abstract Path getResourcePath();
+
+ /**
+ * Return the archive as a ManifestContainer
+ */
+ protected abstract ManifestContainer<T> getManifestContainer();
+
+ /**
+ * Get the manifest path for the container
+ */
+ protected abstract Path getManifestPath();
+
+ /**
+ * Get the archive as a ClassContainer
+ */
+ protected abstract ClassContainer<T> getClassContainer();
+
+ /**
+ * Get the classes path for the container
+ */
+ protected abstract Path getClassesPath();
+
+ /**
+ * Get the archive as a LibraryContainer
+ */
+ protected abstract LibraryContainer<T> getLibraryContainer();
+
+ /**
+ * Get the library path for the container
+ */
+ protected abstract Path getLibraryPath();
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Ensure resources can be added to containers
+ */
+ @Test
+ public void testAddResource() throws Exception
+ {
+ ResourceContainer<T> container = getResourceContainer();
+ container.addResource(TEST_RESOURCE);
+
+ Path expectedPath = new BasicPath(getResourcePath(), TEST_RESOURCE);
+
+ Assert
+ .assertTrue("A resource should be located under " + expectedPath.get(), getArchive().contains(expectedPath));
+ }
+
+ /**
+ * Ensure resources can be added to containers witha specified path
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testAddResourceToPath() throws Exception
+ {
+ ResourceContainer<T> container = getResourceContainer();
+
+ Path path = new BasicPath(NESTED_PATH, TEST_RESOURCE);
+
+ container.addResource(path, TEST_RESOURCE);
+
+ Path expectedPath = new BasicPath(new BasicPath(getResourcePath(), NESTED_PATH), TEST_RESOURCE);
+
+ Assert
+ .assertTrue("A resource should be located under " + expectedPath.get(), getArchive().contains(expectedPath));
+ }
+
+ /**
+ * Ensure resources can be added to containers with names
+ * @throws Exception
+ */
+ @Test
+ public void testAddResourceWithNewName() throws Exception
+ {
+ ResourceContainer<T> container = getResourceContainer();
+
+ String newName = "test.txt";
+ container.addResource(TEST_RESOURCE, newName);
+
+ Path expectedPath = new BasicPath(getResourcePath(), "/org/jboss/shrinkwrap/impl/base/asset/" + newName);
+
+ Assert
+ .assertTrue("A resource should be located under " + expectedPath.get(), getArchive().contains(expectedPath));
+ }
+
+
+ /**
+ * Ensure resources can be added to containers as a URL
+ * @throws Exception
+ */
+ @Test
+ public void testAddResourceFromUrl() throws Exception
+ {
+ ResourceContainer<T> container = getResourceContainer();
+
+ URL url = getClass().getResource("/" + TEST_RESOURCE);
+
+ container.addResource(url);
+
+ Path expectedPath = new BasicPath(getResourcePath(), AssetUtil.getFullPathForURLResource(url));
+
+ Assert
+ .assertTrue("A resource should be located under " + expectedPath.get(), getArchive().contains(expectedPath));
+ }
+
+ /**
+ * Ensure resources can be added to containers as a URL in a specific path
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testAddResourceToPathFromUrl() throws Exception
+ {
+ ResourceContainer<T> container = getResourceContainer();
+
+ URL url = getClass().getResource("/" + TEST_RESOURCE);
+
+ Path path = new BasicPath(TEST_RESOURCE);
+
+ container.addResource(path, url);
+
+ Path expectedPath = new BasicPath(getResourcePath(), TEST_RESOURCE);
+
+ Assert
+ .assertTrue("A resource should be located under " + expectedPath.get(), getArchive().contains(expectedPath));
+ }
+
+ /**
+ * Ensure resources can be added to a container from a classloader
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testAddResourceFromClassloader() throws Exception
+ {
+ ResourceContainer<T> container = getResourceContainer();
+
+ Path path = new BasicPath(TEST_RESOURCE);
+
+ container.addResource(path, TEST_RESOURCE, this.getClass().getClassLoader());
+
+ Path expectedPath = new BasicPath(getResourcePath(), TEST_RESOURCE);
+
+ Assert
+ .assertTrue("A resource should be located under " + expectedPath.get(), getArchive().contains(expectedPath));
+
+ }
+
+ /**
+ * Ensure manifest resources can be added to containers
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testAddManifestResource() throws Exception
+ {
+ ManifestContainer<T> container = getManifestContainer();
+
+ container.addManifestResource(TEST_RESOURCE);
+
+ Path expectedPath = new BasicPath(getManifestPath(), TEST_RESOURCE);
+
+ Assert.assertTrue("A manifest resource should be located at " + expectedPath.get(), getArchive().contains(
+ expectedPath));
+ }
+
+ /**
+ * Ensure manifest resources can be added to containers with names
+ * @throws Exception
+ */
+ @Test
+ public void testAddManifestResourceWithNewName() throws Exception
+ {
+ ManifestContainer<T> container = getManifestContainer();
+
+ String newName = "test.txt";
+ container.addManifestResource(new BasicPath(newName), TEST_RESOURCE);
+
+ Path expectedPath = new BasicPath(getManifestPath(), newName);
+
+ Assert.assertTrue("A manifest resoruce should be located at " + expectedPath.get(), getArchive().contains(
+ expectedPath));
+ }
+
+ /**
+ * Ensure a class can be added to a container
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testAddClass() throws Exception
+ {
+ ClassContainer<T> container = getClassContainer();
+
+ container.addClass(DummyClassUsedForClassResourceTest.class);
+
+ Path expectedPath = new BasicPath(getClassesPath(), AssetUtil
+ .getFullPathForClassResource(DummyClassUsedForClassResourceTest.class));
+
+ Assert.assertTrue("A class should be located at " + expectedPath.get(), getArchive().contains(expectedPath));
+ }
+
+ /**
+ * Ensure classes can be added to containers
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testAddClasses() throws Exception
+ {
+ ClassContainer<T> container = getClassContainer();
+
+ container.addClasses(DummyClassUsedForClassResourceTest.class);
+
+ Path expectedPath = new BasicPath(getClassesPath(), AssetUtil
+ .getFullPathForClassResource(DummyClassUsedForClassResourceTest.class));
+
+ Assert.assertTrue("A class should be located at " + expectedPath.get(), getArchive().contains(expectedPath));
+ }
+
+ /**
+ * Ensure a package can be added to a container
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testAddPackage() throws Exception
+ {
+ ClassContainer<T> container = getClassContainer();
+
+ container.addPackage(DummyClassUsedForClassResourceTest.class.getPackage());
+
+ Path expectedPath = new BasicPath(getClassesPath(), AssetUtil
+ .getFullPathForClassResource(DummyClassUsedForClassResourceTest.class));
+
+ Assert.assertTrue("A class should be located at " + expectedPath.get(), getArchive().contains(expectedPath));
+ }
+
+ /**
+ * Ensure packages can be added to containers
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testAddPackageNonRecursive() throws Exception
+ {
+ ClassContainer<T> container = getClassContainer();
+
+ container.addPackages(false, DummyClassUsedForClassResourceTest.class.getPackage());
+
+ Path expectedPath = new BasicPath(getClassesPath(), AssetUtil
+ .getFullPathForClassResource(DummyClassUsedForClassResourceTest.class));
+
+ Assert.assertTrue("A class should be located at " + expectedPath.get(), getArchive().contains(expectedPath));
+ }
+
+ /**
+ * Ensure libraries can be added to containers
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testAddLibrary() throws Exception
+ {
+ LibraryContainer<T> container = getLibraryContainer();
+
+ container.addLibrary(TEST_RESOURCE);
+
+ Path expectedPath = new BasicPath(getLibraryPath(), TEST_RESOURCE);
+
+ Assert.assertTrue("A library should be located at " + expectedPath.get(), getArchive().contains(expectedPath));
+ }
+
+ /**
+ * Ensure libraries can be added to containers in a specific path
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testAddLibraryToPath() throws Exception
+ {
+ LibraryContainer<T> container = getLibraryContainer();
+
+ Path path = new BasicPath(TEST_RESOURCE);
+
+ container.addLibrary(path, TEST_RESOURCE);
+
+ Path expectedPath = new BasicPath(getLibraryPath(), path);
+
+ Assert.assertTrue("A library should be located at " + expectedPath.get(), getArchive().contains(expectedPath));
+ }
+
+ /**
+ * Ensure archives can be added to containers as libraries
+ * @throws Exception
+ */
+ @Test
+ public void testAddArchiveAsLibrary() throws Exception
+ {
+ Archive<?> library = createNewArchive();
+
+ LibraryContainer<T> container = getLibraryContainer();
+
+ container.addLibrary(library);
+
+ Path expectedPath = new BasicPath(getLibraryPath(), library.getName());
+
+ Assert.assertTrue("A library should be located at " + expectedPath.get(), getArchive().contains(expectedPath));
+ }
+
+}
Modified: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/unit/MemoryMapArchiveTestCase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/unit/MemoryMapArchiveTestCase.java 2009-09-18 18:45:44 UTC (rev 3535)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/unit/MemoryMapArchiveTestCase.java 2009-09-22 04:12:40 UTC (rev 3536)
@@ -18,7 +18,6 @@
import junit.framework.Assert;
-import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.impl.base.MemoryMapArchiveImpl;
import org.jboss.shrinkwrap.impl.base.test.ArchiveTestBase;
import org.jboss.shrinkwrap.spi.MemoryMapArchive;
@@ -39,7 +38,7 @@
private MemoryMapArchive archive;
/**
- * Create a new Archive instance pr Test.
+ * Create a new Archive instance per Test.
*
* @throws Exception
*/
@@ -47,6 +46,7 @@
public void createArchive() throws Exception
{
archive = createNewArchive();
+ archive.toString(false);
}
@Override
@@ -60,7 +60,7 @@
* so it can perform the common test cases.
*/
@Override
- protected Archive<MemoryMapArchive> getArchive()
+ protected MemoryMapArchive getArchive()
{
return archive;
}
More information about the jboss-svn-commits
mailing list