[jboss-cvs] JBossAS SVN: r89736 - 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
Wed Jun 3 10:27:00 EDT 2009


Author: wolfc
Date: 2009-06-03 10:27:00 -0400 (Wed, 03 Jun 2009)
New Revision: 89736

Added:
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1558/
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1558/TXNotSupportedMDB.java
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1558/unit/
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1558/unit/JBossMessageEndpointFactoryTestCase.java
Modified:
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/inflow/JBossMessageEndpointFactory.java
Log:
EJBTHREE-1558: unit test + fixed JBossMessageEndpointFactory (merge 89721)

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/inflow/JBossMessageEndpointFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/inflow/JBossMessageEndpointFactory.java	2009-06-03 14:25:30 UTC (rev 89735)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/inflow/JBossMessageEndpointFactory.java	2009-06-03 14:27:00 UTC (rev 89736)
@@ -181,8 +181,10 @@
       TransactionManagementType mtype = TxUtil.getTransactionManagementType(container.getAdvisor());
       if (mtype == javax.ejb.TransactionManagementType.BEAN) return false;
 
-
-      TransactionAttribute attr = (TransactionAttribute)container.resolveAnnotation(method, TransactionAttribute.class);
+      // JBPAPP-1668: the method can be called by anybody using the interface method (== unadvised)
+      Method advisedMethod = container.getMethodInfo(method).getAdvisedMethod();
+      
+      TransactionAttribute attr = (TransactionAttribute)container.resolveAnnotation(advisedMethod, TransactionAttribute.class);
       if (attr == null)
       {
          attr =(TransactionAttribute)container.resolveAnnotation(TransactionAttribute.class);

Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1558/TXNotSupportedMDB.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1558/TXNotSupportedMDB.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1558/TXNotSupportedMDB.java	2009-06-03 14:27:00 UTC (rev 89736)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 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.ejb3.core.test.ejbthree1558;
+
+import static javax.ejb.TransactionAttributeType.NOT_SUPPORTED;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.ejb.TransactionAttribute;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+
+/**
+ * See also JBPAPP-1668
+ * 
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at MessageDriven(activationConfig = {
+      @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
+      @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/ejbthree1558-notx"),
+      @ActivationConfigProperty(propertyName = "maxSession", propertyValue = "3") })
+public class TXNotSupportedMDB implements MessageListener
+{
+   @TransactionAttribute(NOT_SUPPORTED)
+   public void onMessage(Message message)
+   {
+      throw new RuntimeException("Not implemented");
+   }
+}

Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1558/unit/JBossMessageEndpointFactoryTestCase.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1558/unit/JBossMessageEndpointFactoryTestCase.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1558/unit/JBossMessageEndpointFactoryTestCase.java	2009-06-03 14:27:00 UTC (rev 89736)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 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.ejb3.core.test.ejbthree1558.unit;
+
+import static org.junit.Assert.assertFalse;
+
+import java.lang.reflect.Method;
+import java.util.Hashtable;
+import java.util.Properties;
+
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+
+import org.jboss.aop.Domain;
+import org.jboss.deployers.structure.spi.ClassLoaderFactory;
+import org.jboss.deployers.structure.spi.helpers.AbstractDeploymentContext;
+import org.jboss.deployers.structure.spi.helpers.AbstractDeploymentUnit;
+import org.jboss.ejb3.DeploymentUnit;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.common.deployers.spi.AttachmentNames;
+import org.jboss.ejb3.core.resolvers.ScopedEJBReferenceResolver;
+import org.jboss.ejb3.core.test.common.AbstractEJB3TestCase;
+import org.jboss.ejb3.core.test.common.MockEjb3Deployment;
+import org.jboss.ejb3.core.test.ejbthree1558.TXNotSupportedMDB;
+import org.jboss.ejb3.mdb.MDB;
+import org.jboss.ejb3.test.cachepassivation.MockDeploymentUnit;
+import org.jboss.ejb3.test.common.MetaDataHelper;
+import org.jboss.metadata.ejb.jboss.JBossMessageDrivenBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class JBossMessageEndpointFactoryTestCase extends AbstractEJB3TestCase
+{
+   private static class MyMDB extends MDB
+   {
+      public MyMDB(String ejbName, Domain domain, ClassLoader cl, String beanClassName, Hashtable ctxProperties,
+            Ejb3Deployment deployment, JBossMessageDrivenBeanMetaData beanMetaData) throws ClassNotFoundException
+      {
+         super(ejbName, domain, cl, beanClassName, ctxProperties, deployment, beanMetaData);
+      }
+      
+      protected MessageEndpointFactory getMessageEndpointFactory()
+      {
+         return messageEndpointFactory;
+      }
+   }
+   
+   private static MyMDB container;
+   
+   @BeforeClass
+   public static void beforeClass() throws Exception
+   {
+      AbstractEJB3TestCase.beforeClass();
+      
+      AbstractDeploymentUnit deploymentUnit = new AbstractDeploymentUnit(new AbstractDeploymentContext("ejbthree1558", ""));
+      deploymentUnit.createClassLoader(new ClassLoaderFactory() {
+         public ClassLoader createClassLoader(org.jboss.deployers.structure.spi.DeploymentUnit unit) throws Exception
+         {
+            return Thread.currentThread().getContextClassLoader();
+         }
+
+         public void removeClassLoader(org.jboss.deployers.structure.spi.DeploymentUnit unit) throws Exception
+         {
+         }
+      });
+      DeploymentUnit unit = new MockDeploymentUnit(deploymentUnit);
+      Ejb3Deployment deployment = new MockEjb3Deployment(unit, deploymentUnit);
+
+      deployment.setEJBReferenceResolver(new ScopedEJBReferenceResolver());
+      
+      Class<?> beanImplementationClasses[] = { TXNotSupportedMDB.class };
+      JBossMetaData jbossMetaData = MetaDataHelper.getMetaDataFromBeanImplClasses(beanImplementationClasses);
+      unit.addAttachment(AttachmentNames.PROCESSED_METADATA, jbossMetaData);
+      
+      String ejbName = "TXNotSupportedMDB";
+      JBossMessageDrivenBeanMetaData beanMetaData = (JBossMessageDrivenBeanMetaData) jbossMetaData.getEnterpriseBean(ejbName);
+      Domain domain = getDomain("Message Driven Bean");
+      ClassLoader cl = deploymentUnit.getClassLoader();
+      String beanClassName = beanMetaData.getEjbClass();
+      Properties ctxProperties = null;
+      
+      container = new MyMDB(ejbName, domain, cl, beanClassName, ctxProperties, deployment, beanMetaData);
+   }
+   
+   @Test
+   public void testIsDeliveryTransacted() throws Exception
+   {
+      Method method = MessageListener.class.getDeclaredMethod("onMessage", Message.class);
+      boolean isDeliveryTransacted = container.getMessageEndpointFactory().isDeliveryTransacted(method);
+      assertFalse("TXNotSupportedMDB must not have delivery transacted", isDeliveryTransacted);
+   }
+}




More information about the jboss-cvs-commits mailing list