[jboss-cvs] JBossAS SVN: r67190 - branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/invokerha.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Nov 16 14:13:26 EST 2007
Author: galder.zamarreno at jboss.com
Date: 2007-11-16 14:13:25 -0500 (Fri, 16 Nov 2007)
New Revision: 67190
Added:
branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaMockUtils.java
branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaUnitTestCase.java
Modified:
branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHaUnitTestCase.java
branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaInfrastructure.java
branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/invokerha/UnifiedInvokerHaUnitTestCase.java
Log:
[JBAS-4964] Created JRMPInvokerHaUnitTestCase to test JRMP based invokers. Extended test methods to include all existing load balance policies and also added user transaction based tests.
Modified: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHaUnitTestCase.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHaUnitTestCase.java 2007-11-16 19:12:58 UTC (rev 67189)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHaUnitTestCase.java 2007-11-16 19:13:25 UTC (rev 67190)
@@ -31,6 +31,9 @@
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;
@@ -45,14 +48,26 @@
{
private static final Logger log = Logger.getLogger(AbstractInvokerHaUnitTestCase.class);
- protected InvokerHaInfrastructure infrastructure;
+ private InvokerHaInfrastructure infrastructure;
- protected InvokerHaTransactionalMockUtils transactionalMockUtils;
+ private InvokerHaTransactionalMockUtils transactionalMockUtils;
+
+ private InvokerHaFactory invokerHaFactory;
+
+ private Invoker timeTellerProxy;
+
+ private Invoker systemTimeProxy;
+
+ private Object prevChosenTargetDateTimeTeller;
+
+ private Object prevChosenTargetSystemTimeTeller;
- protected void setUp(int serverCount, InvokerHaFactory invokerHaFactory) throws Exception
+ protected void setUp(int serverCount, InvokerHaFactory factory) throws Exception
{
super.setUp();
+ invokerHaFactory = factory;
+
transactionalMockUtils = new InvokerHaTransactionalMockUtils();
infrastructure = invokerHaFactory.getInvokerHaInfrastructure(2);
@@ -80,43 +95,65 @@
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);
+ }
- protected InvokerHaInfrastructure createInvokerHaInfrastructure(int serverCount, InvokerHaFactory invokerHaFactory)
+ public void testSuccessfulCallsFirstAvailable() throws Exception
{
- return new InvokerHaInfrastructure(serverCount, invokerHaFactory);
+ /* same proxies used in simulated transactions */
+ successfulCalls(TraceFirstAvailable.class, false);
+ /* same proxies used in simulated transactions */
+ successfulCalls(TraceFirstAvailable.class, true);
}
- protected void successfulCalls(Class<? extends LoadBalancePolicy> policyClass, WeakHashMap txFailoverAuthorizations)
+ 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;
- /* Create a proxy instances retrieved from the first server */
- Invoker timeTellerProxy = infrastructure.createDateTimeTellerProxy(0, policyClass);
- Invoker systemTimeProxy = infrastructure.createSystemTimeTellerProxy(0, policyClass);
+ createNewProxies(0, policyClass, true);
-// Commented because tx failover maps are still mapped on tx rather than
-// transaction propagation context. Once it's keyed on tpc, these tests
-// will be enabled.
-//
-// /* Simulate client user transaction */
-// uid = new UID();
-// transactionalMockUtils.getTpcf().setUid(uid);
-// callsWithinTransaction(3, timeTellerProxy, systemTimeProxy, null, policyClass, txFailoverAuthorizations);
-//
-// if (newProxiesInBetweenTransactions)
-// {
-// timeTellerProxy = infrastructure.createDateTimeTellerProxy(0, policyClass);
-// systemTimeProxy = infrastructure.createDateTimeTellerProxy(0, policyClass);
-// }
+ /* 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, timeTellerProxy, systemTimeProxy, tx, policyClass, txFailoverAuthorizations);
+ callsWithinTransaction(3, tx, policyClass, newProxiesInBetweenTransactions);
}
catch(Exception e)
{
@@ -128,17 +165,14 @@
}
protected void callsWithinTransaction(int numberPairCalls,
- Invoker timeTellerProxy,
- Invoker systemTimeProxy,
- Transaction tx,
- Class<? extends LoadBalancePolicy> policyClass,
- WeakHashMap txFailoverAuthorizations) throws Exception
+ Transaction tx, Class<? extends LoadBalancePolicy> policyClass,
+ boolean newProxiesInBetweenTransactions) throws Exception
{
Invocation inv;
Object chosenTarget;
- Object prevChosenTargetDateTimeTeller = null;
- Object prevChosenTargetSystemTimeTeller = null;
-
+
+ WeakHashMap txFailoverAuthorizations = invokerHaFactory.getTxFailoverAuthorizationsMap();
+
for (int i = 0; i < numberPairCalls; i++)
{
/* create invocation to date time teller */
@@ -151,42 +185,96 @@
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 */
- if (policyClass.equals(TraceRoundRobin.class))
- {
- prevChosenTargetDateTimeTeller = checkRoundRobin(i, chosenTarget, prevChosenTargetDateTimeTeller);
- }
+ prevChosenTargetDateTimeTeller = assertChosenTarget(policyClass, chosenTarget, prevChosenTargetDateTimeTeller);
- assertTrue("transaction should have reached the server", txFailoverAuthorizations.containsKey(tx));
-
/* 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());
- if (policyClass.equals(TraceRoundRobin.class))
- {
- prevChosenTargetSystemTimeTeller = checkRoundRobin(i, chosenTarget, prevChosenTargetSystemTimeTeller);
- }
- assertTrue("transaction should have reached the server", txFailoverAuthorizations.containsKey(tx));
-
+ /* 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 Object checkRoundRobin(int callIndex, Object chosenTarget, Object prevChosenTarget)
+ protected void createNewProxies(int serverIndex, Class<? extends LoadBalancePolicy> policyClass, boolean isVery1st) throws Exception
{
- if (callIndex != 0)
+ /* 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 round robin, previous chosen target must be different to the
+ /* 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);
+ }
}
Modified: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaInfrastructure.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaInfrastructure.java 2007-11-16 19:12:58 UTC (rev 67189)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaInfrastructure.java 2007-11-16 19:13:25 UTC (rev 67190)
@@ -26,6 +26,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import java.util.WeakHashMap;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
@@ -33,9 +34,12 @@
import javax.transaction.Transaction;
import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
+import org.jboss.ha.framework.interfaces.FirstAvailable;
+import org.jboss.ha.framework.interfaces.FirstAvailableIdenticalAllProxies;
import org.jboss.ha.framework.interfaces.HAPartition;
import org.jboss.ha.framework.interfaces.HARMIClient;
import org.jboss.ha.framework.interfaces.LoadBalancePolicy;
+import org.jboss.ha.framework.interfaces.RandomRobin;
import org.jboss.ha.framework.interfaces.RoundRobin;
import org.jboss.ha.framework.server.HATarget;
import org.jboss.invocation.Invocation;
@@ -129,12 +133,10 @@
/* create n invoker instances that emulate n AS servers */
for (int i =0; i < serverCount; i++)
{
- InvokerHA server = invokerHaFactory.createInvokerHAServer("Server", i + 1);
+ InvokerHA server = invokerHaFactory.createInvokerHaServer("Server", i + 1);
/* add invoker as replicant */
replicantServers.add(server);
- System.out.println(i);
-
mbs.registerMBean(server, invokerONs.get(i));
}
@@ -360,13 +362,20 @@
InvokerHaInfrastructure getInvokerHaInfrastructure(int serverCount);
/**
+ * Returns the invoker ha tx failover authorisations map.
+ *
+ * @return WeakHashMap containing the tx failover authorisations.
+ */
+ WeakHashMap getTxFailoverAuthorizationsMap();
+
+ /**
* Creates an instance of invoker endpoint.
*
* @param serverName name of invoker endpoint
* @param serverNumber invoker endpoint number
* @return
*/
- InvokerHA createInvokerHAServer(String serverName, int serverNumber);
+ InvokerHA createInvokerHaServer(String serverName, int serverNumber);
}
/**
@@ -487,4 +496,61 @@
super(new RoundRobin());
}
}
+
+ /**
+ * Trace load balance policy specific for first available. This allows for non
+ * argument construction of such load balance policy, which makes it testing
+ * cleaner. We just pass the load balance policy class and we use reflection
+ * to create a new instance.
+ *
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+ public static class TraceFirstAvailable extends TraceLoadBalancePolicy
+ {
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -1626190092127048933L;
+
+ public TraceFirstAvailable()
+ {
+ super(new FirstAvailable());
+ }
+ }
+
+ /**
+ * Trace load balance policy specific for first available indentical all
+ * proxies. This allows for non argument construction of such load balance
+ * policy, which makes it testing cleaner. We just pass the load balance
+ * policy class and we use reflection to create a new instance.
+ *
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+ public static class TraceFirstAvailableIdenticalAllProxies extends TraceLoadBalancePolicy
+ {
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -8656749681577922508L;
+
+ public TraceFirstAvailableIdenticalAllProxies()
+ {
+ super(new FirstAvailableIdenticalAllProxies());
+ }
+ }
+
+ /**
+ * Trace load balance policy specific for random robin. This allows for non
+ * argument construction of such load balance policy, which makes it testing
+ * cleaner. We just pass the load balance policy class and we use reflection
+ * to create a new instance.
+ *
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+ public static class TraceRandomRobin extends TraceLoadBalancePolicy
+ {
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -1626190092127048933L;
+
+ public TraceRandomRobin()
+ {
+ super(new RandomRobin());
+ }
+ }
}
Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaMockUtils.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaMockUtils.java (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaMockUtils.java 2007-11-16 19:13:25 UTC (rev 67190)
@@ -0,0 +1,162 @@
+/*
+ * 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.util.ArrayList;
+
+import org.jboss.ha.framework.interfaces.LoadBalancePolicy;
+import org.jboss.invocation.Invocation;
+import org.jboss.invocation.Invoker;
+import org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxyHA;
+import org.jboss.invocation.jrmp.server.JRMPInvokerHA;
+
+/**
+ * JrmpInvokerHaMockUtils.
+ *
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+public class JRMPInvokerHaMockUtils
+{
+ /**
+ * Mock version of JRMPInvokerHA that eases debugging and swallows an
+ * exception being thrown when unregistering the invoker ha mbean.
+ *
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+ public static class MockJRMPInvokerHA extends JRMPInvokerHA
+ {
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -4557124707606766661L;
+
+ private String name;
+
+ public MockJRMPInvokerHA(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Override postDeregister() to avoid the following exception being
+ * thrown on tearDown():
+ *
+ * javax.management.InstanceNotFoundException: jboss.system:service=ServiceController
+ * at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1010)
+ * at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:804)
+ * at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:784)
+ * at org.jboss.system.ServiceMBeanSupport.postDeregister(ServiceMBeanSupport.java:424)
+ * at org.jboss.invocation.jrmp.server.JRMPInvoker.postDeregister(JRMPInvoker.java:665)
+ */
+ @Override
+ public void postDeregister()
+ {
+ }
+
+ /**
+ * Override toString because in absence of RemoteRef
+ * java.rmi.server.RemoteObject's toString implementation prints just
+ * the class name which makes it pretty ackward for assertions and
+ * debugging.
+ */
+ @Override
+ public String toString()
+ {
+ return name;
+ }
+
+ @Override
+ protected Invoker createProxy(ArrayList targets, LoadBalancePolicy policy, String proxyFamilyName,
+ long viewId)
+ {
+ return new MockJRMPInvokerProxyHA(targets, policy, proxyFamilyName, viewId);
+ }
+
+ @Override
+ public Object invoke(Invocation invocation) throws Exception
+ {
+// Object[] arguments = invocation.getArguments();
+// if (arguments != null && arguments.length != 0)
+// {
+// if (arguments[0].equals(FailureType.AFTER_SERVER_NOT_COMPLETED_BUT_SUCCESS_AFTER)
+// && invocation.getPayloadValue("MOCK_FAILOVER_COUNTER").equals(new Integer(0)))
+// {
+// log.debug("failing because of " + FailureType.AFTER_SERVER_NOT_COMPLETED_BUT_SUCCESS_AFTER);
+// throw new GenericClusteringException(GenericClusteringException.COMPLETED_NO, FailureType.AFTER_SERVER_NOT_COMPLETED_BUT_SUCCESS_AFTER.toString());
+// }
+//
+// if (arguments[0].equals(FailureType.AFTER_SERVER_NOT_COMPLETED_BOTH_SERVERS))
+// {
+// log.debug("failing because of " + FailureType.AFTER_SERVER_NOT_COMPLETED_BOTH_SERVERS);
+// throw new GenericClusteringException(GenericClusteringException.COMPLETED_NO, FailureType.AFTER_SERVER_NOT_COMPLETED_BOTH_SERVERS.toString());
+// }
+// if (arguments[0].equals(FailureType.AFTER_SERVER_COMPLETED))
+// {
+// log.debug("failing because of " + FailureType.AFTER_SERVER_COMPLETED);
+// throw new GenericClusteringException(GenericClusteringException.COMPLETED_YES, FailureType.AFTER_SERVER_COMPLETED.toString());
+// }
+// }
+
+ return super.invoke(invocation);
+ }
+
+ }
+
+ public static class MockJRMPInvokerProxyHA extends JRMPInvokerProxyHA
+ {
+
+ public MockJRMPInvokerProxyHA(ArrayList targets, LoadBalancePolicy policy, String proxyFamilyName, long viewId)
+ {
+ super(targets, policy, proxyFamilyName, viewId);
+ }
+
+// @Override
+// protected void putIfExistsTransactionTarget(Invocation invocation, Object tpc)
+// {
+// Object[] arguments = invocation.getArguments();
+// if (arguments != null && arguments.length != 0 && arguments[0].equals(FailureType.BEFORE_SERVER))
+// {
+// log.info("failing because of " + FailureType.BEFORE_SERVER);
+// throw new IllegalStateException("see how you handle this!!");
+// }
+//
+// super.putIfExistsTransactionTarget(invocation, tpc);
+// }
+
+ @Override
+ public boolean txContextAllowsFailover(Invocation invocation)
+ {
+// int failoverCount = ((Integer)invocation.getPayloadValue("MOCK_FAILOVER_COUNTER")).intValue();
+// failoverCount++;
+// invocation.setValue ("MOCK_FAILOVER_COUNTER", new Integer(failoverCount), PayloadKey.PAYLOAD);
+
+ return super.txContextAllowsFailover(invocation);
+ }
+
+ @Override
+ public Object invoke(Invocation invocation) throws Exception
+ {
+// invocation.setValue ("MOCK_FAILOVER_COUNTER", new Integer(0), PayloadKey.PAYLOAD);
+
+ return super.invoke(invocation);
+ }
+ }
+
+}
Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaUnitTestCase.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaUnitTestCase.java (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaUnitTestCase.java 2007-11-16 19:13:25 UTC (rev 67190)
@@ -0,0 +1,76 @@
+/*
+ * 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.util.WeakHashMap;
+
+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.InvokerHaInfrastructure;
+import org.jboss.test.cluster.invokerha.InvokerHaInfrastructure.InvokerHaFactory;
+import org.jboss.test.cluster.invokerha.JRMPInvokerHaMockUtils.MockJRMPInvokerHA;
+
+/**
+ * Unit test case for jrmp invoker ha proxy and invoker at the other side.
+ *
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+public class JRMPInvokerHaUnitTestCase extends AbstractInvokerHaUnitTestCase
+{
+ @Override
+ protected void setUp() throws Exception
+ {
+ setUp(2, new JRMPInvokerHaFactory());
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ /** Classes **/
+
+ public class JRMPInvokerHaFactory implements InvokerHaFactory
+ {
+ public String getInvokerTypeName()
+ {
+ return "JRMPInvokerHa";
+ }
+
+ public InvokerHaInfrastructure getInvokerHaInfrastructure(int serverCount)
+ {
+ return new InvokerHaInfrastructure(serverCount, this);
+ }
+
+ public WeakHashMap getTxFailoverAuthorizationsMap()
+ {
+ return JRMPInvokerProxyHA.txFailoverAuthorizations;
+ }
+
+ public InvokerHA createInvokerHaServer(String serverName, int serverNumber)
+ {
+ return new MockJRMPInvokerHA(getInvokerTypeName() + "-" + serverName + "-" + serverNumber);
+ }
+ }
+}
Modified: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/invokerha/UnifiedInvokerHaUnitTestCase.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/invokerha/UnifiedInvokerHaUnitTestCase.java 2007-11-16 19:12:58 UTC (rev 67189)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cluster/invokerha/UnifiedInvokerHaUnitTestCase.java 2007-11-16 19:13:25 UTC (rev 67190)
@@ -23,6 +23,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.WeakHashMap;
import javax.management.ObjectName;
@@ -58,11 +59,6 @@
super.tearDown();
}
- public void testSuccessfulCallsRoundRobin() throws Exception
- {
- successfulCalls(TraceRoundRobin.class, UnifiedInvokerHAProxy.txFailoverAuthorizations);
- }
-
/** Classes **/
/**
@@ -72,7 +68,7 @@
{
public String getInvokerTypeName()
{
- return "UnifiedInvokerHA";
+ return "UnifiedInvokerHa";
}
public InvokerHaInfrastructure getInvokerHaInfrastructure(int serverCount)
@@ -80,8 +76,13 @@
return new UnifiedInvokerHaInfrastructure(serverCount, this);
}
- public InvokerHA createInvokerHAServer(String serverName, int serverNumber)
+ public WeakHashMap getTxFailoverAuthorizationsMap()
{
+ return UnifiedInvokerHAProxy.txFailoverAuthorizations;
+ }
+
+ public InvokerHA createInvokerHaServer(String serverName, int serverNumber)
+ {
MockUnifiedInvokerHA invoker = new MockUnifiedInvokerHA(getInvokerTypeName() + "-" + serverName + "-" + serverNumber);
MockClient client = new MockClient(invoker);
MockInvokerLocator locator = new MockInvokerLocator("127.0.0.1", serverNumber, client);
More information about the jboss-cvs-commits
mailing list