[jboss-svn-commits] JBoss Common SVN: r3588 - in shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base: test and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Oct 12 13:15:33 EDT 2009
Author: aslak
Date: 2009-10-12 13:15:32 -0400 (Mon, 12 Oct 2009)
New Revision: 3588
Added:
shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicEnterpriseContainerTestBase.java
shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicResourceAdapterContainerTestBase.java
shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicWebContainerTestBase.java
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/JavaArchiveImplTestCase.java
shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/ResourceAdapterArchiveImplTestCase.java
shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/WebArchiveImplTestCase.java
Log:
SHRINKWRAP-51 Test Cases for all the Archive types and their Container impls
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-10-12 17:14:25 UTC (rev 3587)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/EnterpriseArchiveImplTestCase.java 2009-10-12 17:15:32 UTC (rev 3588)
@@ -18,20 +18,17 @@
import org.jboss.shrinkwrap.api.Path;
import org.jboss.shrinkwrap.api.container.ClassContainer;
+import org.jboss.shrinkwrap.api.container.EnterpriseContainer;
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.test.ContainerTestBase;
+import org.jboss.shrinkwrap.impl.base.test.ArchiveType;
+import org.jboss.shrinkwrap.impl.base.test.DynamicEnterpriseContainerTestBase;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
/**
* EnterpriseArchiveImplTest
@@ -42,14 +39,12 @@
* @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
* @version $Revision: $
*/
-public class EnterpriseArchiveImplTestCase extends ContainerTestBase<EnterpriseArchive>
+ at ArchiveType(EnterpriseArchive.class)
+public class EnterpriseArchiveImplTestCase extends DynamicEnterpriseContainerTestBase<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");
@@ -102,7 +97,7 @@
}
//-------------------------------------------------------------------------------------||
- // Required Impls - ContainerTestBase -------------------------------------------------||
+ // Required Impls - DynamicContainerTestBase ------------------------------------------||
//-------------------------------------------------------------------------------------||
@Override
@@ -112,7 +107,7 @@
}
@Override
- protected Path getClassesPath()
+ protected Path getClassPath()
{
throw new UnsupportedOperationException("EnterpriseArchives do not support classes");
}
@@ -154,87 +149,20 @@
}
//-------------------------------------------------------------------------------------||
- // Tests ------------------------------------------------------------------------------||
+ // Required Impls - DynamicEnterpriseContainerTestBase --------------------------------||
//-------------------------------------------------------------------------------------||
-
- @Test
- 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));
+
+ protected Path getModulePath() {
+ return PATH_MODULE;
}
- @Test
- 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));
+ protected Path getApplicationPath() {
+ return PATH_APPLICATION;
}
-
- @Test
- 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));
- }
-
- @Test
- 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));
- }
-
- @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));
- }
-
- @Ignore
+
@Override
- public void testAddClass() throws Exception
+ protected EnterpriseContainer<EnterpriseArchive> getEnterpriseContainer()
{
+ return getArchive();
}
-
- @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-10-12 17:14:25 UTC (rev 3587)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/JavaArchiveImplTestCase.java 2009-10-12 17:15:32 UTC (rev 3588)
@@ -16,8 +16,6 @@
*/
package org.jboss.shrinkwrap.impl.base.spec;
-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;
@@ -26,12 +24,10 @@
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.impl.base.MemoryMapArchiveImpl;
import org.jboss.shrinkwrap.impl.base.path.BasicPath;
-import org.jboss.shrinkwrap.impl.base.test.ContainerTestBase;
+import org.jboss.shrinkwrap.impl.base.test.ArchiveType;
+import org.jboss.shrinkwrap.impl.base.test.DynamicContainerTestBase;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
/**
* JavaArchiveImplTestCase
@@ -42,16 +38,9 @@
* @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
* @version $Revision: $
*/
-public class JavaArchiveImplTestCase extends ContainerTestBase<JavaArchive>
+ at ArchiveType(JavaArchive.class)
+public class JavaArchiveImplTestCase extends DynamicContainerTestBase<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_CLASS = new BasicPath("/");
@@ -107,24 +96,25 @@
// Required Impls - ContainerTestBase ---------------------------------------------------||
//-------------------------------------------------------------------------------------||
+
@Override
- protected ManifestContainer<JavaArchive> getManifestContainer()
+ protected ResourceContainer<JavaArchive> getResourceContainer()
{
return getArchive();
}
@Override
- protected ResourceContainer<JavaArchive> getResourceContainer()
+ protected ClassContainer<JavaArchive> getClassContainer()
{
return getArchive();
}
@Override
- protected ClassContainer<JavaArchive> getClassContainer()
+ protected ManifestContainer<JavaArchive> getManifestContainer()
{
- return archive;
+ return getArchive();
}
-
+
@Override
protected LibraryContainer<JavaArchive> getLibraryContainer()
{
@@ -144,7 +134,7 @@
}
@Override
- protected Path getClassesPath()
+ protected Path getClassPath()
{
return PATH_CLASS;
}
@@ -154,38 +144,4 @@
{
throw new UnsupportedOperationException("JavaArchive does not support libraries");
}
-
- //-------------------------------------------------------------------------------------||
- // Tests ------------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- @Test
- public void shouldBeAbleToSetManifestFile() throws Exception
- {
- 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));
- }
-
- @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/ResourceAdapterArchiveImplTestCase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/ResourceAdapterArchiveImplTestCase.java 2009-10-12 17:14:25 UTC (rev 3587)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/ResourceAdapterArchiveImplTestCase.java 2009-10-12 17:15:32 UTC (rev 3588)
@@ -20,16 +20,15 @@
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.ResourceAdapterContainer;
import org.jboss.shrinkwrap.api.container.ResourceContainer;
import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
import org.jboss.shrinkwrap.impl.base.MemoryMapArchiveImpl;
import org.jboss.shrinkwrap.impl.base.path.BasicPath;
-import org.jboss.shrinkwrap.impl.base.test.ContainerTestBase;
+import org.jboss.shrinkwrap.impl.base.test.ArchiveType;
+import org.jboss.shrinkwrap.impl.base.test.DynamicResourceAdapterContainerTestBase;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
/**
* ResourceAdapterArchiveImplTestCase
@@ -37,16 +36,16 @@
* Test to ensure that ResourceAdapterArchiveImpl follow to java rar spec.
*
* @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
* @version $Revision: $
*/
-public class ResourceAdapterArchiveImplTestCase extends ContainerTestBase<ResourceAdapterArchive>
+ at ArchiveType(ResourceAdapterArchive.class)
+public class ResourceAdapterArchiveImplTestCase extends DynamicResourceAdapterContainerTestBase<ResourceAdapterArchive>
{
//-------------------------------------------------------------------------------------||
// Class Members ----------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
- private static final String TEST_RESOURCE = "org/jboss/shrinkwrap/impl/base/asset/Test.properties";
-
private static final Path PATH_RESOURCE = new BasicPath("/");
private static final Path PATH_MANIFEST = new BasicPath("META-INF");
@@ -99,7 +98,7 @@
}
//-------------------------------------------------------------------------------------||
- // Required Impls - ContainerTestBase -------------------------------------------------||
+ // Required Impls - DynamicContainerTestBase -------------------------------------------------||
//-------------------------------------------------------------------------------------||
@Override
@@ -109,7 +108,7 @@
}
@Override
- protected Path getClassesPath()
+ protected Path getClassPath()
{
throw new UnsupportedOperationException("ResourceAdapterArchive do not support classes");
}
@@ -149,57 +148,20 @@
{
return getArchive();
}
-
+
//-------------------------------------------------------------------------------------||
- // Tests ------------------------------------------------------------------------------||
+ // Required Impls - DynamicResourceAdapterContainerTestBase ---------------------------||
//-------------------------------------------------------------------------------------||
- @Test
- public void testAddResourceAdapterXML() throws Exception
- {
- archive.setResourceAdapterXML(TEST_RESOURCE);
-
- Path expectedPath = new BasicPath(PATH_MANIFEST, "ra.xml");
-
- Assert.assertTrue("ra.xml should be located in /META-INF/ra.xml", archive.contains(expectedPath));
- }
-
- @Test
- public void testAddResourceAdapterXMLRequireResource() throws Exception
- {
- try
- {
- archive.setResourceAdapterXML(null);
- Assert.fail("Should have thrown IllegalArgumentException");
- }
- catch (IllegalArgumentException expected)
- {
- }
-
- }
-
- @Ignore
@Override
- public void testAddClass() throws Exception
+ protected Path getResourceAdapterPath()
{
+ return getResourcePath();
}
-
- @Ignore
+
@Override
- public void testAddClasses() throws Exception
+ protected ResourceAdapterContainer<ResourceAdapterArchive> getResourceAdapterContainer()
{
+ return getArchive();
}
-
- @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/WebArchiveImplTestCase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/WebArchiveImplTestCase.java 2009-10-12 17:14:25 UTC (rev 3587)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/WebArchiveImplTestCase.java 2009-10-12 17:15:32 UTC (rev 3588)
@@ -21,14 +21,14 @@
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.container.WebContainer;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.impl.base.MemoryMapArchiveImpl;
import org.jboss.shrinkwrap.impl.base.path.BasicPath;
-import org.jboss.shrinkwrap.impl.base.test.ContainerTestBase;
+import org.jboss.shrinkwrap.impl.base.test.ArchiveType;
+import org.jboss.shrinkwrap.impl.base.test.DynamicWebContainerTestBase;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
-import org.junit.Test;
/**
* WebArchiveImplTestCase
@@ -39,7 +39,8 @@
* @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
* @version $Revision: $
*/
-public class WebArchiveImplTestCase extends ContainerTestBase<WebArchive>
+ at ArchiveType(WebArchive.class)
+public class WebArchiveImplTestCase extends DynamicWebContainerTestBase<WebArchive>
{
//-------------------------------------------------------------------------------------||
// Class Members ----------------------------------------------------------------------||
@@ -98,7 +99,7 @@
}
//-------------------------------------------------------------------------------------||
- // Required Impls - ContainerTestBase -------------------------------------------------||
+ // Required Impls - DynamicContainerTestBase ------------------------------------------||
//-------------------------------------------------------------------------------------||
@Override
@@ -138,7 +139,7 @@
}
@Override
- protected Path getClassesPath()
+ protected Path getClassPath()
{
return PATH_CLASSES;
}
@@ -150,51 +151,18 @@
}
//-------------------------------------------------------------------------------------||
- // Tests ------------------------------------------------------------------------------||
+ // Required Impls - DynamicWebContainerTestBase ---------------------------------------||
//-------------------------------------------------------------------------------------||
-
- @Test
- public void shouldBeAbleToSetWebXML() throws Exception
+ @Override
+ public WebContainer<WebArchive> getWebContainer()
{
- 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));
+ return getArchive();
}
-
- @Test
- public void shouldBeAbleToAddWebResource() throws Exception
+
+ @Override
+ public Path getWebPath()
{
-
- 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));
+ return PATH_WEBINF;
}
-
- @Test
- 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));
- }
-
- @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));
- }
-
}
Added: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicEnterpriseContainerTestBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicEnterpriseContainerTestBase.java (rev 0)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicEnterpriseContainerTestBase.java 2009-10-12 17:15:32 UTC (rev 3588)
@@ -0,0 +1,254 @@
+/*
+ * 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 junit.framework.Assert;
+
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.Path;
+import org.jboss.shrinkwrap.api.container.EnterpriseContainer;
+import org.jboss.shrinkwrap.impl.base.path.BasicPath;
+import org.junit.Test;
+
+/**
+ * DynamicEnterpriseContainerTestBase
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ * @param <T>
+ */
+public abstract class DynamicEnterpriseContainerTestBase<T extends Archive<T>> extends DynamicContainerTestBase<T>
+{
+
+ protected abstract Path getModulePath();
+ protected abstract Path getApplicationPath();
+ protected abstract EnterpriseContainer<T> getEnterpriseContainer();
+
+ //-------------------------------------------------------------------------------------||
+ // Test Implementations - WebContainer ------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
+ public void testSetApplicationXMLResource() throws Exception {
+ getEnterpriseContainer().setApplicationXML(NAME_TEST_PROPERTIES);
+
+ Path expectedPath = new BasicPath(getApplicationPath(), "application.xml");
+ Assert.assertTrue(
+ "Archive should contain " + expectedPath,
+ getArchive().contains(expectedPath));
+ }
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
+ public void testSetApplicationXMLFile() throws Exception {
+ getEnterpriseContainer().setApplicationXML(getFileForClassResource(NAME_TEST_PROPERTIES));
+
+ Path expectedPath = new BasicPath(getApplicationPath(), "application.xml");
+ Assert.assertTrue(
+ "Archive should contain " + expectedPath,
+ getArchive().contains(expectedPath));
+ }
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
+ public void testSetApplicationXMLURL() throws Exception {
+ getEnterpriseContainer().setApplicationXML(getURLForClassResource(NAME_TEST_PROPERTIES));
+
+ Path expectedPath = new BasicPath(getApplicationPath(), "application.xml");
+ Assert.assertTrue(
+ "Archive should contain " + expectedPath,
+ getArchive().contains(expectedPath));
+ }
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
+ public void testSetApplicationXMLAsset() throws Exception {
+ getEnterpriseContainer().setApplicationXML(getAssetForClassResource(NAME_TEST_PROPERTIES));
+
+ Path expectedPath = new BasicPath(getApplicationPath(), "application.xml");
+ Assert.assertTrue(
+ "Archive should contain " + expectedPath,
+ getArchive().contains(expectedPath));
+ }
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
+ public void testAddApplicationResource() throws Exception {
+ getEnterpriseContainer().addApplicationResource(NAME_TEST_PROPERTIES);
+
+ Path expectedPath = new BasicPath(getApplicationPath(), NAME_TEST_PROPERTIES);
+ Assert.assertTrue(
+ "Archive should contain " + expectedPath,
+ getArchive().contains(expectedPath));
+ }
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
+ public void testAddApplicationFile() throws Exception {
+ getEnterpriseContainer().addApplicationResource(getFileForClassResource(NAME_TEST_PROPERTIES));
+
+ Path expectedPath = new BasicPath(getApplicationPath(), "Test.properties");
+ Assert.assertTrue(
+ "Archive should contain " + expectedPath,
+ getArchive().contains(expectedPath));
+ }
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
+ public void testAddApplicationURL() throws Exception {
+ getEnterpriseContainer().addApplicationResource(getURLForClassResource(NAME_TEST_PROPERTIES));
+
+ Path expectedPath = new BasicPath(getApplicationPath(), "Test.properties");
+ Assert.assertTrue(
+ "Archive should contain " + expectedPath,
+ getArchive().contains(expectedPath));
+ }
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
+ public void testAddApplicationStringTargetResource() throws Exception {
+ getEnterpriseContainer().addApplicationResource("Test.txt", NAME_TEST_PROPERTIES);
+
+ Path expectedPath = new BasicPath(getApplicationPath(), "Test.txt");
+ Assert.assertTrue(
+ "Archive should contain " + expectedPath,
+ getArchive().contains(expectedPath));
+ }
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
+ public void testAddApplicationStringTargetFile() throws Exception {
+ getEnterpriseContainer().addApplicationResource("Test.txt", getFileForClassResource(NAME_TEST_PROPERTIES));
+
+ Path expectedPath = new BasicPath(getApplicationPath(), "Test.txt");
+ Assert.assertTrue(
+ "Archive should contain " + expectedPath,
+ getArchive().contains(expectedPath));
+ }
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
+ public void testAddApplicationStringTargetURL() throws Exception {
+ getEnterpriseContainer().addApplicationResource("Test.txt", getURLForClassResource(NAME_TEST_PROPERTIES));
+
+ Path expectedPath = new BasicPath(getApplicationPath(), "Test.txt");
+ Assert.assertTrue(
+ "Archive should contain " + expectedPath,
+ getArchive().contains(expectedPath));
+ }
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
+ public void testAddApplicationStringTargetAsset() throws Exception {
+ getEnterpriseContainer().addApplicationResource("Test.txt", getAssetForClassResource(NAME_TEST_PROPERTIES));
+
+ Path expectedPath = new BasicPath(getApplicationPath(), "Test.txt");
+ Assert.assertTrue(
+ "Archive should contain " + expectedPath,
+ getArchive().contains(expectedPath));
+ }
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
+ public void testAddApplicationPathTargetResource() throws Exception {
+ getEnterpriseContainer().addApplicationResource(new BasicPath("Test.txt"), NAME_TEST_PROPERTIES);
+
+ Path expectedPath = new BasicPath(getApplicationPath(), "Test.txt");
+ Assert.assertTrue(
+ "Archive should contain " + expectedPath,
+ getArchive().contains(expectedPath));
+ }
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
+ public void testAddApplicationPathTargetFile() throws Exception {
+ getEnterpriseContainer().addApplicationResource(new BasicPath("Test.txt"), getFileForClassResource(NAME_TEST_PROPERTIES));
+
+ Path expectedPath = new BasicPath(getApplicationPath(), "Test.txt");
+ Assert.assertTrue(
+ "Archive should contain " + expectedPath,
+ getArchive().contains(expectedPath));
+ }
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
+ public void testAddApplicationPathTargetURL() throws Exception {
+ getEnterpriseContainer().addApplicationResource(new BasicPath("Test.txt"), getURLForClassResource(NAME_TEST_PROPERTIES));
+
+ Path expectedPath = new BasicPath(getApplicationPath(), "Test.txt");
+ Assert.assertTrue(
+ "Archive should contain " + expectedPath,
+ getArchive().contains(expectedPath));
+ }
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
+ public void testAddApplicationPathTargetAsset() throws Exception {
+ getEnterpriseContainer().addApplicationResource(new BasicPath("Test.txt"), getAssetForClassResource(NAME_TEST_PROPERTIES));
+
+ Path expectedPath = new BasicPath(getApplicationPath(), "Test.txt");
+ Assert.assertTrue(
+ "Archive should contain " + expectedPath,
+ getArchive().contains(expectedPath));
+ }
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
+ public void testAddModuleResource() throws Exception {
+ getEnterpriseContainer().addModule(NAME_TEST_PROPERTIES);
+
+ Path expectedPath = new BasicPath(getModulePath(), NAME_TEST_PROPERTIES);
+ Assert.assertTrue(
+ "Archive should contain " + expectedPath,
+ getArchive().contains(expectedPath));
+ }
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
+ public void testAddModuleFile() throws Exception {
+ getEnterpriseContainer().addModule(getFileForClassResource(NAME_TEST_PROPERTIES));
+
+ Path expectedPath = new BasicPath(getModulePath(), "Test.properties");
+ Assert.assertTrue(
+ "Archive should contain " + expectedPath,
+ getArchive().contains(expectedPath));
+ }
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
+ public void testAddModuleURL() throws Exception {
+ getEnterpriseContainer().addModule(getURLForClassResource(NAME_TEST_PROPERTIES));
+
+ Path expectedPath = new BasicPath(getModulePath(), "Test.properties");
+ Assert.assertTrue(
+ "Archive should contain " + expectedPath,
+ getArchive().contains(expectedPath));
+ }
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
+ public void testAddModuleArchive() throws Exception {
+ Archive<?> archive = createNewArchive();
+ getEnterpriseContainer().addModule(archive);
+
+ Path expectedPath = new BasicPath(getModulePath(), archive.getName());
+ Assert.assertTrue(
+ "Archive should contain " + expectedPath,
+ getArchive().contains(expectedPath));
+ }
+}
\ No newline at end of file
Added: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicResourceAdapterContainerTestBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicResourceAdapterContainerTestBase.java (rev 0)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicResourceAdapterContainerTestBase.java 2009-10-12 17:15:32 UTC (rev 3588)
@@ -0,0 +1,60 @@
+package org.jboss.shrinkwrap.impl.base.test;
+
+import junit.framework.Assert;
+
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.Path;
+import org.jboss.shrinkwrap.api.container.ResourceAdapterContainer;
+import org.jboss.shrinkwrap.impl.base.path.BasicPath;
+import org.junit.Test;
+
+public abstract class DynamicResourceAdapterContainerTestBase<T extends Archive<T>> extends DynamicContainerTestBase<T>
+{
+
+ protected abstract Path getResourceAdapterPath();
+ protected abstract ResourceAdapterContainer<T> getResourceAdapterContainer();
+
+ @Test
+ @ArchiveType(ResourceAdapterContainer.class)
+ public void testSetResourceAdapterXMLResource() throws Exception {
+ getResourceAdapterContainer().setResourceAdapterXML(NAME_TEST_PROPERTIES);
+
+ Path testPath = new BasicPath(getResourceAdapterPath(), "ra.xml");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(ResourceAdapterContainer.class)
+ public void testSetResourceAdapterXMLFile() throws Exception {
+ getResourceAdapterContainer().setResourceAdapterXML(getFileForClassResource(NAME_TEST_PROPERTIES));
+
+ Path testPath = new BasicPath(getResourceAdapterPath(), "ra.xml");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(ResourceAdapterContainer.class)
+ public void testSetResourceAdapterXMLURL() throws Exception {
+ getResourceAdapterContainer().setResourceAdapterXML(getURLForClassResource(NAME_TEST_PROPERTIES));
+
+ Path testPath = new BasicPath(getResourceAdapterPath(), "ra.xml");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(ResourceAdapterContainer.class)
+ public void testSetResourceAdapterXMLAsset() throws Exception {
+ getResourceAdapterContainer().setResourceAdapterXML(getAssetForClassResource(NAME_TEST_PROPERTIES));
+
+ Path testPath = new BasicPath(getResourceAdapterPath(), "ra.xml");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+}
Added: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicWebContainerTestBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicWebContainerTestBase.java (rev 0)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicWebContainerTestBase.java 2009-10-12 17:15:32 UTC (rev 3588)
@@ -0,0 +1,207 @@
+/*
+ * 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 junit.framework.Assert;
+
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.Path;
+import org.jboss.shrinkwrap.api.container.WebContainer;
+import org.jboss.shrinkwrap.impl.base.path.BasicPath;
+import org.junit.Test;
+
+/**
+ * DynamicWebContainerTestBase
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ * @param <T>
+ */
+public abstract class DynamicWebContainerTestBase<T extends Archive<T>> extends DynamicContainerTestBase<T>
+{
+ public abstract Path getWebPath();
+ public abstract WebContainer<T> getWebContainer();
+
+ //-------------------------------------------------------------------------------------||
+ // Test Implementations - WebContainer ------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ @Test
+ @ArchiveType(WebContainer.class)
+ public void testSetWebXMLResource() throws Exception {
+ getWebContainer().setWebXML(NAME_TEST_PROPERTIES);
+
+ Path testPath = new BasicPath(getWebPath(), "web.xml");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(WebContainer.class)
+ public void testSetWebXMLFile() throws Exception {
+ getWebContainer().setWebXML(getFileForClassResource(NAME_TEST_PROPERTIES));
+
+ Path testPath = new BasicPath(getWebPath(), "web.xml");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(WebContainer.class)
+ public void testSetWebXMLURL() throws Exception {
+ getWebContainer().setWebXML(getURLForClassResource(NAME_TEST_PROPERTIES));
+
+ Path testPath = new BasicPath(getWebPath(), "web.xml");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(WebContainer.class)
+ public void testSetWebXMLAsset() throws Exception {
+ getWebContainer().setWebXML(getAssetForClassResource(NAME_TEST_PROPERTIES));
+
+ Path testPath = new BasicPath(getWebPath(), "web.xml");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(WebContainer.class)
+ public void testAddWebResourceResource() throws Exception {
+ getWebContainer().addWebResource(NAME_TEST_PROPERTIES);
+
+ Path testPath = new BasicPath(getWebPath(), "Test.properties");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(WebContainer.class)
+ public void testAddWebResourceFile() throws Exception {
+ getWebContainer().addWebResource(getFileForClassResource(NAME_TEST_PROPERTIES));
+
+ Path testPath = new BasicPath(getWebPath(), "Test.properties");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(WebContainer.class)
+ public void testAddWebResourceURL() throws Exception {
+ getWebContainer().addWebResource(getURLForClassResource(NAME_TEST_PROPERTIES));
+
+ Path testPath = new BasicPath(getWebPath(), "Test.properties");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(WebContainer.class)
+ public void testAddWebResourceStringTargetResource() throws Exception {
+ getWebContainer().addWebResource("Test.txt", NAME_TEST_PROPERTIES);
+
+ Path testPath = new BasicPath(getWebPath(), "Test.txt");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(WebContainer.class)
+ public void testAddWebResourceStringTargetFile() throws Exception {
+ getWebContainer().addWebResource("Test.txt", getFileForClassResource(NAME_TEST_PROPERTIES));
+
+ Path testPath = new BasicPath(getWebPath(), "Test.txt");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(WebContainer.class)
+ public void testAddWebResourceStringTargetURL() throws Exception {
+ getWebContainer().addWebResource("Test.txt", getURLForClassResource(NAME_TEST_PROPERTIES));
+
+ Path testPath = new BasicPath(getWebPath(), "Test.txt");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(WebContainer.class)
+ public void testAddWebResourceStringTargetAsset() throws Exception {
+ getWebContainer().addWebResource("Test.txt", getAssetForClassResource(NAME_TEST_PROPERTIES));
+
+ Path testPath = new BasicPath(getWebPath(), "Test.txt");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(WebContainer.class)
+ public void testAddWebResourcePathTargetResource() throws Exception {
+ getWebContainer().addWebResource(new BasicPath("Test.txt"), NAME_TEST_PROPERTIES);
+
+ Path testPath = new BasicPath(getWebPath(), "Test.txt");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(WebContainer.class)
+ public void testAddWebResourcePathTargetFile() throws Exception {
+ getWebContainer().addWebResource(new BasicPath("Test.txt"), getFileForClassResource(NAME_TEST_PROPERTIES));
+
+ Path testPath = new BasicPath(getWebPath(), "Test.txt");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(WebContainer.class)
+ public void testAddWebResourcePathTargetURL() throws Exception {
+ getWebContainer().addWebResource(new BasicPath("Test.txt"), getURLForClassResource(NAME_TEST_PROPERTIES));
+
+ Path testPath = new BasicPath(getWebPath(), "Test.txt");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(WebContainer.class)
+ public void testAddWebResourcePathTargetAsset() throws Exception {
+ getWebContainer().addWebResource(new BasicPath("Test.txt"), getAssetForClassResource(NAME_TEST_PROPERTIES));
+
+ Path testPath = new BasicPath(getWebPath(), "Test.txt");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+}
More information about the jboss-svn-commits
mailing list