[jboss-cvs] JBossAS SVN: r83442 - in branches/Branch_5_x/testsuite: src/main/org/jboss/test/cluster/defaultcfg/test and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jan 26 17:39:28 EST 2009


Author: pferraro
Date: 2009-01-26 17:39:28 -0500 (Mon, 26 Jan 2009)
New Revision: 83442

Removed:
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/hasingleton/PreferredMasterElectionPolicyUnitTestCase.java
Modified:
   branches/Branch_5_x/testsuite/imports/config/tests-clustering.xml
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/PreferredMasterElectionPolicyUnitTestCase.java
Log:
Oops - a unit test already exists for PreferredMasterElectionPolicyUnitTestCase.  Delete new one, and update old one.

Modified: branches/Branch_5_x/testsuite/imports/config/tests-clustering.xml
===================================================================
--- branches/Branch_5_x/testsuite/imports/config/tests-clustering.xml	2009-01-26 22:03:33 UTC (rev 83441)
+++ branches/Branch_5_x/testsuite/imports/config/tests-clustering.xml	2009-01-26 22:39:28 UTC (rev 83442)
@@ -64,17 +64,7 @@
     <include name="org/jboss/test/cluster/defaultcfg/ejb2/ustxsticky/test/UserTransactionStickyUnitTestCase.class"/>
   </patternset>    
   <patternset id="cluster.excludes">
-    <exclude name="org/jboss/test/cluster/apache_tomcat/**/*TestCase.class"/>
-    <exclude name="org/jboss/test/cluster/cache/**/*TestCase.class"/>
-    <exclude name="org/jboss/test/cluster/classloader/**/*TestCase.class"/>
-    <exclude name="org/jboss/test/cluster/defaultcfg/**/*TestCase.class"/>
-    <exclude name="org/jboss/test/cluster/ejb2/**/*TestCase.class"/>
-    <exclude name="org/jboss/test/cluster/hapartition/**/*TestCase.class"/>
-    <exclude name="org/jboss/test/cluster/haservice/**/*TestCase.class"/>
-    <exclude name="org/jboss/test/cluster/httpsessionreplication/**/*TestCase.class"/>
-    <exclude name="org/jboss/test/cluster/invokerha/**/*TestCase.class"/>
-    <exclude name="org/jboss/test/cluster/multicfg/**/*TestCase.class"/>
-    <exclude name="org/jboss/test/cluster/web/**/*TestCase.class"/>
+    <exclude name="org/jboss/test/cluster/**/*TestCase.class"/>
   </patternset>
 
   <!--
@@ -706,4 +696,5 @@
    <server:stop name="cluster-field-${jboss-junit-configuration}-BR-1"/>
 	   
   </target>
+
 </project>
\ No newline at end of file

Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/PreferredMasterElectionPolicyUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/PreferredMasterElectionPolicyUnitTestCase.java	2009-01-26 22:03:33 UTC (rev 83441)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/PreferredMasterElectionPolicyUnitTestCase.java	2009-01-26 22:39:28 UTC (rev 83442)
@@ -21,9 +21,12 @@
  */
 package org.jboss.test.cluster.defaultcfg.test;
 
+import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.List;
 
+import junit.framework.Assert;
 import junit.framework.TestCase;
 
 import org.jboss.ha.framework.interfaces.ClusterNode;
