[jboss-cvs] JBossAS SVN: r103516 - in projects/ejb3/trunk/core/src: test/java/org/jboss/ejb3/core/test and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Apr 5 03:46:30 EDT 2010


Author: jaikiran
Date: 2010-04-05 03:46:30 -0400 (Mon, 05 Apr 2010)
New Revision: 103516

Added:
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2068/
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2068/unit/
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2068/unit/DummyEJB.java
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2068/unit/Ejb3DescriptorHandlerTestCase.java
Modified:
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3AnnotationHandler.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3DescriptorHandler.java
Log:
EJBTHREE-2068 Don't throw IllegalStateException if the handler cannot handle a specific bean type

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3AnnotationHandler.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3AnnotationHandler.java	2010-04-05 05:46:48 UTC (rev 103515)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3AnnotationHandler.java	2010-04-05 07:46:30 UTC (rev 103516)
@@ -61,7 +61,7 @@
 
    protected static enum EJB_TYPE
    {
-      STATELESS, STATEFUL, MESSAGE_DRIVEN, ENTITY, SERVICE, CONSUMER
+      STATELESS, STATEFUL, MESSAGE_DRIVEN, ENTITY, SERVICE, CONSUMER, UNKNOWN
    }
 
    protected DeploymentUnit di;

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3DescriptorHandler.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3DescriptorHandler.java	2010-04-05 05:46:48 UTC (rev 103515)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3DescriptorHandler.java	2010-04-05 07:46:30 UTC (rev 103516)
@@ -377,7 +377,7 @@
       else if (enterpriseBean.isConsumer())
          return EJB_TYPE.CONSUMER;
       
-         throw new IllegalStateException("unknown bean type encountered " + enterpriseBean);
+         return EJB_TYPE.UNKNOWN;
    }
    
    public List<Container> getContainers(Ejb3Deployment deployment, Map<String, Container> preexistingContainers) throws Exception
@@ -401,14 +401,7 @@
       {
          String ejbName = ejbNames.get(ejbIndex);
          JBossEnterpriseBeanMetaData enterpriseBean = ejbs.get(ejbIndex);
-         try
-         {
-            ejbType = getEjbType(enterpriseBean);
-         }
-         catch (IllegalStateException ise)
-         {
-            continue;
-         }
+         ejbType = getEjbType(enterpriseBean);
          className = enterpriseBean.getEjbClass();
          
          if (className == null)

Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2068/unit/DummyEJB.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2068/unit/DummyEJB.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2068/unit/DummyEJB.java	2010-04-05 07:46:30 UTC (rev 103516)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.ejbthree2068.unit;
+
+/**
+ * DummyEJB
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class DummyEJB
+{
+
+}

Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2068/unit/Ejb3DescriptorHandlerTestCase.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2068/unit/Ejb3DescriptorHandlerTestCase.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2068/unit/Ejb3DescriptorHandlerTestCase.java	2010-04-05 07:46:30 UTC (rev 103516)
@@ -0,0 +1,91 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.ejbthree2068.unit;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.List;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.bytecode.ClassFile;
+
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.Ejb3DescriptorHandler;
+import org.jboss.ejb3.core.test.common.AbstractEJB3TestCase;
+import org.jboss.ejb3.core.test.common.MockEjb3Deployment;
+import org.jboss.ejb3.test.cachepassivation.MockDeploymentUnit;
+import org.jboss.metadata.ejb.jboss.JBossAssemblyDescriptorMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.junit.Test;
+
+/**
+ * Tests the fix for https://jira.jboss.org/jira/browse/EJBTHREE-2068
+ * 
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class Ejb3DescriptorHandlerTestCase extends AbstractEJB3TestCase
+{
+
+   /**
+    *  Tests that the {@link Ejb3DescriptorHandler} does not throw an {@link IllegalStateException}
+    *  while processing unknown session-type beans.
+    *  
+    *  @see https://jira.jboss.org/jira/browse/EJBTHREE-2068
+    */
+   @Test
+   public void testUnknownSessionType() throws Exception
+   {
+      // create dummy metadata
+      JBossMetaData metaData = new JBossMetaData();
+      JBossAssemblyDescriptorMetaData assemblyDescriptor = new JBossAssemblyDescriptorMetaData();
+      metaData.setAssemblyDescriptor(assemblyDescriptor);
+
+      JBossEnterpriseBeansMetaData enterpriseBeans = new JBossEnterpriseBeansMetaData();
+      metaData.setEnterpriseBeans(enterpriseBeans);
+      // create a session bean without any session-type
+      JBossSessionBeanMetaData sessionBeanMetaData = new JBossSessionBeanMetaData();
+      sessionBeanMetaData.setEnterpriseBeansMetaData(enterpriseBeans);
+      sessionBeanMetaData.setEjbClass(DummyEJB.class.getName());
+      sessionBeanMetaData.setEjbName(DummyEJB.class.getSimpleName());
+      
+      enterpriseBeans.add(sessionBeanMetaData);
+
+      MockEjb3Deployment deployment = new MockEjb3Deployment(new MockDeploymentUnit());
+      ClassPool pool = ClassPool.getDefault();
+      CtClass ctClass = pool.get(DummyEJB.class.getName());
+      ClassFile classFile = ctClass.getClassFile();
+
+      Ejb3DescriptorHandler handler = new Ejb3DescriptorHandler(deployment, classFile, metaData);
+      // get containers
+      List containers = handler.getContainers(classFile, deployment);
+
+      assertTrue("Unexpectedly found a container from metadata", containers.isEmpty());
+
+   }
+
+}




More information about the jboss-cvs-commits mailing list