[jboss-cvs] JBossAS SVN: r64746 - in branches/JBPAPP_4_2/ejb3: src/resources/test-configs and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Aug 21 13:24:32 EDT 2007


Author: bdecoste
Date: 2007-08-21 13:24:32 -0400 (Tue, 21 Aug 2007)
New Revision: 64746

Added:
   branches/JBPAPP_4_2/ejb3/src/resources/test-configs/clusteredjms/
   branches/JBPAPP_4_2/ejb3/src/resources/test-configs/clusteredjms/deploy-hasingleton/
   branches/JBPAPP_4_2/ejb3/src/resources/test-configs/clusteredjms/deploy-hasingleton/mdbtest-service.xml
   branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/
   branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/QueueTestMDB.java
   branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/TestStatus.java
   branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/TestStatusBean.java
   branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/unit/
   branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/unit/MDBUnitTestCase.java
Modified:
   branches/JBPAPP_4_2/ejb3/build-test.xml
Log:
[JBPAPP-260] merge of [EJBTHREE-975] test

Modified: branches/JBPAPP_4_2/ejb3/build-test.xml
===================================================================
--- branches/JBPAPP_4_2/ejb3/build-test.xml	2007-08-21 16:51:37 UTC (rev 64745)
+++ branches/JBPAPP_4_2/ejb3/build-test.xml	2007-08-21 17:24:32 UTC (rev 64746)
@@ -1539,6 +1539,19 @@
          </classes>
       </war>
    </target>
+	
+   <target name="clusteredjms"
+      description="Builds all jar files."
+      depends="compile-classes">
+      
+      <mkdir dir="${build.lib}"/>
+      
+      <jar jarfile="${build.lib}/clusteredjms-test.jar">
+         <fileset dir="${build.classes}">
+            <include name="org/jboss/ejb3/test/clusteredjms/*.class"/>
+         </fileset>
+      </jar>
+   </target>
 
    <target name="servlet"
       description="Builds all jar files."
@@ -3285,7 +3298,7 @@
 	  </copy>
    </target>
    
-   <target name="jars" depends="statelesscreation, defaultremotebindings, localfromremote, entityoptimisticlocking, concurrentnaming, propertyreplacement, persistenceunits, invalidtxmdb, descriptortypo, libdeployment, homeinterface, timestampentity, servicexmbean, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader, 
+   <target name="jars" depends="statelesscreation, defaultremotebindings, localfromremote, clusteredjms, entityoptimisticlocking, concurrentnaming, propertyreplacement, persistenceunits, invalidtxmdb, descriptortypo, libdeployment, homeinterface, timestampentity, servicexmbean, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader, 
       circulardependency, jsp, timerdependency, servicedependency, servlet, stateless14, webservices, ear, ejbthree440, 
       ejbthree454, ejbthree653, ejbthree670, ejbthree712, ejbthree724, ejbthree751, ejbthree832, ejbthree921,
       ejbthree959, ejbthree963,
@@ -3563,6 +3576,7 @@
       <antcall target="ssl-advanced-test"  inheritRefs="true"/>
       <antcall target="jacc-test" inheritRefs="true"/>
       <antcall target="clustered-tests" inheritRefs="true"/>
+	  <antcall target="clustered-jms-test" inheritRefs="true"/>
       <antcall target="invoker-test"  inheritRefs="true"/>
       <antcall target="iiop-tests"  inheritRefs="true"/>
       <antcall target="arjuna-test"  inheritRefs="true"/>
@@ -4193,7 +4207,41 @@
       <stop-jboss url="${node0.jndi.port1.url}" jboss.dist="${ejb3.dist}"/>
 
    </target>
+	
+   <target name="clustered-jms-test">
+      <create-config baseconf="all" newconf="clusteredjms">
+         <patternset>
+	        <include name="conf/**"/>
+	        <include name="deploy*/**"/>
+	        <include name="lib/**"/>
+            <include name="deploy-hasingleton/**"/>
+         </patternset>
+      </create-config>
+      <create-config baseconf="all" newconf="clusteredjms2">
+         <patternset>
+	        <include name="conf/**"/>
+	        <include name="deploy*/**"/>
+	        <include name="lib/**"/>
+            <include name="deploy-hasingleton/**"/>
+            <exclude name="deploy-hasingleton/mdbtest-service.xml"/>
+         </patternset>
+      </create-config>
+      
+      <start-jboss conf="clusteredjms" host="${node0}" jvmargs="${ejb3.jboss.jvmargs}"/>
+	  <start-jboss conf="clusteredjms2" host="${node1}" jvmargs="${ejb3.jboss.jvmargs}"/>
+	  
+	  <antcall target="tests-clustering-wait"/> 
+	
+	  <antcall target="test-with-jvmargs" inheritRefs="true">
+         <param name="test" value="clusteredjms"/>
+         <param name="jvmargs" value=""/>
+      </antcall>
+      
+      <stop-jboss url="${node0.jndi.url}" jboss.dist="${ejb3.dist}"/>
+      <stop-jboss url="${node1.jndi.url}" jboss.dist="${ejb3.dist}"/>
 
+   </target>
+
    <target name="tests-clustering-wait" unless="${tests.clustering.skip.startup}">
       <echo message="Waiting for nodes to start..."/>
       <waitfor maxwait="120" maxwaitunit="second"