@@ -43,75 +46,146 @@
  */
 public class PreferredMasterElectionPolicyUnitTestCase extends TestCase
 {
-   private final List<ClusterNode> candidates = new ArrayList<ClusterNode>(2);
-   
    private PreferredMasterElectionPolicy policy;
+   private List<ClusterNode> candidates = new ArrayList<ClusterNode>();
    
    @Override
-   protected void setUp() throws Exception
+   protected void setUp() throws UnknownHostException
    {
-      super.setUp();
+      InetAddress localAddress = InetAddress.getLocalHost();
       
-      ClusterNode cn1 = new ClusterNodeImpl(new IpAddress("127.0.0.1", 1099));
-      ClusterNode cn2 = new ClusterNodeImpl(new IpAddress("127.0.0.1", 1199));
+      this.candidates.add(new ClusterNodeImpl(new IpAddress(localAddress, 10000)));
+      this.candidates.add(new ClusterNodeImpl(new IpAddress(localAddress, 10001)));
+      this.candidates.add(new ClusterNodeImpl(new IpAddress(localAddress, 10002)));
+      
+      this.policy = new PreferredMasterElectionPolicy();
+   }
+   
+   /**
+    * @{inheritDoc}
+    * @see junit.framework.TestCase#tearDown()
+    */
+   @Override
+   protected void tearDown() throws Exception
+   {
+      this.candidates.clear();
+   }
 
-      candidates.add(cn1);
-      candidates.add(cn2);
+
+   public void testUsePreferredMasterViaHost()
+   {
+      this.policy.setPreferredMaster("localhost:10001");
       
-      policy = new PreferredMasterElectionPolicy();
+      ClusterNode master = this.policy.elect(this.candidates);
       
-      policy.setPosition(0);
+      Assert.assertSame(this.candidates.get(1), master);
    }
-
-   public void testIpPort() throws Exception
+   
+   public void testUsePreferredMasterViaAddress()
    {
-      policy.setPreferredMaster("127.0.0.1:1199");
-      assertEquals(candidates.get(1), policy.elect(this.candidates));
+      this.policy.setPreferredMaster("127.0.0.1:10002");
+      
+      ClusterNode master = this.policy.elect(this.candidates);
+      
+      Assert.assertSame(this.candidates.get(2), master);
    }
-
-   public void testHostPort() throws Exception
+   
+   public void testUseDefaultMaster()
    {
-      policy.setPreferredMaster("localhost:1199");
-      assertEquals(candidates.get(1), policy.elect(this.candidates));
+      this.policy.setPreferredMaster("localhost:10003");
+      
+      ClusterNode master = this.policy.elect(this.candidates);
+      
+      Assert.assertSame(this.candidates.get(0), master);
+      
+      this.policy.setPosition(1);
+      
+      master = this.policy.elect(this.candidates);
+      
+      Assert.assertSame(this.candidates.get(1), master);
    }
    
-   public void testOnlyPort() throws Exception
+   public void testUseDefaultMasterNoPreference()
    {
-      policy.setPreferredMaster(":1199");
-      /* invalid preferred master definiton, so 1st candidate in the list 
-       * should be chosen */
-      assertEquals(candidates.get(0), policy.elect(this.candidates));
+      ClusterNode master = this.policy.elect(this.candidates);
+      
+      Assert.assertSame(this.candidates.get(0), master);
+      
+      this.policy.setPosition(1);
+      
+      master = this.policy.elect(this.candidates);
+      
+      Assert.assertSame(this.candidates.get(1), master);
    }
    
-   public void testNonNumericPort() throws Exception
+   public void testUseDefaultMasterEmptyPreference()
    {
-      policy.setPreferredMaster("localhost:abcd");
-      /* invalid preferred master definiton, so 1st candidate in the list 
-       * should be chosen */
-      assertEquals(candidates.get(0), policy.elect(this.candidates));
+      this.policy.setPreferredMaster("");
+      
+      ClusterNode master = this.policy.elect(this.candidates);
+      
+      Assert.assertSame(this.candidates.get(0), master);
+      
+      this.policy.setPosition(1);
+      
+      master = this.policy.elect(this.candidates);
+      
+      Assert.assertSame(this.candidates.get(1), master);
    }
-
-   public void testUnknownHost() throws Exception
+   
+   public void testMissingHost() throws Exception
    {
-      policy.setPreferredMaster("onceuponatimeinalandfarfarawaylivedamancalledgalder:1199");
-      /* invalid preferred master definiton, so 1st candidate in the list 
-       * should be chosen */
-      assertEquals(candidates.get(0), policy.elect(this.candidates));
+      try
+      {
+         this.policy.setPreferredMaster(":1199");
+         
+         Assert.fail("IllegalArgumentException expected");
+      }
+      catch (IllegalArgumentException e)
+      {
+         // Expected
+      }
    }
    
-   public void testEmpty() throws Exception
+   public void testInvalidPort() throws Exception
    {
-      policy.setPreferredMaster("");
-      /* invalid preferred master definiton, so 1st candidate in the list 
-       * should be chosen */
-      assertEquals(candidates.get(0), policy.elect(this.candidates));
+      try
+      {
+         this.policy.setPreferredMaster("localhost:abcd");
+         
+         Assert.fail("IllegalArgumentException expected");
+      }
+      catch (IllegalArgumentException e)
+      {
+         // Expected
+      }
    }
+
+   public void testUnknownHost() throws Exception
+   {
+      try
+      {
+         this.policy.setPreferredMaster("onceuponatimeinalandfarfarawaylivedamancalledgalder:1199");
+         
+         Assert.fail("IllegalArgumentException expected");
+      }
+      catch (IllegalArgumentException e)
+      {
+         // Expected
+      }
+   }
    
    public void testGarbage() throws Exception
    {
-      policy.setPreferredMaster("%^$%&%^&$%$£");
-      /* invalid preferred master definiton, so 1st candidate in the list 
-       * should be chosen */
-      assertEquals(candidates.get(0), policy.elect(this.candidates));
+      try
+      {
+         this.policy.setPreferredMaster("%^$%&%^&$%$£");
+         
+         Assert.fail("IllegalArgumentException expected");
+      }
+      catch (IllegalArgumentException e)
+      {
+         // Expected
+      }
    }
-}
+}
\ No newline at end of file

