[jboss-cvs] JBossAS SVN: r77594 - in projects/ejb3/trunk/common/src: test/java/org/jboss/ejb3/test/common/registrar/unit and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Aug 28 08:07:15 EDT 2008


Author: ALRubinger
Date: 2008-08-28 08:07:15 -0400 (Thu, 28 Aug 2008)
New Revision: 77594

Modified:
   projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/registrar/spi/Ejb3RegistrarLocator.java
   projects/ejb3/trunk/common/src/test/java/org/jboss/ejb3/test/common/registrar/unit/Ejb3RegistrarTestCaseBase.java
Log:
[EJBTHREE-1477] Allow Ejb3RegistrarLocator to unbind an Ejb3Registrar implementation; added Unit Tests

Modified: projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/registrar/spi/Ejb3RegistrarLocator.java
===================================================================
--- projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/registrar/spi/Ejb3RegistrarLocator.java	2008-08-28 09:11:40 UTC (rev 77593)
+++ projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/registrar/spi/Ejb3RegistrarLocator.java	2008-08-28 12:07:15 UTC (rev 77594)
@@ -105,7 +105,7 @@
       if (Ejb3RegistrarLocator.instance != null)
       {
          throw new DuplicateBindException(Ejb3Registrar.class.getSimpleName()
-               + " is already bound and is now immutable");
+               + " is already bound and is now immutable via bindRegistrar; must explicitly call unbindRegistrar first");
       }
 
       // Make a new instance and set registrar
@@ -131,7 +131,7 @@
       // Unbind Registrar
       Ejb3Registrar reg = Ejb3RegistrarLocator.instance.getRegistrar();
       log.debug("Unbinding " + Ejb3Registrar.class.getSimpleName() + ": " + reg);
-      Ejb3RegistrarLocator.instance.registrar = null;
+      Ejb3RegistrarLocator.instance = null;
    }
 
    /**

Modified: projects/ejb3/trunk/common/src/test/java/org/jboss/ejb3/test/common/registrar/unit/Ejb3RegistrarTestCaseBase.java
===================================================================
--- projects/ejb3/trunk/common/src/test/java/org/jboss/ejb3/test/common/registrar/unit/Ejb3RegistrarTestCaseBase.java	2008-08-28 09:11:40 UTC (rev 77593)
+++ projects/ejb3/trunk/common/src/test/java/org/jboss/ejb3/test/common/registrar/unit/Ejb3RegistrarTestCaseBase.java	2008-08-28 12:07:15 UTC (rev 77594)
@@ -258,7 +258,43 @@
       TestCase.fail("Invocation on unbound name in registry should fail with " + NotBoundException.class.getName());
 
    }
+   
+   /**
+    * Tests that the Registrar implementation can be unbound and rebound
+    *  
+    * @throws Throwable
+    */
+   @Test
+   public void testRegistrarImplementationRebind() throws Throwable
+   {
+      // See if bound
+      boolean registrarBound = Ejb3RegistrarLocator.isRegistrarBound();
 
+      // Ensure reported as bound
+      TestCase.assertTrue(Ejb3Registrar.class.getSimpleName() + " should be reported as bound", registrarBound);
+
+      // Get existing bound Registrar implementation
+      Ejb3Registrar registrar = Ejb3RegistrarLocator.locateRegistrar();
+
+      // Unbind
+      Ejb3RegistrarLocator.unbindRegistrar();
+
+      // See if bound
+      registrarBound = Ejb3RegistrarLocator.isRegistrarBound();
+
+      // Ensure reported as not bound
+      TestCase.assertTrue(Ejb3Registrar.class.getSimpleName() + " should be reported as unbound", !registrarBound);
+
+      // Rebind
+      Ejb3RegistrarLocator.bindRegistrar(registrar);
+
+      // See if bound
+      registrarBound = Ejb3RegistrarLocator.isRegistrarBound();
+
+      // Ensure reported as bound
+      TestCase.assertTrue(Ejb3Registrar.class.getSimpleName() + " should be reported as bound", registrarBound);
+   }
+
    /**
     * Tests that the Registrar implementation cannot 
     * be re-set after it's initially bound




More information about the jboss-cvs-commits mailing list