[jboss-svn-commits] JBoss Common SVN: r3541 - in shrinkwrap/trunk: api/src/main/java/org/jboss/shrinkwrap/api/container and 5 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Sep 26 19:56:21 EDT 2009


Author: johnbailey
Date: 2009-09-26 19:56:21 -0400 (Sat, 26 Sep 2009)
New Revision: 3541

Added:
   shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/ResourceAdapterArchiveFactory.java
   shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/ResourceAdapterContainer.java
   shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/spec/ResourceAdapterArchive.java
   shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ResourceAdapterArchiveFactoryImpl.java
   shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ResourceAdapterContainerBase.java
   shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/spec/ResourceAdapterArchiveImpl.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/unit/ResourceAdapterArchiveFactoryTestCase.java
Log:
[SHRINKWRAP-42] - Added ResourceAdapterArchive components.

Added: shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/ResourceAdapterArchiveFactory.java
===================================================================
--- shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/ResourceAdapterArchiveFactory.java	                        (rev 0)
+++ shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/ResourceAdapterArchiveFactory.java	2009-09-26 23:56:21 UTC (rev 3541)
@@ -0,0 +1,75 @@
+/*
+ * 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.api;
+
+import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
+
+/**
+ * ResourceAdapterArchiveFactory
+ * 
+ * Factory used to create {@link ResourceAdapterArchive} instances. 
+ * 
+ * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: $
+ */
+public abstract class ResourceAdapterArchiveFactory extends ArchiveFactory<ResourceAdapterArchive>
+{
+
+   //-------------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Implementation type as a FQN to avoid direct compile-time dependency
+    */
+   private static final String IMPL_TYPE = "org.jboss.shrinkwrap.impl.base.ResourceAdapterArchiveFactoryImpl";
+
+   /**
+    * Instance of ResourceAdapterArchiveFactory implementation
+    */
+   private static ResourceAdapterArchiveFactory instance;
+
+   //-------------------------------------------------------------------------------------||
+   // Class Methods ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Creates a {@link ResourceAdapterArchive} instance with the provided name.
+    * 
+    * @param archiveName
+    * @return ResourceAdapterArchive 
+    * @throws IllegalArgumentException if the archiveName is not present
+    */
+   public static ResourceAdapterArchive create(String archiveName)
+   {
+      return getInstance().doCreate(archiveName);
+   }
+
+   /**
+    * Return instance of the ResourceAdapterArchive
+    * 
+    * @return
+    */
+   private synchronized static ResourceAdapterArchiveFactory getInstance()
+   {
+      if (instance == null)
+      {
+         instance = createInstance(ResourceAdapterArchiveFactory.class, IMPL_TYPE);
+      }
+      return instance;
+   }
+}

Added: shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/ResourceAdapterContainer.java
===================================================================
--- shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/ResourceAdapterContainer.java	                        (rev 0)
+++ shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/ResourceAdapterContainer.java	2009-09-26 23:56:21 UTC (rev 3541)
@@ -0,0 +1,49 @@
+/*
+ * 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.api.container;
+
+import org.jboss.shrinkwrap.api.Archive;
+
+/**
+ * ResourceAdapterContainer
+ * 
+ * Defines the contract for a component capable of storing Resource adapter
+ * resources. <br/>
+ * <br/>
+ * 
+ * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: $
+ * @param <T>
+ */
+public interface ResourceAdapterContainer<T extends Archive<T>>
+{
+   /**
+    * Adds a resource to this Archive as ra.xml. <br/>
+    * <br/>
+    * The mechanism to obtain the resource is up to the
+    * implementation. <br/>
+    * For instance a resourceName of "test/ra.xml" could be placed in
+    * "/META-INF/ra.xml"
+    * 
+    * @param resourceName Name of the resource to add
+    * @return This virtual archive
+    * @throws IllegalArgumentException
+    *             if resourceName is null
+    */
+   T setResourceAdapterXML(String resourceName) throws IllegalArgumentException;
+
+}

