[jboss-cvs] JBossAS SVN: r110183 - in projects/jboss-jca/trunk: adapters/src/main/resources/jdbc and 8 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Dec 23 12:14:33 EST 2010


Author: maeste
Date: 2010-12-23 12:14:32 -0500 (Thu, 23 Dec 2010)
New Revision: 110183

Added:
   projects/jboss-jca/trunk/adapters/src/main/resources/jdbc/jar/
   projects/jboss-jca/trunk/adapters/src/main/resources/jdbc/jar/META-INF/
   projects/jboss-jca/trunk/adapters/src/main/resources/jdbc/jar/META-INF/MANIFEST.MF
   projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/ArquillianJCATestUtils.java
Removed:
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/AbstractDeployerTest.java
Modified:
   projects/jboss-jca/trunk/adapters/.classpath
   projects/jboss-jca/trunk/adapters/build.xml
   projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/spi/ExceptionSorterTestCase.java
   projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/spi/StaleConnectionCheckerTestCase.java
   projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/spi/ValidConnectionCheckerTestCase.java
   projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/H2TestCase.java
   projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/H2XATestCase.java
   projects/jboss-jca/trunk/core/.classpath
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/IronJacamarTestCase.java
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/RaXmlTestCase.java
   projects/jboss-jca/trunk/embedded/.classpath
   projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCAContainer.java
   projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCATestEnricher.java
Log:
JBJCA-472 Arquillian whereever is possible

Modified: projects/jboss-jca/trunk/adapters/.classpath
===================================================================
--- projects/jboss-jca/trunk/adapters/.classpath	2010-12-23 16:52:16 UTC (rev 110182)
+++ projects/jboss-jca/trunk/adapters/.classpath	2010-12-23 17:14:32 UTC (rev 110183)
@@ -20,5 +20,10 @@
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/test/mockito-all.jar"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/ironjacamar-embedded"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/embedded/shrinkwrap-api.jar"/>
+	<classpathentry kind="lib" path="/ironjacamar-parent/lib/arquillian/arquillian-api.jar"/>
+	<classpathentry kind="lib" path="/ironjacamar-parent/lib/arquillian/arquillian-impl-base.jar"/>
+	<classpathentry kind="lib" path="/ironjacamar-parent/lib/arquillian/arquillian-junit.jar" sourcepath="/dati/project/RH/arquillian/impl-base/src/main/java"/>
+	<classpathentry kind="lib" path="/ironjacamar-parent/lib/arquillian/arquillian-testenricher-resource.jar"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/ironjacamar-deployer"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

Modified: projects/jboss-jca/trunk/adapters/build.xml
===================================================================
--- projects/jboss-jca/trunk/adapters/build.xml	2010-12-23 16:52:16 UTC (rev 110182)
+++ projects/jboss-jca/trunk/adapters/build.xml	2010-12-23 17:14:32 UTC (rev 110183)
@@ -151,11 +151,16 @@
       <sysproperty key="test.dir" value="${test.dir}"/>
       <sysproperty key="xb.builder.useUnorderedSequence" value="true"/>
       <sysproperty key="javax.xml.stream.XMLInputFactory" value="com.sun.xml.internal.stream.XMLInputFactoryImpl"/>
+      <sysproperty key="java.naming.factory.initial" value="org.jnp.interfaces.LocalOnlyContextFactory"/>
+    	<sysproperty key="java.naming.factory.url.pkgs" value="org.jboss.naming:org.jnp.interfaces"/>
+
       
       <classpath>
         <pathelement location="${build.adapters.dir}/test"/>
+        <pathelement location="${build.adapters.dir}"/>
         <fileset dir="${target.dir}" includes="*.jar"/>
         <fileset dir="${build.adapters.dir}" includes="*.jar"/>
+        <fileset dir="${build.adapters.dir}/test" includes="*.jar"/>                
         <fileset dir="${lib.dir}/common" includes="*.jar" />
         <fileset dir="${lib.dir}/embedded" includes="*.jar" />
         <fileset dir="${lib.dir}/arquillian" includes="*.jar" />
@@ -204,9 +209,10 @@
       
       <classpath>
         <pathelement location="${build.adapters.dir}/test"/>
+        <pathelement location="${build.adapters.dir}"/>
         <fileset dir="${target.dir}" includes="*.jar"/>
         <fileset dir="${build.adapters.dir}" includes="*.jar"/>
-        <fileset dir="${lib.dir}/common" includes="*.jar" />
+	     <fileset dir="${lib.dir}/common" includes="*.jar" />
         <fileset dir="${lib.dir}/embedded" includes="*.jar" />
         <fileset dir="${lib.dir}/arquillian" includes="*.jar" />
         <fileset dir="${lib.dir}/sjc" includes="*.jar" />
@@ -243,10 +249,15 @@
       <compilerarg value="-Xlint"/>
     </javac> 
 
-    <copy todir="${build.adapters.dir}/test">
-      <fileset dir="src/test/resources"/>
+    <copy todir="${build.adapters.dir}">
+      <fileset dir="src/main/resources"/>
     </copy>
 
+  	 <copy todir="${build.adapters.dir}">
+  	   <fileset dir="src/test/resources"/>
+  	 </copy>
+
+  	
     <copy todir="${build.adapters.dir}/">
       <fileset dir="${target.dir}">
         <include name="jdbc-local.rar"/>

Added: projects/jboss-jca/trunk/adapters/src/main/resources/jdbc/jar/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-jca/trunk/adapters/src/main/resources/jdbc/jar/META-INF/MANIFEST.MF	                        (rev 0)
+++ projects/jboss-jca/trunk/adapters/src/main/resources/jdbc/jar/META-INF/MANIFEST.MF	2010-12-23 17:14:32 UTC (rev 110183)
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Ant-Version: Apache Ant 1.8.1
+Created-By: 1.6.0_18-b18 (Sun Microsystems Inc.)
+Implementation-Title: IronJacamar JDBC Resource Adapter
+Implementation-Version: 1.0.0.Beta4
+Implementation-Vendor: The IronJacamar project (http://www.jboss.org/i
+ ronjacamar)
+Implementation-Vendor-Id: org.jboss
\ No newline at end of file

Modified: projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/spi/ExceptionSorterTestCase.java
===================================================================
--- projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/spi/ExceptionSorterTestCase.java	2010-12-23 16:52:16 UTC (rev 110182)
+++ projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/spi/ExceptionSorterTestCase.java	2010-12-23 17:14:32 UTC (rev 110183)
@@ -22,21 +22,22 @@
 package org.jboss.jca.adapters.jdbc.spi;
 
 import org.jboss.jca.adapters.jdbc.spi.testimpl.TestExceptionSorter;
-import org.jboss.jca.embedded.Embedded;
-import org.jboss.jca.embedded.EmbeddedFactory;
+import org.jboss.jca.embedded.arquillian.ArquillianJCATestUtils;
 
-import java.io.File;
-import java.net.URL;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.Statement;
 
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
+import javax.annotation.Resource;
 import javax.sql.DataSource;
 
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
+
 import org.junit.Test;
