[jboss-cvs] JBossAS SVN: r67351 - in trunk/testsuite/src/main/org/jboss/test/cluster: invokerha and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Nov 21 13:42:49 EST 2007


Author: galder.zamarreno at jboss.com
Date: 2007-11-21 13:42:49 -0500 (Wed, 21 Nov 2007)
New Revision: 67351

Added:
   trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHa.java
Removed:
   trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHaUnitTestCase.java
Modified:
   trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JRMPInvokerHaUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/UnifiedInvokerHaUnitTestCase.java
Log:
Renamed abstract invokerha test case to avoid it being treated as a unit test and avoid it being run.

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JRMPInvokerHaUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JRMPInvokerHaUnitTestCase.java	2007-11-21 18:36:17 UTC (rev 67350)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JRMPInvokerHaUnitTestCase.java	2007-11-21 18:42:49 UTC (rev 67351)
@@ -25,7 +25,7 @@
 
 import org.jboss.invocation.InvokerHA;
 import org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxyHA;
-import org.jboss.test.cluster.invokerha.AbstractInvokerHaUnitTestCase;
+import org.jboss.test.cluster.invokerha.AbstractInvokerHa;
 import org.jboss.test.cluster.invokerha.InvokerHaInfrastructure;
 import org.jboss.test.cluster.invokerha.InvokerHaInfrastructure.InvokerHaFactory;
 import org.jboss.test.cluster.invokerha.JRMPInvokerHaMockUtils.MockJRMPInvokerHA;
@@ -35,7 +35,7 @@
  *  
  * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
  */
