[jboss-cvs] JBossAS SVN: r69269 - trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jan 24 04:46:38 EST 2008


Author: galder.zamarreno at jboss.com
Date: 2008-01-24 04:46:38 -0500 (Thu, 24 Jan 2008)
New Revision: 69269

Modified:
   trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/DRMTestCase.java
Log:
[JBAS-5155] Added a new test case to DRMTestCase, testReplicantOrderWithLookupReplicantsNodes(), that uses DRM.lookupReplicantsNodes() rather than DRM.lookupReplicantsNodeNodes. DRMTestCase.testReplicantOrder() has been deprecated as it uses deprecated methods.

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/DRMTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/DRMTestCase.java	2008-01-24 09:43:32 UTC (rev 69268)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/DRMTestCase.java	2008-01-24 09:46:38 UTC (rev 69269)
@@ -67,6 +67,7 @@
  *
  * @author  Scott.Stark at jboss.org
  * @author  Brian.Stansberry at jboss.com
+ * @author  <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
  * @version $Revision$
  */
 public class DRMTestCase extends JBossClusteredTestCase
@@ -1220,7 +1221,13 @@
       }
    }
    
-   public void testReplicantOrder() throws Exception
+   /**
+    * testReplicantOrder
+    * 
+    * @throws Exception
+    * @deprecated Test method based in deprecated DRM.lookupReplicantsNodeNames()
+    */
+   @Deprecated public void testReplicantOrder() throws Exception
    {
       MBeanServer mbeanServer =
          MBeanServerFactory.createMBeanServer("mockPartitionA");
@@ -1298,6 +1305,85 @@
       }
    }
    
+   public void testReplicantOrderWithLookupReplicantsNodes() throws Exception
+   {
+      MBeanServer mbeanServer =
+         MBeanServerFactory.createMBeanServer("mockPartitionA");
+      try {
+         
+         //  Create a fake view for the MockHAPartition
+         ClusterNode[] nodes = new ClusterNode[5];
+//         String[] names = new String[nodes.length];
+         Integer[] replicants = new Integer[nodes.length];
+         Vector allNodes = new Vector();
+         for (int i = 0; i < nodes.length; i++)
+         {
+            nodes[i] = new ClusterNodeImpl(new IpAddress("127.0.0.1", 12340 + i));
+            allNodes.add(nodes[i]);
+//            names[i] = nodes[i].getName();
+            replicants[i] = new Integer(i);
+         }
+         
+         MockHAPartition partition = new MockHAPartition(nodes[2]);
+         partition.setCurrentViewClusterNodes(allNodes);
+         
+         DistributedReplicantManagerImpl drm = new DistributedReplicantManagerImpl();
+         drm.setHAPartition(partition);
+         drm.createService();
+         drm.startService();
+         
+         CachingListener listener = new CachingListener();
+         drm.registerListener("TEST", listener);
+         
+         SecureRandom random = new SecureRandom();
+         boolean[] added = new boolean[nodes.length];
+         List lookup = null;
+         List<ClusterNode> lookupReplicantsNodes = null;
+         for (int i = 0; i < 10; i++)
+         {
+            int node = random.nextInt(nodes.length);
+            if (added[node])
+            {
+               if (node == 2)
+                  drm.remove("TEST");
+               else
+                  drm._remove("TEST", nodes[node].getName());
+               added[node] = false;
+            }
+            else
+            {     
+               if (node == 2)
+                  drm.add("TEST", replicants[node]);
+               else
+                  drm._add("TEST", nodes[node].getName(), replicants[node]);   
+               added[node] = true;
+            }
+            
+            // Confirm the proper order of the replicant node names
+            lookupReplicantsNodes = maskListClass(drm.lookupReplicantsNodes("TEST"));
+            confirmReplicantList(lookupReplicantsNodes, nodes, added);
+            
+            // Confirm the proper order of the replicants via lookupReplicants
+            lookup = maskListClass(drm.lookupReplicants("TEST"));
+            confirmReplicantList(lookup, replicants, added);
+            
+            // Confirm the listener got the same list
+//            assertEquals("Listener received a correct list", lookup, 
+//                         maskListClass(listener.replicants));
+         }
+         
+         // Let the asynchronous notification thread catch up
+         sleep(25);
+         
+         // Confirm all lists presented to the listener were properly ordered
+         assertTrue("Listener saw no misordered lists", listener.clean);
+         
+      }
+      finally {
+         MBeanServerFactory.releaseMBeanServer(mbeanServer);
+      }
+   }
+   
    private void confirmReplicantList(List current, Object[] all, boolean[] added)
    {
       Iterator iter = current.iterator();




More information about the jboss-cvs-commits mailing list