[jboss-cvs] JBossAS SVN: r109071 - in projects/ejb3/tags/jboss-ejb3-core-1.3.6/src: test/java/org/jboss/ejb3/core/test and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Nov 2 11:26:33 EDT 2010


Author: jbertram at redhat.com
Date: 2010-11-02 11:26:30 -0400 (Tue, 02 Nov 2010)
New Revision: 109071

Added:
   projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/
   projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/FailingConstructingBean.java
   projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/FailingConstructingLocal.java
   projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/unit/
   projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/unit/FailingPoolTestCase.java
Removed:
   projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/FailingConstructingBean.java
   projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/FailingConstructingLocal.java
   projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/unit/
   projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/unit/FailingPoolTestCase.java
Modified:
   projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/main/java/org/jboss/ejb3/pool/StrictMaxPool.java
   projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java
Log:
JBPAPP-5356

Modified: projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/main/java/org/jboss/ejb3/pool/StrictMaxPool.java
===================================================================
--- projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/main/java/org/jboss/ejb3/pool/StrictMaxPool.java	2010-11-02 15:08:37 UTC (rev 109070)
+++ projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/main/java/org/jboss/ejb3/pool/StrictMaxPool.java	2010-11-02 15:26:30 UTC (rev 109071)
@@ -21,16 +21,15 @@
  */
 package org.jboss.ejb3.pool;
 
+import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.Container;
+import org.jboss.logging.Logger;
+
+import javax.ejb.EJBException;
 import java.util.LinkedList;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 
-import javax.ejb.EJBException;
-
-import org.jboss.ejb3.BeanContext;
-import org.jboss.ejb3.Container;
-import org.jboss.logging.Logger;
-
 /**
  * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
  * @version $Revision$
@@ -66,13 +65,43 @@
 
    Logger log = Logger.getLogger(StrictMaxPool.class);
 
+   /**
+    * Acquire a permit and check the pool.
+    *
+    * @return a BeanContext from the pool or null if one needs to be created
+    */
+   private BeanContext acquire()
+   {
+      boolean trace = log.isTraceEnabled();
+      if (trace)
+         log.trace("Get instance " + this + "#" + pool.size() + "#" + container.getBeanClass());
 
-   // Static --------------------------------------------------------
+      // Block until an instance is available
+      try
+      {
+         boolean acquired = strictMaxSize.tryAcquire(strictTimeout, TimeUnit.MILLISECONDS);
+         if (trace)
+            log.trace("Acquired(" + acquired + ") strictMaxSize semaphore, remaining=" + strictMaxSize.availablePermits());
+         if (acquired == false)
+            throw new EJBException("Failed to acquire the pool semaphore, strictTimeout=" + strictTimeout);
+      }
+      catch (InterruptedException e)
+      {
+         throw new EJBException("Pool strictMaxSize semaphore was interrupted");
+      }
 
-   // Constructors --------------------------------------------------
+      synchronized (pool)
+      {
+         if (!pool.isEmpty())
+         {
+            BeanContext bean = (BeanContext) pool.removeFirst();
+            ++inUse;
+            return bean;
+         }
+      }
+      return null;
+   }
 
-   // Public --------------------------------------------------------
-
    /**
     * super.initialize() must have been called in advance
     */