Added: branches/JBPAPP_4_2/ejb3/src/resources/test-configs/clusteredjms/deploy-hasingleton/mdbtest-service.xml
===================================================================
--- branches/JBPAPP_4_2/ejb3/src/resources/test-configs/clusteredjms/deploy-hasingleton/mdbtest-service.xml	                        (rev 0)
+++ branches/JBPAPP_4_2/ejb3/src/resources/test-configs/clusteredjms/deploy-hasingleton/mdbtest-service.xml	2007-08-21 17:24:32 UTC (rev 64746)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+   <mbean code="org.jboss.mq.server.jmx.Queue"
+      name="jboss.mq.destination:service=Queue,name=queuetest">
+      <attribute name="JNDIName">queue/mdbtest</attribute>
+      <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+   </mbean>
+</server>

Added: branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/QueueTestMDB.java
===================================================================
--- branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/QueueTestMDB.java	                        (rev 0)
+++ branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/QueueTestMDB.java	2007-08-21 17:24:32 UTC (rev 64746)
@@ -0,0 +1,63 @@
+/*
+ * 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.clusteredjms;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+import javax.ejb.MessageDriven;
+import javax.ejb.MessageDrivenContext;
+import javax.ejb.EJB;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.naming.InitialContext;
+
+import javax.annotation.security.RunAs;
+
+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/mdbtest")
+        })
+public class QueueTestMDB
+implements MessageListener
+{
+   private static final Logger log = Logger.getLogger(QueueTestMDB.class);
+   
+   public int count = 0;
+
+   public void onMessage(Message recvMsg)
+   {
+      ++TestStatusBean.queueRan;
+      
+      System.out.println("+++ QueueTestMDB onMessage " + TestStatusBean.queueRan + " " + count + " " + this);
+   }
+}

Added: branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/TestStatus.java
===================================================================
--- branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/TestStatus.java	                        (rev 0)
+++ branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/TestStatus.java	2007-08-21 17:24:32 UTC (rev 64746)
@@ -0,0 +1,34 @@
+/*
+ * 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.clusteredjms;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface TestStatus
+{
+   void clear();
+
+   int queueFired();
+   
+   String testInjection() throws Exception;
+}

Added: branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/TestStatusBean.java
===================================================================
--- branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/TestStatusBean.java	                        (rev 0)
+++ branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/TestStatusBean.java	2007-08-21 17:24:32 UTC (rev 64746)
@@ -0,0 +1,58 @@
+/*
+ * 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.clusteredjms;
+
+import javax.annotation.Resource;
+import javax.ejb.Stateless;
+import javax.ejb.Remote;
+import javax.jms.Queue;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateless
+ at Remote(TestStatus.class)
+public class TestStatusBean implements TestStatus
+{
+   private static final Logger log = Logger.getLogger(TestStatusBean.class);
+   
+   public static int queueRan = 0;
+   
+   @Resource(mappedName="queue/mdbtest") Queue queue;
+
+   public void clear()
+   {
+      queueRan = 0;
+   }
+
+   public int queueFired()
+   {
+      return queueRan;
+   }
+   
+   public String testInjection() throws Exception
+   {
+      return queue.getQueueName();
+   }
+}

Added: branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/unit/MDBUnitTestCase.java
===================================================================
--- branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/unit/MDBUnitTestCase.java	                        (rev 0)
+++ branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/unit/MDBUnitTestCase.java	2007-08-21 17:24:32 UTC (rev 64746)
@@ -0,0 +1,135 @@
+/*
+ * 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.clusteredjms.unit;
+
+import java.util.Properties;
+
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.TextMessage;
+import javax.jms.TopicConnectionFactory;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.clusteredjms.TestStatus;
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class MDBUnitTestCase extends JBossTestCase
+{
+   private static final Logger log = Logger.getLogger(MDBUnitTestCase.class);
+
+   public MDBUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testQueue() 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/mdbtest");
+      QueueConnectionFactory factory = getQueueConnectionFactory();
+      cnn = factory.createQueueConnection();
+      session = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+
+      TextMessage msg = session.createTextMessage("Hello World");
+
+      sender = session.createSender(queue);
+      sender.send(msg);
+      sender.send(msg);
+      sender.send(msg);
+      sender.send(msg);
+      sender.send(msg);
+      session.close();
+      cnn.close();
+
+      Thread.sleep(2000);
+      assertEquals(5, status.queueFired());
+      
+      assertEquals("queuetest", status.testInjection());
+   }
+
+   protected QueueConnectionFactory getQueueConnectionFactory()
+         throws Exception
+   {
+      try
+      {
+         return (QueueConnectionFactory) getInitialContext().lookup(
+               "ConnectionFactory");
+      } catch (NamingException e)
+      {
+         return (QueueConnectionFactory) getInitialContext().lookup(
+               "java:/ConnectionFactory");
+      }
+   }
+
+   protected TopicConnectionFactory getTopicConnectionFactory()
+         throws Exception
+   {
+      try
+      {
+         return (TopicConnectionFactory) getInitialContext().lookup(
+               "ConnectionFactory");
+      } catch (NamingException e)
+      {
+         return (TopicConnectionFactory) getInitialContext().lookup(
+               "java:/ConnectionFactory");
+      }
+   }
+
+   protected void clear(TestStatus status)
+   {
+      status.clear();
+   }
+   
+   protected InitialContext getInitialContext() throws Exception
+   {
+      Properties env = new Properties();
+      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
+      env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
+      //env.put(Context.PROVIDER_URL, "localhost:1100");
+      
+      return new InitialContext(env);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(MDBUnitTestCase.class, "clusteredjms-test.jar");
+   }
+
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list