+import org.junit.runner.RunWith;
 
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertNotNull;
@@ -50,118 +51,74 @@
  * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
  *
  */
+ at RunWith(Arquillian.class)
 public class ExceptionSorterTestCase
 {
 
-   // --------------------------------------------------------------------------------||
-   // Tests --------------------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+   //---------------------- GIVEN --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+   /**
+    * Define the deployment
+    * @return The deployment archive
+    * @throws Exception in case of errors
+    */
+   @Deployment
+   public static ResourceAdapterArchive createDeployment() throws Exception
+   {
+      String archiveName = "jdbc-local.rar";
+      ResourceAdapterArchive raa = ArquillianJCATestUtils.buildShrinkwrapJdbcLocal(archiveName);
+      ResourceAdapterArchive external = ShrinkWrap.create(ResourceAdapterArchive.class, "complex_" + archiveName);
+      external.add(raa, "/");
+      external.addResource("h2-exception-sorter-ds.xml", "datasources-ds.xml");
+      return external;
 
+   }
+
+   //-------------------------------------------------------------------------------------||
+   //---------------------- WHEN  --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+   //
+   @Resource(mappedName = "java:/H2DS")
+   private DataSource ds;
+
+   //-------------------------------------------------------------------------------------||
+   //---------------------- THEN  --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
    /**
-    * shouldInjectCorrectExceptionSorter
-    * @throws Throwable in case of error
+    * Basic
+    * @exception Throwable Thrown if case of an error
     */
    @Test
    public void shouldInjectCorrectExceptionSorter() throws Throwable
    {
-      /*
-       * Embedded
-       */
-      Embedded embedded = null;
-
       try
       {
-         // Create and set an embedded JCA instance
-         embedded = EmbeddedFactory.create();
+         assertNotNull(ds);
 
-         // Startup
-         embedded.startup();
+         Connection c = ds.getConnection();
+         assertNotNull(c);
 
-         // Deploy jdbc-local.rar
-         embedded.deploy(getURL("jdbc-local.rar"));
-
-         // Deploy H2 datasource
-         URL url = getURL("test/h2-exception-sorter-ds.xml");
-
-         embedded.deploy(url);
-
-         Context context = null;
-
-         try
-         {
-            context = new InitialContext();
-
-            DataSource ds = (DataSource) context.lookup("java:/H2DS");
-            assertNotNull(ds);
-
-            Connection c = ds.getConnection();
-            assertNotNull(c);
-
-            Statement st = c.createStatement();
-            st.execute("dssd");
-
-         }
-         catch (SQLException e)
-         {
-            // nothing we need an exception ;)
-         }
-
-         finally
-         {
-            assertThat(TestExceptionSorter.isConstructorInvoked(), is(true));
-
-            assertThat(TestExceptionSorter.isMethodInvoked(), is(true));
-
-            assertThat(TestExceptionSorter.getStringInjected(), hasItems("MyTest", "MyTest2"));
-
-            if (context != null)
-            {
-               try
-               {
-                  context.close();
-               }
-               catch (NamingException ne)
-               {
-                  // Ignore
-               }
-            }
-         }
-
+         Statement st = c.createStatement();
+         st.execute("dssd");
       }
+      catch (SQLException e)
+      {
+         // nothing we need an exception ;)
+      }
+
       finally
       {
-         if (embedded != null)
-         {
-            // Undeploy H2 datasource
-            embedded.undeploy(getURL("test/h2-exception-sorter-ds.xml"));
+         assertThat(TestExceptionSorter.isConstructorInvoked(), is(true));
 
-            // Undeploy jdbc-local.rar
-            embedded.undeploy(getURL("jdbc-local.rar"));
+         assertThat(TestExceptionSorter.isMethodInvoked(), is(true));
 
-            // Shutdown embedded
-            embedded.shutdown();
+         assertThat(TestExceptionSorter.getStringInjected(), hasItems("MyTest", "MyTest2"));
 
-            // Set embedded to null
-            embedded = null;
-         }
       }
 
    }
 
-   // --------------------------------------------------------------------------------||
-   // Helper Methods -----------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
 
-   /**
-    * Get the URL for a test archive
-    * @param archive The name of the test archive
-    * @return The URL to the archive
-    * @throws Throwable throwable exception
-    */
-   private static URL getURL(String archive) throws Throwable
-   {
-      File f = new File(System.getProperty("archives.dir") + File.separator + archive);
-      return f.toURI().toURL();
-   }
-
 }

Modified: projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/spi/StaleConnectionCheckerTestCase.java
===================================================================
--- projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/spi/StaleConnectionCheckerTestCase.java	2010-12-23 16:52:16 UTC (rev 110182)
+++ projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/spi/StaleConnectionCheckerTestCase.java	2010-12-23 17:14:32 UTC (rev 110183)
@@ -23,20 +23,22 @@
 
 import org.jboss.jca.adapters.jdbc.spi.testimpl.TestStaleConnectionChecker;
 import org.jboss.jca.embedded.Embedded;
-import org.jboss.jca.embedded.EmbeddedFactory;
+import org.jboss.jca.embedded.arquillian.ArquillianJCATestUtils;
 
-import java.io.File;
-import java.net.URL;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.Statement;
 
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
+import javax.annotation.Resource;
 import javax.sql.DataSource;
 
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
+
 import org.junit.Test;
+import org.junit.runner.RunWith;
 
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertNotNull;
@@ -49,13 +51,41 @@
  * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
  *
  */
