[jboss-svn-commits] JBoss Common SVN: r3478 - declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/spec.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Aug 24 13:31:59 EDT 2009
Author: aslak
Date: 2009-08-24 13:31:59 -0400 (Mon, 24 Aug 2009)
New Revision: 3478
Added:
declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/spec/EnterpriseArchiveImplTestCase.java
Log:
TMPARCH-6 Renamed to TestCase due to maven filter
Copied: declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/spec/EnterpriseArchiveImplTestCase.java (from rev 3477, declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/spec/EnterpriseArchiveImplTest.java)
===================================================================
--- declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/spec/EnterpriseArchiveImplTestCase.java (rev 0)
+++ declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/spec/EnterpriseArchiveImplTestCase.java 2009-08-24 17:31:59 UTC (rev 3478)
@@ -0,0 +1,146 @@
+/*
+ * 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.declarchive.impl.base.spec;
+
+import org.jboss.declarchive.api.Path;
+import org.jboss.declarchive.api.spec.EnterpriseArchive;
+import org.jboss.declarchive.api.spec.JavaArchive;
+import org.jboss.declarchive.impl.base.MemoryMapArchiveImpl;
+import org.jboss.declarchive.impl.base.asset.AssetUtil;
+import org.jboss.declarchive.impl.base.path.BasicPath;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+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>
+ * @version $Revision: $
+ */
+public class EnterpriseArchiveImplTestCase
+{
+ private static final String TEST_RESOURCE = "org/jboss/declarchive/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("/");
+
+ private EnterpriseArchive archive;
+
+ @Before
+ public void createWebArchive() throws Exception
+ {
+ archive = new EnterpriseArchiveImpl(new MemoryMapArchiveImpl());
+ }
+
+ @After
+ public void ls()
+ {
+ System.out.println("test at jboss:/$ ls -l " + archive.getName());
+ System.out.println(archive.toString(true));
+ }
+
+ @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));
+ }
+
+ @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));
+ }
+
+ @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 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
+ {
+ 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
+ // 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
+ {
+ 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));
+ }
+
+}
More information about the jboss-svn-commits
mailing list