Added: shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/spec/ResourceAdapterArchive.java
===================================================================
--- shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/spec/ResourceAdapterArchive.java	                        (rev 0)
+++ shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/spec/ResourceAdapterArchive.java	2009-09-26 23:56:21 UTC (rev 3541)
@@ -0,0 +1,42 @@
+/*
+ * 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.api.spec;
+
+import org.jboss.shrinkwrap.api.Archive;
+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;
+
+/**
+ * ResourceAdapterArchive
+ * 
+ * Traditional RAR (Resource Adapter Archive) structure. Used in 
+ * construction of resource adapters.
+ *
+ * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: $
+ */
+public interface ResourceAdapterArchive
+      extends
+         Archive<ResourceAdapterArchive>,
+         ManifestContainer<ResourceAdapterArchive>,
+         LibraryContainer<ResourceAdapterArchive>,
+         ResourceContainer<ResourceAdapterArchive>,
+         ResourceAdapterContainer<ResourceAdapterArchive>
+{
+}

Added: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ResourceAdapterArchiveFactoryImpl.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ResourceAdapterArchiveFactoryImpl.java	                        (rev 0)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ResourceAdapterArchiveFactoryImpl.java	2009-09-26 23:56:21 UTC (rev 3541)
@@ -0,0 +1,52 @@
+/*
+ * 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.ResourceAdapterArchiveFactory;
+import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
+import org.jboss.shrinkwrap.impl.base.spec.ResourceAdapterArchiveImpl;
+import org.jboss.shrinkwrap.spi.MemoryMapArchive;
+
+/**
+ * ResourceAdapterArchiveFactoryImpl
+ * 
+ * ResourceAdapterArchiveFactory implementation used to create {@link ResourceAdapterArchive} instances. Thread-safe.
+ *
+ * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: $
+ */
+public class ResourceAdapterArchiveFactoryImpl extends ResourceAdapterArchiveFactory
+{
+
+   /*
+    * {@inheritDoc}
+    * @see org.jboss.declarchive.api.ResourceAdapterArchiveFactory#doCreate(java.lang.String)
+    */
+   @Override
+   protected ResourceAdapterArchive doCreate(String archiveName)
+   {
+      // Create storage delegate
+      MemoryMapArchive memoryMapArchive = new MemoryMapArchiveImpl(archiveName);
+
+      // Create Resource Adapter Archive
+      ResourceAdapterArchive resourceAdapterArchive = new ResourceAdapterArchiveImpl(memoryMapArchive);
+
+      // Return archive
+      return resourceAdapterArchive;
+   }
+
+}

