[jboss-cvs] JBoss Messaging SVN: r2244 - in trunk: tests/src/org/jboss/test/messaging/jms/clustering and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Feb 9 12:36:42 EST 2007


Author: clebert.suconic at jboss.com
Date: 2007-02-09 12:36:42 -0500 (Fri, 09 Feb 2007)
New Revision: 2244

Added:
   trunk/src/etc/server/default/deploy/connection-factory-http.xml
Modified:
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java
   trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java
   trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-759 - adding testcase / changing test framework to support two connection factories at the same time

Added: trunk/src/etc/server/default/deploy/connection-factory-http.xml
===================================================================
--- trunk/src/etc/server/default/deploy/connection-factory-http.xml	                        (rev 0)
+++ trunk/src/etc/server/default/deploy/connection-factory-http.xml	2007-02-09 17:36:42 UTC (rev 2244)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+     Messaging Connection Factories deployment descriptor for HTTP.
+
+     $Id$
+ -->
+
+<server>
+
+
+   <mbean code="org.jboss.jms.server.connectionfactory.ConnectionFactory"
+      name="jboss.messaging.destination:service=HTTPConnectionFactory"
+      xmbean-dd="xmdesc/ConnectionFactory-xmbean.xml">
+      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+      <depends optional-attribute-name="Connector">jboss.messaging:service=Connector,transport=http</depends>
+      <depends>jboss.messaging:service=PostOffice</depends>
+
+      <attribute name="JNDIBindings">
+         <bindings>
+            <binding>/HTTPConnectionFactory</binding>
+            <binding>/HTTPXAConnectionFactory</binding>
+            <binding>java:/HTTPConnectionFactory</binding>
+            <binding>java:/HTTPXAConnectionFactory</binding>
+         </bindings>
+      </attribute>
+
+      <attribute name="Clustered">true</attribute>
+      <attribute name="LoadBalancingFactory">org.jboss.jms.client.plugin.RoundRobinLoadBalancingFactory</attribute>
+   </mbean>
+
+</server>
\ No newline at end of file


Property changes on: trunk/src/etc/server/default/deploy/connection-factory-http.xml
___________________________________________________________________
Name: svn:keywords
   + Id LastChangedDate Author Revision

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java	2007-02-09 16:12:51 UTC (rev 2243)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java	2007-02-09 17:36:42 UTC (rev 2244)
@@ -27,8 +27,10 @@
 import org.jboss.jms.client.JBossConnectionFactory;
 import org.jboss.jms.client.state.ConnectionState;
 import org.jboss.jms.client.delegate.ClientClusteredConnectionFactoryDelegate;
+import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
 import javax.jms.Connection;
 import javax.jms.Session;