+ at RunWith(Arquillian.class)
 public class StaleConnectionCheckerTestCase
 {
 
-   // --------------------------------------------------------------------------------||
-   // Tests --------------------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+   //---------------------- GIVEN --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+   /**
+    * Define the deployment
+    * @return The deployment archive
+    * @throws Exception in case of errors
+    */
+   @Deployment
+   public static ResourceAdapterArchive createDeployment() throws Exception
+   {
+      String archiveName = "jdbc-local.rar";
+      ResourceAdapterArchive raa = ArquillianJCATestUtils.buildShrinkwrapJdbcLocal(archiveName);
+      ResourceAdapterArchive external = ShrinkWrap.create(ResourceAdapterArchive.class, "complex_" + archiveName);
+      external.add(raa, "/");
+      external.addResource("h2-stale-connection-checker-ds.xml", "datasources-ds.xml");
+      return external;
 
+   }
+
+   //-------------------------------------------------------------------------------------||
+   //---------------------- WHEN  --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+   //
+   @Resource(mappedName = "java:/H2DS")
+   private DataSource ds;
+
+   //-------------------------------------------------------------------------------------||
+   //---------------------- THEN  --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
    /**
     * shouldInjectCorrectStaleConnectionChecker
     * @throws Throwable in case of error
@@ -70,97 +100,30 @@
 
       try
       {
-         // Create and set an embedded JCA instance
-         embedded = EmbeddedFactory.create();
+         assertNotNull(ds);
 
-         // Startup
-         embedded.startup();
+         Connection c = ds.getConnection();
+         assertNotNull(c);
 
-         // Deploy jdbc-local.rar
-         embedded.deploy(getURL("jdbc-local.rar"));
+         Statement st = c.createStatement();
+         st.execute("dssd");
 
-         // Deploy H2 datasource
-         URL url = getURL("test/h2-stale-connection-checker-ds.xml");
-
-         embedded.deploy(url);
-
-         Context context = null;
-
-         try
-         {
-            context = new InitialContext();
-
-            DataSource ds = (DataSource) context.lookup("java:/H2DS");
-            assertNotNull(ds);
-
-            Connection c = ds.getConnection();
-            assertNotNull(c);
-
-            Statement st = c.createStatement();
-            st.execute("dssd");
-
-         }
-         catch (SQLException e)
-         {
-            // nothing we need an exception ;)
-         }
-
-         finally
-         {
-            assertThat(TestStaleConnectionChecker.isConstructorInvoked(), is(true));
-
-            assertThat(TestStaleConnectionChecker.isMethodInvoked(), is(true));
-
-            assertThat(TestStaleConnectionChecker.getInjectedInteger(), is(100));
-
-            if (context != null)
-            {
-               try
-               {
-                  context.close();
-               }
-               catch (NamingException ne)
-               {
-                  // Ignore
-               }
-            }
-         }
-
       }
+      catch (SQLException e)
+      {
+         // nothing we need an exception ;)
+      }
+
       finally
       {
-         if (embedded != null)
-         {
-            // Undeploy H2 datasource
-            embedded.undeploy(getURL("test/h2-stale-connection-checker-ds.xml"));
+         assertThat(TestStaleConnectionChecker.isConstructorInvoked(), is(true));
 
-            // Undeploy jdbc-local.rar
-            embedded.undeploy(getURL("jdbc-local.rar"));
+         assertThat(TestStaleConnectionChecker.isMethodInvoked(), is(true));
 
-            // Shutdown embedded
-            embedded.shutdown();
+         assertThat(TestStaleConnectionChecker.getInjectedInteger(), is(100));
 
-            // Set embedded to null
-            embedded = null;
-         }
       }
 
    }
 
-   // --------------------------------------------------------------------------------||
-   // Helper Methods -----------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   /**
-    * Get the URL for a test archive
-    * @param archive The name of the test archive
-    * @return The URL to the archive
-    * @throws Throwable throwable exception
-    */
-   private static URL getURL(String archive) throws Throwable
-   {
-      File f = new File(System.getProperty("archives.dir") + File.separator + archive);
-      return f.toURI().toURL();
-   }
-
 }

Modified: projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/spi/ValidConnectionCheckerTestCase.java
===================================================================
--- projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/spi/ValidConnectionCheckerTestCase.java	2010-12-23 16:52:16 UTC (rev 110182)
+++ projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/spi/ValidConnectionCheckerTestCase.java	2010-12-23 17:14:32 UTC (rev 110183)
@@ -22,21 +22,22 @@
 package org.jboss.jca.adapters.jdbc.spi;
 
 import org.jboss.jca.adapters.jdbc.spi.testimpl.TestValidConnectionChecker;
-import org.jboss.jca.embedded.Embedded;
-import org.jboss.jca.embedded.EmbeddedFactory;
+import org.jboss.jca.embedded.arquillian.ArquillianJCATestUtils;
 
-import java.io.File;
-import java.net.URL;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.Statement;
 
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
+import javax.annotation.Resource;
 import javax.sql.DataSource;
 
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
+
 import org.junit.Test;
+import org.junit.runner.RunWith;
 
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertNotNull;
@@ -49,13 +50,41 @@
  * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
  *
  */
+ at RunWith(Arquillian.class)
 public class ValidConnectionCheckerTestCase
 {
 
-   // --------------------------------------------------------------------------------||
-   // Tests --------------------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+   //---------------------- GIVEN --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+   /**
+    * Define the deployment
+    * @return The deployment archive
+    * @throws Exception in case of errors
+    */
+   @Deployment
+   public static ResourceAdapterArchive createDeployment() throws Exception
+   {
+      String archiveName = "jdbc-local.rar";
+      ResourceAdapterArchive raa = ArquillianJCATestUtils.buildShrinkwrapJdbcLocal(archiveName);
+      ResourceAdapterArchive external = ShrinkWrap.create(ResourceAdapterArchive.class, "complex_" + archiveName);
+      external.add(raa, "/");
+      external.addResource("h2-valid-connection-checker-ds.xml", "datasources-ds.xml");
+      return external;
 
+   }
+
+   //-------------------------------------------------------------------------------------||
+   //---------------------- WHEN  --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+   //
+   @Resource(mappedName = "java:/H2DS")
+   private DataSource ds;
+
+   //-------------------------------------------------------------------------------------||
+   //---------------------- THEN  --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
    /**
     * shouldInjectCorrectStaleConnectionChecker
     * @throws Throwable in case of error
@@ -63,106 +92,35 @@
    @Test
    public void shouldInjectCorrectStaleConnectionChecker() throws Throwable
    {
-      /*
-       * Embedded
-       */
-      Embedded embedded = null;
 
       try
       {
-         // Create and set an embedded JCA instance
-         embedded = EmbeddedFactory.create();
+         assertNotNull(ds);
 
-         // Startup
-         embedded.startup();
+         Connection c = ds.getConnection();
+         assertNotNull(c);
+         c.close();
+         c = ds.getConnection();
 
-         // Deploy jdbc-local.rar
-         embedded.deploy(getURL("jdbc-local.rar"));
+         Statement st = c.createStatement();
+         st.execute("dssd");
 
-         // Deploy H2 datasource
-         URL url = getURL("test/h2-valid-connection-checker-ds.xml");
-
-         embedded.deploy(url);
-
-         Context context = null;
-
-         try
-         {
-            context = new InitialContext();
-
-            DataSource ds = (DataSource) context.lookup("java:/H2DS");
-            assertNotNull(ds);
-
-            Connection c = ds.getConnection();
-            assertNotNull(c);
-            c.close();
-            c = ds.getConnection();
-
-            Statement st = c.createStatement();
-            st.execute("dssd");
-
-         }
-         catch (SQLException e)
-         {
-            // nothing we need an exception ;)
-         }
-
-         finally
-         {
-            assertThat(TestValidConnectionChecker.isConstructorInvoked(), is(true));
-
-            assertThat(TestValidConnectionChecker.isMethodInvoked(), is(true));
-
-            //assertThat(TestValidConnectionChecker.getInjectedInteger(), is(100));
-
-            if (context != null)
-            {
-               try
-               {
-                  context.close();
-               }
-               catch (NamingException ne)
-               {
-                  // Ignore
-               }
-            }
-         }
-
       }
+      catch (SQLException e)
+      {
+         // nothing we need an exception ;)
+      }
+
       finally
       {
-         if (embedded != null)
-         {
-            // Undeploy H2 datasource
-            embedded.undeploy(getURL("test/h2-stale-connection-checker-ds.xml"));
+         assertThat(TestValidConnectionChecker.isConstructorInvoked(), is(true));
 
-            // Undeploy jdbc-local.rar
-            embedded.undeploy(getURL("jdbc-local.rar"));
+         assertThat(TestValidConnectionChecker.isMethodInvoked(), is(true));
 
-            // Shutdown embedded
-            embedded.shutdown();
+         //assertThat(TestValidConnectionChecker.getInjectedInteger(), is(100));
 
-            // Set embedded to null
-            embedded = null;
-         }
       }
 
    }
 