Added: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ResourceAdapterContainerBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ResourceAdapterContainerBase.java	                        (rev 0)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ResourceAdapterContainerBase.java	2009-09-26 23:56:21 UTC (rev 3541)
@@ -0,0 +1,68 @@
+/*
+ * 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.util.logging.Logger;
+
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.container.ResourceAdapterContainer;
+import org.jboss.shrinkwrap.impl.base.asset.ClassLoaderAsset;
+
+/**
+ * ResourceAdapterContainerBase
+ * 
+ * Abstract class that helps implement the ResourceAdapter. 
+ * Used by specs that extends the ResourceAdapter.
+ *
+ * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: $
+ * @param <T>
+ */
+public abstract class ResourceAdapterContainerBase<T extends Archive<T>> extends ContainerBase<T>
+      implements
+         ResourceAdapterContainer<T>
+{
+   //-------------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   private static final Logger log = Logger.getLogger(ResourceAdapterContainerBase.class.getName());
+
+   //-------------------------------------------------------------------------------------||
+   // Constructor ------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   protected ResourceAdapterContainerBase(Class<T> actualType, Archive<?> archive)
+   {
+      super(actualType, archive);
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Required Implementations - ResourceAdapterContainer - Resources --------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /* (non-Javadoc)
+    * @see org.jboss.declarchive.api.container.RContainer#setApplicationXML(java.lang.String)
+    */
+   @Override
+   public T setResourceAdapterXML(String resourceName) throws IllegalArgumentException
+   {
+      Validate.notNull(resourceName, "ResourceName must be specified");
+      return add(getManinfestPath(), "ra.xml", new ClassLoaderAsset(resourceName));
+   }
+
+}

Added: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/spec/ResourceAdapterArchiveImpl.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/spec/ResourceAdapterArchiveImpl.java	                        (rev 0)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/spec/ResourceAdapterArchiveImpl.java	2009-09-26 23:56:21 UTC (rev 3541)
@@ -0,0 +1,113 @@
+/*
+ * 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.spec;
+
+import java.util.logging.Logger;
+
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.Path;
+import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
+import org.jboss.shrinkwrap.impl.base.ResourceAdapterContainerBase;
+import org.jboss.shrinkwrap.impl.base.path.BasicPath;
+
+/**
+ * ResourceAdapterArchiveImpl
+ *
+ * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: $
+ */
+public class ResourceAdapterArchiveImpl 
+   extends ResourceAdapterContainerBase<ResourceAdapterArchive> 
+   implements ResourceAdapterArchive 
+{
+   //-------------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   private static final Logger log = Logger.getLogger(ResourceAdapterArchiveImpl.class.getName());
+
+   /**
+    * Path to the manifests inside of the Archive.
+    */
+   private static final Path PATH_MANIFEST = new BasicPath("META-INF");
+
+   /**
+    * Path to the resources inside of the Archive.
+    */
+   private static final Path PATH_RESOURCE = new BasicPath("/");
+
+   /**
+    * Path to the application libraries.
+    */
+   private static final Path PATH_LIBRARY = new BasicPath("/");
+
+   //-------------------------------------------------------------------------------------||
+   // Constructor ------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Create a new ResourceAdapterArchive with any type storage engine as backing.
+    * 
+    * @param delegate The storage backing.
+    */
+   public ResourceAdapterArchiveImpl(final Archive<?> delegate)
+   {
+      super(ResourceAdapterArchive.class, delegate);
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Required Implementations -----------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+   
+   /* (non-Javadoc)
+    * @see org.jboss.declarchive.impl.base.ContainerBase#getLibraryPath()
+    */
+   @Override
+   public Path getLibraryPath()
+   {
+      return PATH_LIBRARY;
+   }
+   
+   /* (non-Javadoc)
+    * @see org.jboss.declarchive.impl.base.ContainerBase#getResourcePath()
+    */
+   @Override
+   protected Path getResourcePath()
+   {
+      return PATH_RESOURCE;
+   }
+   
+   /* (non-Javadoc)
+    * @see org.jboss.declarchive.impl.base.ContainerBase#getManinfestPath()
+    */
+   @Override
+   protected Path getManinfestPath()
+   {
+      return PATH_MANIFEST;
+   }
+   
+   /**
+    * Classes are not supported by ResourceAdapterArchive.
+    * 
+    * @throws UnsupportedOperationException ResourceAdapterArchive does not support classes
+    */
+   @Override
+   protected Path getClassesPath()
+   {
+      throw new UnsupportedOperationException("ResourceAdapterArchive does not support classes");
+   }
+}

Added: 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	                        (rev 0)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/spec/ResourceAdapterArchiveImplTestCase.java	2009-09-26 23:56:21 UTC (rev 3541)
@@ -0,0 +1,205 @@
+/*
+ * 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.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.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.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * ResourceAdapterArchiveImplTestCase
+ *
+ * Test to ensure that ResourceAdapterArchiveImpl follow to java rar spec.
+ *
+ * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: $
+ */
+public class ResourceAdapterArchiveImplTestCase extends ContainerTestBase<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");
+
+   private static final Path PATH_LIBRARY = new BasicPath("/");
+
+   //-------------------------------------------------------------------------------------||
+   // Instance Members -------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   private ResourceAdapterArchive archive;
+
+   //-------------------------------------------------------------------------------------||
+   // Lifecycle Methods ------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   @Before
+   public void createResourceAdapterArchive() throws Exception
+   {
+      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 ResourceAdapterArchive
+    */
+   @Override
+   protected ResourceAdapterArchive getArchive()
+   {
+      return archive;
+   }
+
+   /**
+    * Create a new instance of a ResourceAdapterArchive
+    */
+   @Override
+   protected ResourceAdapterArchive createNewArchive()
+   {
+      return new ResourceAdapterArchiveImpl(new MemoryMapArchiveImpl());
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Required Impls - ContainerTestBase -------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   @Override
+   protected ClassContainer<ResourceAdapterArchive> getClassContainer()
+   {
+      throw new UnsupportedOperationException("ResourceAdapterArchive do not support classes");
+   }
+
+   @Override
+   protected Path getClassesPath()
+   {
+      throw new UnsupportedOperationException("ResourceAdapterArchive do not support classes");
+   }
+
+   @Override
+   protected LibraryContainer<ResourceAdapterArchive> getLibraryContainer()
+   {
+      return archive;
+   }
+
+   @Override
+   protected Path getManifestPath()
+   {
+      return PATH_MANIFEST;
+   }
+
+   @Override
+   protected Path getResourcePath()
+   {
+      return PATH_RESOURCE;
+   }
+
+   @Override
+   protected Path getLibraryPath()
+   {
+      return PATH_LIBRARY;
+   }
+
+   @Override
+   protected ManifestContainer<ResourceAdapterArchive> getManifestContainer()
+   {
+      return getArchive();
+   }
+
+   @Override
+   protected ResourceContainer<ResourceAdapterArchive> getResourceContainer()
+   {
+      return getArchive();
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Tests ------------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   @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
+   {
+   }
+
+   @Ignore
+   @Override
+   public void testAddClasses() throws Exception
+   {
+   }
+
+   @Ignore
+   @Override
+   public void testAddPackage() throws Exception
+   {
+   }
+
+   @Ignore
+   @Override
+   public void testAddPackageNonRecursive() throws Exception
+   {
+   }
+
+}

Added: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/unit/ResourceAdapterArchiveFactoryTestCase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/unit/ResourceAdapterArchiveFactoryTestCase.java	                        (rev 0)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/unit/ResourceAdapterArchiveFactoryTestCase.java	2009-09-26 23:56:21 UTC (rev 3541)
@@ -0,0 +1,67 @@
+/*
+ * 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.unit;
+
+import junit.framework.Assert;
+
+import org.jboss.shrinkwrap.api.ResourceAdapterArchiveFactory;
+import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
+import org.junit.Test;
+
+/**
+ * ResourceAdapterArchiveFactoryTestCase
+ * 
+ * TestCase to ensure the ResourceAdapterArchiveFactory functions correctly.
+ *
+ * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: $
+ */
+public class ResourceAdapterArchiveFactoryTestCase
+{
+
+   /**
+    * Test to ensure ResourceAdapterArchiveFactory returns a valid archive
+    * @throws Exception
+    */
+   @Test
+   public void testCreateArchive() throws Exception
+   {
+      String name = "test.rar";
+      ResourceAdapterArchive resourceAdapterArchive = ResourceAdapterArchiveFactory.create(name);
+      Assert.assertNotNull("Should return a valid resource adapter archive", resourceAdapterArchive);
+      Assert.assertEquals("Should return the same name as factory arg", name, resourceAdapterArchive.getName());
+   }
+
+   /**
+    * Test to ensure ResourceAdapterArchiveFactory.create requires an archive name
+    * @throws Exception
+    */
+   @Test
+   public void testCreateArchiveRequiresName() throws Exception
+   {
+      try
+      {
+         ResourceAdapterArchiveFactory.create(null);
+         Assert.fail("Should have thrown IllegalArgumentException");
+      }
+      catch (IllegalArgumentException expected)
+      {
+      }
+
+   }
+
+}



More information about the jboss-svn-commits mailing list