Deleted: branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/hasingleton/PreferredMasterElectionPolicyUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/hasingleton/PreferredMasterElectionPolicyUnitTestCase.java	2009-01-26 22:03:33 UTC (rev 83441)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/hasingleton/PreferredMasterElectionPolicyUnitTestCase.java	2009-01-26 22:39:28 UTC (rev 83442)
@@ -1,93 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.cluster.hasingleton;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.jboss.ha.framework.interfaces.ClusterNode;
-import org.jboss.ha.framework.server.ClusterNodeImpl;
-import org.jboss.ha.singleton.PreferredMasterElectionPolicy;
-import org.jgroups.stack.IpAddress;
-
-/**
- * A PreferredMasterElectionPolicyTestCase.
- * 
- * @author Paul Ferraro
- */
-public class PreferredMasterElectionPolicyUnitTestCase extends TestCase
-{
-   private List<ClusterNode> candidates = new ArrayList<ClusterNode>();
-   
-   public void setUp() throws UnknownHostException
-   {
-      InetAddress localAddress = InetAddress.getLocalHost();
-      
-      this.candidates.add(new ClusterNodeImpl(new IpAddress(localAddress, 10000)));
-      this.candidates.add(new ClusterNodeImpl(new IpAddress(localAddress, 10001)));
-      this.candidates.add(new ClusterNodeImpl(new IpAddress(localAddress, 10002)));
-   }
-   
-   public void testUsePreferredMasterViaHost()
-   {
-      PreferredMasterElectionPolicy policy = new PreferredMasterElectionPolicy();
-      policy.setPreferredMaster("localhost:10001");
-      
-      ClusterNode master = policy.elect(this.candidates);
-      
-      Assert.assertSame(this.candidates.get(1), master);
-   }
-   
-   public void testUsePreferredMasterViaAddress()
-   {
-      PreferredMasterElectionPolicy policy = new PreferredMasterElectionPolicy();
-      policy.setPreferredMaster("127.0.0.1:10002");
-      
-      ClusterNode master = policy.elect(this.candidates);
-      
-      Assert.assertSame(this.candidates.get(2), master);
-   }
-   
-   public void testUseDefaultMaster()
-   {
-      PreferredMasterElectionPolicy policy = new PreferredMasterElectionPolicy();
-      policy.setPreferredMaster("localhost:10003");
-      
-      ClusterNode master = policy.elect(this.candidates);
-      
-      Assert.assertSame(this.candidates.get(0), master);
-   }
-   
-   public void testUseDefaultMasterNoPreference()
-   {
-      PreferredMasterElectionPolicy policy = new PreferredMasterElectionPolicy();
-      
-      ClusterNode master = policy.elect(this.candidates);
-      
-      Assert.assertSame(this.candidates.get(0), master);
-   }
-}




More information about the jboss-cvs-commits mailing list