-   // --------------------------------------------------------------------------------||
-   // Helper Methods -----------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   /**
-    * Get the URL for a test archive
-    * @param archive The name of the test archive
-    * @return The URL to the archive
-    * @throws Throwable throwable exception
-    */
-   private static URL getURL(String archive) throws Throwable
-   {
-      File f = new File(System.getProperty("archives.dir") + File.separator + archive);
-      return f.toURI().toURL();
-   }
-
 }

Modified: projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/H2TestCase.java
===================================================================
--- projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/H2TestCase.java	2010-12-23 16:52:16 UTC (rev 110182)
+++ projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/H2TestCase.java	2010-12-23 17:14:32 UTC (rev 110183)
@@ -22,148 +22,73 @@
 
 package org.jboss.jca.adapters.jdbc.unit;
 
-import org.jboss.jca.embedded.Embedded;
-import org.jboss.jca.embedded.EmbeddedFactory;
+import org.jboss.jca.embedded.arquillian.ArquillianJCATestUtils;
 
-import java.io.File;
-import java.net.URL;
 import java.sql.Connection;
 
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
+import javax.annotation.Resource;
 import javax.sql.DataSource;
 
-import org.jboss.logging.Logger;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
 
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
 import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.runner.RunWith;
 
+import static org.junit.Assert.assertNotNull;
+
 /**
  * Test cases for getting a connection from the H2 database
- * 
+ *
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
  * @version $Revision: $
  */
+ at RunWith(Arquillian.class)
 public class H2TestCase
 {
 
-   // --------------------------------------------------------------------------------||
-   // Class Members ------------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   private static Logger log = Logger.getLogger(H2TestCase.class);
-
-   private static final String JNDI_NAME = "java:/H2DS";
-
-   /*
-    * Embedded
-    */
-   private static Embedded embedded;
-
-   // --------------------------------------------------------------------------------||
-   // Tests --------------------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
+   //-------------------------------------------------------------------------------------||
+   //---------------------- GIVEN --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
    /**
-    * Get a connection from the database
-    * @exception Throwable Thrown if case of an error
+    * Define the deployment
+    * @return The deployment archive
+    * @throws Exception in case of errors
     */
-   @Test
-   public void testConnection() throws Throwable
+   @Deployment
+   public static ResourceAdapterArchive createDeployment() throws Exception
    {
-      Context context = null;
+      String archiveName = "jdbc-local.rar";
+      ResourceAdapterArchive raa = ArquillianJCATestUtils.buildShrinkwrapJdbcLocal(archiveName);
+      ResourceAdapterArchive external = ShrinkWrap.create(ResourceAdapterArchive.class, "complex_" + archiveName);
+      external.add(raa, "/");
+      external.addResource("h2-ds.xml", "datasources-ds.xml");
+      return external;
 
-      try
-      {
-         context = new InitialContext();
-         
-         DataSource ds = (DataSource)context.lookup(JNDI_NAME);
-         assertNotNull(ds);
-
-         Connection c = ds.getConnection();
-         assertNotNull(c);
-      }
-      catch (Throwable t)
-      {
-         log.error(t.getMessage(), t);
-         fail(t.getMessage());
-      }
-      finally
-      {
-         if (context != null)
-         {
-            try
-            {
-               context.close();
-            }
-            catch (NamingException ne)
-            {
-               // Ignore
-            }
-         }
-      }
    }
 
-   // --------------------------------------------------------------------------------||
-   // Helper Methods -----------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+   //---------------------- WHEN  --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+   //
+   @Resource(mappedName = "java:/H2DS")
+   private DataSource ds;
 
-   /**
-    * Get the URL for a test archive
-    * @param archive The name of the test archive
-    * @return The URL to the archive
-    * @throws Throwable throwable exception
-    */
-   private static URL getURL(String archive) throws Throwable
-   {
-      File f = new File(System.getProperty("archives.dir") + File.separator + archive);
-      return f.toURI().toURL();
-   }
+   //-------------------------------------------------------------------------------------||
+   //---------------------- THEN  --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
 
-   // --------------------------------------------------------------------------------||
-   // Lifecycle Methods --------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
    /**
-    * Lifecycle start, before the suite is executed
-    * @throws Throwable throwable exception 
+    * Basic
+    * @exception Throwable Thrown if case of an error
     */
-   @BeforeClass
-   public static void beforeClass() throws Throwable
+   @Test
+   public void testBasic() throws Throwable
    {
-      // Create and set an embedded JCA instance
-      embedded = EmbeddedFactory.create();
-
-      // Startup
-      embedded.startup();
-
-      // Deploy jdbc-local.rar
-      embedded.deploy(getURL("jdbc-local.rar"));
-
-      // Deploy H2 datasource
-      embedded.deploy(getURL("test/h2-ds.xml"));
+      assertNotNull(ds);
+      Connection c = ds.getConnection();
+      assertNotNull(c);
    }
-
-   /**
-    * Lifecycle stop, after the suite is executed
-    * @throws Throwable throwable exception 
-    */
-   @AfterClass
-   public static void afterClass() throws Throwable
-   {
-      // Undeploy H2 datasource
-      embedded.undeploy(getURL("test/h2-ds.xml"));
-
-      // Undeploy jdbc-local.rar
-      embedded.undeploy(getURL("jdbc-local.rar"));
-
-      // Shutdown embedded
-      embedded.shutdown();
-
-      // Set embedded to null
-      embedded = null;
-   }
 }

Modified: projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/H2XATestCase.java
===================================================================
--- projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/H2XATestCase.java	2010-12-23 16:52:16 UTC (rev 110182)
+++ projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/H2XATestCase.java	2010-12-23 17:14:32 UTC (rev 110183)
@@ -22,148 +22,74 @@
 
 package org.jboss.jca.adapters.jdbc.unit;
 
-import org.jboss.jca.embedded.Embedded;
-import org.jboss.jca.embedded.EmbeddedFactory;
+import org.jboss.jca.embedded.arquillian.ArquillianJCATestUtils;
 
-import java.io.File;
-import java.net.URL;
 import java.sql.Connection;
 
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
+import javax.annotation.Resource;
 import javax.sql.DataSource;
 
-import org.jboss.logging.Logger;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
 
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
 import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.runner.RunWith;
 
+import static org.junit.Assert.assertNotNull;
+
 /**
  * Test cases for getting a XA connection from the H2 database
- * 
+ *
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
  * @version $Revision: $
  */