@@ -113,73 +142,48 @@
     */
    public BeanContext get()
    {
-      boolean trace = log.isTraceEnabled();
-      if (trace)
-         log.trace("Get instance " + this + "#" + pool.size() + "#" + container.getBeanClass());
+      BeanContext bean = acquire();
+      if(bean != null)
+         return bean;
 
-      // Block until an instance is available
       try
       {
-         boolean acquired = strictMaxSize.tryAcquire(strictTimeout, TimeUnit.MILLISECONDS);
-         if (trace)
-            log.trace("Acquired(" + acquired + ") strictMaxSize semaphore, remaining=" + strictMaxSize.availablePermits());
-         if (acquired == false)
-            throw new EJBException("Failed to acquire the pool semaphore, strictTimeout=" + strictTimeout);
+         // Pool is empty, create an instance
+         ++inUse;
+         bean = create();
       }
-      catch (InterruptedException e)
+      finally
       {
-         throw new EJBException("Pool strictMaxSize semaphore was interrupted");
-      }
-
-      synchronized (pool)
-      {
-         if (!pool.isEmpty())
+         if(bean == null)
          {
-            BeanContext bean = (BeanContext) pool.removeFirst();
-            ++inUse;
-            return bean;
+            --inUse;
+            strictMaxSize.release();
          }
       }
-
-      // Pool is empty, create an instance
-      ++inUse;
-      return create();
-
+      return bean;
    }
 
    public BeanContext get(Class[] initTypes, Object[] initValues)
    {
-      boolean trace = log.isTraceEnabled();
-      if (trace)
-         log.trace("Get instance " + this + "#" + pool.size() + "#" + container.getBeanClass());
-
-      // Block until an instance is available
+      BeanContext bean = acquire();
+      if(bean != null)
+         return bean;
+      
       try
       {
-         boolean acquired = strictMaxSize.tryAcquire(strictTimeout, TimeUnit.MILLISECONDS);
-         if (trace)
-            log.trace("Acquired(" + acquired + ") strictMaxSize semaphore, remaining=" + strictMaxSize.availablePermits());
-         if (acquired == false)
-            throw new EJBException("Failed to acquire the pool semaphore, strictTimeout=" + strictTimeout);
+         // Pool is empty, create an instance
+         ++inUse;
+         bean = create(initTypes, initValues);
       }
-      catch (InterruptedException e)
+      finally
       {
-         throw new EJBException("Pool strictMaxSize semaphore was interrupted");
-      }
-
-      synchronized (pool)
-      {
-         if (!pool.isEmpty())
+         if(bean == null)
          {
-            BeanContext bean = (BeanContext) pool.removeFirst();
-            ++inUse;
-            return bean;
+            --inUse;
+            strictMaxSize.release();
          }
       }
-
-      // Pool is empty, create an instance
-      ++inUse;
-      return create(initTypes, initValues);
+      return bean;
    }
 
    /**

Modified: projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java
===================================================================
--- projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java	2010-11-02 15:08:37 UTC (rev 109070)
+++ projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java	2010-11-02 15:26:30 UTC (rev 109071)
@@ -73,6 +73,8 @@
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 
+import static org.junit.Assert.assertEquals;
+
 /**
  * Create an environment with some basic facilities on which EJB 3 containers
  * depend.
@@ -131,6 +133,20 @@
 
    }
 
+   protected static void assertCause(Throwable expected, Throwable actual)
+   {
+      Throwable cause = actual.getCause();
+      if(cause != null)
+         assertCause(expected, cause);
+      else
+         assertThrowable(expected, actual);
+   }
+
+   protected static void assertThrowable(Throwable expected, Throwable actual)
+   {
+      assertEquals(expected.toString(), actual.toString());
+   }
+
    @BeforeClass
    public static void beforeClass() throws Exception
    {

Copied: projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191 (from rev 108962, projects/ejb3/branches/jboss-ejb3-core-1.3/src/test/java/org/jboss/ejb3/core/test/ejbthree2191)

Deleted: projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/FailingConstructingBean.java
===================================================================
--- projects/ejb3/branches/jboss-ejb3-core-1.3/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/FailingConstructingBean.java	2010-10-28 12:30:28 UTC (rev 108962)
+++ projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/FailingConstructingBean.java	2010-11-02 15:26:30 UTC (rev 109071)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright (c) 2010, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.ejb3.core.test.ejbthree2191;
-
-import org.jboss.ejb3.annotation.Pool;
-
-import javax.annotation.PostConstruct;
-import javax.ejb.Local;
-import javax.ejb.Stateless;
-
-/**
- * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
- */
- at Stateless
- at Local(FailingConstructingLocal.class)
- at Pool(value="StrictMaxPool", maxSize=1, timeout=1L)
-public class FailingConstructingBean implements FailingConstructingLocal
-{
-   @PostConstruct
-   public void postConstruct()
-   {
-      throw new RuntimeException("I fail construction purposely");
-   }
-
-   @Override
-   public void solveAllMyProblems()
-   {
-      // this actually never happens
-      throw new RuntimeException("NYI: org.jboss.ejb3.core.test.ejbthree2191.FailingConstructingBean.solveAllMyProblems");
-   }
-}

Copied: projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/FailingConstructingBean.java (from rev 108962, projects/ejb3/branches/jboss-ejb3-core-1.3/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/FailingConstructingBean.java)
===================================================================
--- projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/FailingConstructingBean.java	                        (rev 0)
+++ projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/FailingConstructingBean.java	2010-11-02 15:26:30 UTC (rev 109071)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.ejb3.core.test.ejbthree2191;
+
+import org.jboss.ejb3.annotation.Pool;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.Local;
+import javax.ejb.Stateless;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+ at Stateless
+ at Local(FailingConstructingLocal.class)
+ at Pool(value="StrictMaxPool", maxSize=1, timeout=1L)
+public class FailingConstructingBean implements FailingConstructingLocal
+{
+   @PostConstruct
+   public void postConstruct()
+   {
+      throw new RuntimeException("I fail construction purposely");
+   }
+
+   @Override
+   public void solveAllMyProblems()
+   {
+      // this actually never happens
+      throw new RuntimeException("NYI: org.jboss.ejb3.core.test.ejbthree2191.FailingConstructingBean.solveAllMyProblems");
+   }
+}

