[jboss-cvs] JBossAS SVN: r93547 - in projects/jboss-jca/trunk: deployers/src/test/java/org/jboss/jca/test/deployers/spec and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Sep 15 12:33:58 EDT 2009


Author: jesper.pedersen
Date: 2009-09-15 12:33:58 -0400 (Tue, 15 Sep 2009)
New Revision: 93547

Added:
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/RarTestCase.java
Modified:
   projects/jboss-jca/trunk/deployers/build.xml
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/FileUtil.java
Log:
[JBJCA-173] Add test cases for .rar deployments

Modified: projects/jboss-jca/trunk/deployers/build.xml
===================================================================
--- projects/jboss-jca/trunk/deployers/build.xml	2009-09-15 16:32:09 UTC (rev 93546)
+++ projects/jboss-jca/trunk/deployers/build.xml	2009-09-15 16:33:58 UTC (rev 93547)
@@ -270,7 +270,7 @@
    	<filelist dir="${build.deployers.dir}" files="ra16inoutjar.jar"/> 
       <fileset dir="src/test/resources/ra16inoutjar.rar"/>
    </jar>
-  	<delete file="${build.deployers.dir}/ra16inoutjar.jar"/>
+   <delete file="${build.deployers.dir}/ra16inoutjar.jar"/>
   	
   </target>
 
@@ -309,6 +309,7 @@
       
       <jvmarg line="${junit.jvm.options}"/>
       <sysproperty key="test.dir" value="${test.dir}"/>
+      <sysproperty key="archives.dir" value="${build.deployers.dir}"/>
       
       <classpath>
         <pathelement location="${build.deployers.dir}/test"/>