-public class JRMPInvokerHaUnitTestCase extends AbstractInvokerHaUnitTestCase
+public class JRMPInvokerHaUnitTestCase extends AbstractInvokerHa
 {
    @Override
    protected void setUp() throws Exception

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/UnifiedInvokerHaUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/UnifiedInvokerHaUnitTestCase.java	2007-11-21 18:36:17 UTC (rev 67350)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/UnifiedInvokerHaUnitTestCase.java	2007-11-21 18:42:49 UTC (rev 67351)
@@ -31,7 +31,7 @@
 import org.jboss.invocation.InvokerHA;
 import org.jboss.invocation.unified.interfaces.UnifiedInvokerHAProxy;
 import org.jboss.remoting.InvokerLocator;
-import org.jboss.test.cluster.invokerha.AbstractInvokerHaUnitTestCase;
+import org.jboss.test.cluster.invokerha.AbstractInvokerHa;
 import org.jboss.test.cluster.invokerha.InvokerHaInfrastructure;
 import org.jboss.test.cluster.invokerha.InvokerHaInfrastructure.InvokerHaFactory;
 import org.jboss.test.cluster.invokerha.UnifiedInvokerHaMockUtils.MockClient;
@@ -46,7 +46,7 @@
  * 
  * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
  */
-public class UnifiedInvokerHaUnitTestCase extends AbstractInvokerHaUnitTestCase
+public class UnifiedInvokerHaUnitTestCase extends AbstractInvokerHa
 {
    @Override
    protected void setUp() throws Exception

Copied: trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHa.java (from rev 67340, trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHaUnitTestCase.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHa.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHa.java	2007-11-21 18:42:49 UTC (rev 67351)
@@ -0,0 +1,280 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.invokerha;
+
+import java.rmi.server.UID;
+import java.util.WeakHashMap;
+
+import javax.transaction.Transaction;
+
+import org.jboss.ha.framework.interfaces.LoadBalancePolicy;
+import org.jboss.invocation.Invocation;
+import org.jboss.invocation.Invoker;
+import org.jboss.logging.Logger;
+import org.jboss.test.cluster.invokerha.InvokerHaInfrastructure.InvokerHaFactory;
+import org.jboss.test.cluster.invokerha.InvokerHaInfrastructure.TraceFirstAvailable;
+import org.jboss.test.cluster.invokerha.InvokerHaInfrastructure.TraceFirstAvailableIdenticalAllProxies;
+import org.jboss.test.cluster.invokerha.InvokerHaInfrastructure.TraceRandomRobin;
+import org.jboss.test.cluster.invokerha.InvokerHaInfrastructure.TraceRoundRobin;
+import org.jboss.test.cluster.invokerha.InvokerHaTransactionalMockUtils.MockTransaction;
+
+import junit.framework.TestCase;
+
+/**
+ * Base class for invoker related tests that do not run within AS.
+ * 
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+public abstract class AbstractInvokerHa extends TestCase
+{
+   private static final Logger log = Logger.getLogger(AbstractInvokerHa.class);
+   
+   private InvokerHaInfrastructure infrastructure;
+   
+   private InvokerHaTransactionalMockUtils transactionalMockUtils;
+   
+   private InvokerHaFactory invokerHaFactory;
+   
+   private Invoker timeTellerProxy;
+   
+   private Invoker systemTimeProxy;
+   
+   private Object prevChosenTargetDateTimeTeller;
+   
+   private Object prevChosenTargetSystemTimeTeller;
+
+   protected void setUp(int serverCount, InvokerHaFactory factory) throws Exception
+   {
+      super.setUp();
+      
+      invokerHaFactory = factory; 
+      
+      transactionalMockUtils = new InvokerHaTransactionalMockUtils();
+      
+      infrastructure = invokerHaFactory.getInvokerHaInfrastructure(2);
+      
+      infrastructure.registerManagedObjects();
+      
+      infrastructure.deployServers();
+      
+      infrastructure.createDateTimeTeller();
+      infrastructure.createSystemTimeTeller();
+
+      infrastructure.deployDateTimeTeller();
+      infrastructure.deploySystemTimeTeller();
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+      
+      infrastructure.unregisterManagedObjects();
+      
+      infrastructure.undeployDateTimeTeller();
+      infrastructure.undeploySystemTimeTeller();
+      
+      infrastructure.undeployServers();
+   }
+   
+   public void testSuccessfulCallsRoundRobin() throws Exception
+   {
+      /* same proxies used in simulated transactions */
+      successfulCalls(TraceRoundRobin.class, false);
+      /* different proxies in simulated transactions */
+      successfulCalls(TraceRoundRobin.class, true);
+   }
+   
+   public void testSuccessfulCallsFirstAvailable() throws Exception
+   {
+      /* same proxies used in simulated transactions */
+      successfulCalls(TraceFirstAvailable.class, false);
+      /* same proxies used in simulated transactions */
+      successfulCalls(TraceFirstAvailable.class, true);            
+   }
+   
+   public void testSuccessfulCallsFirstAvailableIndenticalAllProxies() throws Exception
+   {
+      /* same proxies used in simulated transactions */
+      successfulCalls(TraceFirstAvailableIdenticalAllProxies.class, false);
+      /* same proxies used in simulated transactions */
+      successfulCalls(TraceFirstAvailableIdenticalAllProxies.class, true);                  
+   }
+   
+   public void testSuccessfulCallsRandomRobin() throws Exception
+   {
+      /* same proxies used in simulated transactions */
+      successfulCalls(TraceRandomRobin.class, false);
+      /* same proxies used in simulated transactions */
+      successfulCalls(TraceRandomRobin.class, true);                  
+   }
+   
+   protected void successfulCalls(Class<? extends LoadBalancePolicy> policyClass, boolean newProxiesInBetweenTransactions)
+   {
+      log.debug("successfull calls [policy=" + policyClass + ",newProxiesInBetweenTransactions=" + newProxiesInBetweenTransactions + "]");
+      
+      try
+      {
+         UID uid;
+         
+         createNewProxies(0, policyClass, true);
+
+         /* Simulate client user transaction */
+         uid = new UID();         
+         transactionalMockUtils.getTpcf().setUid(uid);
+         callsWithinTransaction(3, null, policyClass, newProxiesInBetweenTransactions);
+         
+         if (newProxiesInBetweenTransactions)
+         {
+            createNewProxies(0, policyClass, false);
+         }
+         
+         /* Simulate transaction interceptor */
+         uid = new UID();
+         Transaction tx = new MockTransaction();
+         transactionalMockUtils.getTpcf().setUid(uid);
+         transactionalMockUtils.getTpci().setTransaction(tx);
+         callsWithinTransaction(3, tx, policyClass, newProxiesInBetweenTransactions);                  
+      }
+      catch(Exception e)
+      {
+         /* catching to log the error properly (JUnit in eclipse does not show 
+          * correctly exceptions from invokers) and fail */
+         log.error("error", e);
+         fail();
+      }
+   }
+
+   protected void callsWithinTransaction(int numberPairCalls, 
+         Transaction tx, Class<? extends LoadBalancePolicy> policyClass, 
+         boolean newProxiesInBetweenTransactions) throws Exception
+   {
+      Invocation inv;
+      Object chosenTarget;
+      
+      WeakHashMap txFailoverAuthorizations = invokerHaFactory.getTxFailoverAuthorizationsMap();
+      
+      for (int i = 0; i < numberPairCalls; i++)
+      {
+         /* create invocation to date time teller */
+         inv = infrastructure.createDateTimeTellerInvocation(tx);
+         /* invoke on proxy passing the invocation */
+         log.debug(timeTellerProxy.invoke(inv));
+
+         assertEquals(0, inv.getAsIsValue("FAILOVER_COUNTER"));
+         chosenTarget = inv.getTransientValue("TEST_CHOSEN_TARGET");
+         assertNotNull(chosenTarget);
+         /* if tx was null, invocation's tx should be null after invocation. */
+         assertEquals(tx, inv.getTransaction());
+         /* check tx failover authorisations */
+         assertTrue("transaction should have reached the server", txFailoverAuthorizations.containsKey(transactionalMockUtils.getTpcf().getUid()));
+         /* check chosen target with previously chosen target, if there's any */
+         prevChosenTargetDateTimeTeller = assertChosenTarget(policyClass, chosenTarget, prevChosenTargetDateTimeTeller);
+         
+         /* create invocation to system time teller */
+         inv = infrastructure.createSystemTimeTellerInvocation(tx);
+         /* invoke on proxy passing the invocation */
+         log.debug(systemTimeProxy.invoke(inv));
+         
+         assertEquals(0, inv.getAsIsValue("FAILOVER_COUNTER"));
+         chosenTarget = inv.getTransientValue("TEST_CHOSEN_TARGET");
+         assertNotNull(chosenTarget);
+         /* if tx was null, invocation's tx should be null after invocation. */
+         assertEquals(tx, inv.getTransaction());
+         /* check tx failover authorisations */
+         assertTrue("transaction should have reached the server", txFailoverAuthorizations.containsKey(transactionalMockUtils.getTpcf().getUid()));
+         /* check chosen target with previously chosen target, if there's any */
+         prevChosenTargetSystemTimeTeller = assertChosenTarget(policyClass, chosenTarget, prevChosenTargetSystemTimeTeller);
+      }
+   }
+   
+   protected void createNewProxies(int serverIndex, Class<? extends LoadBalancePolicy> policyClass, boolean isVery1st) throws Exception
+   {
+      /* Create a proxy instances retrieved from the first server */
+      timeTellerProxy = infrastructure.createDateTimeTellerProxy(serverIndex, policyClass);
+      systemTimeProxy = infrastructure.createSystemTimeTellerProxy(serverIndex, policyClass);
+      
+      /* Initialise previous chosen targets. If not new proxies elected 
+       * between transactions, this allows to carry on checking chosen 
+       * targets in between transactions. */ 
+      if (!isVery1st && policyClass.equals(TraceFirstAvailableIdenticalAllProxies.class))
+      {
+         /* In the particular case of first availble indentical proxies, if we're 
+         * not creating the proxies for the first time, do not initialise the 
+         * proxies because we need them to check them with next chosen ones. */
+      }
+      else
+      {
+         prevChosenTargetDateTimeTeller = null;
+         prevChosenTargetSystemTimeTeller = null;                  
+      }
+   }
+   
+   protected Object assertChosenTarget(Class<? extends LoadBalancePolicy> policyClass, Object chosenTarget, Object prevChosenTarget)
+   {
+      if (policyClass.equals(TraceRoundRobin.class))
+      {
+         prevChosenTarget = checkRoundRobin(chosenTarget, prevChosenTarget);
+      }
+      else if (policyClass.equals(TraceFirstAvailable.class))
+      {
+         prevChosenTarget = checkFirstAvailable(chosenTarget, prevChosenTarget);
+      }
+      else if (policyClass.equals(TraceFirstAvailableIdenticalAllProxies.class))
+      {
+         prevChosenTarget = checkFirstAvailableIndenticalAllProxies(chosenTarget, prevChosenTarget);
+      }
+      
+      return prevChosenTarget;
+   }
+   
+   protected Object checkRoundRobin(Object chosenTarget, Object prevChosenTarget)
+   {
+      if (prevChosenTarget != null)
+      {
+         /* In round robin, previous chosen target must be different to the 
+          * current one, unless there's only one node in the cluster, but we're 
+          * not testing that here. */
+         assertNotSame(prevChosenTarget, chosenTarget);
+      }      
+      
+      return chosenTarget;
+   }
+   
+   protected Object checkFirstAvailable(Object chosenTarget, Object prevChosenTarget)
+   {
+      if (prevChosenTarget != null)
+      {
+         /* In first available robin, previous chosen target must be the same to the 
+          * current one, unless there's only one node in the cluster, but we're 
+          * not testing that here. */
+         assertEquals(prevChosenTarget, chosenTarget);
+      }
+      
+      return chosenTarget;      
+   }
+   
+   protected Object checkFirstAvailableIndenticalAllProxies(Object chosenTarget, Object prevChosenTarget)
+   {
+      return checkFirstAvailable(chosenTarget, prevChosenTarget);
+   }   
+}

Deleted: trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHaUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHaUnitTestCase.java	2007-11-21 18:36:17 UTC (rev 67350)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHaUnitTestCase.java	2007-11-21 18:42:49 UTC (rev 67351)
@@ -1,280 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2007, 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.invokerha;
-
-import java.rmi.server.UID;
-import java.util.WeakHashMap;
-
-import javax.transaction.Transaction;
-
-import org.jboss.ha.framework.interfaces.LoadBalancePolicy;
-import org.jboss.invocation.Invocation;
-import org.jboss.invocation.Invoker;
-import org.jboss.logging.Logger;
-import org.jboss.test.cluster.invokerha.InvokerHaInfrastructure.InvokerHaFactory;
-import org.jboss.test.cluster.invokerha.InvokerHaInfrastructure.TraceFirstAvailable;
-import org.jboss.test.cluster.invokerha.InvokerHaInfrastructure.TraceFirstAvailableIdenticalAllProxies;
-import org.jboss.test.cluster.invokerha.InvokerHaInfrastructure.TraceRandomRobin;
-import org.jboss.test.cluster.invokerha.InvokerHaInfrastructure.TraceRoundRobin;
-import org.jboss.test.cluster.invokerha.InvokerHaTransactionalMockUtils.MockTransaction;
-
-import junit.framework.TestCase;
-
-/**
- * Base class for invoker related tests that do not run within AS.
- * 
- * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
- */
-public abstract class AbstractInvokerHaUnitTestCase extends TestCase
-{
-   private static final Logger log = Logger.getLogger(AbstractInvokerHaUnitTestCase.class);
-   
-   private InvokerHaInfrastructure infrastructure;
-   
-   private InvokerHaTransactionalMockUtils transactionalMockUtils;
-   
-   private InvokerHaFactory invokerHaFactory;
-   
-   private Invoker timeTellerProxy;
-   
-   private Invoker systemTimeProxy;
-   
-   private Object prevChosenTargetDateTimeTeller;
-   
-   private Object prevChosenTargetSystemTimeTeller;
-
-   protected void setUp(int serverCount, InvokerHaFactory factory) throws Exception
-   {
-      super.setUp();
-      
-      invokerHaFactory = factory; 
-      
-      transactionalMockUtils = new InvokerHaTransactionalMockUtils();
-      
-      infrastructure = invokerHaFactory.getInvokerHaInfrastructure(2);
-      
-      infrastructure.registerManagedObjects();
-      
-      infrastructure.deployServers();
-      
-      infrastructure.createDateTimeTeller();
-      infrastructure.createSystemTimeTeller();
-
-      infrastructure.deployDateTimeTeller();
-      infrastructure.deploySystemTimeTeller();
-   }
-
-   @Override
-   protected void tearDown() throws Exception
-   {
-      super.tearDown();
-      
-      infrastructure.unregisterManagedObjects();
-      
-      infrastructure.undeployDateTimeTeller();
-      infrastructure.undeploySystemTimeTeller();
-      
-      infrastructure.undeployServers();
-   }
-   
-   public void testSuccessfulCallsRoundRobin() throws Exception
-   {
-      /* same proxies used in simulated transactions */
-      successfulCalls(TraceRoundRobin.class, false);
-      /* different proxies in simulated transactions */
-      successfulCalls(TraceRoundRobin.class, true);
-   }
-   
-   public void testSuccessfulCallsFirstAvailable() throws Exception
-   {
-      /* same proxies used in simulated transactions */
-      successfulCalls(TraceFirstAvailable.class, false);
-      /* same proxies used in simulated transactions */
-      successfulCalls(TraceFirstAvailable.class, true);            
-   }
-   
-   public void testSuccessfulCallsFirstAvailableIndenticalAllProxies() throws Exception
-   {
-      /* same proxies used in simulated transactions */
-      successfulCalls(TraceFirstAvailableIdenticalAllProxies.class, false);
-      /* same proxies used in simulated transactions */
-      successfulCalls(TraceFirstAvailableIdenticalAllProxies.class, true);                  
-   }
-   
-   public void testSuccessfulCallsRandomRobin() throws Exception
-   {
-      /* same proxies used in simulated transactions */
-      successfulCalls(TraceRandomRobin.class, false);
-      /* same proxies used in simulated transactions */
-      successfulCalls(TraceRandomRobin.class, true);                  
-   }
-   
-   protected void successfulCalls(Class<? extends LoadBalancePolicy> policyClass, boolean newProxiesInBetweenTransactions)
-   {
-      log.debug("successfull calls [policy=" + policyClass + ",newProxiesInBetweenTransactions=" + newProxiesInBetweenTransactions + "]");
-      
-      try
-      {
-         UID uid;
-         
-         createNewProxies(0, policyClass, true);
-
-         /* Simulate client user transaction */
-         uid = new UID();         
-         transactionalMockUtils.getTpcf().setUid(uid);
-         callsWithinTransaction(3, null, policyClass, newProxiesInBetweenTransactions);
-         
-         if (newProxiesInBetweenTransactions)
-         {
-            createNewProxies(0, policyClass, false);
-         }
-         
-         /* Simulate transaction interceptor */
-         uid = new UID();
-         Transaction tx = new MockTransaction();
-         transactionalMockUtils.getTpcf().setUid(uid);
-         transactionalMockUtils.getTpci().setTransaction(tx);
-         callsWithinTransaction(3, tx, policyClass, newProxiesInBetweenTransactions);                  
-      }
-      catch(Exception e)
-      {
-         /* catching to log the error properly (JUnit in eclipse does not show 
-          * correctly exceptions from invokers) and fail */
-         log.error("error", e);
-         fail();
-      }
-   }
-
-   protected void callsWithinTransaction(int numberPairCalls, 
-         Transaction tx, Class<? extends LoadBalancePolicy> policyClass, 
-         boolean newProxiesInBetweenTransactions) throws Exception
-   {
-      Invocation inv;
-      Object chosenTarget;
-      
-      WeakHashMap txFailoverAuthorizations = invokerHaFactory.getTxFailoverAuthorizationsMap();
-      
-      for (int i = 0; i < numberPairCalls; i++)
-      {
-         /* create invocation to date time teller */
-         inv = infrastructure.createDateTimeTellerInvocation(tx);
-         /* invoke on proxy passing the invocation */
-         log.debug(timeTellerProxy.invoke(inv));
-
-         assertEquals(0, inv.getAsIsValue("FAILOVER_COUNTER"));
-         chosenTarget = inv.getTransientValue("TEST_CHOSEN_TARGET");
-         assertNotNull(chosenTarget);
-         /* if tx was null, invocation's tx should be null after invocation. */
-         assertEquals(tx, inv.getTransaction());
-         /* check tx failover authorisations */
-         assertTrue("transaction should have reached the server", txFailoverAuthorizations.containsKey(transactionalMockUtils.getTpcf().getUid()));
-         /* check chosen target with previously chosen target, if there's any */
-         prevChosenTargetDateTimeTeller = assertChosenTarget(policyClass, chosenTarget, prevChosenTargetDateTimeTeller);
-         
-         /* create invocation to system time teller */
-         inv = infrastructure.createSystemTimeTellerInvocation(tx);
-         /* invoke on proxy passing the invocation */
-         log.debug(systemTimeProxy.invoke(inv));
-         
-         assertEquals(0, inv.getAsIsValue("FAILOVER_COUNTER"));
-         chosenTarget = inv.getTransientValue("TEST_CHOSEN_TARGET");
-         assertNotNull(chosenTarget);
-         /* if tx was null, invocation's tx should be null after invocation. */
-         assertEquals(tx, inv.getTransaction());
-         /* check tx failover authorisations */
-         assertTrue("transaction should have reached the server", txFailoverAuthorizations.containsKey(transactionalMockUtils.getTpcf().getUid()));
-         /* check chosen target with previously chosen target, if there's any */
-         prevChosenTargetSystemTimeTeller = assertChosenTarget(policyClass, chosenTarget, prevChosenTargetSystemTimeTeller);
-      }
-   }
-   
-   protected void createNewProxies(int serverIndex, Class<? extends LoadBalancePolicy> policyClass, boolean isVery1st) throws Exception
-   {
-      /* Create a proxy instances retrieved from the first server */
-      timeTellerProxy = infrastructure.createDateTimeTellerProxy(serverIndex, policyClass);
-      systemTimeProxy = infrastructure.createSystemTimeTellerProxy(serverIndex, policyClass);
-      
-      /* Initialise previous chosen targets. If not new proxies elected 
-       * between transactions, this allows to carry on checking chosen 
-       * targets in between transactions. */ 
-      if (!isVery1st && policyClass.equals(TraceFirstAvailableIdenticalAllProxies.class))
-      {
-         /* In the particular case of first availble indentical proxies, if we're 
-         * not creating the proxies for the first time, do not initialise the 
-         * proxies because we need them to check them with next chosen ones. */
-      }
-      else
-      {
-         prevChosenTargetDateTimeTeller = null;
-         prevChosenTargetSystemTimeTeller = null;                  
-      }
-   }
-   
-   protected Object assertChosenTarget(Class<? extends LoadBalancePolicy> policyClass, Object chosenTarget, Object prevChosenTarget)
-   {
-      if (policyClass.equals(TraceRoundRobin.class))
-      {
-         prevChosenTarget = checkRoundRobin(chosenTarget, prevChosenTarget);
-      }
-      else if (policyClass.equals(TraceFirstAvailable.class))
-      {
-         prevChosenTarget = checkFirstAvailable(chosenTarget, prevChosenTarget);
-      }
-      else if (policyClass.equals(TraceFirstAvailableIdenticalAllProxies.class))
-      {
-         prevChosenTarget = checkFirstAvailableIndenticalAllProxies(chosenTarget, prevChosenTarget);
-      }
-      
-      return prevChosenTarget;
-   }
-   
-   protected Object checkRoundRobin(Object chosenTarget, Object prevChosenTarget)
-   {
-      if (prevChosenTarget != null)
-      {
-         /* In round robin, previous chosen target must be different to the 
-          * current one, unless there's only one node in the cluster, but we're 
-          * not testing that here. */
-         assertNotSame(prevChosenTarget, chosenTarget);
-      }      
-      
-      return chosenTarget;
-   }
-   
-   protected Object checkFirstAvailable(Object chosenTarget, Object prevChosenTarget)
-   {
-      if (prevChosenTarget != null)
-      {
-         /* In first available robin, previous chosen target must be the same to the 
-          * current one, unless there's only one node in the cluster, but we're 
-          * not testing that here. */
-         assertEquals(prevChosenTarget, chosenTarget);
-      }
-      
-      return chosenTarget;      
-   }
-   
-   protected Object checkFirstAvailableIndenticalAllProxies(Object chosenTarget, Object prevChosenTarget)
-   {
-      return checkFirstAvailable(chosenTarget, prevChosenTarget);
-   }   
-}




More information about the jboss-cvs-commits mailing list