Deleted: projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/FailingConstructingLocal.java
===================================================================
--- projects/ejb3/branches/jboss-ejb3-core-1.3/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/FailingConstructingLocal.java	2010-10-28 12:30:28 UTC (rev 108962)
+++ projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/FailingConstructingLocal.java	2010-11-02 15:26:30 UTC (rev 109071)
@@ -1,30 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright (c) 2010, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.ejb3.core.test.ejbthree2191;
-
-/**
- * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
- */
-public interface FailingConstructingLocal
-{
-   void solveAllMyProblems();
-}

Copied: projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/FailingConstructingLocal.java (from rev 108962, projects/ejb3/branches/jboss-ejb3-core-1.3/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/FailingConstructingLocal.java)
===================================================================
--- projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/FailingConstructingLocal.java	                        (rev 0)
+++ projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/FailingConstructingLocal.java	2010-11-02 15:26:30 UTC (rev 109071)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.ejb3.core.test.ejbthree2191;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public interface FailingConstructingLocal
+{
+   void solveAllMyProblems();
+}

Copied: projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/unit (from rev 108962, projects/ejb3/branches/jboss-ejb3-core-1.3/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/unit)

Deleted: projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/unit/FailingPoolTestCase.java
===================================================================
--- projects/ejb3/branches/jboss-ejb3-core-1.3/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/unit/FailingPoolTestCase.java	2010-10-28 12:30:28 UTC (rev 108962)
+++ projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/unit/FailingPoolTestCase.java	2010-11-02 15:26:30 UTC (rev 109071)
@@ -1,66 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright (c) 2010, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.ejb3.core.test.ejbthree2191.unit;
-
-import org.jboss.ejb3.core.test.common.AbstractEJB3TestCase;
-import org.jboss.ejb3.core.test.ejbthree2191.FailingConstructingBean;
-import org.jboss.ejb3.core.test.ejbthree2191.FailingConstructingLocal;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import javax.ejb.EJBException;
-
-import static org.junit.Assert.fail;
-
-/**
- * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
- */
-public class FailingPoolTestCase extends AbstractEJB3TestCase
-{
-   @BeforeClass
-   public static void beforeClass() throws Exception
-   {
-      AbstractEJB3TestCase.beforeClass();
-      
-      deploySessionEjb(FailingConstructingBean.class);
-   }
-
-   @Test
-   public void testConstruction() throws Exception
-   {
-      FailingConstructingLocal bean = lookup("FailingConstructingBean/local", FailingConstructingLocal.class);
-      // the first try will succeed
-      // the second will fail to acquire a permit, if the bug is present
-      for(int i = 0; i < 2; i++)
-      {
-         try
-         {
-            bean.solveAllMyProblems();
-            fail("I doubt that all my problems are solved.");
-         }
-         catch(EJBException e)
-         {
-            assertCause(new RuntimeException("I fail construction purposely"), e);
-         }
-      }
-   }
-}

Copied: projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/unit/FailingPoolTestCase.java (from rev 108962, projects/ejb3/branches/jboss-ejb3-core-1.3/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/unit/FailingPoolTestCase.java)
===================================================================
--- projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/unit/FailingPoolTestCase.java	                        (rev 0)
+++ projects/ejb3/tags/jboss-ejb3-core-1.3.6/src/test/java/org/jboss/ejb3/core/test/ejbthree2191/unit/FailingPoolTestCase.java	2010-11-02 15:26:30 UTC (rev 109071)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.ejb3.core.test.ejbthree2191.unit;
+
+import org.jboss.ejb3.core.test.common.AbstractEJB3TestCase;
+import org.jboss.ejb3.core.test.ejbthree2191.FailingConstructingBean;
+import org.jboss.ejb3.core.test.ejbthree2191.FailingConstructingLocal;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.EJBException;
+
+import static org.junit.Assert.fail;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class FailingPoolTestCase extends AbstractEJB3TestCase
+{
+   @BeforeClass
+   public static void beforeClass() throws Exception
+   {
+      AbstractEJB3TestCase.beforeClass();
+      
+      deploySessionEjb(FailingConstructingBean.class);
+   }
+
+   @Test
+   public void testConstruction() throws Exception
+   {
+      FailingConstructingLocal bean = lookup("FailingConstructingBean/local", FailingConstructingLocal.class);
+      // the first try will succeed
+      // the second will fail to acquire a permit, if the bug is present
+      for(int i = 0; i < 2; i++)
+      {
+         try
+         {
+            bean.solveAllMyProblems();
+            fail("I doubt that all my problems are solved.");
+         }
+         catch(EJBException e)
+         {
+            assertCause(new RuntimeException("I fail construction purposely"), e);
+         }
+      }
+   }
+}



More information about the jboss-cvs-commits mailing list