[jboss-cvs] JBossAS SVN: r63280 - in branches/Branch_4_2/ejb3/src: test/org/jboss/ejb3/test/mdbtransactions and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu May 31 13:50:40 EDT 2007


Author: bdecoste
Date: 2007-05-31 13:50:40 -0400 (Thu, 31 May 2007)
New Revision: 63280

Added:
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdbtransactions/BadCreationMDB.java
Modified:
   branches/Branch_4_2/ejb3/src/resources/test/mdbtransactions/mdbtransactionstest-service.xml
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdbtransactions/unit/MDBUnitTestCase.java
Log:
[EJBTHREE-783] added test for failure during creation of MDB instance

Modified: branches/Branch_4_2/ejb3/src/resources/test/mdbtransactions/mdbtransactionstest-service.xml
===================================================================
--- branches/Branch_4_2/ejb3/src/resources/test/mdbtransactions/mdbtransactionstest-service.xml	2007-05-31 17:16:51 UTC (rev 63279)
+++ branches/Branch_4_2/ejb3/src/resources/test/mdbtransactions/mdbtransactionstest-service.xml	2007-05-31 17:50:40 UTC (rev 63280)
@@ -6,6 +6,11 @@
       <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
    </mbean>
    <mbean code="org.jboss.mq.server.jmx.Queue"
+      name="jboss.mq.destination:service=Queue,name=badcreationtest">
+      <attribute name="JNDIName">queue/badcreationmdb</attribute>
+      <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+   </mbean>
+   <mbean code="org.jboss.mq.server.jmx.Queue"
       name="jboss.mq.destination:service=Queue,name=rollbackqueuetest">
       <attribute name="JNDIName">queue/rollbackmdbtest</attribute>
       <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdbtransactions/BadCreationMDB.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdbtransactions/BadCreationMDB.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdbtransactions/BadCreationMDB.java	2007-05-31 17:50:40 UTC (rev 63280)
@@ -0,0 +1,53 @@
+/*
+  * 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.test.mdbtransactions;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.EJB;
+import javax.ejb.MessageDriven;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.ObjectMessage;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at MessageDriven(activationConfig =
+        {
+        @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
+        @ActivationConfigProperty(propertyName="destination", propertyValue="queue/badcreationmdb")
+        })
+public class BadCreationMDB implements MessageListener
+{
+   private static final Logger log = Logger.getLogger(BadCreationMDB.class);
+   
+   @EJB(mappedName="bogus") StatelessFacade stateless;
+   
+   public void onMessage(Message recvMsg)
+   {    
+      log.info("*** onMessage " + recvMsg);
+   }
+}

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdbtransactions/unit/MDBUnitTestCase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdbtransactions/unit/MDBUnitTestCase.java	2007-05-31 17:16:51 UTC (rev 63279)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdbtransactions/unit/MDBUnitTestCase.java	2007-05-31 17:50:40 UTC (rev 63280)
@@ -73,6 +73,50 @@
       assertTrue(status.caughtRollback());
    }
    
+   public void testRollback() throws Exception
+   {
+      TestStatus status = (TestStatus)getInitialContext().lookup("TestStatusBean/remote");
+      status.clear();
+      
+      sendMessages("queue/rollbackmdbtest", 1);
+      
+      Thread.sleep(5000);
+      
+      Queue queue = (Queue) getInitialContext().lookup("queue/DLQ");
+      QueueConnectionFactory factory = getQueueConnectionFactory();
+      QueueConnection connection = factory.createQueueConnection();
+      connection.start();
+      QueueSession session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+      QueueReceiver receiver = session.createReceiver(queue);
+      Message message = receiver.receiveNoWait();
+      assertNotNull(message);
+      
+      session.close();
+      connection.close();
+   }
+   
+   public void testBadCreation() throws Exception
+   {
+      TestStatus status = (TestStatus)getInitialContext().lookup("TestStatusBean/remote");
+      status.clear();
+      
+      sendMessages("queue/badcreationmdb", 1);
+      
+      Thread.sleep(5000);
+      
+      Queue queue = (Queue) getInitialContext().lookup("queue/DLQ");
+      QueueConnectionFactory factory = getQueueConnectionFactory();
+      QueueConnection connection = factory.createQueueConnection();
+      connection.start();
+      QueueSession session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+      QueueReceiver receiver = session.createReceiver(queue);
+      Message message = receiver.receiveNoWait();
+      assertNotNull(message);
+      
+      session.close();
+      connection.close();
+   }
+   
    protected void sendMessages(String queueName, int numMessages) throws Exception
    {
       QueueConnection connection = null;
@@ -109,28 +153,6 @@
       connection.close();
    }
    
-   public void testRollback() throws Exception
-   {
-      TestStatus status = (TestStatus)getInitialContext().lookup("TestStatusBean/remote");
-      status.clear();
-      
-      sendMessages("queue/rollbackmdbtest", 1);
-      
-      Thread.sleep(5000);
-      
-      Queue queue = (Queue) getInitialContext().lookup("queue/DLQ");
-      QueueConnectionFactory factory = getQueueConnectionFactory();
-      QueueConnection connection = factory.createQueueConnection();
-      connection.start();
-      QueueSession session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
-      QueueReceiver receiver = session.createReceiver(queue);
-      Message message = receiver.receiveNoWait();
-      assertNotNull(message);
-      
-      session.close();
-      connection.close();
-   }
-   
    protected QueueConnectionFactory getQueueConnectionFactory()
       throws Exception
    {




More information about the jboss-cvs-commits mailing list