[jboss-svn-commits] JBoss Common SVN: r3646 - in shrinkwrap/trunk/impl-base/src: test/java/org/jboss/shrinkwrap/impl/base and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Nov 10 10:16:41 EST 2009
Author: aslak
Date: 2009-11-10 10:16:40 -0500 (Tue, 10 Nov 2009)
New Revision: 3646
Added:
shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/Archives.java
shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/ArchivesTest.java
Log:
SHRINKWRAP-50 Unified factory for archive creation
Added: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/Archives.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/Archives.java (rev 0)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/Archives.java 2009-11-10 15:16:40 UTC (rev 3646)
@@ -0,0 +1,51 @@
+/*
+ * 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 org.jboss.shrinkwrap.api.Specializer;
+
+/**
+ * Generic unified factory for archive creation.
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class Archives
+{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Create a Specialized archive base from where any other archive type can be made.
+ *
+ * @param archiveName The name of the archive
+ * @return A {@link Specializer} archive base
+ */
+ public static Specializer create(String archiveName) {
+ return new MemoryMapArchiveImpl(archiveName);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * No instantiation
+ */
+ private Archives() {}
+}
Added: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/ArchivesTest.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/ArchivesTest.java (rev 0)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/ArchivesTest.java 2009-11-10 15:16:40 UTC (rev 3646)
@@ -0,0 +1,53 @@
+/*
+ * 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 junit.framework.Assert;
+
+import org.jboss.shrinkwrap.api.Specializer;
+import org.jboss.shrinkwrap.spi.MemoryMapArchive;
+import org.junit.Test;
+
+
+/**
+ * ArchivesTest
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class ArchivesTest
+{
+
+ @Test
+ public void shouldBeAbleToCreateANewArchive() throws Exception {
+ String archiveName = "test.war";
+
+ Specializer archive = Archives.create(archiveName);
+
+ Assert.assertNotNull(
+ "A archive should have been created", archive);
+
+ Assert.assertTrue(
+ "A MemoryMapArchive should have been created",
+ archive instanceof MemoryMapArchive);
+
+ Assert.assertEquals(
+ "Should have the same name as given imput",
+ archiveName,
+ ((MemoryMapArchive)archive).getName());
+ }
+}
More information about the jboss-svn-commits
mailing list