Added: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/RarTestCase.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/RarTestCase.java	                        (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/RarTestCase.java	2009-09-15 16:33:58 UTC (rev 93547)
@@ -0,0 +1,588 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, 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.embedded.EmbeddedJCA;
+
+import java.io.File;
+import java.net.URL;
+
+import org.jboss.logging.Logger;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ * Test cases for deploying resource adapter archives (.RAR)
+ * 
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ * @version $Revision: $
+ */
+public class RarTestCase
+{
+
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private static final Logger LOG = Logger.getLogger(RarTestCase.class);
+
+   /*
+    * Embedded
+    */
+   private static EmbeddedJCA embedded;
+
+   // --------------------------------------------------------------------------------||
+   // Tests --------------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * ra15dtdinout.rar
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testRa15dtdinout() throws Throwable
+   {
+     URL archive = getURL("ra15dtdinout.rar");
+ 
+     try
+     {
+        embedded.deploy(archive);
+     }
+     catch (Throwable t)
+     {
+        fail(t.getMessage());
+     }
+     finally
+     {
+        embedded.undeploy(archive);
+     }
+   }
+
+   /**
+    * ra15inoutjbossra.rar
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testRa15inoutjbossra() throws Throwable
+   {
+     URL archive = getURL("ra15inoutjbossra.rar");
+ 
+     try
+     {
+        embedded.deploy(archive);
+     }
+     catch (Throwable t)
+     {
+        fail(t.getMessage());
+     }
+     finally
+     {
+        embedded.undeploy(archive);
+     }
+   }
+
+   /**
+    * ra15inout.rar
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testRa15inout() throws Throwable
+   {
+     URL archive = getURL("ra15inout.rar");
+ 
+     try
+     {
+        embedded.deploy(archive);
+     }
+     catch (Throwable t)
+     {
+        fail(t.getMessage());
+     }
+     finally
+     {
+        embedded.undeploy(archive);
+     }
+   }
+
+   /**
+    * ra15outjbossradefaultns.rar
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testRa15outjbossradefaultns() throws Throwable
+   {
+     URL archive = getURL("ra15outjbossradefaultns.rar");
+ 
+     try
+     {
+        embedded.deploy(archive);
+     }
+     catch (Throwable t)
+     {
+        fail(t.getMessage());
+     }
+     finally
+     {
+        embedded.undeploy(archive);
+     }
+   }
+
+   /**
+    * ra15outjbossra.rar
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testRa15outjbossra() throws Throwable
+   {
+     URL archive = getURL("ra15outjbossra.rar");
+ 
+     try
+     {
+        embedded.deploy(archive);
+     }
+     catch (Throwable t)
+     {
+        fail(t.getMessage());
+     }
+     finally
+     {
+        embedded.undeploy(archive);
+     }
+   }
+
+   /**
+    * ra15out.rar
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testRa15out() throws Throwable
+   {
+     URL archive = getURL("ra15out.rar");
+ 
+     try
+     {
+        embedded.deploy(archive);
+     }
+     catch (Throwable t)
+     {
+        fail(t.getMessage());
+     }
+     finally
+     {
+        embedded.undeploy(archive);
+     }
+   }
+
+   /**
+    * ra16dtdinout.rar
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testRa16dtdinout() throws Throwable
+   {
+     URL archive = getURL("ra16dtdinout.rar");
+ 
+     try
+     {
+        embedded.deploy(archive);
+     }
+     catch (Throwable t)
+     {
+        fail(t.getMessage());
+     }
+     finally
+     {
+        embedded.undeploy(archive);
+     }
+   }
+
+   /**
+    * ra16inoutanno.rar
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testRa16inoutanno() throws Throwable
+   {
+     URL archive = getURL("ra16inoutanno.rar");
+ 
+     try
+     {
+        embedded.deploy(archive);
+     }
+     catch (Throwable t)
+     {
+        fail(t.getMessage());
+     }
+     finally
+     {
+        embedded.undeploy(archive);
+     }
+   }
+
+   /**
+    * ra16inoutjar.rar
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testRa16inoutjar() throws Throwable
+   {
+     URL archive = getURL("ra16inoutjar.rar");
+ 
+     try
+     {
+        embedded.deploy(archive);
+     }
+     catch (Throwable t)
+     {
+        fail(t.getMessage());
+     }
+     finally
+     {
+        embedded.undeploy(archive);
+     }
+   }
+
+   /**
+    * ra16inoutjbossra.rar
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testRa16inoutjbossra() throws Throwable
+   {
+     URL archive = getURL("ra16inoutjbossra.rar");
+ 
+     try
+     {
+        embedded.deploy(archive);
+     }
+     catch (Throwable t)
+     {
+        fail(t.getMessage());
+     }
+     finally
+     {
+        embedded.undeploy(archive);
+     }
+   }
+
+   /**
+    * ra16inoutnora.rar
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testRa16inoutnora() throws Throwable
+   {
+     URL archive = getURL("ra16inoutnora.rar");
+ 
+     try
+     {
+        embedded.deploy(archive);
+     }
+     catch (Throwable t)
+     {
+        fail(t.getMessage());
+     }
+     finally
+     {
+        embedded.undeploy(archive);
+     }
+   }
+
+   /**
+    * ra16inoutoverwrite.rar
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testRa16inoutoverwrite() throws Throwable
+   {
+     URL archive = getURL("ra16inoutoverwrite.rar");
+ 
+     try
+     {
+        embedded.deploy(archive);
+     }
+     catch (Throwable t)
+     {
+        fail(t.getMessage());
+     }
+     finally
+     {
+        embedded.undeploy(archive);
+     }
+   }
+
+   /**
+    * ra16inout.rar
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testRa16inout() throws Throwable
+   {
+     URL archive = getURL("ra16inout.rar");
+ 
+     try
+     {
+        embedded.deploy(archive);
+     }
+     catch (Throwable t)
+     {
+        fail(t.getMessage());
+     }
+     finally
+     {
+        embedded.undeploy(archive);
+     }
+   }
+
+   /**
+    * ra16outjbossradefaultns.rar
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testRa16outjbossradefaultns() throws Throwable
+   {
+     URL archive = getURL("ra16outjbossradefaultns.rar");
+ 
+     try
+     {
+        embedded.deploy(archive);
+     }
+     catch (Throwable t)
+     {
+        fail(t.getMessage());
+     }
+     finally
+     {
+        embedded.undeploy(archive);
+     }
+   }
+
+   /**
+    * ra16outjbossra.rar
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testRa16outjbossra() throws Throwable
+   {
+     URL archive = getURL("ra16outjbossra.rar");
+ 
+     try
+     {
+        embedded.deploy(archive);
+     }
+     catch (Throwable t)
+     {
+        fail(t.getMessage());
+     }
+     finally
+     {
+        embedded.undeploy(archive);
+     }
+   }
+
+   /**
+    * ra16outnora.rar
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testRa16outnora() throws Throwable
+   {
+      URL archive = getURL("ra16outnora.rar");
+ 
+      try
+      {
+         embedded.deploy(archive);
+      }
+      catch (Throwable t)
+      {
+         fail(t.getMessage());
+      }
+      finally
+      {
+         embedded.undeploy(archive);
+      }
+   }
+
+   /**
+    * ra16out.rar
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testRa16out() throws Throwable
+   {
+      URL archive = getURL("ra16out.rar");
+ 
+      try
+      {
+         embedded.deploy(archive);
+      }
+      catch (Throwable t)
+      {
+         fail(t.getMessage());
+      }
+      finally
+      {
+         embedded.undeploy(archive);
+      }
+   }
+
+   /**
+    * ra16standard303jbossra.rar
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testRa16standard303jbossra() throws Throwable
+   {
+      URL archive = getURL("ra16standard303jbossra.rar");
+ 
+      try
+      {
+         embedded.deploy(archive);
+      }
+      catch (Throwable t)
+      {
+         fail(t.getMessage());
+      }
+      finally
+      {
+         embedded.undeploy(archive);
+      }
+   }
+
+   /**
+    * ra16standard303.rar
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testRa16standard303() throws Throwable
+   {
+      URL archive = getURL("ra16standard303.rar");
+ 
+      try
+      {
+         embedded.deploy(archive);
+      }
+      catch (Throwable t)
+      {
+         fail(t.getMessage());
+      }
+      finally
+      {
+         embedded.undeploy(archive);
+      }
+   }
+
+   /**
+    * ra16user303jbossra.rar
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testRa16user303jbossra() throws Throwable
+   {
+      URL archive = getURL("ra16user303jbossra.rar");
+ 
+      try
+      {
+         embedded.deploy(archive);
+         fail("Deployment success");
+      }
+      catch (Throwable t)
+      {
+         // Ok
+      }
+      finally
+      {
+         embedded.undeploy(archive);
+      }
+   }
+
+   /**
+    * ra16user303.rar
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testRa16user303() throws Throwable
+   {
+      URL archive = getURL("ra16user303.rar");
+ 
+      try
+      {
+         embedded.deploy(archive);
+      }
+      catch (Throwable t)
+      {
+         fail(t.getMessage());
+      }
+      finally
+      {
+         embedded.undeploy(archive);
+      }
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Lifecycle Methods --------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * 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 = new EmbeddedJCA();
+
+      // Startup
+      embedded.startup();
+   }
+
+   /**
+    * Lifecycle stop, after the suite is executed
+    * @throws Throwable throwable exception 
+    */
+   @AfterClass
+   public static void afterClass() throws Throwable
+   {
+      // Shutdown embedded
+      embedded.shutdown();
+
+      // Set embedded to null
+      embedded = null;
+   }
+
+   /**
+    * 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/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java	2009-09-15 16:32:09 UTC (rev 93546)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java	2009-09-15 16:33:58 UTC (rev 93547)
@@ -82,6 +82,9 @@
    /** MBeanServer */
    private MBeanServer mbeanServer;
 
+   /** Temporary environment */
+   private boolean temporaryEnvironment;
+
    /** Logging */
    private Object logging;
 
@@ -92,6 +95,7 @@
    public KernelImpl(KernelConfiguration kc)
    {
       this.kernelConfiguration = kc;
+      this.temporaryEnvironment = false;
    }
 
    /**
@@ -125,7 +129,28 @@
          }
          else
          {
-            // TODO
+            File tmp = new File(SecurityActions.getSystemProperty("java.io.tmpdir"));
+            root = new File(tmp, "jboss-jca");
+
+            if (root.exists())
+            {
+               try
+               {
+                  recursiveDelete(root);
+               }
+               catch (Throwable t)
+               {
+                  // TODO
+                  error(t.getMessage(), t);
+               }
+            }
+
+            if (!root.mkdirs())
+               throw new IOException("Could not create directory " + root.getAbsolutePath());
+
+            SecurityActions.setSystemProperty("jboss.jca.home", root.getAbsolutePath());
+
+            temporaryEnvironment = true;
          }
 
          File libDirectory = null;
@@ -301,6 +326,22 @@
 
       info("Shutdown complete");
 
+      if (temporaryEnvironment)
+      {
+         File tmp = new File(SecurityActions.getSystemProperty("java.io.tmpdir"));
+         File root = new File(tmp, "jboss-jca");
+
+         try
+         {
+            recursiveDelete(root);
+         }
+         catch (Throwable t)
+         {
+            // TODO
+            error(t.getMessage(), t);
+         }
+      }
+
       if (kernelClassLoader != null && kernelClassLoader instanceof Closeable)
       {
          try
@@ -455,6 +496,36 @@
    }
 
    /**
+    * 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);
+      }
+   }
+
+   /**
     * Init logging
     * @param cl The classloader to load from
     */

Modified: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/FileUtil.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/FileUtil.java	2009-09-15 16:32:09 UTC (rev 93546)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/FileUtil.java	2009-09-15 16:33:58 UTC (rev 93547)
@@ -199,7 +199,7 @@
     */
    public static void recursiveDelete(File f) throws IOException
    {
-      if (f.exists())
+      if (f != null && f.exists())
       {
          File[] files = f.listFiles();
          if (files != null)




More information about the jboss-cvs-commits mailing list