[jboss-cvs] JBoss Messaging SVN: r2364 - in projects/jms-integration: src/etc/deployments and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Feb 19 21:28:10 EST 2007
Author: clebert.suconic at jboss.com
Date: 2007-02-19 21:28:09 -0500 (Mon, 19 Feb 2007)
New Revision: 2364
Added:
projects/jms-integration/src/etc/deployments/mdb-ejb20-durable/
projects/jms-integration/src/etc/deployments/mdb-ejb20-durable/META-INF/
projects/jms-integration/src/etc/deployments/mdb-ejb20-durable/META-INF/ejb-jar.xml
projects/jms-integration/src/etc/deployments/mdb-ejb20-durable/META-INF/jboss.xml
projects/jms-integration/src/main/org/jboss/test/jms/integration/tests/SimpleMDBDurableTest.java
Modified:
projects/jms-integration/build.xml
projects/jms-integration/src/main/org/jboss/test/jms/integration/support/ejb20/TestMessageDriven.java
Log:
Adding MDB for durable subscriptions
Modified: projects/jms-integration/build.xml
===================================================================
--- projects/jms-integration/build.xml 2007-02-20 01:09:59 UTC (rev 2363)
+++ projects/jms-integration/build.xml 2007-02-20 02:28:09 UTC (rev 2364)
@@ -62,7 +62,9 @@
<property name="javac.include.java.runtime" value="true"/>
<property name="javac.fail.onerror" value="true"/>
+ <property name="test-mask" value="*Test"/>
+
<!--
JUnit configuration (values specified in ./build.properties have priority)
-->
@@ -187,6 +189,7 @@
<property name="integration.test.mdb20" value="integration-mdb20.jar"/>
<property name="integration.test.mdb20.selector" value="integration-mdb20-selector.jar"/>
+ <property name="integration.test.mdb20.durable" value="integration-mdb20-durable.jar"/>
<target name="integration-ejb20-jar" depends="compile">
<mkdir dir="${build.tests.lib}"/>
@@ -208,9 +211,19 @@
</jar>
</target>
- <target name="tests-jar" depends="compile, integration-ejb20-jar, integration-ejb20-selector-jar"/>
+ <target name="integration-ejb20-selector-durable" depends="compile">
+ <mkdir dir="${build.tests.lib}"/>
+ <jar jarfile="${build.tests.lib}/${integration.test.mdb20.durable}">
+ <metainf dir="${tests.root}/src/etc/deployments/mdb-ejb20-durable/META-INF"/>
+ <fileset dir="${build.tests.classes}">
+ <include name="org/jboss/test/messaging/integration/mdb/support/ejb20/**"/>
+ </fileset>
+ </jar>
+ </target>
+ <target name="tests-jar" depends="compile, integration-ejb20-jar, integration-ejb20-selector-jar, integration-ejb20-selector-durable"/>
+
<target name="integration-tests"
depends="tests-jar, integration-ejb20-jar"
description="Runs the clustering tests">
@@ -259,7 +272,7 @@
<formatter type="plain" usefile="${junit.formatter.usefile}"/>
<fileset dir="${build.tests.classes}">
- <include name="**/*Test.class"/>
+ <include name="**/*${test-mask}.class"/>
</fileset>
</batchtest>
</junit>
Added: projects/jms-integration/src/etc/deployments/mdb-ejb20-durable/META-INF/ejb-jar.xml
===================================================================
--- projects/jms-integration/src/etc/deployments/mdb-ejb20-durable/META-INF/ejb-jar.xml (rev 0)
+++ projects/jms-integration/src/etc/deployments/mdb-ejb20-durable/META-INF/ejb-jar.xml 2007-02-20 02:28:09 UTC (rev 2364)
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_2_0.dtd">
+
+<ejb-jar>
+ <description>MBean Integration Tests</description>
+ <display-name>QueueAdapter</display-name>
+ <enterprise-beans>
+ <message-driven>
+ <ejb-name>TopicAdapter1</ejb-name>
+ <ejb-class>
+ org.jboss.test.messaging.integration.mdb.support.ejb20.TestMessageDriven
+ </ejb-class>
+ <transaction-type>Container</transaction-type>
+ <message-selector></message-selector>
+ <message-driven-destination>
+ <destination-type>javax.jms.Topic</destination-type>
+ <subscription-durability>
+ Durable
+ </subscription-durability>
+ </message-driven-destination>
+ <resource-ref>
+ <description>A ConnectionFactory</description>
+ <res-ref-name>connectionFactory</res-ref-name>
+ <res-type>javax.jms.ConnectionFactory</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
+ </message-driven>
+ <message-driven>
+ <ejb-name>TopicAdapter2</ejb-name>
+ <ejb-class>
+ org.jboss.test.messaging.integration.mdb.support.ejb20.TestMessageDriven
+ </ejb-class>
+ <transaction-type>Container</transaction-type>
+ <message-selector></message-selector>
+ <message-driven-destination>
+ <destination-type>javax.jms.Topic</destination-type>
+ <subscription-durability>
+ Durable
+ </subscription-durability>
+ </message-driven-destination>
+ <resource-ref>
+ <description>A ConnectionFactory</description>
+ <res-ref-name>connectionFactory</res-ref-name>
+ <res-type>javax.jms.ConnectionFactory</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
+ </message-driven>
+ </enterprise-beans>
+ <assembly-descriptor>
+ <container-transaction>
+ <method>
+ <ejb-name>TopicAdapter1</ejb-name>
+ <method-name>*</method-name>
+ </method>
+ <trans-attribute>Required</trans-attribute>
+ </container-transaction>
+ <container-transaction>
+ <method>
+ <ejb-name>TopicAdapter2</ejb-name>
+ <method-name>*</method-name>
+ </method>
+ <trans-attribute>Required</trans-attribute>
+ </container-transaction>
+ </assembly-descriptor>
+</ejb-jar>
Property changes on: projects/jms-integration/src/etc/deployments/mdb-ejb20-durable/META-INF/ejb-jar.xml
___________________________________________________________________
Name: svn:keywords
+ Id LastChangedDate Author Revision
Added: projects/jms-integration/src/etc/deployments/mdb-ejb20-durable/META-INF/jboss.xml
===================================================================
--- projects/jms-integration/src/etc/deployments/mdb-ejb20-durable/META-INF/jboss.xml (rev 0)
+++ projects/jms-integration/src/etc/deployments/mdb-ejb20-durable/META-INF/jboss.xml 2007-02-20 02:28:09 UTC (rev 2364)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 4.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
+
+<jboss>
+ <enterprise-beans>
+ <message-driven>
+ <ejb-name>TopicAdapter1</ejb-name>
+ <destination-jndi-name>topic/testTopic</destination-jndi-name>
+ <mdb-client-id>mdb</mdb-client-id>
+ <mdb-subscription-id>sub1</mdb-subscription-id>
+ <configuration-name>Standard Message Driven Bean</configuration-name>
+ <resource-ref>
+ <res-ref-name>connectionFactory</res-ref-name>
+ <resource-name>connectionFactory</resource-name>
+ </resource-ref>
+ </message-driven>
+ <message-driven>
+ <ejb-name>TopicAdapter2</ejb-name>
+ <destination-jndi-name>topic/testTopic</destination-jndi-name>
+ <mdb-client-id>mdb2</mdb-client-id>
+ <mdb-subscription-id>sub2</mdb-subscription-id>
+ <configuration-name>Standard Message Driven Bean</configuration-name>
+ <resource-ref>
+ <res-ref-name>connectionFactory</res-ref-name>
+ <resource-name>connectionFactory</resource-name>
+ </resource-ref>
+ </message-driven>
+ </enterprise-beans>
+
+ <resource-managers>
+ <resource-manager>
+ <res-name>connectionFactory</res-name>
+ <res-jndi-name>java:/JmsXA</res-jndi-name>
+ </resource-manager>
+ </resource-managers>
+</jboss>
+
Property changes on: projects/jms-integration/src/etc/deployments/mdb-ejb20-durable/META-INF/jboss.xml
___________________________________________________________________
Name: svn:keywords
+ Id LastChangedDate Author Revision
Modified: projects/jms-integration/src/main/org/jboss/test/jms/integration/support/ejb20/TestMessageDriven.java
===================================================================
--- projects/jms-integration/src/main/org/jboss/test/jms/integration/support/ejb20/TestMessageDriven.java 2007-02-20 01:09:59 UTC (rev 2363)
+++ projects/jms-integration/src/main/org/jboss/test/jms/integration/support/ejb20/TestMessageDriven.java 2007-02-20 02:28:09 UTC (rev 2364)
@@ -98,13 +98,33 @@
public void ejbRemove() throws EJBException
{
+ try
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+ catch (JMSException e)
+ {
+ throw new EJBException (e);
+ }
}
public void onMessage(Message message)
{
- System.out.println("Received message");
+ TextMessage txtMessage = null;
try
{
+ if (message instanceof TextMessage)
+ {
+ txtMessage = (TextMessage)message;
+ System.out.println("Received message " + txtMessage.getText());
+ }
+ else
+ {
+ System.out.println("Received message " + message);
+ }
Destination replyTo = message.getJMSReplyTo();
Session session = null;
try
@@ -114,9 +134,8 @@
TextMessage reply = null;
- if (message instanceof TextMessage)
+ if (txtMessage != null)
{
- TextMessage txtMessage = (TextMessage)message;
reply = session.createTextMessage("reply to message " + txtMessage.getText());
}
else
@@ -142,6 +161,12 @@
}
}
+ // I'm not doing anything with this connections... this is just to validate
+ // if there isn't any problem on creating connections (such as classLoading isolations)
+ ConnectionFactory localCF = (ConnectionFactory)ctx.lookup("/ConnectionFactory");
+ Connection conn = localCF.createConnection();
+ conn.close();
+
} catch (Exception e)
{
log.error(e);
Added: projects/jms-integration/src/main/org/jboss/test/jms/integration/tests/SimpleMDBDurableTest.java
===================================================================
--- projects/jms-integration/src/main/org/jboss/test/jms/integration/tests/SimpleMDBDurableTest.java (rev 0)
+++ projects/jms-integration/src/main/org/jboss/test/jms/integration/tests/SimpleMDBDurableTest.java 2007-02-20 02:28:09 UTC (rev 2364)
@@ -0,0 +1,153 @@
+/*
+ * 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.test.messaging.integration.tests;
+
+import org.jboss.test.messaging.integration.MessagingIntegrationTestBase;
+import javax.naming.InitialContext;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.MessageProducer;
+import javax.jms.MessageConsumer;
+import javax.jms.TextMessage;
+import java.util.Random;
+import junit.framework.Test;
+
+/**
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class SimpleMDBDurableTest extends MessagingIntegrationTestBase
+{
+
+ // Constants ------------------------------------------------------------------------------------
+
+ static final String CONNECTION_FACTORY = "ConnectionFactory";
+ static final String TEST_QUEUE = "topic/testTopic";
+ static final String TEST_QUEUE_RESPONSE = "queue/testQueueResponse";
+
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ InitialContext ctx;
+ ConnectionFactory cf;
+ Destination targetDestination;
+ Destination responseDestination;
+ Random random = new Random();
+
+ // Static ---------------------------------------------------------------------------------------
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public SimpleMDBDurableTest(String name)
+ {
+ super(name);
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ public void testSimpleMDB() throws Exception
+ {
+ Connection conn = cf.createConnection();
+ conn.start();
+ Session sess = null;
+
+ try
+ {
+ sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer producer = sess.createProducer(targetDestination);
+ MessageConsumer consumer = sess.createConsumer(responseDestination);
+
+ for (int i=0;i<100;i++)
+ {
+ TextMessage message = sess.createTextMessage("Message " + i);
+ message.setStringProperty("pair", i%2==0?"even":"odd");
+ message.setJMSReplyTo(responseDestination);
+ producer.send(message);
+ }
+
+ Thread.sleep(2000);
+
+ int messagesReceived = 0;
+
+ while (true)
+ {
+ TextMessage message = (TextMessage) consumer.receive(5000);
+ if (message == null)
+ {
+ break;
+ }
+ System.out.println("-----" + message.getText());
+ messagesReceived++;
+ }
+
+ assertEquals(200, messagesReceived);
+
+ }
+ finally
+ {
+ if (conn!=null)
+ {
+ conn.close();
+ }
+ }
+
+ }
+
+ public static Test suite() throws Exception
+ {
+ // This is from JBoss testsuite framework.. it will deploy the MDB before running the test
+ return getDeploySetup(SimpleMDBDurableTest.class, "integration-mdb20-durable.jar");
+ }
+
+
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ ctx = new InitialContext();
+ cf = (ConnectionFactory)ctx.lookup(CONNECTION_FACTORY);
+ targetDestination = (Destination) ctx.lookup(TEST_QUEUE);
+ responseDestination = (Destination) ctx.lookup(TEST_QUEUE_RESPONSE);
+ drainDestination(cf, targetDestination);
+ drainDestination(cf, responseDestination);
+
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+
+}
Property changes on: projects/jms-integration/src/main/org/jboss/test/jms/integration/tests/SimpleMDBDurableTest.java
___________________________________________________________________
Name: svn:keywords
+ Id LastChangedDate Author Revision
More information about the jboss-cvs-commits
mailing list