+ at RunWith(Arquillian.class)
 public class H2XATestCase
 {
 
-   // --------------------------------------------------------------------------------||
-   // Class Members ------------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   private static Logger log = Logger.getLogger(H2XATestCase.class);
-
-   private static final String JNDI_NAME = "java:/H2XADS";
-
-   /*
-    * Embedded
-    */
-   private static Embedded embedded;
-
-   // --------------------------------------------------------------------------------||
-   // Tests --------------------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
+   //-------------------------------------------------------------------------------------||
+   //---------------------- GIVEN --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
    /**
-    * Get a connection from the database
-    * @exception Throwable Thrown if case of an error
+    * Define the deployment
+    * @return The deployment archive
+    * @throws Exception in case of errors
     */
-   @Test
-   public void testConnection() throws Throwable
+   @Deployment
+   public static ResourceAdapterArchive createDeployment() throws Exception
    {
-      Context context = null;
+      String archiveName = "jdbc-xa.rar";
+      ResourceAdapterArchive raa = ArquillianJCATestUtils.buildShrinkwrapJdbcXa(archiveName);
+      ResourceAdapterArchive external = ShrinkWrap.create(ResourceAdapterArchive.class, "complex_" + archiveName);
+      external.add(raa, "/");
+      external.addResource("h2-xa-ds.xml", "datasources-xa-ds.xml");
+      return external;
 
-      try
-      {
-         context = new InitialContext();
-         
-         DataSource ds = (DataSource)context.lookup(JNDI_NAME);
-         assertNotNull(ds);
-
-         Connection c = ds.getConnection();
-         assertNotNull(c);
-      }
-      catch (Throwable t)
-      {
-         log.error(t.getMessage(), t);
-         fail(t.getMessage());
-      }
-      finally
-      {
-         if (context != null)
-         {
-            try
-            {
-               context.close();
-            }
-            catch (NamingException ne)
-            {
-               // Ignore
-            }
-         }
-      }
    }
 
-   // --------------------------------------------------------------------------------||
-   // Helper Methods -----------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+   //---------------------- WHEN  --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+   //
+   @Resource(mappedName = "java:/H2XADS")
+   private DataSource ds;
 
-   /**
-    * Get the URL for a test archive
-    * @param archive The name of the test archive
-    * @return The URL to the archive
-    * @throws Throwable throwable exception
-    */
-   private static URL getURL(String archive) throws Throwable
-   {
-      File f = new File(System.getProperty("archives.dir") + File.separator + archive);
-      return f.toURI().toURL();
-   }
+   //-------------------------------------------------------------------------------------||
+   //---------------------- THEN  --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
 
-   // --------------------------------------------------------------------------------||
-   // Lifecycle Methods --------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
    /**
-    * Lifecycle start, before the suite is executed
-    * @throws Throwable throwable exception 
+    * Basic
+    * @exception Throwable Thrown if case of an error
     */
-   @BeforeClass
-   public static void beforeClass() throws Throwable
+   @Test
+   public void testBasic() throws Throwable
    {
-      // Create and set an embedded JCA instance
-      embedded = EmbeddedFactory.create();
-
-      // Startup
-      embedded.startup();
-
-      // Deploy jdbc-local.rar
-      embedded.deploy(getURL("jdbc-xa.rar"));
-
-      // Deploy H2 datasource
-      embedded.deploy(getURL("test/h2-xa-ds.xml"));
+      assertNotNull(ds);
+      Connection c = ds.getConnection();
+      assertNotNull(c);
    }
 
-   /**
-    * Lifecycle stop, after the suite is executed
-    * @throws Throwable throwable exception 
-    */
-   @AfterClass
-   public static void afterClass() throws Throwable
-   {
-      // Undeploy H2 datasource
-      embedded.undeploy(getURL("test/h2-xa-ds.xml"));
-
-      // Undeploy jdbc-local.rar
-      embedded.undeploy(getURL("jdbc-xa.rar"));
-
-      // Shutdown embedded
-      embedded.shutdown();
-
-      // Set embedded to null
-      embedded = null;
-   }
 }

Modified: projects/jboss-jca/trunk/core/.classpath
===================================================================
--- projects/jboss-jca/trunk/core/.classpath	2010-12-23 16:52:16 UTC (rev 110182)
+++ projects/jboss-jca/trunk/core/.classpath	2010-12-23 17:14:32 UTC (rev 110183)
@@ -7,7 +7,6 @@
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/ironjacamar-api"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/ironjacamar-common"/>
-	<classpathentry combineaccessrules="false" kind="src" path="/ironjacamar-embedded"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/jboss-common-core.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/jboss-integration.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/jboss-jaspi-api.jar"/>
@@ -23,5 +22,6 @@
 	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/test/mockito-all.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/test/h2.jar"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/ironjacamar-embedded"/>
 	<classpathentry kind="output" path="eclipse-target/classes"/>
 </classpath>

Deleted: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/AbstractDeployerTest.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/AbstractDeployerTest.java	2010-12-23 16:52:16 UTC (rev 110182)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/AbstractDeployerTest.java	2010-12-23 17:14:32 UTC (rev 110183)
@@ -1,126 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jca.test.deployers.spec;
-
-import org.jboss.jca.test.deployers.spec.rars.TestConnection;
-import org.jboss.jca.test.deployers.spec.rars.TestConnectionInterface;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.UUID;
-
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
-
-public abstract class AbstractDeployerTest
-{
-
-   /**
-    * Build a shrinkwrap rar adding all necessary classes
-    *
-    * @param archiveName the archhive name
-    * @param packageName the package name
-    * @return the shrinkwrapped rar
-    * @throws Exception in case of error creating the archive
-    */
-   protected static ResourceAdapterArchive buidShrinkwrapRa(String archiveName, String packageName) throws Exception
-   {
-      ResourceAdapterArchive raa = ShrinkWrap.create(ResourceAdapterArchive.class, archiveName);
-
-      JavaArchive ja = ShrinkWrap.create(JavaArchive.class, UUID.randomUUID().toString() + ".jar");
-      ja.addClasses(TestConnection.class, TestConnectionInterface.class);
-      ja.addClasses(getClasses(packageName));
-
-      raa.addLibrary(ja);
-      return raa;
-   }
-
-   /**
-    * Scans all classes accessible from the context class loader which belong to the given package and subpackages.
-    *
-    * @param packageName The base package
-    * @return The classes
-    * @throws ClassNotFoundException
-    * @throws IOException
-    */
-   private static Class[] getClasses(String packageName) throws ClassNotFoundException, IOException
-   {
-      ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-      assert classLoader != null;
-      String path = packageName.replace('.', '/');
-      Enumeration<URL> resources = classLoader.getResources(path);
-      List<File> dirs = new ArrayList<File>();
-      while (resources.hasMoreElements())
-      {
-         URL resource = resources.nextElement();
-         dirs.add(new File(resource.getFile()));
-      }
-      ArrayList<Class> classes = new ArrayList<Class>();
-      for (File directory : dirs)
-      {
-         classes.addAll(findClasses(directory, packageName));
-      }
-      return classes.toArray(new Class[classes.size()]);
-   }
-
-   /**
-    * Recursive method used to find all classes in a given directory and subdirs.
-    *
-    * @param directory   The base directory
-    * @param packageName The package name for classes found inside the base directory
-    * @return The classes
-    * @throws ClassNotFoundException
-    */
-   private static List<Class> findClasses(File directory, String packageName) throws ClassNotFoundException
-   {
-      List<Class> classes = new ArrayList<Class>();
-      if (!directory.exists())
-      {
-         return classes;
-      }
-      File[] files = directory.listFiles();
-      for (File file : files)
-      {
-         if (file.isDirectory())
-         {
-            assert !file.getName().contains(".");
-            classes.addAll(findClasses(file, packageName + "." + file.getName()));
-         }
-         else if (file.getName().endsWith(".class"))
-         {
-            classes.add(Class.forName(packageName + '.' + file.getName().substring(0, file.getName().length() - 6)));
-         }
-      }
-      return classes;
-   }
-
-   public AbstractDeployerTest()
-   {
-      super();
-   }
-
-}
\ No newline at end of file

