[jboss-cvs] JBossAS SVN: r101122 - 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
Thu Feb 18 11:40:03 EST 2010
Author: jaikiran
Date: 2010-02-18 11:40:02 -0500 (Thu, 18 Feb 2010)
New Revision: 101122
Added:
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2022/
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2022/UnSpecifiedSessionTypeBean.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2022/unit/
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2022/unit/Ejb3DescriptorHandlerTestCase.java
Modified:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3DescriptorHandler.java
Log:
EJBTHREE-2022 Fixed the code to not incorrectly create a StatefulContainer for non-stateless session beans
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-02-18 16:37:18 UTC (rev 101121)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3DescriptorHandler.java 2010-02-18 16:40:02 UTC (rev 101122)
@@ -366,7 +366,7 @@
{
if (((JBossSessionBeanMetaData) enterpriseBean).isStateless())
return EJB_TYPE.STATELESS;
- else
+ else if (((JBossSessionBeanMetaData) enterpriseBean).isStateful())
return EJB_TYPE.STATEFUL;
} else if (enterpriseBean.isEntity())
return EJB_TYPE.ENTITY;
@@ -376,7 +376,7 @@
return EJB_TYPE.SERVICE;
else if (enterpriseBean.isConsumer())
return EJB_TYPE.CONSUMER;
- else
+
throw new IllegalStateException("unknown bean type encountered " + enterpriseBean);
}
@@ -401,7 +401,14 @@
{
String ejbName = ejbNames.get(ejbIndex);
JBossEnterpriseBeanMetaData enterpriseBean = ejbs.get(ejbIndex);
- ejbType = getEjbType(enterpriseBean);
+ try
+ {
+ ejbType = getEjbType(enterpriseBean);
+ }
+ catch (IllegalStateException ise)
+ {
+ continue;
+ }
className = enterpriseBean.getEjbClass();
if (className == null)
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2022/UnSpecifiedSessionTypeBean.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2022/UnSpecifiedSessionTypeBean.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2022/UnSpecifiedSessionTypeBean.java 2010-02-18 16:40:02 UTC (rev 101122)
@@ -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.ejbthree2022;
+
+/**
+ * UnSpecifiedSessionTypeBean
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class UnSpecifiedSessionTypeBean
+{
+
+}
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2022/unit/Ejb3DescriptorHandlerTestCase.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2022/unit/Ejb3DescriptorHandlerTestCase.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2022/unit/Ejb3DescriptorHandlerTestCase.java 2010-02-18 16:40:02 UTC (rev 101122)
@@ -0,0 +1,87 @@
+/*
+* 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.ejbthree2022.unit;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.List;
+
+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.core.test.ejbthree2022.UnSpecifiedSessionTypeBean;
+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;
+
+/**
+ * Ejb3DescriptorHandlerTestCase
+ *
+ * Tests the fix for https://jira.jboss.org/jira/browse/EJBTHREE-2022
+ *
+ * The bug was incorrectly creating a StatefulContainer for any non-stateless session beans.
+ * The assumption that any non-stateless session bean is a stateful bean is no longer valid
+ * in EJB3.1 with the introduction of Singleton session bean.
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class Ejb3DescriptorHandlerTestCase extends AbstractEJB3TestCase
+{
+
+ /**
+ * Tests that the {@link Ejb3DescriptorHandler} does not create a stateful container
+ * for a non-stateless session bean.
+ *
+ * @see https://jira.jboss.org/jira/browse/EJBTHREE-2022
+ */
+ @Test
+ public void testNonStatelessSessionBean() 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 setting any SessionType (i.e. session type unknown)
+ JBossSessionBeanMetaData sessionBeanMetaData = new JBossSessionBeanMetaData();
+ sessionBeanMetaData.setEnterpriseBeansMetaData(enterpriseBeans);
+ sessionBeanMetaData.setEjbClass(UnSpecifiedSessionTypeBean.class.getName());
+ sessionBeanMetaData.setEjbName(UnSpecifiedSessionTypeBean.class.getSimpleName());
+ enterpriseBeans.add(sessionBeanMetaData);
+
+ MockEjb3Deployment deployment = new MockEjb3Deployment(new MockDeploymentUnit());
+ Ejb3DescriptorHandler handler = new Ejb3DescriptorHandler(deployment, metaData);
+ // get containers
+ List<Container> containers = handler.getContainers(deployment, new HashMap<String, Container>());
+
+ assertTrue("Unexpectedly found a container from metadata", containers.isEmpty());
+
+ }
+}
More information about the jboss-cvs-commits
mailing list