[jboss-cvs] JBossAS SVN: r66794 - in branches/Branch_4_2/testsuite: src/main/org/jboss/test and 7 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Nov 6 13:02:53 EST 2007
Author: adrian at jboss.org
Date: 2007-11-06 13:02:53 -0500 (Tue, 06 Nov 2007)
New Revision: 66794
Added:
branches/Branch_4_2/testsuite/src/main/org/jboss/test/resendmdb/
branches/Branch_4_2/testsuite/src/main/org/jboss/test/resendmdb/beans/
branches/Branch_4_2/testsuite/src/main/org/jboss/test/resendmdb/beans/ResendMDB.java
branches/Branch_4_2/testsuite/src/main/org/jboss/test/resendmdb/beans/RollbackMDB.java
branches/Branch_4_2/testsuite/src/main/org/jboss/test/resendmdb/test/
branches/Branch_4_2/testsuite/src/main/org/jboss/test/resendmdb/test/ResendMDBUnitTestCase.java
branches/Branch_4_2/testsuite/src/resources/resendmdb/
branches/Branch_4_2/testsuite/src/resources/resendmdb/META-INF/
branches/Branch_4_2/testsuite/src/resources/resendmdb/META-INF/ejb-jar.xml
branches/Branch_4_2/testsuite/src/resources/resendmdb/META-INF/jboss.xml
Modified:
branches/Branch_4_2/testsuite/imports/sections/mdb.xml
branches/Branch_4_2/testsuite/src/main/org/jboss/test/messagedriven/beans/TestMessageDriven.java
Log:
[JBAS-4945] - Add a test for messages bouncing around MDBs both via the DLQ and resends
Modified: branches/Branch_4_2/testsuite/imports/sections/mdb.xml
===================================================================
--- branches/Branch_4_2/testsuite/imports/sections/mdb.xml 2007-11-06 17:02:00 UTC (rev 66793)
+++ branches/Branch_4_2/testsuite/imports/sections/mdb.xml 2007-11-06 18:02:53 UTC (rev 66794)
@@ -62,4 +62,20 @@
</jar>
</target>
+
+ <!-- messagedriven test -->
+ <target name="_jars-resendmdb">
+ <mkdir dir="${build.lib}"/>
+
+ <!-- build testresendmdb.jar -->
+ <jar destfile="${build.lib}/testresendmdb.jar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/test/resendmdb/beans/**"/>
+ </fileset>
+ <fileset dir="${build.resources}/resendmdb">
+ <include name="**/*.xml"/>
+ </fileset>
+ </jar>
+
+ </target>
</project>
Modified: branches/Branch_4_2/testsuite/src/main/org/jboss/test/messagedriven/beans/TestMessageDriven.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/messagedriven/beans/TestMessageDriven.java 2007-11-06 17:02:00 UTC (rev 66793)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/messagedriven/beans/TestMessageDriven.java 2007-11-06 18:02:53 UTC (rev 66794)
@@ -31,7 +31,6 @@
import javax.jms.MessageListener;
import javax.transaction.Transaction;
-import org.jboss.ejb.plugins.jms.DLQHandler;
import org.jboss.logging.Logger;
import org.jboss.mx.util.MBeanProxyExt;
import org.jboss.test.messagedriven.mbeans.TestMessageDrivenManagementMBean;
@@ -72,7 +71,7 @@
{
try
{
- if (message.getStringProperty(DLQHandler.JBOSS_ORIG_DESTINATION) != null)
+ if (message.getStringProperty("JBOSS_ORIG_DESTINATION") != null)
return true;
}
catch (JMSException e)
Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/resendmdb/beans/ResendMDB.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/resendmdb/beans/ResendMDB.java (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/resendmdb/beans/ResendMDB.java 2007-11-06 18:02:53 UTC (rev 66794)
@@ -0,0 +1,92 @@
+/*
+ * 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.test.resendmdb.beans;
+
+import javax.ejb.MessageDrivenBean;
+import javax.ejb.MessageDrivenContext;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.naming.InitialContext;
+
+import org.jboss.logging.Logger;
+
+/**
+ * An MDB that resends a message
+ *
+ * @author <a href="mailto:adrian at jboss.com>Adrian Brock</a>
+ * @version <tt>$Revision: 1.4</tt>
+ */
+public class ResendMDB implements MessageDrivenBean, MessageListener
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ protected static final Logger log = Logger.getLogger(ResendMDB.class);
+
+ protected MessageDrivenContext ctx;
+
+ public void onMessage(Message message)
+ {
+ log.info("Resending message: " + message);
+ try
+ {
+ InitialContext context = new InitialContext();
+ String name = (String) context.lookup("java:comp/env/queueName");
+ Queue queue = (Queue) context.lookup(name);
+ ConnectionFactory cf = (ConnectionFactory) context.lookup("java:/JmsXA");
+ Connection c = cf.createConnection();
+ try
+ {
+ Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer p = s.createProducer(queue);
+ p.send(message);
+ }
+ finally
+ {
+ c.close();
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("Error", e);
+ }
+
+ }
+
+ public void ejbCreate()
+ {
+ }
+
+ public void ejbRemove()
+ {
+ }
+
+ public void setMessageDrivenContext(MessageDrivenContext ctx)
+ {
+ this.ctx = ctx;
+ }
+}
Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/resendmdb/beans/RollbackMDB.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/resendmdb/beans/RollbackMDB.java (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/resendmdb/beans/RollbackMDB.java 2007-11-06 18:02:53 UTC (rev 66794)
@@ -0,0 +1,64 @@
+/*
+ * 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.test.resendmdb.beans;
+
+import javax.ejb.MessageDrivenBean;
+import javax.ejb.MessageDrivenContext;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+
+import org.jboss.logging.Logger;
+
+/**
+ * An MDB that always rollsback
+ *
+ * @author <a href="mailto:adrian at jboss.com>Adrian Brock</a>
+ * @version <tt>$Revision: 1.4</tt>
+ */
+public class RollbackMDB implements MessageDrivenBean, MessageListener
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ protected static final Logger log = Logger.getLogger(RollbackMDB.class);
+
+ protected MessageDrivenContext ctx;
+
+ public void onMessage(Message message)
+ {
+ log.info("Got message: " + message);
+ ctx.setRollbackOnly();
+ }
+
+ public void ejbCreate()
+ {
+ }
+
+ public void ejbRemove()
+ {
+ }
+
+ public void setMessageDrivenContext(MessageDrivenContext ctx)
+ {
+ this.ctx = ctx;
+ }
+}
Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/resendmdb/test/ResendMDBUnitTestCase.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/resendmdb/test/ResendMDBUnitTestCase.java (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/resendmdb/test/ResendMDBUnitTestCase.java 2007-11-06 18:02:53 UTC (rev 66794)
@@ -0,0 +1,98 @@
+/*
+ * 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.test.resendmdb.test;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestCase;
+
+/**
+ * A fairly complicated test that bounces a message around mdbs
+ * both via the DLQ and deliberate resends.
+ *
+ * @author <a href="mailto:adrian at jboss.com>Adrian Brock</a>
+ * @version <tt>$Revision: 1.4</tt>
+ */
+public class ResendMDBUnitTestCase extends JBossTestCase
+{
+ public ResendMDBUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(ResendMDBUnitTestCase.class, "testresendmdb.jar");
+ }
+
+ public void testResends() throws Exception
+ {
+ InitialContext ctx = getInitialContext();
+ Queue a = (Queue) ctx.lookup("queue/A");
+ Queue b = (Queue) ctx.lookup("queue/B");
+ Queue c = (Queue) ctx.lookup("queue/C");
+ Queue d = (Queue) ctx.lookup("queue/D");
+ ConnectionFactory cf = (ConnectionFactory) ctx.lookup("ConnectionFactory");
+ Connection connection = cf.createConnection();
+ try
+ {
+ Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ connection.start();
+
+ // Clear all the queues
+ MessageConsumer r = s.createConsumer(a);
+ while (r.receiveNoWait() != null);
+ r.close();
+ r = s.createConsumer(b);
+ while (r.receiveNoWait() != null);
+ r.close();
+ r = s.createConsumer(c);
+ while (r.receiveNoWait() != null);
+ r.close();
+ r = s.createConsumer(d);
+ while (r.receiveNoWait() != null);
+ r.close();
+
+ MessageProducer p = s.createProducer(a);
+ Message m = s.createTextMessage("Test");
+ p.send(m);
+
+ r = s.createConsumer(d);
+ m = r.receive(20000l);
+ if (m == null)
+ fail("No message in 20 seconds");
+ }
+ finally
+ {
+ connection.close();
+ }
+ }
+}
Added: branches/Branch_4_2/testsuite/src/resources/resendmdb/META-INF/ejb-jar.xml
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/resendmdb/META-INF/ejb-jar.xml (rev 0)
+++ branches/Branch_4_2/testsuite/src/resources/resendmdb/META-INF/ejb-jar.xml 2007-11-06 18:02:53 UTC (rev 66794)
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"
+ version="2.1">
+
+ <enterprise-beans>
+
+ <message-driven>
+ <ejb-name>MDBA</ejb-name>
+ <ejb-class>org.jboss.test.resendmdb.beans.RollbackMDB</ejb-class>
+ <messaging-type>javax.jms.MessageListener</messaging-type>
+ <transaction-type>Container</transaction-type>
+ <activation-config>
+ <activation-config-property>
+ <activation-config-property-name>destination</activation-config-property-name>
+ <activation-config-property-value>queue/A</activation-config-property-value>
+ </activation-config-property>
+ <activation-config-property>
+ <activation-config-property-name>destinationType</activation-config-property-name>
+ <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
+ </activation-config-property>
+ <activation-config-property>
+ <activation-config-property-name>DLQJNDIName</activation-config-property-name>
+ <activation-config-property-value>queue/B</activation-config-property-value>
+ </activation-config-property>
+ </activation-config>
+ </message-driven>
+
+ <message-driven>
+ <ejb-name>MDBB</ejb-name>
+ <ejb-class>org.jboss.test.resendmdb.beans.RollbackMDB</ejb-class>
+ <messaging-type>javax.jms.MessageListener</messaging-type>
+ <transaction-type>Container</transaction-type>
+ <activation-config>
+ <activation-config-property>
+ <activation-config-property-name>destination</activation-config-property-name>
+ <activation-config-property-value>queue/B</activation-config-property-value>
+ </activation-config-property>
+ <activation-config-property>
+ <activation-config-property-name>destinationType</activation-config-property-name>
+ <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
+ </activation-config-property>
+ </activation-config>
+ <activation-config-property>
+ <activation-config-property-name>DLQJNDIName</activation-config-property-name>
+ <activation-config-property-value>queue/C</activation-config-property-value>
+ </activation-config-property>
+ </message-driven>
+
+ <message-driven>
+ <ejb-name>MDBC</ejb-name>
+ <ejb-class>org.jboss.test.resendmdb.beans.ResendMDB</ejb-class>
+ <messaging-type>javax.jms.MessageListener</messaging-type>
+ <transaction-type>Container</transaction-type>
+ <env-entry>
+ <env-entry-name>queueName</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>queue/D</env-entry-value>
+ </env-entry>
+ <activation-config>
+ <activation-config-property>
+ <activation-config-property-name>destination</activation-config-property-name>
+ <activation-config-property-value>queue/C</activation-config-property-value>
+ </activation-config-property>
+ <activation-config-property>
+ <activation-config-property-name>destinationType</activation-config-property-name>
+ <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
+ </activation-config-property>
+ </activation-config>
+ </message-driven>
+
+ </enterprise-beans>
+
+ <assembly-descriptor>
+
+ <container-transaction>
+ <method>
+ <ejb-name>MDBA</ejb-name>
+ <method-name>*</method-name>
+ </method>
+ <trans-attribute>Required</trans-attribute>
+ </container-transaction>
+
+ <container-transaction>
+ <method>
+ <ejb-name>MDBB</ejb-name>
+ <method-name>*</method-name>
+ </method>
+ <trans-attribute>Required</trans-attribute>
+ </container-transaction>
+
+ <container-transaction>
+ <method>
+ <ejb-name>MDBC</ejb-name>
+ <method-name>*</method-name>
+ </method>
+ <trans-attribute>Required</trans-attribute>
+ </container-transaction>
+
+ </assembly-descriptor>
+
+</ejb-jar>
Added: branches/Branch_4_2/testsuite/src/resources/resendmdb/META-INF/jboss.xml
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/resendmdb/META-INF/jboss.xml (rev 0)
+++ branches/Branch_4_2/testsuite/src/resources/resendmdb/META-INF/jboss.xml 2007-11-06 18:02:53 UTC (rev 66794)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE jboss PUBLIC
+ "-//JBoss//DTD JBOSS 3.2//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
+
+<jboss>
+ <enterprise-beans>
+ <message-driven>
+ <ejb-name>MDBA</ejb-name>
+ <invoker-bindings>
+ <invoker>
+ <invoker-proxy-binding-name>jms-message-inflow-driven-bean</invoker-proxy-binding-name>
+ </invoker>
+ </invoker-bindings>
+ </message-driven>
+ <message-driven>
+ <ejb-name>MDBB</ejb-name>
+ <invoker-bindings>
+ <invoker>
+ <invoker-proxy-binding-name>jms-message-inflow-driven-bean</invoker-proxy-binding-name>
+ </invoker>
+ </invoker-bindings>
+ </message-driven>
+ <message-driven>
+ <ejb-name>MDBC</ejb-name>
+ <invoker-bindings>
+ <invoker>
+ <invoker-proxy-binding-name>jms-message-inflow-driven-bean</invoker-proxy-binding-name>
+ </invoker>
+ </invoker-bindings>
+ </message-driven>
+ </enterprise-beans>
+</jboss>
More information about the jboss-cvs-commits
mailing list