Modified: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/IronJacamarTestCase.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/IronJacamarTestCase.java	2010-12-23 16:52:16 UTC (rev 110182)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/IronJacamarTestCase.java	2010-12-23 17:14:32 UTC (rev 110183)
@@ -22,6 +22,8 @@
 
 package org.jboss.jca.test.deployers.spec;
 
+import org.jboss.jca.embedded.arquillian.ArquillianJCATestUtils;
+
 import javax.annotation.Resource;
 import javax.resource.cci.ConnectionFactory;
 
@@ -42,7 +44,7 @@
  * @version $Revision: $
  */
 @RunWith(Arquillian.class)
-public class IronJacamarTestCase extends AbstractDeployerTest
+public class IronJacamarTestCase
 {
    //-------------------------------------------------------------------------------------||
    //---------------------- GIVEN --------------------------------------------------------||
@@ -57,7 +59,7 @@
    {
       String archiveName = "ra15outironjacamar.rar";
       String packageName = "org.jboss.jca.test.deployers.spec.rars.ra15out";
-      ResourceAdapterArchive raa = buidShrinkwrapRa(archiveName, packageName);
+      ResourceAdapterArchive raa = ArquillianJCATestUtils.buidShrinkwrapRa(archiveName, packageName);
       raa.addManifestResource(archiveName + "/META-INF/ra.xml", "ra.xml");
       raa.addManifestResource(archiveName + "/META-INF/ironjacamar.xml", "ironjacamar.xml");
 

Modified: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/RaXmlTestCase.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/RaXmlTestCase.java	2010-12-23 16:52:16 UTC (rev 110182)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/RaXmlTestCase.java	2010-12-23 17:14:32 UTC (rev 110183)
@@ -22,144 +22,74 @@
 
 package org.jboss.jca.test.deployers.spec;
 
-import org.jboss.jca.deployers.fungal.RAActivator;
-import org.jboss.jca.embedded.Embedded;
-import org.jboss.jca.embedded.EmbeddedFactory;
+import org.jboss.jca.embedded.arquillian.ArquillianJCATestUtils;
 
-import java.io.File;
-import java.net.URL;
+import javax.annotation.Resource;
+import javax.resource.cci.ConnectionFactory;
 
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
 
-import org.jboss.logging.Logger;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
 import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.runner.RunWith;
 
+import static org.junit.Assert.assertNotNull;
+
 /**
  * Test cases for deploying resource adapter archives (.RAR) using -ra.xml files
  * for activation
- * 
+ *
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
  * @version $Revision: $
  */
+ at RunWith(Arquillian.class)
 public class RaXmlTestCase
 {
 
-   // --------------------------------------------------------------------------------||
-   // Class Members ------------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   private static Logger log = Logger.getLogger(RaXmlTestCase.class);
-
-   private static final String JNDI_PREFIX = "java:/eis/";
-
-   /*
-    * Embedded
-    */
-   private static Embedded embedded;
-
-   // --------------------------------------------------------------------------------||
-   // Tests --------------------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
+   //-------------------------------------------------------------------------------------||
+   //---------------------- GIVEN --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
    /**
-    * ra16out.rar
-    * @throws Throwable throwable exception 
+    * Define the deployment
+    * @return The deployment archive
+    * @throws Exception in case of errors
     */
-   @Test
-   public void testRa16out() throws Throwable
+   @Deployment
+   public static ResourceAdapterArchive createDeployment() throws Exception
    {
-      URL archive = getURL("ra16out.rar");
-      URL raXml = getURL("test" + File.separator + "ra16out-ra.xml");
-      Context context = null;
- 
-      try
-      {
-         embedded.deploy(archive);
-         embedded.deploy(raXml);
+      String archiveName = "ra16out.rar";
+      String packageName = "org.jboss.jca.test.deployers.spec.rars.ra16out";
+      ResourceAdapterArchive raa = ArquillianJCATestUtils.buidShrinkwrapRa(archiveName, packageName);
+      raa.addManifestResource(archiveName + "/META-INF/ra.xml", "ra.xml");
+      raa.addManifestResource("ra16out-ra.xml", "ra16out-ra.xml");
 
-         context = new InitialContext();
-         Object o = context.lookup(JNDI_PREFIX + "ra16out-raxml");
-         assertNotNull(o);
-      }
-      catch (Throwable t)
-      {
-         log.error(t.getMessage(), t);
-         fail(t.getMessage());
-      }
-      finally
-      {
-         if (context != null)
-         {
-            try
-            {
-               context.close();
-            }
-            catch (NamingException ne)
-            {
-               // Ignore
-            }
-         }
-
-         embedded.undeploy(raXml);
-         embedded.undeploy(archive);
-      }
+      ResourceAdapterArchive external = ShrinkWrap.create(ResourceAdapterArchive.class, "complex_" + archiveName);
+      external.add(raa, "/");
+      external.addResource("ra16out-ra.xml", "resource-adapters-ra.xml");
+      return external;
    }
 
-   // --------------------------------------------------------------------------------||
-   // Lifecycle Methods --------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+   //---------------------- WHEN  --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+   //
+   @Resource(mappedName = "java:/eis/ra16out-raxml")
+   private ConnectionFactory connectionFactory;
 
-   /**
-    * Lifecycle start, before the suite is executed
-    * @throws Throwable throwable exception 
-    */
-   @BeforeClass
-   public static void beforeClass() throws Throwable
-   {
-      // Create and set an embedded JCA instance
-      embedded = EmbeddedFactory.create();
+   //-------------------------------------------------------------------------------------||
+   //---------------------- THEN  --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
 
-      // Startup
-      embedded.startup();
-
-      // Disable RAActivator
-      RAActivator raa = embedded.lookup("RAActivator", RAActivator.class);
-      
-      if (raa == null)
-         throw new IllegalStateException("RAActivator not defined");
-
-      raa.setEnabled(false);
-   }
-
    /**
-    * Lifecycle stop, after the suite is executed
-    * @throws Throwable throwable exception 
+    * Basic
+    * @exception Throwable Thrown if case of an error
     */
-   @AfterClass
-   public static void afterClass() throws Throwable
+   @Test
+   public void testBasic() throws Throwable
    {
-      // Shutdown embedded
-      embedded.shutdown();
-
-      // Set embedded to null
-      embedded = null;
+      assertNotNull(connectionFactory);
    }
 
-   /**
-    * Get the URL for a test archive
-    * @param archive The name of the test archive
-    * @return The URL to the archive
-    * @throws Throwable throwable exception
-    */
-   public URL getURL(String archive) throws Throwable
-   {
-      File f = new File(System.getProperty("archives.dir") + File.separator + archive);
-      return f.toURI().toURL();
-   }
 }

Modified: projects/jboss-jca/trunk/embedded/.classpath
===================================================================
--- projects/jboss-jca/trunk/embedded/.classpath	2010-12-23 16:52:16 UTC (rev 110182)
+++ projects/jboss-jca/trunk/embedded/.classpath	2010-12-23 17:14:32 UTC (rev 110183)
@@ -24,5 +24,7 @@
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/jboss-integration.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/jboss-stdio.jar"/>
 	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/hibernate-validator.jar"/>
+	<classpathentry kind="lib" path="/ironjacamar-parent/lib/embedded/shrinkwrap-impl-base.jar"/>
+	<classpathentry kind="lib" path="/ironjacamar-parent/lib/common/validation-api.jar"/>
 	<classpathentry kind="output" path="eclipse-target/classes"/>
 </classpath>

Copied: projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/ArquillianJCATestUtils.java (from rev 110063, projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/AbstractDeployerTest.java)
===================================================================
--- projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/ArquillianJCATestUtils.java	                        (rev 0)
+++ projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/ArquillianJCATestUtils.java	2010-12-23 17:14:32 UTC (rev 110183)
@@ -0,0 +1,181 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.embedded.arquillian;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.UUID;
+
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
+
+/**
+ *
+ * A ArquillianJCATestUtils.
+ *
+ * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
+ *
+ */
+public final class ArquillianJCATestUtils
+{
+
+   /**
+    * Build a shrinkwrap rar adding all necessary classes
+    *
+    * @param archiveName the archhive name
+    * @param packageName the package name
+    * @return the shrinkwrapped rar
+    * @throws Exception in case of error creating the archive
+    */
+   public static ResourceAdapterArchive buidShrinkwrapRa(String archiveName, String packageName) throws Exception
+   {
+      ResourceAdapterArchive raa = ShrinkWrap.create(ResourceAdapterArchive.class, archiveName);
+
+      JavaArchive ja = ShrinkWrap.create(JavaArchive.class, UUID.randomUUID().toString() + ".jar");
+      ja.addClasses(getClasses(packageName));
+
+      raa.addLibrary(ja);
+
+
+      return raa;
+   }
+
+   /**
+    * Build a shrinkwrap rar for jdbc local
+    *
+    * @param archiveName the archhive name
+    * @return the shrinkwrapped rar
+    * @throws Exception in case of error creating the archive
+    */
+   public static ResourceAdapterArchive buildShrinkwrapJdbcLocal(String archiveName)
+      throws Exception
+   {
+      ResourceAdapterArchive raa = ShrinkWrap.create(ResourceAdapterArchive.class, archiveName);
+      JavaArchive ja = buildShrinkwrapJdbcJar();
+      raa.addLibrary(ja);
+
+      raa.addManifestResource("jdbc/local/META-INF/ra.xml", "ra.xml");
+
+      return raa;
+   }
+
+   /**
+    * Build a shrinkwrap rar for jdbc xa
+    *
+    * @param archiveName the archhive name
+    * @return the shrinkwrapped rar
+    * @throws Exception in case of error creating the archive
+    */
+   public static ResourceAdapterArchive buildShrinkwrapJdbcXa(String archiveName) throws Exception
+   {
+      ResourceAdapterArchive raa = ShrinkWrap.create(ResourceAdapterArchive.class, archiveName);
+      JavaArchive ja = buildShrinkwrapJdbcJar();
+      raa.addLibrary(ja);
+
+      raa.addManifestResource("jdbc/xa/META-INF/ra.xml", "ra.xml");
+
+      return raa;
+   }
+
+   /**
+    * FIXME Comment this
+    *
+    * @return
+    * @throws ClassNotFoundException
+    * @throws IOException
+    */
+   private static JavaArchive buildShrinkwrapJdbcJar() throws ClassNotFoundException, IOException
+   {
+      String packageName = "org.jboss.jca.adapters";
+
+      JavaArchive ja = ShrinkWrap.create(JavaArchive.class, "ironjacamar-jdbc.jar");
+      ja.addClasses(getClasses(packageName));
+      ja.setManifest("jdbc/jar/META-INF/MANIFEST.MF");
+      return ja;
+   }
+
+
+   /**
+    * Scans all classes accessible from the context class loader which belong to the given package and subpackages.
+    *
+    * @param packageName The base package
+    * @return The classes
+    * @throws ClassNotFoundException
+    * @throws IOException
+    */
+   private static Class[] getClasses(String packageName) throws ClassNotFoundException, IOException
+   {
+      ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+      String path = packageName.replace('.', '/');
+      Enumeration<URL> resources = classLoader.getResources(path);
+      List<File> dirs = new ArrayList<File>();
+      while (resources.hasMoreElements())
+      {
+         URL resource = resources.nextElement();
+         dirs.add(new File(resource.getFile()));
+      }
+      ArrayList<Class> classes = new ArrayList<Class>();
+      for (File directory : dirs)
+      {
+         classes.addAll(findClasses(directory, packageName));
+      }
+      return classes.toArray(new Class[classes.size()]);
+   }
+
+   /**
+    * Recursive method used to find all classes in a given directory and subdirs.
+    *
+    * @param directory   The base directory
+    * @param packageName The package name for classes found inside the base directory
+    * @return The classes
+    * @throws ClassNotFoundException
+    */
+   private static List<Class> findClasses(File directory, String packageName) throws ClassNotFoundException
+   {
+      List<Class> classes = new ArrayList<Class>();
+      if (!directory.exists())
+      {
+         return classes;
+      }
+      File[] files = directory.listFiles();
+      for (File file : files)
+      {
+         if (file.isDirectory())
+         {
+            assert !file.getName().contains(".");
+            classes.addAll(findClasses(file, packageName + "." + file.getName()));
+         }
+         else if (file.getName().endsWith(".class"))
+         {
+            classes.add(Class.forName(packageName + '.' + file.getName().substring(0, file.getName().length() - 6)));
+         }
+      }
+      return classes;
+   }
+
+
+}

Modified: projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCAContainer.java
===================================================================
--- projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCAContainer.java	2010-12-23 16:52:16 UTC (rev 110182)
+++ projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCAContainer.java	2010-12-23 17:14:32 UTC (rev 110183)
@@ -24,6 +24,15 @@
 import org.jboss.jca.embedded.Embedded;
 import org.jboss.jca.embedded.EmbeddedFactory;
 
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
 import org.jboss.arquillian.protocol.local.LocalMethodExecutor;
 import org.jboss.arquillian.spi.Configuration;
 import org.jboss.arquillian.spi.ContainerMethodExecutor;
@@ -32,11 +41,12 @@
 import org.jboss.arquillian.spi.DeploymentException;
 import org.jboss.arquillian.spi.LifecycleException;
 import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.asset.Asset;
 import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
 
 /**
  * Arquillian {@link DeployableContainer} adaptor for EmbeddedJCA
- * 
+ *
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
  * @version $Revision: $
  */
@@ -68,14 +78,48 @@
 
       try
       {
-         embedded.deploy(ResourceAdapterArchive.class.cast(archive));
+         ResourceAdapterArchive raa = ResourceAdapterArchive.class.cast(archive);
+         if (raa.getName() != null && raa.getName().startsWith("complex_"))
+         {
+            if (raa.get(raa.getName().substring(8)) != null)
+            {
+               Asset asset = raa.get(raa.getName().substring(8)).getAsset();
+               String name = raa.getName().substring(raa.getName().indexOf("complex_"));
+               deployinternalAsset(asset, name);
+
+            }
+            if (raa.get("resource-adapters-ra.xml") != null)
+            {
+
+               Asset asset = raa.get("resource-adapters-ra.xml").getAsset();
+               String name = "resource-adapters-ra.xml";
+               deployinternalAsset(asset, name);
+            }
+            if (raa.get("datasources-ds.xml") != null)
+            {
+
+               Asset asset = raa.get("datasources-ds.xml").getAsset();
+               String name = "datasources-ds.xml";
+               deployinternalAsset(asset, name);
+            }
+            if (raa.get("datasources-xa-ds.xml") != null)
+            {
+
+               Asset asset = raa.get("datasources-xa-ds.xml").getAsset();
+               String name = "datasources-xa-ds.xml";
+               deployinternalAsset(asset, name);
+            }
+
+         }
+         else
+         {
+            embedded.deploy(ResourceAdapterArchive.class.cast(archive));
+         }
+
       }
-      catch (Exception e)
-      {
-         throw new DeploymentException("Could not deploy the application", e);
-      }
       catch (Throwable t)
       {
+         t.printStackTrace();
          throw new DeploymentException("Could not deploy the application: " + t.getMessage());
       }
 
@@ -84,6 +128,71 @@
    }
 
    /**
+    * deploy an internal asset
+    *
+    * @param asset asset
+    * @param name asset
+    * @throws FileNotFoundException IOException
+    * @throws IOException IOException
+    * @throws MalformedURLException MalformedURLException
+    * @throws Throwable Throwable
+    *
+    */
+   protected void deployinternalAsset(Asset asset, String name) throws IOException, FileNotFoundException, Throwable,
+      MalformedURLException
+   {
+      File parentDirectory = new File(SecurityActions.getSystemProperty("java.io.tmpdir"));
+      File raaFile = new File(parentDirectory, name);
+
+      if (raaFile.exists())
+         recursiveDelete(raaFile);
+      InputStream is = null;
+      FileOutputStream os = null;
+
+      byte[] buffer = new byte[4096];
+      int read = 0;
+      try
+      {
+         is = asset.openStream();
+         os = new FileOutputStream(raaFile);
+         while ((read = is.read(buffer)) != -1)
+         {
+            os.write(buffer, 0, read);
+         }
+
+         os.flush();
+      }
+      finally
+      {
+         if (os != null)
+         {
+            try
+            {
+               os.close();
+            }
+            catch (IOException ignore)
+            {
+               // Ignore
+            }
+         }
+
+         if (is != null)
+         {
+            try
+            {
+               is.close();
+            }
+            catch (IOException ignore)
+            {
+               // Ignore
+            }
+         }
+      }
+      embedded.deploy(raaFile.toURI().toURL());
+
+   }
+
+   /**
     * {@inheritDoc}
     * @see org.jboss.arquillian.spi.DeployableContainer#undeploy
     */
@@ -102,11 +211,11 @@
       }
       catch (Exception e)
       {
-         throw new DeploymentException("Could not undeploy the application", e);
+         //throw new DeploymentException("Could not undeploy the application", e);
       }
       catch (Throwable t)
       {
-         throw new DeploymentException("Could not undeploy the application: " + t.getMessage());
+         //throw new DeploymentException("Could not undeploy the application: " + t.getMessage());
       }
    }
 