+import javax.jms.ConnectionFactory;
 
 /**
  * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
@@ -91,6 +93,63 @@
 
    }
 
+   public void testUpdateMixedConnectionFactory() throws Exception
+   {
+      Connection conn = cf.createConnection();
+      JBossConnectionFactory jbcf = (JBossConnectionFactory)cf;
+
+      ClientClusteredConnectionFactoryDelegate cfDelegate =
+         (ClientClusteredConnectionFactoryDelegate)jbcf.getDelegate();
+
+      assertEquals(3, cfDelegate.getDelegates().length);
+
+      ConnectionFactory httpCF = (ConnectionFactory)ic[0].lookup("/HTTPConnectionFactory");
+      JBossConnectionFactory jbhttpCF = (JBossConnectionFactory) httpCF;
+      
+      Connection httpConn = httpCF.createConnection();
+
+      ClientClusteredConnectionFactoryDelegate httpcfDelegate =
+         (ClientClusteredConnectionFactoryDelegate)jbhttpCF.getDelegate();
+
+      assertEquals(3, httpcfDelegate.getDelegates().length);
+
+
+      validateCFs(cfDelegate, httpcfDelegate);
+
+      Connection conn1 = cf.createConnection();
+      Connection httpConn1 = httpCF.createConnection();
+
+      assertEquals(1, getServerId(conn1));
+      assertEquals(1, getServerId(httpConn1));
+
+      ServerManagement.killAndWait(1);
+
+      log.info("sleeping 5 secs ...");
+      Thread.sleep(5000);
+
+      // first part of the test, verifies if the CF was updated
+      assertEquals(2, cfDelegate.getDelegates().length);
+      assertEquals(2, httpcfDelegate.getDelegates().length);
+
+      validateCFs(cfDelegate, httpcfDelegate);
+
+      conn.close();
+      httpConn.close();
+
+      log.info("sleeping 25 secs ...");
+      Thread.sleep(25000);
+
+      // Second part, verifies a possible racing condition on failoverMap and handleFilover
+
+      log.info("ServerId=" + getServerId(conn1));
+      assertTrue(1 != getServerId(conn1));
+
+      //Session sess = conn1.createSession(true, Session.SESSION_TRANSACTED);
+      conn1.close();
+      httpConn.close();
+
+   }
+
    /**
     * Test if an update on failoverMap on the connectionFactory would
     * cause any problems during failover
@@ -127,7 +186,6 @@
       // first part of the test, verifies if the CF was updated
       assertEquals(2, cfDelegate.getDelegates().length);
 
-      log.info("ServerId=" + getServerId(conn1));
       assertTrue(1 != getServerId(conn1));
 
       conn.close();
@@ -142,6 +200,7 @@
 
    protected void setUp() throws Exception
    {
+      config = "all+http";
       nodeCount = 3;
       super.setUp();
    }
@@ -149,10 +208,33 @@
    protected void tearDown() throws Exception
    {
       super.tearDown();
+      config="all";
    }
 
    // Private --------------------------------------------------------------------------------------
 
+   // Validate if two distinct CFs are valid
+   private void validateCFs(ClientClusteredConnectionFactoryDelegate cfDelegate,
+                            ClientClusteredConnectionFactoryDelegate httpcfDelegate)
+   {
+      ClientConnectionFactoryDelegate delegatesSocket[] = cfDelegate.getDelegates();
+      ClientConnectionFactoryDelegate delegatesHTTP[] = httpcfDelegate.getDelegates();
+
+      log.info("ValidateCFs:");
+
+      assertEquals(delegatesSocket.length, delegatesHTTP.length);
+      for (int i=0;i<delegatesSocket.length;i++)
+      {
+         log.info("DelegateSocket[" + i + "]=" + delegatesSocket[i].getServerLocatorURI());
+         log.info("DelegateHttp[" + i + "]=" + delegatesHTTP[i].getServerLocatorURI());
+         for (int j=0;j<delegatesHTTP.length;j++)
+         {
+            assertFalse(delegatesSocket[i].getServerLocatorURI().
+               equals(delegatesHTTP[j].getServerLocatorURI()));
+         }
+      }
+   }
+
    // Inner classes --------------------------------------------------------------------------------
 
 }

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java	2007-02-09 16:12:51 UTC (rev 2243)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java	2007-02-09 17:36:42 UTC (rev 2244)
@@ -53,6 +53,7 @@
    // Attributes -----------------------------------------------------------------------------------
 
    protected int nodeCount;
+   protected String config = "all";
 
    protected Context[] ic;
    protected Queue queue[];
@@ -94,7 +95,7 @@
          // make sure all servers are created and started; make sure that database is zapped
          // ONLY for the first server, the others rely on values they expect to find in shared
          // tables; don't clear the database for those.
-         ServerManagement.start(i, "all", i == 0);
+         ServerManagement.start(i, config, i == 0);
 
          ServerManagement.deployQueue("testDistributedQueue", i);
          ServerManagement.deployTopic("testDistributedTopic", i);

Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java	2007-02-09 16:12:51 UTC (rev 2243)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java	2007-02-09 17:36:42 UTC (rev 2244)
@@ -130,6 +130,9 @@
 
    public static ObjectName REMOTING_OBJECT_NAME;
 
+   // Used only on testcases where Socket and HTTP are deployed at the same time
+   public static ObjectName HTTP_REMOTING_OBJECT_NAME;
+
    public static String DATA_SOURCE_JNDI_NAME = "java:/DefaultDS";
    public static String TRANSACTION_MANAGER_JNDI_NAME = "java:/TransactionManager";
    public static String USER_TRANSACTION_JNDI_NAME = "UserTransaction";
@@ -137,6 +140,10 @@
 
    public static long HTTP_CONNECTOR_CALLBACK_POLL_PERIOD = 102;
 
+   // List<ObjectName>
+   private List connFactoryObjectNames = new ArrayList();
+
+
    static
    {
       try
@@ -170,6 +177,9 @@
 
          REMOTING_OBJECT_NAME =
          new ObjectName("jboss.messaging:service=Connector,transport=socket");
+
+         HTTP_REMOTING_OBJECT_NAME =
+         new ObjectName("jboss.messaging:service=Connector,transport=http");
       }
       catch(Exception e)
       {
@@ -208,6 +218,7 @@
    private boolean jca;
    private boolean remoting;
    private boolean security;
+   private boolean httpDatasource;
    private boolean multiplexer; // the JGroups channels multiplexer
 
    private List toUnbindAtExit;
@@ -436,7 +447,7 @@
 
          if (remoting)
          {
-            startRemoting(attrOverrides);
+            startRemoting(attrOverrides, config.getRemotingTransport(), REMOTING_OBJECT_NAME);
          }
 
          if (security)
@@ -471,6 +482,48 @@
       }
    }
 
+   public void startDataSources(ServiceAttributeOverrides attrOverrides) throws Exception
+   {
+      deployDatasource("server/default/deploy/connection-factories-service.xml", attrOverrides);
+
+      log.info("httpDatasource=" + httpDatasource);
+      if (httpDatasource)
+      {
+         log.info("Installing HTTP datasource");
+         ServiceAttributeOverrides httpOverride = new ServiceAttributeOverrides();
+         startRemoting(httpOverride, "http", HTTP_REMOTING_OBJECT_NAME);
+         deployDatasource("server/default/deploy/connection-factory-http.xml", attrOverrides);
+      }
+
+      // bind the default JMS provider
+      bindDefaultJMSProvider();
+      // bind the JCA ConnectionFactory
+      bindJCAJMSConnectionFactory();
+   }
+
+   public void stopDatasources() throws Exception
+   {
+      for(Iterator i = connFactoryObjectNames.iterator(); i.hasNext(); )
+      {
+         try
+         {
+            ObjectName on = (ObjectName)i.next();
+            invoke(on, "stop", new Object[0], new String[0]);
+            invoke(on, "destroy", new Object[0], new String[0]);
+            unregisterService(on);
+         }
+         catch (Exception ignore)
+         {
+            //If the serverpeer failed when starting up previously, then only some of the
+            //services may be started. The ones that didn't start will fail when attempting to shut
+            //them down.
+            //Hence we must catch and ignore or we won't shut everything down
+         }
+      }
+      connFactoryObjectNames.clear();
+
+   }
+
    public void stop() throws Exception
    {
 
@@ -478,6 +531,11 @@
 
       stopService(REMOTING_OBJECT_NAME);
 
+      if (httpDatasource)
+      {
+         stopService(HTTP_REMOTING_OBJECT_NAME);
+      }
+
       if (jbossjta)
       {
          if (recoveryManager != null)
@@ -1265,8 +1323,11 @@
       stopService(managedConnFactoryObjectName);
    }
 
-   private void startRemoting(ServiceAttributeOverrides attrOverrides) throws Exception
+   private void startRemoting(ServiceAttributeOverrides attrOverrides,
+                              String transport,
+                              ObjectName objectName) throws Exception
    {
+      log.debug("Starting remoting transport=" + transport + " objectName=" + objectName);
       RemotingJMXWrapper mbean;
       String locatorURI = null;
 
@@ -1276,7 +1337,7 @@
 
       if (attrOverrides != null)
       {
-         overrideMap = attrOverrides.get(REMOTING_OBJECT_NAME);
+         overrideMap = attrOverrides.get(objectName);
 
          if (overrideMap != null)
          {
@@ -1295,8 +1356,6 @@
          //       a JMS ObjectMessage in which case Java serialization is always currently used -
          //       (we could make this configurable)
 
-         String transport = config.getRemotingTransport();
-
          long clientLeasePeriod = 20000;
 
          String marshallers =
@@ -1352,17 +1411,17 @@
       log.debug("Started remoting connector on uri:" + locator.getLocatorURI());
 
       mbean = new RemotingJMXWrapper(locator);
-      mbeanServer.registerMBean(mbean, REMOTING_OBJECT_NAME);
-      mbeanServer.invoke(REMOTING_OBJECT_NAME, "start", new Object[0], new String[0]);
+      mbeanServer.registerMBean(mbean, objectName);
+      mbeanServer.invoke(objectName, "start", new Object[0], new String[0]);
 
       ServerInvocationHandler handler = new JMSServerInvocationHandler();
 
-      mbeanServer.invoke(REMOTING_OBJECT_NAME, "addInvocationHandler",
+      mbeanServer.invoke(objectName, "addInvocationHandler",
                          new Object[] { ServerPeer.REMOTING_JMS_SUBSYSTEM, handler},
                          new String[] { "java.lang.String",
                                         "org.jboss.remoting.ServerInvocationHandler"});
 
-      log.debug("started " + REMOTING_OBJECT_NAME);
+      log.debug("started " + objectName);
    }
 
 
@@ -1574,6 +1633,60 @@
       invoke(nameMultiplexer,"start", new Object[0], new String[0]);
    }
 
+   private void overrideAttributes(ObjectName on, ServiceAttributeOverrides attrOverrides)
+      throws Exception
+   {
+      if (attrOverrides == null)
+      {
+         return;
+      }
+
+      Map sao = attrOverrides.get(on);
+
+      for(Iterator i = sao.entrySet().iterator(); i.hasNext();)
+      {
+         Map.Entry entry = (Map.Entry)i.next();
+         String attrName = (String)entry.getKey();
+         Object attrValue = entry.getValue();
+         setAttribute(on, attrName, attrValue.toString());
+
+      }
+   }
+
+   public void deployDatasource(String connFactoryConfigFile,
+                                ServiceAttributeOverrides attrOverrides) throws Exception
+   {
+
+      URL connFactoryConfigFileURL =
+         getClass().getClassLoader().getResource(connFactoryConfigFile);
+
+      if (connFactoryConfigFileURL == null)
+      {
+         throw new Exception("Cannot find " + connFactoryConfigFile + " in the classpath");
+      }
+
+      ServiceDeploymentDescriptor cfdd =
+         new ServiceDeploymentDescriptor(connFactoryConfigFileURL);
+      List connFactoryElements = cfdd.query("service", "ConnectionFactory");
+      if (connFactoryElements.isEmpty())
+      {
+         connFactoryElements = cfdd.query("service", "HTTPConnectionFactory");
+      }
+      connFactoryObjectNames.clear();
+      for (Iterator i = connFactoryElements.iterator(); i.hasNext();)
+      {
+         MBeanConfigurationElement connFactoryElement = (MBeanConfigurationElement) i.next();
+         ObjectName on = registerAndConfigureService(connFactoryElement);
+         overrideAttributes(on, attrOverrides);
+         // dependencies have been automatically injected already
+         invoke(on, "create", new Object[0], new String[0]);
+         invoke(on, "start", new Object[0], new String[0]);
+         connFactoryObjectNames.add(on);
+      }
+   }
+
+
+
    private void parseConfig(String config)
    {
       config = config.toLowerCase();
@@ -1596,6 +1709,16 @@
             remoting = true;
             security = true;
          }
+         else
+         if ("all+http".equals(tok))
+         {
+            transaction = true;
+            database = true;
+            jca = true;
+            remoting = true;
+            security = true;
+            httpDatasource = true;
+         }
          else if ("transaction".equals(tok))
          {
             transaction = true;

Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java	2007-02-09 16:12:51 UTC (rev 2243)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java	2007-02-09 17:36:42 UTC (rev 2244)
@@ -91,9 +91,6 @@
    // the server MBean itself
    private ObjectName serverPeerObjectName;
 
-   // List<ObjectName>
-   private List connFactoryObjectNames;
-
    private int serverIndex;
 
    // Constructors ---------------------------------------------------------------------------------
@@ -101,8 +98,6 @@
    public LocalTestServer()
    {
       super();
-
-      connFactoryObjectNames = new ArrayList();
    }
 
    public LocalTestServer(int serverIndex)
@@ -345,21 +340,10 @@
             throw new Exception("Cannot find " + persistenceConfigFile + " in the classpath");
          }
 
-         String connFactoryConfigFile = "server/default/deploy/connection-factories-service.xml";
-         URL connFactoryConfigFileURL =
-            getClass().getClassLoader().getResource(connFactoryConfigFile);
-
-         if (connFactoryConfigFileURL == null)
-         {
-            throw new Exception("Cannot find " + connFactoryConfigFile + " in the classpath");
-         }
-
          ServiceDeploymentDescriptor mdd =
             new ServiceDeploymentDescriptor(mainConfigFileURL);
          ServiceDeploymentDescriptor pdd =
             new ServiceDeploymentDescriptor(persistenceConfigFileURL);
-         ServiceDeploymentDescriptor cfdd =
-            new ServiceDeploymentDescriptor(connFactoryConfigFileURL);
 
          MBeanConfigurationElement persistenceManagerConfig =
             (MBeanConfigurationElement)pdd.query("service", "PersistenceManager").iterator().next();
@@ -415,23 +399,7 @@
 
          log.debug("deploying connection factories");
 
-         List connFactoryElements = cfdd.query("service", "ConnectionFactory");
-         connFactoryObjectNames.clear();
-         for(Iterator i = connFactoryElements.iterator(); i.hasNext(); )
-         {
-            MBeanConfigurationElement connFactoryElement = (MBeanConfigurationElement)i.next();
-            ObjectName on = sc.registerAndConfigureService(connFactoryElement);
-            overrideAttributes(on, attrOverrides);
-            // dependencies have been automatically injected already
-            sc.invoke(on, "create", new Object[0], new String[0]);
-            sc.invoke(on, "start", new Object[0], new String[0]);
-            connFactoryObjectNames.add(on);
-         }
-
-         // bind the default JMS provider
-         sc.bindDefaultJMSProvider();
-         // bind the JCA ConnectionFactory
-         sc.bindJCAJMSConnectionFactory();
+         sc.startDataSources(attrOverrides);
       }
       catch (Exception e)
       {
@@ -464,24 +432,7 @@
 
          log.debug("stopping connection factories");
 
-         for(Iterator i = connFactoryObjectNames.iterator(); i.hasNext(); )
-         {
-            try
-            {
-               ObjectName on = (ObjectName)i.next();
-               sc.invoke(on, "stop", new Object[0], new String[0]);
-               sc.invoke(on, "destroy", new Object[0], new String[0]);
-               sc.unregisterService(on);
-            }
-            catch (Exception ignore)
-            {
-               //If the serverpeer failed when starting up previously, then only some of the
-               //services may be started. The ones that didn't start will fail when attempting to shut
-               //them down.
-               //Hence we must catch and ignore or we won't shut everything down
-            }
-         }
-         connFactoryObjectNames.clear();
+         sc.stopDatasources();
 
          log.debug("stopping all destinations");
 




More information about the jboss-cvs-commits mailing list