[jboss-cvs] JBossAS SVN: r108581 - in projects/jboss-jca/trunk: core/src/main/java/org/jboss/jca/core/mdr and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Oct 14 09:41:36 EDT 2010


Author: jesper.pedersen
Date: 2010-10-14 09:41:35 -0400 (Thu, 14 Oct 2010)
New Revision: 108581

Added:
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/mdr/
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/mdr/MetadataRepositoryTestCase.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/mdr/package.html
Modified:
   projects/jboss-jca/trunk/build.xml
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/mdr/SimpleMetadataRepository.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/mdr/MetadataRepository.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalRADeployer.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivator.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivatorDeployment.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployment.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployer.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployment.java
Log:
[JBJCA-442] Enhance MDR

Modified: projects/jboss-jca/trunk/build.xml
===================================================================
--- projects/jboss-jca/trunk/build.xml	2010-10-14 13:14:12 UTC (rev 108580)
+++ projects/jboss-jca/trunk/build.xml	2010-10-14 13:41:35 UTC (rev 108581)
@@ -796,12 +796,54 @@
       </batchtest>
     </junit>
 
+    <junit dir="adapters/src/test"
+           printsummary="${junit.printsummary}"
+           haltonerror="${junit.haltonerror}"
+           haltonfailure="${junit.haltonfailure}"
+           fork="yes"
+           timeout="${junit.timeout}">
+      
+      <jvmarg line="${junit.jvm.options}"/>
+      <sysproperty key="test.dir" value="${test.dir}"/>
+      <sysproperty key="archives.dir" value="${build.dir}/adapters"/>
+      <sysproperty key="net.sourceforge.cobertura.datafile" file="${reports.dir}/cobertura/cobertura.ser" />
+      <sysproperty key="xb.builder.useUnorderedSequence" value="true"/>
+      <sysproperty key="javax.xml.stream.XMLInputFactory" value="com.sun.xml.internal.stream.XMLInputFactoryImpl"/>
+      <sysproperty key="java.util.logging.manager" value="org.jboss.logmanager.LogManager"/>
+      <sysproperty key="org.jboss.logging.Logger.pluginClass" value="org.jboss.logging.logmanager.LoggerPluginImpl"/>
+      <sysproperty key="log4j.defaultInitOverride" value="true"/>
+
+      <classpath>
+        <fileset dir="${build.dir}/instrumented" includes="*.jar" />
+        <pathelement location="${build.dir}/adapters/test"/>
+        <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}/jetty" includes="*.jar" />
+        <fileset dir="${lib.dir}/sjc" includes="*.jar" />
+        <fileset dir="${lib.dir}/test" includes="*.jar" />
+        <fileset dir="${lib.dir}/tools" includes="*.jar" />
+      </classpath>
+      <classpath refid="cobertura.lib.path.id" />
+      
+      <formatter type="xml"/>
+      
+      <batchtest todir="${reports.dir}/cobertura/tests">
+        <fileset dir="${build.dir}/adapters/test">
+          <include name="**/*TestCase.class"/>
+        </fileset>
+      </batchtest>
+    </junit>
+
     <cobertura-report format="html" 
                       destdir="${reports.dir}/cobertura/html" 
                       datafile="${reports.dir}/cobertura/cobertura.ser">
       <fileset dir="api/src/main/java">
         <include name="**/*.java" />
       </fileset>
+      <fileset dir="adapters/src/main/java">
+        <include name="**/*.java" />
+      </fileset>
       <fileset dir="codegenerator/src/main/java">
         <include name="**/*.java" />
       </fileset>
@@ -834,6 +876,9 @@
       <fileset dir="api/src/main/java">
         <include name="**/*.java" />
       </fileset>
