[jboss-cvs] JBossAS SVN: r59422 - in trunk/ejb3/src: main/org/jboss/ejb3/tx resources/test/mdb resources/test/reference21_30/META-INF test/org/jboss/ejb3/test/mdb test/org/jboss/ejb3/test/mdb/unit test/org/jboss/ejb3/test/reference21_30
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jan 8 18:18:45 EST 2007
Author: bdecoste
Date: 2007-01-08 18:18:40 -0500 (Mon, 08 Jan 2007)
New Revision: 59422
Added:
trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/TransactionQueueTestMDB.java
Modified:
trunk/ejb3/src/main/org/jboss/ejb3/tx/TxInterceptorFactory.java
trunk/ejb3/src/resources/test/mdb/mdbtest-service.xml
trunk/ejb3/src/resources/test/reference21_30/META-INF/ejb-jar2.xml
trunk/ejb3/src/resources/test/reference21_30/META-INF/jboss2.xml
trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/TestStatus.java
trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/TestStatusBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MDBUnitTestCase.java
trunk/ejb3/src/test/org/jboss/ejb3/test/reference21_30/Test2Bean.java
Log:
fix and test for class @TransactionTimeout. Additional tests on accessing 30 beans from 21 beans
Modified: trunk/ejb3/src/main/org/jboss/ejb3/tx/TxInterceptorFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/tx/TxInterceptorFactory.java 2007-01-08 20:04:36 UTC (rev 59421)
+++ trunk/ejb3/src/main/org/jboss/ejb3/tx/TxInterceptorFactory.java 2007-01-08 23:18:40 UTC (rev 59422)
@@ -84,6 +84,10 @@
protected int resolveTransactionTimeout(Advisor advisor, Method method)
{
TransactionTimeout annotation = (TransactionTimeout)advisor.resolveAnnotation(method, TransactionTimeout.class);
+
+ if (annotation == null)
+ annotation = (TransactionTimeout)advisor.resolveAnnotation(TransactionTimeout.class);
+
if (annotation != null)
{
return annotation.value();
Modified: trunk/ejb3/src/resources/test/mdb/mdbtest-service.xml
===================================================================
--- trunk/ejb3/src/resources/test/mdb/mdbtest-service.xml 2007-01-08 20:04:36 UTC (rev 59421)
+++ trunk/ejb3/src/resources/test/mdb/mdbtest-service.xml 2007-01-08 23:18:40 UTC (rev 59422)
@@ -51,6 +51,12 @@
</mbean>
<mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.mq.destination:service=Queue,name=transactionmdbtest">
+ <attribute name="JNDIName">queue/transactionmdbtest</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=expirytest">
<attribute name="JNDIName">queue/expirytest</attribute>
<!-- <attribute name="ExpiryDestination">jboss.mq.destination:name=DLQ,service=Queue</attribute> -->
Modified: trunk/ejb3/src/resources/test/reference21_30/META-INF/ejb-jar2.xml
===================================================================
--- trunk/ejb3/src/resources/test/reference21_30/META-INF/ejb-jar2.xml 2007-01-08 20:04:36 UTC (rev 59421)
+++ trunk/ejb3/src/resources/test/reference21_30/META-INF/ejb-jar2.xml 2007-01-08 23:18:40 UTC (rev 59422)
@@ -15,6 +15,12 @@
<ejb-ref-type>Session</ejb-ref-type>
<home>org.jboss.ejb3.test.reference21_30.Test3Home</home>
<remote>org.jboss.ejb3.test.reference21_30.Test3</remote>
+ </ejb-ref>
+ <ejb-ref>
+ <ejb-ref-name>ejb/Test3Home</ejb-ref-name>
+ <ejb-ref-type>Session</ejb-ref-type>
+ <home>org.jboss.ejb3.test.reference21_30.Test3Home</home>
+ <remote>org.jboss.ejb3.test.reference21_30.Test3</remote>
</ejb-ref>
</session>
</enterprise-beans>
Modified: trunk/ejb3/src/resources/test/reference21_30/META-INF/jboss2.xml
===================================================================
--- trunk/ejb3/src/resources/test/reference21_30/META-INF/jboss2.xml 2007-01-08 20:04:36 UTC (rev 59421)
+++ trunk/ejb3/src/resources/test/reference21_30/META-INF/jboss2.xml 2007-01-08 23:18:40 UTC (rev 59422)
@@ -6,9 +6,13 @@
<ejb-name>ejb/Test2</ejb-name>
<jndi-name>Test2</jndi-name>
<ejb-ref>
- <ejb-ref-name>ejb/Test3</ejb-ref-name>
- <jndi-name>Test3</jndi-name>
- </ejb-ref>
+ <ejb-ref-name>ejb/Test3Home</ejb-ref-name>
+ <jndi-name>Test3Home</jndi-name>
+ </ejb-ref>
+ <ejb-ref>
+ <ejb-ref-name>ejb/Test3</ejb-ref-name>
+ <jndi-name>Test3</jndi-name>
+ </ejb-ref>
</session>
</enterprise-beans>
</jboss>
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/TestStatus.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/TestStatus.java 2007-01-08 20:04:36 UTC (rev 59421)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/TestStatus.java 2007-01-08 23:18:40 UTC (rev 59422)
@@ -50,6 +50,8 @@
int cmtQueueRan();
+ int transactionQueueRan();
+
int messageCount();
boolean interceptedTopic();
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/TestStatusBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/TestStatusBean.java 2007-01-08 20:04:36 UTC (rev 59421)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/TestStatusBean.java 2007-01-08 23:18:40 UTC (rev 59422)
@@ -47,6 +47,7 @@
public static int topicRan = 0;
public static int bmtQueueRan = 0;
static int cmtQueueRan = 0;
+ public static int transactionQueueRan = 0;
public static int messageCount = 0;
public static boolean interceptedTopic = false;
public static boolean interceptedQueue = false;
@@ -66,6 +67,7 @@
overrideDefaultedQueueRan = 0;
messageCount = 0;
nondurableQueueRan = 0;
+ transactionQueueRan = 0;
interceptedTopic = false;
interceptedQueue = false;
postConstruct = false;
@@ -92,6 +94,11 @@
return defaultedQueueRan;
}
+ public int transactionQueueRan()
+ {
+ return transactionQueueRan;
+ }
+
public int nondurableQueueFired()
{
return nondurableQueueRan;
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/TransactionQueueTestMDB.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/TransactionQueueTestMDB.java 2007-01-08 20:04:36 UTC (rev 59421)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/TransactionQueueTestMDB.java 2007-01-08 23:18:40 UTC (rev 59422)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.test.mdb;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.ejb.MessageDrivenContext;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+
+import javax.annotation.security.RunAs;
+import javax.annotation.Resource;
+
+import org.jboss.annotation.ejb.TransactionTimeout;
+import org.jboss.annotation.security.SecurityDomain;
+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/transactionmdbtest"),
+ @ActivationConfigProperty(propertyName="maxSession", propertyValue="1")
+ })
+ at TransactionTimeout(1)
+//@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+public class TransactionQueueTestMDB implements MessageListener
+{
+ private static final Logger log = Logger.getLogger(TransactionQueueTestMDB.class);
+
+
+ public void onMessage(Message recvMsg)
+ {
+ System.out.println("*** TransactionQueueTestMDB onMessage " + this);
+
+ try
+ {
+ Thread.sleep(1000 * 60 * 6);
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+
+ TestStatusBean.transactionQueueRan++;
+ }
+}
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MDBUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MDBUnitTestCase.java 2007-01-08 20:04:36 UTC (rev 59421)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MDBUnitTestCase.java 2007-01-08 23:18:40 UTC (rev 59422)
@@ -564,7 +564,44 @@
Thread.sleep(2000);
assertEquals(1, status.queueFired());
}
+
+ public void testTransactionTimeout() throws Exception
+ {
+ TestStatus status = (TestStatus) getInitialContext().lookup(
+ "TestStatusBean/remote");
+ clear(status);
+ QueueConnection cnn = null;
+ QueueSender sender = null;
+ QueueSession session = null;
+ Queue queue = (Queue) getInitialContext().lookup("queue/transactionmdbtest");
+ QueueConnectionFactory factory = getQueueConnectionFactory();
+ cnn = factory.createQueueConnection();
+ cnn.start();
+ session = cnn.createQueueSession(true, QueueSession.AUTO_ACKNOWLEDGE);
+
+ TextMessage msg = session.createTextMessage("Hello World");
+
+ sender = session.createSender(queue);
+
+ sender.send(msg);
+ session.commit();
+
+ Thread.sleep(1000 * 60 * 7);
+ assertEquals(1, status.transactionQueueRan());
+
+ msg = session.createTextMessage("Hello World II");
+ sender.send(msg);
+ session.commit();
+
+ Thread.sleep(1000 * 60 * 7);
+ assertEquals(2, status.transactionQueueRan());
+
+ session.close();
+ cnn.close();
+ }
+
+
private List list(QueueSession session, Queue queue) throws Exception
{
QueueBrowser browser = session.createBrowser(queue);
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/reference21_30/Test2Bean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/reference21_30/Test2Bean.java 2007-01-08 20:04:36 UTC (rev 59421)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/reference21_30/Test2Bean.java 2007-01-08 23:18:40 UTC (rev 59422)
@@ -1,24 +1,24 @@
/*
- * 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.
- */
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.test.reference21_30;
import javax.ejb.SessionContext;
@@ -35,18 +35,15 @@
{
private static final Logger log = Logger.getLogger(Test2Bean.class);
- public void testAccess()
+ public void testAccess() throws Exception
{
- try
- {
- InitialContext jndiContext = new InitialContext();
- Test3 session = (Test3)jndiContext.lookup("java:comp/env/ejb/Test3");
- session.testAccess();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
+ InitialContext jndiContext = new InitialContext();
+ Test3 session = (Test3)jndiContext.lookup("java:comp/env/ejb/Test3");
+ session.testAccess();
+
+ Test3Home home = (Test3Home)jndiContext.lookup("java:comp/env/ejb/Test3Home");
+ session = home.create();
+ session.testAccess();
}
public void ejbCreate()
More information about the jboss-cvs-commits
mailing list