[jboss-cvs] JBossAS SVN: r81078 - in branches/JBPAPP_4_2_0_GA_CP/testsuite/src: main/org/jboss/test/cluster/invokerha/ejb/test and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Nov 14 12:02:26 EST 2008
Author: galder.zamarreno at jboss.com
Date: 2008-11-14 12:02:25 -0500 (Fri, 14 Nov 2008)
New Revision: 81078
Modified:
branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHa.java
branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHaTransactionSticky.java
branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaFailureType.java
branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaInfrastructure.java
branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaTransactionalMockUtils.java
branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaMockUtils.java
branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaTransactionStickyUnitTestCase.java
branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/UnifiedInvokerHaMockUtils.java
branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/ejb/test/UserTransactionStickyUnitTestCase.java
branches/JBPAPP_4_2_0_GA_CP/testsuite/src/resources/cluster/invokerha/ejb/META-INF/jboss.xml
branches/JBPAPP_4_2_0_GA_CP/testsuite/src/resources/test-configs/ustxsticky/conf/jboss-service.xml
Log:
[JBPAPP-1410] Fixed standalone unit tests so that a client user transaction is now used that uses one of the sticky interceptors. Bean invocations now go past the EJB sticky interceptor too. Finally, modified descriptors for in-server unit test.
Modified: branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHa.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHa.java 2008-11-14 17:01:37 UTC (rev 81077)
+++ branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHa.java 2008-11-14 17:02:25 UTC (rev 81078)
@@ -65,6 +65,8 @@
Invoker systemTimeProxy;
+ Invoker clientUserTransactionProxy;
+
Object prevChosenTargetDateTimeTeller;
Object prevChosenTargetSystemTimeTeller;
@@ -87,9 +89,11 @@
infrastructure.createDateTimeTeller();
infrastructure.createSystemTimeTeller();
+ infrastructure.createClientUserTransactionService();
infrastructure.deployDateTimeTeller();
infrastructure.deploySystemTimeTeller();
+ infrastructure.deployClientUserTransactionService();
}
@Override
@@ -101,6 +105,7 @@
infrastructure.undeployDateTimeTeller();
infrastructure.undeploySystemTimeTeller();
+ infrastructure.undeployClientUserTransactionService();
infrastructure.undeployServers();
}
@@ -247,6 +252,7 @@
/* Create a proxy instances retrieved from the first server */
timeTellerProxy = infrastructure.createDateTimeTellerProxy(serverIndex, policyClass);
systemTimeProxy = infrastructure.createSystemTimeTellerProxy(serverIndex, policyClass);
+ clientUserTransactionProxy = infrastructure.createClientUserTransactionProxy(serverIndex, policyClass);
/* Initialise previous chosen targets. If not new proxies elected
* between transactions, this allows to carry on checking chosen
Modified: branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHaTransactionSticky.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHaTransactionSticky.java 2008-11-14 17:01:37 UTC (rev 81077)
+++ branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHaTransactionSticky.java 2008-11-14 17:02:25 UTC (rev 81078)
@@ -21,13 +21,13 @@
*/
package org.jboss.test.cluster.invokerha;
-import java.rmi.server.UID;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.transaction.Transaction;
+import javax.transaction.UserTransaction;
import org.jboss.ha.framework.interfaces.LoadBalancePolicy;
import org.jboss.ha.framework.interfaces.TransactionStickyFirstAvailable;
@@ -35,10 +35,12 @@
import org.jboss.ha.framework.interfaces.TransactionStickyRandomRobin;
import org.jboss.ha.framework.interfaces.TransactionStickyRoundRobin;
import org.jboss.invocation.Invocation;
+import org.jboss.invocation.Invoker;
import org.jboss.invocation.InvokerProxyHA;
import org.jboss.invocation.ServiceUnavailableException;
import org.jboss.logging.Logger;
-import org.jboss.test.cluster.invokerha.InvokerHaTransactionalMockUtils.MockTransaction;
+import org.jboss.test.cluster.invokerha.InvokerHaTransactionalMockUtils.MockUserTransaction;
+import org.jboss.test.cluster.invokerha.InvokerHaTransactionalMockUtils.MockTransactionStickyInterceptor;
/**
* AbstractInvokerHaTransactionSticky.
@@ -161,28 +163,24 @@
try
{
- UID uid;
-
createNewProxies(0, policyClass, true);
- /* Simulate client user transaction */
- uid = new UID();
- transactionalMockUtils.getTpcf().setUid(uid);
+ UserTransaction ut = new MockUserTransaction(clientUserTransactionProxy, infrastructure);
+ ut.begin();
performTransactionalStickyCalls(3, null, policyClass, newProxiesInBetweenTransactions);
+ ut.commit();
/* either set would do because they should be the same */
Set<Object> chosenTargetsTx1 = chosenTargets;
if (newProxiesInBetweenTransactions)
{
+ ut = new MockUserTransaction(clientUserTransactionProxy, infrastructure);
createNewProxies(0, policyClass, false);
}
- /* Simulate transaction interceptor */
- uid = new UID();
- Transaction tx = new MockTransaction();
- transactionalMockUtils.getTpcf().setUid(uid);
- transactionalMockUtils.getTpci().setTransaction(tx);
- performTransactionalStickyCalls(3, tx, policyClass, newProxiesInBetweenTransactions);
+ ut.begin();
+ performTransactionalStickyCalls(3, null, policyClass, newProxiesInBetweenTransactions);
+ ut.commit();
/* either set would do because they should be the same */
Set<Object> chosenTargetsTx2 = chosenTargets;
@@ -204,10 +202,11 @@
try
{
- UID uid = new UID();
createNewProxies(0, policyClass, true);
- transactionalMockUtils.getTpcf().setUid(uid);
+ UserTransaction ut = new MockUserTransaction(clientUserTransactionProxy, infrastructure);
+ ut.begin();
performTransactionalCallsWithNodeShutdown(null, policyClass);
+ ut.commit();
}
catch(Exception e)
{
@@ -249,14 +248,14 @@
/* create invocation to date time teller */
inv = infrastructure.createDateTimeTellerInvocation(tx, null);
/* invoke on proxy passing the invocation */
- log.debug(timeTellerProxy.invoke(inv));
+ log.debug(invokeTimeTellerProxy(inv));
/* assert post conditions after invocation */
chosenTargetsDateTimeTeller = assertSuccessfulPostConditions(inv, chosenTargetsDateTimeTeller);
/* create invocation to system time teller */
inv = infrastructure.createSystemTimeTellerInvocation(tx, null);
/* invoke on proxy passing the invocation */
- log.debug(systemTimeProxy.invoke(inv));
+ log.debug(invokeSystemTimeProxy(inv));
/* assert post conditions after invocation */
chosenTargetsSystemTimeTeller = assertSuccessfulPostConditions(inv, chosenTargetsSystemTimeTeller);
}
@@ -291,7 +290,7 @@
/* create invocation to date time teller */
inv = infrastructure.createDateTimeTellerInvocation(tx, null);
/* invoke on proxy passing the invocation */
- log.debug(timeTellerProxy.invoke(inv));
+ log.debug(invokeTimeTellerProxy(inv));
/* assert post conditions after invocation */
chosenTargetsDateTimeTeller = assertSuccessfulPostConditions(inv, chosenTargetsDateTimeTeller);
@@ -301,13 +300,13 @@
inv = infrastructure.createDateTimeTellerInvocation(tx, null);
try
{
- log.debug(timeTellerProxy.invoke(inv));
+ log.debug(invokeTimeTellerProxy(inv));
fail("Should have thrown an exception because sticky target is no longer available");
}
catch(Exception e)
{
log.debug("Expected exception", e);
- assertTrue(e instanceof ServiceUnavailableException || e.getCause() instanceof ServiceUnavailableException);
+ assertTrue(e.getCause() instanceof ServiceUnavailableException);
}
}
@@ -356,15 +355,21 @@
try
{
/* fail in 1st call */
+ UserTransaction ut = new MockUserTransaction(clientUserTransactionProxy, infrastructure);
+ ut.begin();
failureCall(failureType, true, policyClass, newProxiesInBetweenFailures);
+ ut.commit();
if (newProxiesInBetweenFailures)
{
+ ut = new MockUserTransaction(clientUserTransactionProxy, infrastructure);
createNewProxies(0, policyClass, false);
}
/* fail in Nth call */
+ ut.begin();
failureCall(failureType, false, policyClass, newProxiesInBetweenFailures);
+ ut.commit();
}
catch(Exception e)
{
@@ -377,38 +382,31 @@
protected void failureCall(InvokerHaFailureType failureType, boolean injectFailureIn1stCall, Class<? extends LoadBalancePolicy> policyClass, boolean newProxiesInBetweenFailures) throws Exception
{
- UID uid;
Invocation inv;
if (injectFailureIn1stCall)
{
- uid = new UID();
- transactionalMockUtils.getTpcf().setUid(uid);
/* When failure must happen in the very 1st call, we create a 1st
* invocation with the failure injected */
inv = infrastructure.createDateTimeTellerInvocation(null, failureType);
}
else
{
- uid = new UID();
- Transaction tx = new MockTransaction();
- transactionalMockUtils.getTpcf().setUid(uid);
- transactionalMockUtils.getTpci().setTransaction(tx);
/* When failure is not in first call, we do a call to each bean before
* injecting the faliure */
- performTransactionalStickyCalls(1, tx, policyClass, newProxiesInBetweenFailures);
+ performTransactionalStickyCalls(1, null, policyClass, newProxiesInBetweenFailures);
/* Now we create the invocation with the failure injected */
inv = infrastructure.createDateTimeTellerInvocation(null, failureType);
}
try
{
- log.debug(timeTellerProxy.invoke(inv));
+ log.debug(invokeTimeTellerProxy(inv));
if (failureType.isRecoverable(injectFailureIn1stCall))
{
failureType.assertFailoverCounter(injectFailureIn1stCall, inv.getAsIsValue("FAILOVER_COUNTER"));
inv = infrastructure.createDateTimeTellerInvocation(null, null);
- log.debug(timeTellerProxy.invoke(inv));
+ log.debug(invokeTimeTellerProxy(inv));
}
else
{
@@ -417,6 +415,7 @@
}
catch (Exception e)
{
+ log.debug("Exception (could be expected) during failure call testing", e);
if (failureType.isRecoverable(injectFailureIn1stCall))
{
fail("should have failed, failover is not allowed for " + failureType);
@@ -425,9 +424,31 @@
{
assertNull("transaction on the client side should be null", inv.getTransaction());
failureType.assertFailoverCounter(injectFailureIn1stCall, inv.getAsIsValue("FAILOVER_COUNTER"));
- failureType.assertException(e);
+ failureType.assertException(e.getCause());
}
}
}
+ protected Object invokeTimeTellerProxy(Invocation inv) throws Exception
+ {
+ return invokeProxy(timeTellerProxy, "UnitTestPartition/DateTimeTellerMBean", inv);
+ }
+
+ protected Object invokeSystemTimeProxy(Invocation inv) throws Exception
+ {
+ return invokeProxy(systemTimeProxy, "UnitTestPartition/SystemTimeTellerMBean", inv);
+ }
+
+ protected Object invokeProxy(Invoker invoker, String proxyFamilyName, Invocation inv) throws Exception
+ {
+ try
+ {
+ return new MockTransactionStickyInterceptor(invoker, proxyFamilyName).invoke(inv);
+ }
+ catch(Throwable t)
+ {
+ throw new Exception("Throwable", t);
+ }
+
+ }
}
Modified: branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaFailureType.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaFailureType.java 2008-11-14 17:01:37 UTC (rev 81077)
+++ branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaFailureType.java 2008-11-14 17:02:25 UTC (rev 81078)
@@ -53,14 +53,16 @@
return false;
case AFTER_SERVER_NOT_COMPLETED_BUT_SUCCESS_AFTER:
- /* - if failure happens after reaching the server but didn't complete, and
- * it happens in the 1st transactional invocation, it's recoverable as
- * long as the failover call succeeds, otherwise (Nth invocation) it's
- * not recoverable. */
- if (injectFailureIn1stCall)
- {
- return true;
- }
+ /* it is not recoverable because UserTransaction.begin() already
+ * reached a server.*/
+// /* - if failure happens after reaching the server but didn't complete, and
+// * it happens in the 1st transactional invocation, it's recoverable as
+// * long as the failover call succeeds, otherwise (Nth invocation) it's
+// * not recoverable. */
+// if (injectFailureIn1stCall)
+// {
+// return true;
+// }
return false;
case AFTER_SERVER_NOT_COMPLETED_BOTH_SERVERS:
@@ -116,7 +118,7 @@
switch(this)
{
case BEFORE_SERVER:
- TestCase.assertEquals(0, failoverCounter);
+ TestCase.assertNull(failoverCounter);
break;
case AFTER_SERVER_NOT_COMPLETED_BUT_SUCCESS_AFTER:
@@ -124,18 +126,21 @@
break;
case AFTER_SERVER_NOT_COMPLETED_BOTH_SERVERS:
- if (injectFailureIn1stCall)
- {
- /* Two failovers were attempted before finally giving up */
- TestCase.assertEquals(2, failoverCounter);
- }
- else
- {
- /* It's 1 because after several calls, the transaction has
- * already reached the server, so that's good enough not to
- * succeed */
+ /* Only one attempted failover because it won't be available to
+ * failover due to UserTransaction.begin() having already hit the
+ * server and hence, txFailoverAuthorization maps contains that tpc. */
+// if (injectFailureIn1stCall)
+// {
+// /* Two failovers were attempted before finally giving up */
+// TestCase.assertEquals(2, failoverCounter);
+// }
+// else
+// {
+// /* It's 1 because after several calls, the transaction has
+// * already reached the server, so that's good enough not to
+// * succeed */
TestCase.assertEquals(1, failoverCounter);
- }
+// }
break;
case AFTER_SERVER_COMPLETED:
@@ -146,23 +151,23 @@
}
}
- public void assertException(Exception e)
+ public void assertException(Throwable t)
{
switch(this)
{
case BEFORE_SERVER:
- TestCase.assertTrue(e instanceof IllegalStateException);
+ TestCase.assertTrue(t instanceof IllegalStateException);
break;
case AFTER_SERVER_NOT_COMPLETED_BUT_SUCCESS_AFTER:
case AFTER_SERVER_NOT_COMPLETED_BOTH_SERVERS:
- TestCase.assertTrue(e instanceof ServiceUnavailableException);
- TestCase.assertTrue(e.getCause() instanceof GenericClusteringException);
+ TestCase.assertTrue(t instanceof ServiceUnavailableException);
+ TestCase.assertTrue(t.getCause() instanceof GenericClusteringException);
break;
case AFTER_SERVER_COMPLETED:
- TestCase.assertTrue(e instanceof ServerException);
- TestCase.assertTrue(e.getCause() instanceof GenericClusteringException);
+ TestCase.assertTrue(t instanceof ServerException);
+ TestCase.assertTrue(t.getCause() instanceof GenericClusteringException);
break;
}
}
Modified: branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaInfrastructure.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaInfrastructure.java 2008-11-14 17:01:37 UTC (rev 81077)
+++ branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaInfrastructure.java 2008-11-14 17:02:25 UTC (rev 81078)
@@ -23,6 +23,7 @@
import java.io.Serializable;
import java.lang.management.ManagementFactory;
+import java.rmi.server.UID;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -70,10 +71,14 @@
private final ObjectName systemTimeTellerON;
+ private final ObjectName clientUserTransactionServiceON;
+
private final Integer dateTimeTellerONHashCode;
private final Integer systemTimeTellerONHashCode;
+ private final Integer clientUserTransactionServiceONHashCode;
+
private final int serverCount;
private List<? extends InvokerHA> replicants;
@@ -96,8 +101,10 @@
/* initialise ObjectNames and hashcodes */
dateTimeTellerON = new ObjectName("com.acme.mbeans:type=DateTimeTeller");
systemTimeTellerON = new ObjectName("com.acme.mbeans:type=SystemTimeTeller");
+ clientUserTransactionServiceON = new ObjectName("com.acme.mbeans:type=ClientUserTransactionService");
dateTimeTellerONHashCode = new Integer(dateTimeTellerON.hashCode());
systemTimeTellerONHashCode = new Integer(systemTimeTellerON.hashCode());
+ clientUserTransactionServiceONHashCode = new Integer(clientUserTransactionServiceON.hashCode());
/* create a list of object names for the invoker endpoints */
invokerONs = new ArrayList<ObjectName>(this.serverCount);
@@ -120,6 +127,7 @@
{
Registry.bind(dateTimeTellerONHashCode, dateTimeTellerON);
Registry.bind(systemTimeTellerONHashCode, systemTimeTellerON);
+ Registry.bind(clientUserTransactionServiceONHashCode, clientUserTransactionServiceON);
}
/**
@@ -169,6 +177,13 @@
return systemTimeTellerMBean;
}
+ public ClientUserTransactionService createClientUserTransactionService() throws Exception
+ {
+ ClientUserTransactionService clientUserTransactionServiceMBean = new ClientUserTransactionService();
+ mbs.registerMBean(clientUserTransactionServiceMBean, clientUserTransactionServiceON);
+ return clientUserTransactionServiceMBean;
+ }
+
/**
* Deploy date time teller mbean in each server, or invoker endpoint,
* creating a mock HATarget with the list of replicants and associating the
@@ -188,6 +203,11 @@
{
deploy(replicants, systemTimeTellerON, "SystemTimeTellerReplicant");
}
+
+ public void deployClientUserTransactionService() throws Exception
+ {
+ deploy(replicants, clientUserTransactionServiceON, "ClientUserTransactionServiceReplicant");
+ }
/**
* Create a proxy to date time teller bean.
@@ -217,6 +237,12 @@
return server.createProxy(systemTimeTellerON, policyClass.newInstance(), "UnitTestPartition/SystemTimeTellerMBean");
}
+ public Invoker createClientUserTransactionProxy(int serverIndex, Class<? extends LoadBalancePolicy> policyClass) throws Exception
+ {
+ InvokerHA server = replicants.get(serverIndex);
+ return server.createProxy(clientUserTransactionServiceON, policyClass.newInstance(), "UnitTestPartition/ClientUserTransactionServiceMBean");
+ }
+
/**
* Create a new invocation for date time teller mbean
*
@@ -245,6 +271,11 @@
public Invocation createSystemTimeTellerInvocation(Transaction tx, InvokerHaFailureType failureType)
{
return createInvocation(tx, systemTimeTellerONHashCode, failureType);
+ }
+
+ public Invocation createClientUserTransactionInvocation(Transaction tx, InvokerHaFailureType failureType)
+ {
+ return createInvocation(tx, clientUserTransactionServiceONHashCode, failureType);
}
/**
@@ -254,7 +285,8 @@
{
/* Unregister from the JMX registry */
Registry.unbind(dateTimeTellerONHashCode);
- Registry.unbind(systemTimeTellerONHashCode);
+ Registry.unbind(systemTimeTellerONHashCode);
+ Registry.unbind(clientUserTransactionServiceONHashCode);
}
/**
@@ -274,6 +306,11 @@
{
undeploy(replicants, systemTimeTellerON);
}
+
+ public void undeployClientUserTransactionService() throws Exception
+ {
+ undeploy(replicants, clientUserTransactionServiceON);
+ }
/**
* Unregister invoker endpoints from mbean server.
@@ -414,6 +451,11 @@
Object invoke(Invocation invocation) throws Exception;
}
+ public interface ClientUserTransactionServiceMBean
+ {
+ Object invoke(Invocation invocation) throws Exception;
+ }
+
/** Classes **/
public class DateTimeTeller implements DateTimeTellerMBean
@@ -434,6 +476,15 @@
}
}
+ public class ClientUserTransactionService implements ClientUserTransactionServiceMBean
+ {
+ public Object invoke(Invocation invocation) throws Exception
+ {
+ // Return new tpc -> only begin() calls really tested as they set the sticky target
+ return new UID();
+ }
+ }
+
/**
* MockHATarget class that avoids using DistributedReplicantManager in any
* way. The unit test will force changes in the composition of replicants,
Modified: branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaTransactionalMockUtils.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaTransactionalMockUtils.java 2008-11-14 17:01:37 UTC (rev 81077)
+++ branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaTransactionalMockUtils.java 2008-11-14 17:02:25 UTC (rev 81078)
@@ -25,12 +25,20 @@
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
import javax.transaction.RollbackException;
import javax.transaction.Synchronization;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
+import javax.transaction.UserTransaction;
import javax.transaction.xa.XAResource;
+import org.jboss.invocation.Invocation;
+import org.jboss.invocation.Invoker;
+import org.jboss.invocation.InvokerInterceptor;
+import org.jboss.proxy.ClientUserTransactionStickyInterceptor;
+import org.jboss.proxy.Interceptor;
+import org.jboss.proxy.TransactionStickyInterceptor;
import org.jboss.tm.TransactionPropagationContextFactory;
import org.jboss.tm.TransactionPropagationContextImporter;
import org.jboss.tm.TransactionPropagationContextUtil;
@@ -42,7 +50,7 @@
*/
public class InvokerHaTransactionalMockUtils
{
- private MockTransactionPropagationContextFactory tpcf;
+ private static MockTransactionPropagationContextFactory tpcf;
private MockTransactionPropagationContextImporter tpci;
@@ -155,4 +163,127 @@
}
}
+ public static class MockUserTransaction implements UserTransaction
+ {
+ private Invoker invoker;
+
+ private InvokerHaInfrastructure infrastructure;
+
+ public MockUserTransaction(Invoker invoker, InvokerHaInfrastructure infrastructure)
+ {
+ this.invoker = invoker;
+ this.infrastructure = infrastructure;
+ }
+
+ public void begin() throws NotSupportedException, SystemException
+ {
+ try
+ {
+ Invocation inv = infrastructure.createClientUserTransactionInvocation(null, null);
+ UID uid = (UID) new MockClientUserTransactionStickyInterceptor(invoker).invoke(inv);
+ tpcf.setUid(uid);
+ }
+ catch (Throwable e)
+ {
+ throw new RuntimeException("Exception during mock UT.begin", e);
+ }
+ }
+
+ public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException,
+ SecurityException, IllegalStateException, SystemException
+ {
+ tpcf.setUid(null);
+ }
+
+ public int getStatus() throws SystemException
+ {
+ return 0;
+ }
+
+ public void rollback() throws IllegalStateException, SecurityException, SystemException
+ {
+ }
+
+ public void setRollbackOnly() throws IllegalStateException, SystemException
+ {
+ }
+
+ public void setTransactionTimeout(int seconds) throws SystemException
+ {
+ }
+ }
+
+ public static class MockClientUserTransactionStickyInterceptor extends ClientUserTransactionStickyInterceptor
+ {
+ private Invoker invoker;
+
+ public MockClientUserTransactionStickyInterceptor(Invoker invoker)
+ {
+ this.invoker = invoker;
+ }
+
+ @Override
+ public Interceptor getNext()
+ {
+ InvokerInterceptor.setLocal(invoker);
+
+ return new InvokerInterceptor()
+ {
+ @Override
+ public boolean isLocal(Invocation invocation)
+ {
+ return true;
+ }
+ };
+// return new Interceptor()
+// {
+// @Override
+// public Object invoke(Invocation mi) throws Throwable
+// {
+// return new UID();
+// }
+// };
+ }
+
+ @Override
+ protected String getProxyFamilyName(Invocation invocation) throws Exception
+ {
+ return "UnitTestPartition/ClientUserTransactionServiceMBean";
+ }
+ }
+
+ public static class MockTransactionStickyInterceptor extends TransactionStickyInterceptor
+ {
+ private Invoker invoker;
+
+ private String proxyFamilyName;
+
+ public MockTransactionStickyInterceptor(Invoker invoker, String proxyFamilyName)
+ {
+ this.invoker = invoker;
+ this.proxyFamilyName = proxyFamilyName;
+ }
+
+ @Override
+ public Interceptor getNext()
+ {
+ InvokerInterceptor.setLocal(invoker);
+
+ return new InvokerInterceptor()
+ {
+ @Override
+ public boolean isLocal(Invocation invocation)
+ {
+ return true;
+ }
+ };
+ }
+
+ @Override
+ protected String getProxyFamilyName(Invocation invocation) throws Exception
+ {
+ return proxyFamilyName;
+ }
+ }
+
}
Modified: branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaMockUtils.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaMockUtils.java 2008-11-14 17:01:37 UTC (rev 81077)
+++ branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaMockUtils.java 2008-11-14 17:02:25 UTC (rev 81078)
@@ -23,7 +23,6 @@
import java.util.ArrayList;
-import org.jboss.ha.framework.interfaces.GenericClusteringException;
import org.jboss.ha.framework.interfaces.LoadBalancePolicy;
import org.jboss.invocation.Invocation;
import org.jboss.invocation.Invoker;
@@ -122,18 +121,6 @@
public Object invoke(Invocation invocation) throws Exception
{
return super.invoke(invocation);
- }
-
- @Override
- protected void putIfExistsTransactionTarget(Invocation invocation, Object tpc) throws Exception
- {
- InvokerHaFailureType failureType = (InvokerHaFailureType)invocation.getValue("FAILURE_TYPE");
- if (failureType != null)
- {
- failureType.injectFailureIfExistsBeforeServer();
- }
-
- super.putIfExistsTransactionTarget(invocation, tpc);
}
}
Modified: branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaTransactionStickyUnitTestCase.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaTransactionStickyUnitTestCase.java 2008-11-14 17:01:37 UTC (rev 81077)
+++ branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaTransactionStickyUnitTestCase.java 2008-11-14 17:02:25 UTC (rev 81078)
@@ -23,6 +23,9 @@
import java.util.List;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
import org.jboss.invocation.InvokerHA;
import org.jboss.test.cluster.invokerha.JRMPInvokerHaUnitTestCase.JRMPInvokerHaFactory;
import org.jboss.test.cluster.invokerha.AbstractInvokerHaTransactionSticky;
@@ -62,4 +65,12 @@
return "TX_STICKY_TARGET";
}
}
+
+ public static Test suite()
+ {
+ /* No transactions to be run for JRMP invoker version of transaction
+ * sticky functionality because this old legacy invoker is no longer
+ * supported for transaction sticky functionality. */
+ return new TestSuite();
+ }
}
Modified: branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/UnifiedInvokerHaMockUtils.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/UnifiedInvokerHaMockUtils.java 2008-11-14 17:01:37 UTC (rev 81077)
+++ branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/UnifiedInvokerHaMockUtils.java 2008-11-14 17:02:25 UTC (rev 81078)
@@ -142,9 +142,22 @@
{
return new MockClient(locator);
}
+
+// @Override
+// protected void putIfExistsTransactionTarget(Invocation invocation, Object tpc) throws Exception
+// {
+// InvokerHaFailureType failureType = (InvokerHaFailureType)invocation.getValue("FAILURE_TYPE");
+// if (failureType != null)
+// {
+// failureType.injectFailureIfExistsBeforeServer();
+// }
+//
+// super.putIfExistsTransactionTarget(invocation, tpc);
+// }
+
@Override
- protected void putIfExistsTransactionTarget(Invocation invocation, Object tpc) throws Exception
+ public Object invoke(Invocation invocation) throws Exception
{
InvokerHaFailureType failureType = (InvokerHaFailureType)invocation.getValue("FAILURE_TYPE");
if (failureType != null)
@@ -152,9 +165,9 @@
failureType.injectFailureIfExistsBeforeServer();
}
- super.putIfExistsTransactionTarget(invocation, tpc);
+ return super.invoke(invocation);
}
-
+
public InvokerLocator getLocator()
{
return super.getLocator();
Modified: branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/ejb/test/UserTransactionStickyUnitTestCase.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/ejb/test/UserTransactionStickyUnitTestCase.java 2008-11-14 17:01:37 UTC (rev 81077)
+++ branches/JBPAPP_4_2_0_GA_CP/testsuite/src/main/org/jboss/test/cluster/invokerha/ejb/test/UserTransactionStickyUnitTestCase.java 2008-11-14 17:02:25 UTC (rev 81078)
@@ -68,8 +68,15 @@
{
UserTransaction tx;
- ctx = createDefaultPartitionContext();
+ // Connect to the server0 JNDI
+ String[] urls = getNamingURLs();
+ Properties env1 = new Properties();
+ env1.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.NamingContextFactory");
+ env1.setProperty(Context.PROVIDER_URL, urls[0]);
+ ctx = new InitialContext(env1);
+ // ctx = createDefaultPartitionContext();
+
for (int i = 1; i <= numTxs; i++)
{
tx = (UserTransaction)ctx.lookup("UserTransaction");
@@ -100,21 +107,21 @@
}
}
- private Properties getDefaultProperties()
- {
- Properties p = new Properties();
- p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
- p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
- return p;
- }
+// private Properties getDefaultProperties()
+// {
+// Properties p = new Properties();
+// p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
+// p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
+// return p;
+// }
+//
+// private Context createDefaultPartitionContext() throws Exception
+// {
+// Properties p = getDefaultProperties();
+// p.put(NamingContext.JNP_PARTITION_NAME, "DefaultPartition"); // partition name.
+// return new InitialContext(p);
+// }
- private Context createDefaultPartitionContext() throws Exception
- {
- Properties p = getDefaultProperties();
- p.put(NamingContext.JNP_PARTITION_NAME, "DefaultPartition"); // partition name.
- return new InitialContext(p);
- }
-
private static void log(Object message)
{
log.info(message);
Modified: branches/JBPAPP_4_2_0_GA_CP/testsuite/src/resources/cluster/invokerha/ejb/META-INF/jboss.xml
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/testsuite/src/resources/cluster/invokerha/ejb/META-INF/jboss.xml 2008-11-14 17:01:37 UTC (rev 81077)
+++ branches/JBPAPP_4_2_0_GA_CP/testsuite/src/resources/cluster/invokerha/ejb/META-INF/jboss.xml 2008-11-14 17:02:25 UTC (rev 81078)
@@ -18,10 +18,10 @@
</enterprise-beans>
- <!-- invoker-proxy-bindings>
+ <invoker-proxy-bindings>
<invoker-proxy-binding>
<name>ustxsticky-clustered-stateless-unified-invoker</name>
- <invoker-mbean>jboss:service=invoker,type=unifiedha,ext=ustxsticky</invoker-mbean>
+ <invoker-mbean>jboss:service=invoker,type=unifiedha</invoker-mbean>
<proxy-factory>org.jboss.proxy.ejb.ProxyFactoryHA</proxy-factory>
<proxy-factory-config>
<client-interceptors>
@@ -30,6 +30,7 @@
<interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
<interceptor>org.jboss.proxy.TransactionInterceptor</interceptor>
<interceptor>org.jboss.proxy.ejb.SingleRetryInterceptor</interceptor>
+ <interceptor>org.jboss.proxy.TransactionStickyInterceptor</interceptor>
<interceptor call-by-value="false">org.jboss.invocation.InvokerInterceptor</interceptor>
<interceptor call-by-value="true">org.jboss.invocation.MarshallingInvokerInterceptor</interceptor>
</home>
@@ -38,17 +39,19 @@
<interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
<interceptor>org.jboss.proxy.TransactionInterceptor</interceptor>
<interceptor>org.jboss.proxy.ejb.SingleRetryInterceptor</interceptor>
+ <interceptor>org.jboss.proxy.TransactionStickyInterceptor</interceptor>
<interceptor call-by-value="false">org.jboss.invocation.InvokerInterceptor</interceptor>
<interceptor call-by-value="true">org.jboss.invocation.MarshallingInvokerInterceptor</interceptor>
</bean>
</client-interceptors>
</proxy-factory-config>
</invoker-proxy-binding>
- </invoker-proxy-bindings -->
+ </invoker-proxy-bindings>
<container-configurations>
<container-configuration extends="Clustered Stateless SessionBean">
<container-name>User Transaction Stickiness Verifier Clustered Stateless SessionBean</container-name>
+ <invoker-proxy-binding-name>ustxsticky-clustered-stateless-unified-invoker</invoker-proxy-binding-name>
<container-interceptors>
<interceptor>org.jboss.test.cluster.invokerha.ejb.UserTransactionStickinessVerifierInterceptor</interceptor>
<interceptor>org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor</interceptor>
Modified: branches/JBPAPP_4_2_0_GA_CP/testsuite/src/resources/test-configs/ustxsticky/conf/jboss-service.xml
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/testsuite/src/resources/test-configs/ustxsticky/conf/jboss-service.xml 2008-11-14 17:01:37 UTC (rev 81077)
+++ branches/JBPAPP_4_2_0_GA_CP/testsuite/src/resources/test-configs/ustxsticky/conf/jboss-service.xml 2008-11-14 17:02:25 UTC (rev 81078)
@@ -395,6 +395,7 @@
<attribute name="ClientInterceptors">
<interceptors>
<interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
+ <interceptor>org.jboss.proxy.ClientUserTransactionStickyInterceptor</interceptor>
<interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
</interceptors>
</attribute>
More information about the jboss-cvs-commits
mailing list