+      <fileset dir="adapters/src/main/java">
+        <include name="**/*.java" />
+      </fileset>
       <fileset dir="codegenerator/src/main/java">
         <include name="**/*.java" />
       </fileset>

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/mdr/SimpleMetadataRepository.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/mdr/SimpleMetadataRepository.java	2010-10-14 13:14:12 UTC (rev 108580)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/mdr/SimpleMetadataRepository.java	2010-10-14 13:41:35 UTC (rev 108581)
@@ -29,7 +29,6 @@
 import org.jboss.jca.core.spi.mdr.NotFoundException;
 
 import java.io.File;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -47,77 +46,105 @@
 public class SimpleMetadataRepository implements MetadataRepository
 {
    /** Resource adapter templates */
-   private ConcurrentMap<URL, Connector> raTemplates;
+   private ConcurrentMap<String, Connector> raTemplates;
 
    /** Resource adapter roots */
-   private ConcurrentMap<URL, File> raRoots;
+   private ConcurrentMap<String, File> raRoots;
 
    /** IronJacamar metadata */
-   private Map<URL, IronJacamar> ironJacamar;
+   private Map<String, IronJacamar> ironJacamar;
 
    /** JNDI mappings */
-   private ConcurrentMap<URL, Map<String, List<String>>> jndiMappings;
+   private ConcurrentMap<String, Map<String, List<String>>> jndiMappings;
 
    /**
     * Constructor
     */
    public SimpleMetadataRepository()
    {
-      this.raTemplates = new ConcurrentHashMap<URL, Connector>();
-      this.raRoots = new ConcurrentHashMap<URL, File>();
-      this.ironJacamar = new HashMap<URL, IronJacamar>();
-      this.jndiMappings = new ConcurrentHashMap<URL, Map<String, List<String>>>();
+      this.raTemplates = new ConcurrentHashMap<String, Connector>();
+      this.raRoots = new ConcurrentHashMap<String, File>();
+      this.ironJacamar = new HashMap<String, IronJacamar>();
+      this.jndiMappings = new ConcurrentHashMap<String, Map<String, List<String>>>();
    }
 
    /**
     * {@inheritDoc}
     */
-   public void registerResourceAdapter(URL deployment, File root, Connector md, IronJacamar ijmd)
+   public void registerResourceAdapter(String uniqueId, File root, Connector md, IronJacamar ijmd)
       throws AlreadyExistsException
    {
-      if (deployment == null)
-         throw new IllegalArgumentException("Deployment is null");
+      if (uniqueId == null)
+         throw new IllegalArgumentException("UniqueId is null");
 
+      if (uniqueId.trim().equals(""))
+         throw new IllegalArgumentException("UniqueId is empty");
+
+      if (root == null)
+         throw new IllegalArgumentException("Root is null");
+
       if (md == null)
-         throw new IllegalArgumentException("Metadata is null");
+         throw new IllegalArgumentException("Connector is null");
 
-      if (raTemplates.containsKey(deployment))
-         throw new AlreadyExistsException(deployment + " already registered");
+      // The IronJacamar metadata object can be null
 
-      raTemplates.put(deployment, md);
-      raRoots.put(deployment, root);
-      ironJacamar.put(deployment, ijmd);
+      if (raTemplates.containsKey(uniqueId))
+         throw new AlreadyExistsException(uniqueId + " already registered");
+
+      raTemplates.put(uniqueId, md);
+      raRoots.put(uniqueId, root);
+      ironJacamar.put(uniqueId, ijmd);
    }
 
    /**
     * {@inheritDoc}
     */
-   public void unregisterResourceAdapter(URL deployment) throws NotFoundException
+   public void unregisterResourceAdapter(String uniqueId) throws NotFoundException
    {
-      if (deployment == null)
-         throw new IllegalArgumentException("Deployment is null");
+      if (uniqueId == null)
+         throw new IllegalArgumentException("UniqueId is null");
 
-      if (!raTemplates.containsKey(deployment))
-         throw new NotFoundException(deployment + " isn't registered");
+      if (uniqueId.trim().equals(""))
+         throw new IllegalArgumentException("UniqueId is empty");
 
-      raTemplates.remove(deployment);
-      raRoots.remove(deployment);
-      ironJacamar.remove(deployment);
+      if (!raTemplates.containsKey(uniqueId))
+         throw new NotFoundException(uniqueId + " isn't registered");
+
+      raTemplates.remove(uniqueId);
+      raRoots.remove(uniqueId);
+      ironJacamar.remove(uniqueId);
    }
 
    /**
     * {@inheritDoc}
     */
-   public Connector getResourceAdapter(URL deployment) throws NotFoundException
+   public boolean hasResourceAdapter(String uniqueId)
    {
-      if (deployment == null)
-         throw new IllegalArgumentException("Deployment is null");
+      if (uniqueId == null)
+         throw new IllegalArgumentException("UniqueId is null");
+      
+      if (uniqueId.trim().equals(""))
+         throw new IllegalArgumentException("UniqueId is empty");
 
-      if (!raTemplates.containsKey(deployment))
-         throw new NotFoundException(deployment + " isn't registered");
+      return raTemplates.containsKey(uniqueId);
+   }
 
-      Connector md = raTemplates.get(deployment);
+   /**
+    * {@inheritDoc}
+    */
+   public Connector getResourceAdapter(String uniqueId) throws NotFoundException
+   {
+      if (uniqueId == null)
+         throw new IllegalArgumentException("UniqueId is null");
 
+      if (uniqueId.trim().equals(""))
+         throw new IllegalArgumentException("UniqueId is empty");
+
+      if (!raTemplates.containsKey(uniqueId))
+         throw new NotFoundException(uniqueId + " isn't registered");
+
+      Connector md = raTemplates.get(uniqueId);
+
       // Always return a copy as the caller may make changes to it
       return (Connector)md.copy();
    }
@@ -125,7 +152,7 @@
    /**
     * {@inheritDoc}
     */
-   public Set<URL> getResourceAdapters()
+   public Set<String> getResourceAdapters()
    {
       return Collections.unmodifiableSet(raTemplates.keySet());
    }
@@ -133,50 +160,65 @@
    /**
     * {@inheritDoc}
     */
-   public File getRoot(URL deployment) throws NotFoundException
+   public File getRoot(String uniqueId) throws NotFoundException
    {
-      if (deployment == null)
-         throw new IllegalArgumentException("Deployment is null");
+      if (uniqueId == null)
+         throw new IllegalArgumentException("UniqueId is null");
 
-      if (!raRoots.containsKey(deployment))
-         throw new NotFoundException(deployment + " isn't registered");
+      if (uniqueId.trim().equals(""))
+         throw new IllegalArgumentException("UniqueId is empty");
 
-      return raRoots.get(deployment);
+      if (!raRoots.containsKey(uniqueId))
+         throw new NotFoundException(uniqueId + " isn't registered");
+
+      return raRoots.get(uniqueId);
    }
 
    /**
     * {@inheritDoc}
     */
-   public IronJacamar getIronJacamar(URL deployment) throws NotFoundException
+   public IronJacamar getIronJacamar(String uniqueId) throws NotFoundException
    {
-      if (deployment == null)
-         throw new IllegalArgumentException("Deployment is null");
+      if (uniqueId == null)
+         throw new IllegalArgumentException("UniqueId is null");
 
-      if (!ironJacamar.containsKey(deployment))
-         throw new NotFoundException(deployment + " isn't registered");
+      if (uniqueId.trim().equals(""))
+         throw new IllegalArgumentException("UniqueId is empty");
 
-      return ironJacamar.get(deployment);
+      if (!ironJacamar.containsKey(uniqueId))
+         throw new NotFoundException(uniqueId + " isn't registered");
+
+      return ironJacamar.get(uniqueId);
    }
 
    /**
     * {@inheritDoc}
     */
-   public void registerJndiMapping(URL deployment, String clz, String jndi)
+   public void registerJndiMapping(String uniqueId, String clz, String jndi)
    {
-      if (deployment == null)
-         throw new IllegalArgumentException("Deployment is null");
+      if (uniqueId == null)
+         throw new IllegalArgumentException("UniqueId is null");
 
+      if (uniqueId.trim().equals(""))
+         throw new IllegalArgumentException("UniqueId is empty");
+
       if (clz == null)
          throw new IllegalArgumentException("Clz is null");
 
+      if (clz.trim().equals(""))
+         throw new IllegalArgumentException("Clz is empty");
+
       if (jndi == null)
          throw new IllegalArgumentException("Jndi is null");
 
-      Map<String, List<String>> mappings = jndiMappings.get(deployment);
+      if (jndi.trim().equals(""))
+         throw new IllegalArgumentException("Jndi is empty");
+
+      Map<String, List<String>> mappings = jndiMappings.get(uniqueId);
       if (mappings == null)
       {
          Map<String, List<String>> newMappings = new HashMap<String, List<String>>(1);
-         mappings = jndiMappings.putIfAbsent(deployment, newMappings);
+         mappings = jndiMappings.putIfAbsent(uniqueId, newMappings);
 
          if (mappings == null)
          {
@@ -196,19 +238,31 @@
    /**
     * {@inheritDoc}
     */
-   public void unregisterJndiMapping(URL deployment, String clz, String jndi)
+   public void unregisterJndiMapping(String uniqueId, String clz, String jndi) throws NotFoundException
    {
-      if (deployment == null)
-         throw new IllegalArgumentException("Deployment is null");
+      if (uniqueId == null)
+         throw new IllegalArgumentException("UniqueId is null");
 
+      if (uniqueId.trim().equals(""))
+         throw new IllegalArgumentException("Uniqueid is empty");
+
       if (clz == null)
          throw new IllegalArgumentException("Clz is null");
 
+      if (clz.trim().equals(""))
+         throw new IllegalArgumentException("Clz is empty");
+
       if (jndi == null)
          throw new IllegalArgumentException("Jndi is null");
 
-      Map<String, List<String>> mappings = jndiMappings.get(deployment);
+      if (jndi.trim().equals(""))
+         throw new IllegalArgumentException("Jndi is empty");
 
+      if (!jndiMappings.containsKey(uniqueId))
+         throw new NotFoundException(uniqueId + " isn't registered");
+
+      Map<String, List<String>> mappings = jndiMappings.get(uniqueId);
+
       if (mappings != null)
       {
          List<String> l = mappings.get(clz);
@@ -225,7 +279,7 @@
 
          if (mappings.size() == 0)
          {
-            jndiMappings.remove(deployment);
+            jndiMappings.remove(uniqueId);
          }
       }
    }
@@ -233,11 +287,36 @@
    /**
     * {@inheritDoc}
     */
-   public Map<String, List<String>> getJndiMappings(URL deployment)
+   public boolean hasJndiMappings(String uniqueId)
    {
-      if (deployment == null)
-         throw new IllegalArgumentException("Deployment is null");
+      if (uniqueId == null)
+         throw new IllegalArgumentException("UniqueId is null");
       
-      return jndiMappings.get(deployment);
+      if (uniqueId.trim().equals(""))
+         throw new IllegalArgumentException("UniqueId is empty");
+
+      return jndiMappings.containsKey(uniqueId);
    }
+
+   /**
+    * {@inheritDoc}
+    */
+   public Map<String, List<String>> getJndiMappings(String uniqueId) throws NotFoundException
+   {
+      if (uniqueId == null)
+         throw new IllegalArgumentException("UniqueId is null");
+      
+      if (uniqueId.trim().equals(""))
+         throw new IllegalArgumentException("UniqueId is empty");
+
+      if (!jndiMappings.containsKey(uniqueId))
+         throw new NotFoundException(uniqueId + " isn't registered");
+
+      Map<String, List<String>> mappings = jndiMappings.get(uniqueId);
+
+      if (mappings == null)
+         return Collections.unmodifiableMap(new HashMap<String, List<String>>(0));
+
+      return Collections.unmodifiableMap(mappings);
+   }
 }

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/mdr/MetadataRepository.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/mdr/MetadataRepository.java	2010-10-14 13:14:12 UTC (rev 108580)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/mdr/MetadataRepository.java	2010-10-14 13:41:35 UTC (rev 108581)
@@ -26,7 +26,6 @@
 import org.jboss.jca.common.api.metadata.ra.Connector;
 
 import java.io.File;
-import java.net.URL;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -40,72 +39,88 @@
 {
    /**
     * Register a resource adapter template
-    * @param deployment The deployment
+    * @param uniqueId An unique id that represents the deployment
     * @param root The deployment root
     * @param md The connector metadata
     * @param ijmd The IronJacamar metadata
-    * @exception AlreadyExistsException Thrown if the deployment is already registered
+    * @exception AlreadyExistsException Thrown if the unique id is already registered
     */
-   public void registerResourceAdapter(URL deployment, File root, Connector md, IronJacamar ijmd) 
+   public void registerResourceAdapter(String uniqueId, File root, Connector md, IronJacamar ijmd) 
       throws AlreadyExistsException;
 
    /**
     * Unregister a resource adapter template
-    * @param deployment The deployment
-    * @exception NotFoundException Thrown if the deployment isn't registered
+    * @param uniqueId An unique id that represents the deployment
+    * @exception NotFoundException Thrown if the unique id isn't registered
     */
-   public void unregisterResourceAdapter(URL deployment) throws NotFoundException;
+   public void unregisterResourceAdapter(String uniqueId) throws NotFoundException;
 
    /**
+    * Check if there exists a resource adapter for a unique id
+    * @param uniqueId An unique id that represents the deployment
+    * @return True if there is a resource adapter; otherwise false
+    */
+   public boolean hasResourceAdapter(String uniqueId);
+
+   /**
     * Get the metadata for a resource adapter
-    * @param deployment The deployment
+    * @param uniqueId An unique id that represents the deployment
     * @return The metadata
-    * @exception NotFoundException Thrown if the deployment isn't registered
+    * @exception NotFoundException Thrown if the unique id isn't registered
     */
-   public Connector getResourceAdapter(URL deployment) throws NotFoundException;
+   public Connector getResourceAdapter(String uniqueId) throws NotFoundException;
 
    /**
-    * Get the resource adapters deployments registered
-    * @return The names of the deployments
+    * Get the resource adapters unique ids registered
+    * @return The unique ids
     */
-   public Set<URL> getResourceAdapters();
+   public Set<String> getResourceAdapters();
 
    /**
     * Get the root for a resource adapter deployment
-    * @param deployment The deployment
+    * @param uniqueId An unique id that represents the deployment
     * @return The root
-    * @exception NotFoundException Thrown if the deployment isn't registered
+    * @exception NotFoundException Thrown if the unique id isn't registered
     */
-   public File getRoot(URL deployment) throws NotFoundException;
+   public File getRoot(String uniqueId) throws NotFoundException;
 
    /**
     * Get the IronJacamar metadata for a resource adapter deployment
-    * @param deployment The deployment
+    * @param uniqueId An unique id that represents the deployment
     * @return The metadata
-    * @exception NotFoundException Thrown if the deployment isn't registered
+    * @exception NotFoundException Thrown if the unique id isn't registered
     */
-   public IronJacamar getIronJacamar(URL deployment) throws NotFoundException;
+   public IronJacamar getIronJacamar(String uniqueId) throws NotFoundException;
 
    /**
-    * Register a JNDI mapping for a deployment
-    * @param deployment The deployment
+    * Register a JNDI mapping for a unique id
+    * @param uniqueId An unique id that represents the deployment
     * @param clz The fully qualified class name
     * @param jndi The JNDI name
     */
-   public void registerJndiMapping(URL deployment, String clz, String jndi);
+   public void registerJndiMapping(String uniqueId, String clz, String jndi);
 
    /**
-    * Unregister a JNDI mapping for a deployment
-    * @param deployment The deployment
+    * Unregister a JNDI mapping for a unique id
+    * @param uniqueId An unique id that represents the deployment
     * @param clz The fully qualified class name
     * @param jndi The JNDI name
+    * @exception NotFoundException Thrown if the unique id isn't registered
     */
-   public void unregisterJndiMapping(URL deployment, String clz, String jndi);
+   public void unregisterJndiMapping(String uniqueId, String clz, String jndi) throws NotFoundException;
 
    /**
-    * Get the JNDI mappings for a deployment
-    * @param deployment The deployment
+    * Check if there exists JNDI mappings for a unique id
+    * @param uniqueId An unique id that represents the deployment
+    * @return True if there are mappings; otherwise false
+    */
+   public boolean hasJndiMappings(String uniqueId);
+
+   /**
+    * Get the JNDI mappings for a unique id
+    * @param uniqueId An unique id that represents the deployment
     * @return The mappings
+    * @exception NotFoundException Thrown if the unique id isn't registered
     */
-   public Map<String, List<String>> getJndiMappings(URL deployment);
+   public Map<String, List<String>> getJndiMappings(String uniqueId) throws NotFoundException;
 }

Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/mdr/MetadataRepositoryTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/mdr/MetadataRepositoryTestCase.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/mdr/MetadataRepositoryTestCase.java	2010-10-14 13:41:35 UTC (rev 108581)
@@ -0,0 +1,870 @@
+/*
+ * 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.core.mdr;
+
+import org.jboss.jca.common.api.metadata.ironjacamar.IronJacamar;
+import org.jboss.jca.common.api.metadata.ra.Connector;
+import org.jboss.jca.core.spi.mdr.AlreadyExistsException;
+import org.jboss.jca.core.spi.mdr.MetadataRepository;
+import org.jboss.jca.core.spi.mdr.NotFoundException;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.mock;
+
+/**
+ * Unit test for the SimpleMetadataRepository
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a> 
+ */
+public class MetadataRepositoryTestCase
+{
+   /**
+    * Test: Constructor
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test
+   public void testConstructor() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+   }
+
+   /**
+    * Test: RegisterResourceAdapter
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testRegisterResourceAdapterNullUniqueId() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = null;
+      File root = new File(".");
+      Connector md = mock(Connector.class);
+      IronJacamar ijmd = mock(IronJacamar.class);
+
+      mdr.registerResourceAdapter(null, root, md, ijmd);
+   }
+
+   /**
+    * Test: RegisterResourceAdapter
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testRegisterResourceAdapterEmptyUniqueId() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "";
+      File root = new File(".");
+      Connector md = mock(Connector.class);
+      IronJacamar ijmd = mock(IronJacamar.class);
+
+      mdr.registerResourceAdapter(uniqueId, root, md, ijmd);
+   }
+
+   /**
+    * Test: RegisterResourceAdapter
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testRegisterResourceAdapterNullFile() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "KEY";
+      File root = null;
+      Connector md = mock(Connector.class);
+      IronJacamar ijmd = mock(IronJacamar.class);
+
+      mdr.registerResourceAdapter(uniqueId, root, md, ijmd);
+   }
+
+   /**
+    * Test: RegisterResourceAdapter
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testRegisterResourceAdapterNullConnector() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "KEY";
+      File root = new File(".");
+      Connector md = null;
+      IronJacamar ijmd = mock(IronJacamar.class);
+
+      mdr.registerResourceAdapter(uniqueId, root, md, ijmd);
+   }
+
+   /**
+    * Test: RegisterResourceAdapter
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = AlreadyExistsException.class)
+   public void testRegisterResourceAdapterAlreadyExists() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "KEY";
+      File root = new File(".");
+      Connector md = mock(Connector.class);
+      IronJacamar ijmd = mock(IronJacamar.class);
+
+      mdr.registerResourceAdapter(uniqueId, root, md, ijmd);
+      mdr.registerResourceAdapter(uniqueId, root, md, ijmd);
+   }
+
+   /**
+    * Test: RegisterResourceAdapter
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test
+   public void testRegisterResourceAdapter() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "KEY";
+      File root = new File(".");
+      Connector md = mock(Connector.class);
+      IronJacamar ijmd = mock(IronJacamar.class);
+
+      mdr.registerResourceAdapter(uniqueId, root, md, ijmd);
+   }
+
+   /**
+    * Test: UnregisterResourceAdapter
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testUnregisterResourceAdapterNullUniqueId() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = null;
+
+      mdr.unregisterResourceAdapter(uniqueId);
+   }
+
+   /**
+    * Test: UnregisterResourceAdapter
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testUnregisterResourceAdapterEmptyUniqueId() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "";
+
+      mdr.unregisterResourceAdapter(uniqueId);
+   }
+
+   /**
+    * Test: UnregisterResourceAdapter
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = NotFoundException.class)
+   public void testUnregisterResourceAdapterNotFoundException() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "KEY";
+
+      mdr.unregisterResourceAdapter(uniqueId);
+   }
+
+   /**
+    * Test: UnregisterResourceAdapter
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test
+   public void testUnregisterResourceAdapter() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "KEY";
+      File root = new File(".");
+      Connector md = mock(Connector.class);
+      IronJacamar ijmd = mock(IronJacamar.class);
+
+      mdr.registerResourceAdapter(uniqueId, root, md, ijmd);
+      mdr.unregisterResourceAdapter(uniqueId);
+   }
+
+   /**
+    * Test: GetResourceAdapter
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testGetResourceAdapterNullUniqueId() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = null;
+
+      Connector connector = mdr.getResourceAdapter(uniqueId);
+   }
+
+   /**
+    * Test: GetResourceAdapter
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testGetResourceAdapterEmptyUniqueId() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "";
+
+      Connector connector = mdr.getResourceAdapter(uniqueId);
+   }
+
+   /**
+    * Test: GetResourceAdapter
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = NotFoundException.class)
+   public void testGetResourceAdapterNotFoundException() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "KEY";
+
+      Connector connector = mdr.getResourceAdapter(uniqueId);
+   }
+
+   /**
+    * Test: GetResourceAdapter
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test
+   public void testGetResourceAdapter() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "KEY";
+      File root = new File(".");
+      Connector md = mock(Connector.class);
+      IronJacamar ijmd = mock(IronJacamar.class);
+
+      mdr.registerResourceAdapter(uniqueId, root, md, ijmd);
+
+      Connector cmd = mdr.getResourceAdapter(uniqueId);
+
+      assertFalse(md.equals(cmd));
+   }
+
+   /**
+    * Test: GetResourceAdapters
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = UnsupportedOperationException.class)
+   public void testGetResourceAdaptersUnsupportedOperationException() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      Set<String> ids = mdr.getResourceAdapters();
+      assertNotNull(ids);
+      assertEquals(ids.size(), 0);
+
+      ids.add("KEY");
+   }
+
+   /**
+    * Test: GetResourceAdapters
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test
+   public void testGetResourceAdapters() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      Set<String> ids = mdr.getResourceAdapters();
+      assertNotNull(ids);
+      assertEquals(ids.size(), 0);
+
+      String uniqueId = "KEY";
+      File root = new File(".");
+      Connector md = mock(Connector.class);
+      IronJacamar ijmd = mock(IronJacamar.class);
+
+      mdr.registerResourceAdapter(uniqueId, root, md, ijmd);
+
+      ids = mdr.getResourceAdapters();
+      assertNotNull(ids);
+      assertEquals(ids.size(), 1);
+      assertTrue(ids.contains("KEY"));
+   }
+
+   /**
+    * Test: GetRoot
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testGetRootNullUniqueId() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = null;
+
+      File root = mdr.getRoot(uniqueId);
+   }
+
+   /**
+    * Test: GetRoot
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testGetRootEmptyUniqueId() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "";
+
+      File root = mdr.getRoot(uniqueId);
+   }
+
+   /**
+    * Test: GetRoot
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = NotFoundException.class)
+   public void testGetRootNotFoundException() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "KEY";
+
+      File root = mdr.getRoot(uniqueId);
+   }
+
+   /**
+    * Test: GetRoot
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test
+   public void testGetRoot() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "KEY";
+      File root = new File(".");
+      Connector md = mock(Connector.class);
+      IronJacamar ijmd = mock(IronJacamar.class);
+
+      mdr.registerResourceAdapter(uniqueId, root, md, ijmd);
+
+      File f = mdr.getRoot(uniqueId);
+      assertEquals(root, f);
+   }
+
+   /**
+    * Test: GetIronJacamar
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testGetIronJacamarNullUniqueId() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = null;
+
+      IronJacamar ijmd = mdr.getIronJacamar(uniqueId);
+   }
+
+   /**
+    * Test: GetIronJacamar
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testGetIronJacamarEmptyUniqueId() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "";
+
+      IronJacamar ijmd = mdr.getIronJacamar(uniqueId);
+   }
+
+   /**
+    * Test: GetIronJacamar
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = NotFoundException.class)
+   public void testGetIronJacamarNotFoundException() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "KEY";
+
+      IronJacamar ijmd = mdr.getIronJacamar(uniqueId);
+   }
+
+   /**
+    * Test: GetIronJacamar
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test
+   public void testGetIronJacamar() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "KEY";
+      File root = new File(".");
+      Connector md = mock(Connector.class);
+      IronJacamar ijmd = mock(IronJacamar.class);
+
+      mdr.registerResourceAdapter(uniqueId, root, md, ijmd);
+
+      IronJacamar ij = mdr.getIronJacamar(uniqueId);
+      assertEquals(ijmd, ij);
+   }
+
+   /**
+    * Test: HasResourceAdapter
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testHasResourceAdapterNullUniqueId() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = null;
+
+      boolean result = mdr.hasResourceAdapter(uniqueId);
+   }
+
+   /**
+    * Test: HasResourceAdapter
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testHasResourceAdapterEmptyUniqueId() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "";
+
+      boolean result = mdr.hasResourceAdapter(uniqueId);
+   }
+
+   /**
+    * Test: HasResourceAdapter
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test
+   public void testHasResourceAdapter() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "key";
+
+      assertFalse(mdr.hasResourceAdapter(uniqueId));
+
+      File root = new File(".");
+      Connector md = mock(Connector.class);
+      IronJacamar ijmd = mock(IronJacamar.class);
+
+      mdr.registerResourceAdapter(uniqueId, root, md, ijmd);
+
+      assertTrue(mdr.hasResourceAdapter(uniqueId));
+   }
+
+   /**
+    * Test: RegisterJndiMapping
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testRegisterJndiMappingNullUniqueId() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = null;
+      String clz = "class";
+      String jndi = "mapping";
+
+      mdr.registerJndiMapping(uniqueId, clz, jndi);
+   }
+
+   /**
+    * Test: RegisterJndiMapping
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testRegisterJndiMappingEmptyUniqueId() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "";
+      String clz = "class";
+      String jndi = "mapping";
+
+      mdr.registerJndiMapping(uniqueId, clz, jndi);
+   }
+
+   /**
+    * Test: RegisterJndiMapping
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testRegisterJndiMappingNullClz() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "key";
+      String clz = null;
+      String jndi = "mapping";
+
+      mdr.registerJndiMapping(uniqueId, clz, jndi);
+   }
+
+   /**
+    * Test: RegisterJndiMapping
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testRegisterJndiMappingEmptyClz() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "key";
+      String clz = "";
+      String jndi = "mapping";
+
+      mdr.registerJndiMapping(uniqueId, clz, jndi);
+   }
+
+   /**
+    * Test: RegisterJndiMapping
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testRegisterJndiMappingNullJndi() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "key";
+      String clz = "class";
+      String jndi = null;
+
+      mdr.registerJndiMapping(uniqueId, clz, jndi);
+   }
+
+   /**
+    * Test: RegisterJndiMapping
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testRegisterJndiMappingEmptyJndi() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "key";
+      String clz = "class";
+      String jndi = "";
+
+      mdr.registerJndiMapping(uniqueId, clz, jndi);
+   }
+
+   /**
+    * Test: RegisterJndiMapping
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test
+   public void testRegisterJndiMapping() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "key";
+      String clz = "class";
+      String jndi = "mapping";
+
+      mdr.registerJndiMapping(uniqueId, clz, jndi);
+
+      String clz2 = "class2";
+      String jndi2 = "mapping2";
+
+      mdr.registerJndiMapping(uniqueId, clz2, jndi2);
+   }
+
+   /**
+    * Test: UnregisterJndiMapping
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testUnregisterJndiMappingNullUniqueId() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = null;
+      String clz = "class";
+      String jndi = "mapping";
+
+      mdr.unregisterJndiMapping(uniqueId, clz, jndi);
+   }
+
+   /**
+    * Test: UnregisterJndiMapping
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testUnregisterJndiMappingEmptyUniqueId() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "";
+      String clz = "class";
+      String jndi = "mapping";
+
+      mdr.unregisterJndiMapping(uniqueId, clz, jndi);
+   }
+
+   /**
+    * Test: UnregisterJndiMapping
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testUnregisterJndiMappingNullClz() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "key";
+      String clz = null;
+      String jndi = "mapping";
+
+      mdr.unregisterJndiMapping(uniqueId, clz, jndi);
+   }
+
+   /**
+    * Test: UnregisterJndiMapping
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testUnregisterJndiMappingEmptyClz() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "key";
+      String clz = "";
+      String jndi = "mapping";
+
+      mdr.unregisterJndiMapping(uniqueId, clz, jndi);
+   }
+
+   /**
+    * Test: UnregisterJndiMapping
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testUnregisterJndiMappingNullJndi() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "key";
+      String clz = "class";
+      String jndi = null;
+
+      mdr.unregisterJndiMapping(uniqueId, clz, jndi);
+   }
+
+   /**
+    * Test: UnregisterJndiMapping
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testUnregisterJndiMappingEmptyJndi() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "key";
+      String clz = "class";
+      String jndi = "";
+
+      mdr.unregisterJndiMapping(uniqueId, clz, jndi);
+   }
+
+   /**
+    * Test: UnregisterJndiMapping
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test
+   public void testUnregisterJndiMapping() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "key";
+      String clz = "class";
+      String jndi = "mapping";
+
+      mdr.registerJndiMapping(uniqueId, clz, jndi);
+
+      String clz2 = "class2";
+      String jndi2 = "mapping2";
+
+      mdr.registerJndiMapping(uniqueId, clz2, jndi2);
+
+      mdr.unregisterJndiMapping(uniqueId, clz, jndi);
+      mdr.unregisterJndiMapping(uniqueId, clz2, jndi2);
+   }
+
+   /**
+    * Test: HasJndiMappings
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testHasJndiMappingsNullUniqueId() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = null;
+
+      boolean result = mdr.hasJndiMappings(uniqueId);
+   }
+
+   /**
+    * Test: HasJndiMappings
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testHasJndiMappingsEmptyUniqueId() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "";
+
+      boolean result = mdr.hasJndiMappings(uniqueId);
+   }
+
+   /**
+    * Test: HasJndiMappings
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test
+   public void testHasJndiMappings() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "key";
+
+      assertFalse(mdr.hasJndiMappings(uniqueId));
+
+      String clz = "class";
+      String jndi = "mapping";
+
+      mdr.registerJndiMapping(uniqueId, clz, jndi);
+
+      assertTrue(mdr.hasJndiMappings(uniqueId));
+   }
+
+   /**
+    * Test: GetJndiMappings
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testGetJndiMappingsNullUniqueId() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = null;
+
+      Map<String, List<String>> mappings = mdr.getJndiMappings(uniqueId);
+   }
+
+   /**
+    * Test: GetJndiMappings
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testGetJndiMappingsEmptyUniqueId() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "";
+
+      Map<String, List<String>> mappings = mdr.getJndiMappings(uniqueId);
+   }
+
+   /**
+    * Test: GetJndiMappings
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = NotFoundException.class)
+   public void testGetJndiMappingsNotFoundException() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "key";
+
+      Map<String, List<String>> mappings = mdr.getJndiMappings(uniqueId);
+   }
+
+   /**
+    * Test: GetJndiMappings
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test(expected = UnsupportedOperationException.class)
+   public void testGetJndiMappingsUnsupportedOperationException() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "key";
+      String clz = "class";
+      String jndi = "mapping";
+
+      mdr.registerJndiMapping(uniqueId, clz, jndi);
+
+      Map<String, List<String>> mappings = mdr.getJndiMappings(uniqueId);
+      assertNotNull(mappings);
+      assertEquals(mappings.size(), 1);
+
+      List<String> l = new ArrayList<String>(1);
+      l.add("value");
+      mappings.put("hack", l);
+   }
+
+   /**
+    * Test: GetJndiMappings
+    * @exception Throwable Thrown in case of an error
+    */
+   @Test
+   public void testGetJndiMappings() throws Throwable
+   {
+      MetadataRepository mdr = new SimpleMetadataRepository();
+
+      String uniqueId = "key";
+      String clz = "class";
+      String jndi = "mapping";
+
+      mdr.registerJndiMapping(uniqueId, clz, jndi);
+
+      Map<String, List<String>> mappings = mdr.getJndiMappings(uniqueId);
+      assertNotNull(mappings);
+      assertEquals(mappings.size(), 1);
+   }
+}

Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/mdr/package.html
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/mdr/package.html	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/mdr/package.html	2010-10-14 13:41:35 UTC (rev 108581)
@@ -0,0 +1,3 @@
+<body>
+Unit Test cases covering the MetadataRepository implementation.
+</body>

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalRADeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalRADeployer.java	2010-10-14 13:14:12 UTC (rev 108580)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalRADeployer.java	2010-10-14 13:41:35 UTC (rev 108581)
@@ -137,7 +137,7 @@
 
       String[] result = js.bindConnectionFactories(deployment, new Object[]{cf});
 
-      ((RAConfiguration) getConfiguration()).getMetadataRepository().registerJndiMapping(url,
+      ((RAConfiguration) getConfiguration()).getMetadataRepository().registerJndiMapping(url.toExternalForm(),
          cf.getClass().getName(), result[0]);
 
       return result;
@@ -150,7 +150,7 @@
 
       String[] result = js.bindConnectionFactories(deployment, new Object[]{cf}, new String[]{jndi});
 
-      ((RAConfiguration) getConfiguration()).getMetadataRepository().registerJndiMapping(url,
+      ((RAConfiguration) getConfiguration()).getMetadataRepository().registerJndiMapping(url.toExternalForm(),
          cf.getClass().getName(), jndi);
 
       return result;
@@ -184,6 +184,7 @@
    protected void registerResourceAdapterToMDR(URL url, File root, Connector cmd, IronJacamar ijmd)
       throws AlreadyExistsException
    {
-      ((RAConfiguration) getConfiguration()).getMetadataRepository().registerResourceAdapter(url, root, cmd, ijmd);
+      ((RAConfiguration) getConfiguration()).getMetadataRepository().
+         registerResourceAdapter(url.toExternalForm(), root, cmd, ijmd);
    }
 }

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java	2010-10-14 13:14:12 UTC (rev 108580)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java	2010-10-14 13:41:35 UTC (rev 108581)
@@ -221,19 +221,19 @@
 
          String deploymentName = f.getName();
 
-         Set<URL> raDeployments = mdr.getResourceAdapters();
+         Set<String> raDeployments = mdr.getResourceAdapters();
          URL urlJdbcLocal = null;
          URL urlJdbcXA = null;
 
-         for (URL u : raDeployments)
+         for (String s : raDeployments)
          {
-            if (u.toExternalForm().endsWith(jdbcLocal))
+            if (s.endsWith(jdbcLocal))
             {
-               urlJdbcLocal = u;
+               urlJdbcLocal = new URL(s);
             }
-            else if (u.toExternalForm().endsWith(jdbcXA))
+            else if (s.endsWith(jdbcXA))
             {
-               urlJdbcXA = u;
+               urlJdbcXA = new URL(s);
             }
          }
 
@@ -359,7 +359,7 @@
 
       Merger merger = new Merger();
 
-      Connector md = mdr.getResourceAdapter(ra);
+      Connector md = mdr.getResourceAdapter(ra.toExternalForm());
       md = merger.mergeConnectorAndDs(ds, md);
 
       // Get the first connection definition as there is only one
@@ -413,7 +413,7 @@
 
       Merger merger = new Merger();
 
-      Connector md = mdr.getResourceAdapter(ra);
+      Connector md = mdr.getResourceAdapter(ra.toExternalForm());
       md = merger.mergeConnectorAndDs(ds, md);
 
       // Get the first connection definition as there is only one

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivator.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivator.java	2010-10-14 13:14:12 UTC (rev 108580)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivator.java	2010-10-14 13:41:35 UTC (rev 108581)
@@ -155,13 +155,14 @@
    {
       if (enabled)
       {
-         Set<URL> rarDeployments = ((RAConfiguration) getConfiguration()).getMetadataRepository()
-            .getResourceAdapters();
+         MetadataRepository mdr = ((RAConfiguration) getConfiguration()).getMetadataRepository();
 
-         for (URL deployment : rarDeployments)
+         Set<String> rarDeployments = mdr.getResourceAdapters();
+
+         for (String deployment : rarDeployments)
          {
             if (trace)
-               log.trace("Processing: " + deployment.toExternalForm());
+               log.trace("Processing: " + deployment);
 
             boolean include = true;
 
@@ -169,30 +170,24 @@
             {
                for (String excludedArchive : excludeArchives)
                {
-                  if (deployment.toExternalForm().endsWith(excludedArchive))
+                  if (deployment.endsWith(excludedArchive))
                      include = false;
                }
             }
 
-            if (include)
+            if (include && !mdr.hasJndiMappings(deployment))
             {
-               Map<String, List<String>> jndiMappings = ((RAConfiguration) getConfiguration())
-                  .getMetadataRepository().getJndiMappings(deployment);
-
                // If there isn't any JNDI mappings then the archive isn't active
                // so activate it
-               if (jndiMappings == null)
+               Deployment raDeployment = deploy(new URL(deployment), kernel.getKernelClassLoader());
+               if (raDeployment != null)
                {
-                  Deployment raDeployment = deploy(deployment, kernel.getKernelClassLoader());
-                  if (raDeployment != null)
-                  {
-                     if (deployments == null)
-                        deployments = new ArrayList<Deployment>(1);
+                  if (deployments == null)
+                     deployments = new ArrayList<Deployment>(1);
 
-                     deployments.add(raDeployment);
-
-                     kernel.getMainDeployer().registerDeployment(raDeployment);
-                  }
+                  deployments.add(raDeployment);
+                  
+                  kernel.getMainDeployer().registerDeployment(raDeployment);
                }
             }
          }
@@ -284,8 +279,8 @@
          // Get metadata
          MetadataRepository metadataRepository = ((RAConfiguration) getConfiguration()).getMetadataRepository();
 
-         Connector cmd = metadataRepository.getResourceAdapter(url);
-         IronJacamar ijmd = metadataRepository.getIronJacamar(url);
+         Connector cmd = metadataRepository.getResourceAdapter(url.toExternalForm());
+         IronJacamar ijmd = metadataRepository.getIronJacamar(url.toExternalForm());
 
          cmd = (new Merger()).mergeConnectorWithCommonIronJacamar(ijmd, cmd);
 

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivatorDeployment.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivatorDeployment.java	2010-10-14 13:14:12 UTC (rev 108580)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivatorDeployment.java	2010-10-14 13:41:35 UTC (rev 108581)
@@ -23,6 +23,7 @@
 package org.jboss.jca.deployers.fungal;
 
 import org.jboss.jca.core.spi.mdr.MetadataRepository;
+import org.jboss.jca.core.spi.mdr.NotFoundException;
 import org.jboss.jca.core.spi.naming.JndiStrategy;
 
 import java.io.Closeable;
@@ -125,10 +126,17 @@
       {
          for (int i = 0; i < cfs.length; i++)
          {
-            String cf = cfs[i].getClass().getName();
-            String jndi = jndis[i];
+            try
+            {
+               String cf = cfs[i].getClass().getName();
+               String jndi = jndis[i];
 
-            mdr.unregisterJndiMapping(deployment, cf, jndi);
+               mdr.unregisterJndiMapping(deployment.toExternalForm(), cf, jndi);
+            }
+            catch (NotFoundException nfe)
+            {
+               log.warn("Exception during unregistering deployment", nfe);
+            }
          }
       }
 

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployment.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployment.java	2010-10-14 13:14:12 UTC (rev 108580)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployment.java	2010-10-14 13:41:35 UTC (rev 108581)
@@ -23,6 +23,7 @@
 package org.jboss.jca.deployers.fungal;
 
 import org.jboss.jca.core.spi.mdr.MetadataRepository;
+import org.jboss.jca.core.spi.mdr.NotFoundException;
 import org.jboss.jca.core.spi.naming.JndiStrategy;
 
 import java.io.Closeable;
@@ -136,7 +137,7 @@
       {
          try
          {
-            mdr.unregisterResourceAdapter(deployment);
+            mdr.unregisterResourceAdapter(deployment.toExternalForm());
          }
          catch (Throwable t)
          {
@@ -152,10 +153,17 @@
          {
             for (int i = 0; i < cfs.length; i++)
             {
-               String cf = cfs[i].getClass().getName();
-               String jndi = jndis[i];
+               try
+               {
+                  String cf = cfs[i].getClass().getName();
+                  String jndi = jndis[i];
 
-               mdr.unregisterJndiMapping(deployment, cf, jndi);
+                  mdr.unregisterJndiMapping(deployment.toExternalForm(), cf, jndi);
+               }
+               catch (NotFoundException nfe)
+               {
+                  log.warn("Exception during unregistering deployment", nfe);
+               }
             }
          }
 

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployer.java	2010-10-14 13:14:12 UTC (rev 108580)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployer.java	2010-10-14 13:41:35 UTC (rev 108581)
@@ -41,6 +41,7 @@
 import org.jboss.jca.core.connectionmanager.pool.api.PoolConfiguration;
 import org.jboss.jca.core.connectionmanager.pool.api.PoolFactory;
 import org.jboss.jca.core.connectionmanager.pool.api.PoolStrategy;
+import org.jboss.jca.core.spi.mdr.MetadataRepository;
 import org.jboss.jca.deployers.common.BeanValidation;
 import org.jboss.jca.validator.Failure;
 import org.jboss.jca.validator.Key;
@@ -286,12 +287,12 @@
          // Find the archive in MDR
          String archive = raxml.getArchive();
          URL deployment = null;
-         Set<URL> deployments = ((RAConfiguration) getConfiguration()).getMetadataRepository().getResourceAdapters();
+         Set<String> deployments = ((RAConfiguration) getConfiguration()).getMetadataRepository().getResourceAdapters();
 
-         for (URL u : deployments)
+         for (String s : deployments)
          {
-            if (u.toExternalForm().endsWith(archive))
-               deployment = u;
+            if (s.endsWith(archive))
+               deployment = new URL(s);
          }
 
          if (deployment == null)
@@ -299,10 +300,10 @@
             throw new DeployException("Archive " + archive + " couldn't be resolved in " + url.toExternalForm());
          }
 
-         Connector cmd = ((RAConfiguration) getConfiguration()).getMetadataRepository()
-            .getResourceAdapter(deployment);
-         IronJacamar ijmd = ((RAConfiguration) getConfiguration()).getMetadataRepository().getIronJacamar(deployment);
-         File root = ((RAConfiguration) getConfiguration()).getMetadataRepository().getRoot(deployment);
+         MetadataRepository mdr = ((RAConfiguration) getConfiguration()).getMetadataRepository();
+         Connector cmd = mdr.getResourceAdapter(deployment.toExternalForm());
+         IronJacamar ijmd = mdr.getIronJacamar(deployment.toExternalForm());
+         File root = mdr.getRoot(deployment.toExternalForm());
 
          cmd = (new Merger()).mergeConnectorWithCommonIronJacamar(raxml, cmd);
          // Create classloader

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployment.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployment.java	2010-10-14 13:14:12 UTC (rev 108580)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployment.java	2010-10-14 13:41:35 UTC (rev 108581)
@@ -23,6 +23,7 @@
 package org.jboss.jca.deployers.fungal;
 
 import org.jboss.jca.core.spi.mdr.MetadataRepository;
+import org.jboss.jca.core.spi.mdr.NotFoundException;
 import org.jboss.jca.core.spi.naming.JndiStrategy;
 
 import java.io.Closeable;
@@ -131,10 +132,17 @@
       {
          for (int i = 0; i < cfs.length; i++)
          {
-            String cf = cfs[i].getClass().getName();
-            String jndi = jndis[i];
+            try
+            {
+               String cf = cfs[i].getClass().getName();
+               String jndi = jndis[i];
 
-            mdr.unregisterJndiMapping(raDeployment, cf, jndi);
+               mdr.unregisterJndiMapping(raDeployment.toExternalForm(), cf, jndi);
+            }
+            catch (NotFoundException nfe)
+            {
+               log.warn("Exception during unregistering deployment", nfe);
+            }
          }
       }
 



More information about the jboss-cvs-commits mailing list