@@ -163,4 +272,85 @@
       }
       embedded = null;
    }
+
+   /**
+    * Recursive delete
+    * @param f The file handler
+    * @exception IOException Thrown if a file could not be deleted
+    */
+   private void recursiveDelete(File f) throws IOException
+   {
+      if (f != null && f.exists())
+      {
+         File[] files = f.listFiles();
+         if (files != null)
+         {
+            for (int i = 0; i < files.length; i++)
+            {
+               if (files[i].isDirectory())
+               {
+                  recursiveDelete(files[i]);
+               }
+               else
+               {
+                  if (!files[i].delete())
+                     throw new IOException("Could not delete " + files[i]);
+               }
+            }
+         }
+         if (!f.delete())
+            throw new IOException("Could not delete " + f);
+      }
+   }
+
+   /**
+    *
+    * A SecurityActions.
+    *
+    * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
+    *
+    */
+   public static class SecurityActions
+   {
+      /**
+       * Constructor
+       */
+      private SecurityActions()
+      {
+      }
+
+      /**
+       * Get a system property
+       * @param name The property name
+       * @return The property value
+       */
+      @SuppressWarnings("unchecked")
+      static String getSystemProperty(final String name)
+      {
+         return (String) AccessController.doPrivileged(new PrivilegedAction()
+         {
+            public Object run()
+            {
+               return System.getProperty(name);
+            }
+         });
+      }
+
+      /**
+       * Set a system property
+       * @param name The property name
+       * @param value The property value
+       */
+      static void setSystemProperty(final String name, final String value)
+      {
+         AccessController.doPrivileged(new PrivilegedAction<Object>()
+         {
+            public Object run()
+            {
+               System.setProperty(name, value);
+               return null;
+            }
+         });
+      }
+   }
 }

Modified: projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCATestEnricher.java
===================================================================
--- projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCATestEnricher.java	2010-12-23 16:52:16 UTC (rev 110182)
+++ projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCATestEnricher.java	2010-12-23 17:14:32 UTC (rev 110183)
@@ -28,8 +28,8 @@
 import org.jboss.arquillian.testenricher.resource.ResourceInjectionEnricher;
 
 /**
- * {@link TestEnricher} implementation specific to the EmbeddedJCA container
- * 
+ * TestEnricher implementation specific to the EmbeddedJCA container
+ *
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
  */
 public class EmbeddedJCATestEnricher extends ResourceInjectionEnricher
@@ -41,14 +41,15 @@
    {
    }
 
-   /** 
+   /**
     * Lookup an object in JNDI
     * @param jndiName The JNDI name
     * @return The object
     * @see org.jboss.arquillian.testenricher.resource.ResourceInjectionEnricher#lookup(java.lang.String)
     * @exception Exception Thrown if the lookup can't be performed
     */
-   protected Object lookup(String jndiName) throws Exception 
+   @Override
+   protected Object lookup(String jndiName) throws Exception
    {
       return createContext().lookup(jndiName);
    }



More information about the jboss-cvs-commits mailing list