Add patch with some tweaks submitted by Bernhard Trummer to clean up the
logging for XA TX.
This commit is contained in:
Timothy Bish 2015-07-02 11:59:11 -04:00
parent e4af2eb635
commit 8e7556f397
3 changed files with 278 additions and 126 deletions

View File

@ -40,9 +40,9 @@ import org.apache.activemq.command.TransactionId;
import org.apache.activemq.command.TransactionInfo; import org.apache.activemq.command.TransactionInfo;
import org.apache.activemq.command.XATransactionId; import org.apache.activemq.command.XATransactionId;
import org.apache.activemq.transaction.Synchronization; import org.apache.activemq.transaction.Synchronization;
import org.apache.activemq.transport.failover.FailoverTransport;
import org.apache.activemq.util.JMSExceptionSupport; import org.apache.activemq.util.JMSExceptionSupport;
import org.apache.activemq.util.LongSequenceGenerator; import org.apache.activemq.util.LongSequenceGenerator;
import org.apache.activemq.util.XASupport;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -71,7 +71,7 @@ public class TransactionContext implements XAResource {
// XATransactionId -> ArrayList of TransactionContext objects // XATransactionId -> ArrayList of TransactionContext objects
private final static HashMap<TransactionId, List<TransactionContext>> ENDED_XA_TRANSACTION_CONTEXTS = private final static HashMap<TransactionId, List<TransactionContext>> ENDED_XA_TRANSACTION_CONTEXTS =
new HashMap<TransactionId, List<TransactionContext>>(); new HashMap<TransactionId, List<TransactionContext>>();
private ActiveMQConnection connection; private ActiveMQConnection connection;
private final LongSequenceGenerator localTransactionIdGenerator; private final LongSequenceGenerator localTransactionIdGenerator;
@ -95,17 +95,17 @@ public class TransactionContext implements XAResource {
public boolean isInXATransaction() { public boolean isInXATransaction() {
if (transactionId != null && transactionId.isXATransaction()) { if (transactionId != null && transactionId.isXATransaction()) {
return true; return true;
} else { } else {
if (!ENDED_XA_TRANSACTION_CONTEXTS.isEmpty()) { if (!ENDED_XA_TRANSACTION_CONTEXTS.isEmpty()) {
synchronized(ENDED_XA_TRANSACTION_CONTEXTS) { synchronized(ENDED_XA_TRANSACTION_CONTEXTS) {
for(List<TransactionContext> transactions : ENDED_XA_TRANSACTION_CONTEXTS.values()) { for(List<TransactionContext> transactions : ENDED_XA_TRANSACTION_CONTEXTS.values()) {
if (transactions.contains(this)) { if (transactions.contains(this)) {
return true; return true;
} }
} }
} }
} }
} }
return false; return false;
@ -161,7 +161,7 @@ public class TransactionContext implements XAResource {
try { try {
synchronizations.get(i).afterRollback(); synchronizations.get(i).afterRollback();
} catch (Throwable t) { } catch (Throwable t) {
LOG.debug("Exception from afterRollback on " + synchronizations.get(i), t); LOG.debug("Exception from afterRollback on {}", synchronizations.get(i), t);
if (firstException == null) { if (firstException == null) {
firstException = t; firstException = t;
} }
@ -184,7 +184,7 @@ public class TransactionContext implements XAResource {
try { try {
synchronizations.get(i).afterCommit(); synchronizations.get(i).afterCommit();
} catch (Throwable t) { } catch (Throwable t) {
LOG.debug("Exception from afterCommit on " + synchronizations.get(i), t); LOG.debug("Exception from afterCommit on {}", synchronizations.get(i), t);
if (firstException == null) { if (firstException == null) {
firstException = t; firstException = t;
} }
@ -245,11 +245,9 @@ public class TransactionContext implements XAResource {
if (localTransactionEventListener != null) { if (localTransactionEventListener != null) {
localTransactionEventListener.beginEvent(); localTransactionEventListener.beginEvent();
} }
if (LOG.isDebugEnabled()) {
LOG.debug("Begin:" + transactionId);
}
}
LOG.debug("Begin:{}", transactionId);
}
} }
/** /**
@ -272,11 +270,8 @@ public class TransactionContext implements XAResource {
LOG.warn("rollback processing error", canOcurrOnFailover); LOG.warn("rollback processing error", canOcurrOnFailover);
} }
if (transactionId != null) { if (transactionId != null) {
if (LOG.isDebugEnabled()) { LOG.debug("Rollback: {} syncCount: {}",
LOG.debug("Rollback: " + transactionId transactionId, (synchronizations != null ? synchronizations.size() : 0));
+ " syncCount: "
+ (synchronizations != null ? synchronizations.size() : 0));
}
TransactionInfo info = new TransactionInfo(getConnectionId(), transactionId, TransactionInfo.ROLLBACK); TransactionInfo info = new TransactionInfo(getConnectionId(), transactionId, TransactionInfo.ROLLBACK);
this.transactionId = null; this.transactionId = null;
@ -314,11 +309,8 @@ public class TransactionContext implements XAResource {
// Only send commit if the transaction was started. // Only send commit if the transaction was started.
if (transactionId != null) { if (transactionId != null) {
if (LOG.isDebugEnabled()) { LOG.debug("Commit: {} syncCount: {}",
LOG.debug("Commit: " + transactionId transactionId, (synchronizations != null ? synchronizations.size() : 0));
+ " syncCount: "
+ (synchronizations != null ? synchronizations.size() : 0));
}
TransactionInfo info = new TransactionInfo(getConnectionId(), transactionId, TransactionInfo.COMMIT_ONE_PHASE); TransactionInfo info = new TransactionInfo(getConnectionId(), transactionId, TransactionInfo.COMMIT_ONE_PHASE);
this.transactionId = null; this.transactionId = null;
@ -330,7 +322,7 @@ public class TransactionContext implements XAResource {
} }
afterCommit(); afterCommit();
} catch (JMSException cause) { } catch (JMSException cause) {
LOG.info("commit failed for transaction " + info.getTransactionId(), cause); LOG.info("commit failed for transaction {}", info.getTransactionId(), cause);
if (localTransactionEventListener != null) { if (localTransactionEventListener != null) {
localTransactionEventListener.rollbackEvent(); localTransactionEventListener.rollbackEvent();
} }
@ -349,11 +341,11 @@ public class TransactionContext implements XAResource {
/** /**
* Associates a transaction with the resource. * Associates a transaction with the resource.
*/ */
@Override
public void start(Xid xid, int flags) throws XAException { public void start(Xid xid, int flags) throws XAException {
if (LOG.isDebugEnabled()) { LOG.debug("Start: {}, flags: {}", xid, XASupport.toString(flags));
LOG.debug("Start: " + xid + ", flags:" + flags);
}
if (isInLocalTransaction()) { if (isInLocalTransaction()) {
throw new XAException(XAException.XAER_PROTO); throw new XAException(XAException.XAER_PROTO);
} }
@ -365,7 +357,7 @@ public class TransactionContext implements XAResource {
// if ((flags & TMJOIN) == TMJOIN) { // if ((flags & TMJOIN) == TMJOIN) {
// TODO: verify that the server has seen the xid // TODO: verify that the server has seen the xid
// // } // // }
// if ((flags & TMJOIN) == TMRESUME) { // if ((flags & TMRESUME) == TMRESUME) {
// // TODO: verify that the xid was suspended. // // TODO: verify that the xid was suspended.
// } // }
@ -382,11 +374,10 @@ public class TransactionContext implements XAResource {
return connection.getConnectionInfo().getConnectionId(); return connection.getConnectionInfo().getConnectionId();
} }
@Override
public void end(Xid xid, int flags) throws XAException { public void end(Xid xid, int flags) throws XAException {
if (LOG.isDebugEnabled()) { LOG.debug("End: {}, flags: {}", xid, XASupport.toString(flags));
LOG.debug("End: " + xid + ", flags:" + flags);
}
if (isInLocalTransaction()) { if (isInLocalTransaction()) {
throw new XAException(XAException.XAER_PROTO); throw new XAException(XAException.XAER_PROTO);
@ -434,10 +425,9 @@ public class TransactionContext implements XAResource {
&& Arrays.equals(xid1.getGlobalTransactionId(), xid2.getGlobalTransactionId()); && Arrays.equals(xid1.getGlobalTransactionId(), xid2.getGlobalTransactionId());
} }
@Override
public int prepare(Xid xid) throws XAException { public int prepare(Xid xid) throws XAException {
if (LOG.isDebugEnabled()) { LOG.debug("Prepare: {}", xid);
LOG.debug("Prepare: " + xid);
}
// We allow interleaving multiple transactions, so // We allow interleaving multiple transactions, so
// we don't limit prepare to the associated xid. // we don't limit prepare to the associated xid.
@ -458,41 +448,38 @@ public class TransactionContext implements XAResource {
IntegerResponse response = (IntegerResponse)syncSendPacketWithInterruptionHandling(info); IntegerResponse response = (IntegerResponse)syncSendPacketWithInterruptionHandling(info);
if (XAResource.XA_RDONLY == response.getResult()) { if (XAResource.XA_RDONLY == response.getResult()) {
// transaction stops now, may be syncs that need a callback // transaction stops now, may be syncs that need a callback
synchronized(ENDED_XA_TRANSACTION_CONTEXTS) { synchronized(ENDED_XA_TRANSACTION_CONTEXTS) {
List<TransactionContext> l = ENDED_XA_TRANSACTION_CONTEXTS.remove(x); List<TransactionContext> l = ENDED_XA_TRANSACTION_CONTEXTS.remove(x);
if (l != null && !l.isEmpty()) { if (l != null && !l.isEmpty()) {
if (LOG.isDebugEnabled()) { LOG.debug("firing afterCommit callbacks on XA_RDONLY from prepare: {}", xid);
LOG.debug("firing afterCommit callbacks on XA_RDONLY from prepare: " + xid); for (TransactionContext ctx : l) {
} ctx.afterCommit();
for (TransactionContext ctx : l) { }
ctx.afterCommit(); }
} }
}
}
} }
return response.getResult(); return response.getResult();
} catch (JMSException e) { } catch (JMSException e) {
LOG.warn("prepare of: " + x + " failed with: " + e, e); LOG.warn("prepare of: " + x + " failed with: " + e, e);
synchronized(ENDED_XA_TRANSACTION_CONTEXTS) { synchronized(ENDED_XA_TRANSACTION_CONTEXTS) {
List<TransactionContext> l = ENDED_XA_TRANSACTION_CONTEXTS.remove(x); List<TransactionContext> l = ENDED_XA_TRANSACTION_CONTEXTS.remove(x);
if (l != null && !l.isEmpty()) { if (l != null && !l.isEmpty()) {
for (TransactionContext ctx : l) { for (TransactionContext ctx : l) {
try { try {
ctx.afterRollback(); ctx.afterRollback();
} catch (Throwable ignored) { } catch (Throwable ignored) {
if (LOG.isDebugEnabled()) { LOG.debug("failed to firing afterRollback callbacks on prepare " +
LOG.debug("failed to firing afterRollback callbacks on prepare failure, txid: " + "failure, txid: {}, context: {}", x, ctx, ignored);
x + ", context: " + ctx, ignored); }
} }
} }
} }
}
}
throw toXAException(e); throw toXAException(e);
} }
} }
@Override
public void rollback(Xid xid) throws XAException { public void rollback(Xid xid) throws XAException {
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
@ -521,25 +508,24 @@ public class TransactionContext implements XAResource {
TransactionInfo info = new TransactionInfo(getConnectionId(), x, TransactionInfo.ROLLBACK); TransactionInfo info = new TransactionInfo(getConnectionId(), x, TransactionInfo.ROLLBACK);
syncSendPacketWithInterruptionHandling(info); syncSendPacketWithInterruptionHandling(info);
synchronized(ENDED_XA_TRANSACTION_CONTEXTS) { synchronized(ENDED_XA_TRANSACTION_CONTEXTS) {
List<TransactionContext> l = ENDED_XA_TRANSACTION_CONTEXTS.remove(x); List<TransactionContext> l = ENDED_XA_TRANSACTION_CONTEXTS.remove(x);
if (l != null && !l.isEmpty()) { if (l != null && !l.isEmpty()) {
for (TransactionContext ctx : l) { for (TransactionContext ctx : l) {
ctx.afterRollback(); ctx.afterRollback();
} }
} }
} }
} catch (JMSException e) { } catch (JMSException e) {
throw toXAException(e); throw toXAException(e);
} }
} }
// XAResource interface // XAResource interface
@Override
public void commit(Xid xid, boolean onePhase) throws XAException { public void commit(Xid xid, boolean onePhase) throws XAException {
if (LOG.isDebugEnabled()) { LOG.debug("Commit: {}, onePhase={}", xid, onePhase);
LOG.debug("Commit: " + xid + ", onePhase=" + onePhase);
}
// We allow interleaving multiple transactions, so // We allow interleaving multiple transactions, so
// we don't limit commit to the associated xid. // we don't limit commit to the associated xid.
@ -561,46 +547,42 @@ public class TransactionContext implements XAResource {
syncSendPacketWithInterruptionHandling(info); syncSendPacketWithInterruptionHandling(info);
synchronized(ENDED_XA_TRANSACTION_CONTEXTS) { synchronized(ENDED_XA_TRANSACTION_CONTEXTS) {
List<TransactionContext> l = ENDED_XA_TRANSACTION_CONTEXTS.remove(x); List<TransactionContext> l = ENDED_XA_TRANSACTION_CONTEXTS.remove(x);
if (l != null && !l.isEmpty()) { if (l != null && !l.isEmpty()) {
for (TransactionContext ctx : l) { for (TransactionContext ctx : l) {
try { try {
ctx.afterCommit(); ctx.afterCommit();
} catch (Exception ignored) { } catch (Exception ignored) {
LOG.debug("ignoring exception from after completion on ended transaction: " + ignored, ignored); LOG.debug("ignoring exception from after completion on ended transaction: {}", ignored, ignored);
} }
} }
} }
} }
} catch (JMSException e) { } catch (JMSException e) {
LOG.warn("commit of: " + x + " failed with: " + e, e); LOG.warn("commit of: " + x + " failed with: " + e, e);
if (onePhase) { if (onePhase) {
synchronized(ENDED_XA_TRANSACTION_CONTEXTS) { synchronized(ENDED_XA_TRANSACTION_CONTEXTS) {
List<TransactionContext> l = ENDED_XA_TRANSACTION_CONTEXTS.remove(x); List<TransactionContext> l = ENDED_XA_TRANSACTION_CONTEXTS.remove(x);
if (l != null && !l.isEmpty()) { if (l != null && !l.isEmpty()) {
for (TransactionContext ctx : l) { for (TransactionContext ctx : l) {
try { try {
ctx.afterRollback(); ctx.afterRollback();
} catch (Throwable ignored) { } catch (Throwable ignored) {
if (LOG.isDebugEnabled()) { LOG.debug("failed to firing afterRollback callbacks commit failure, txid: {}, context: {}", x, ctx, ignored);
LOG.debug("failed to firing afterRollback callbacks commit failure, txid: " + x + ", context: " + ctx, ignored); }
} }
} }
} }
}
}
} }
throw toXAException(e); throw toXAException(e);
} }
} }
@Override
public void forget(Xid xid) throws XAException { public void forget(Xid xid) throws XAException {
if (LOG.isDebugEnabled()) { LOG.debug("Forget: {}", xid);
LOG.debug("Forget: " + xid);
}
// We allow interleaving multiple transactions, so // We allow interleaving multiple transactions, so
// we don't limit forget to the associated xid. // we don't limit forget to the associated xid.
@ -623,11 +605,12 @@ public class TransactionContext implements XAResource {
} catch (JMSException e) { } catch (JMSException e) {
throw toXAException(e); throw toXAException(e);
} }
synchronized(ENDED_XA_TRANSACTION_CONTEXTS) { synchronized(ENDED_XA_TRANSACTION_CONTEXTS) {
ENDED_XA_TRANSACTION_CONTEXTS.remove(x); ENDED_XA_TRANSACTION_CONTEXTS.remove(x);
} }
} }
@Override
public boolean isSameRM(XAResource xaResource) throws XAException { public boolean isSameRM(XAResource xaResource) throws XAException {
if (xaResource == null) { if (xaResource == null) {
return false; return false;
@ -643,6 +626,7 @@ public class TransactionContext implements XAResource {
} }
} }
@Override
public Xid[] recover(int flag) throws XAException { public Xid[] recover(int flag) throws XAException {
LOG.debug("recover({})", flag); LOG.debug("recover({})", flag);
@ -667,10 +651,12 @@ public class TransactionContext implements XAResource {
} }
} }
@Override
public int getTransactionTimeout() throws XAException { public int getTransactionTimeout() throws XAException {
return 0; return 0;
} }
@Override
public boolean setTransactionTimeout(int seconds) throws XAException { public boolean setTransactionTimeout(int seconds) throws XAException {
return false; return false;
} }
@ -702,9 +688,7 @@ public class TransactionContext implements XAResource {
TransactionInfo info = new TransactionInfo(getConnectionId(), transactionId, TransactionInfo.BEGIN); TransactionInfo info = new TransactionInfo(getConnectionId(), transactionId, TransactionInfo.BEGIN);
try { try {
this.connection.asyncSendPacket(info); this.connection.asyncSendPacket(info);
if (LOG.isDebugEnabled()) { LOG.debug("{} started XA transaction {}", this, transactionId);
LOG.debug("{} started XA transaction {} ", this, transactionId);
}
} catch (JMSException e) { } catch (JMSException e) {
disassociate(); disassociate();
throw toXAException(e); throw toXAException(e);
@ -716,9 +700,7 @@ public class TransactionContext implements XAResource {
TransactionInfo info = new TransactionInfo(getConnectionId(), transactionId, TransactionInfo.END); TransactionInfo info = new TransactionInfo(getConnectionId(), transactionId, TransactionInfo.END);
try { try {
syncSendPacketWithInterruptionHandling(info); syncSendPacketWithInterruptionHandling(info);
if (LOG.isDebugEnabled()) { LOG.debug("{} ended XA transaction {}", this, transactionId);
LOG.debug("{} ended XA transaction {}", this, transactionId);
}
} catch (JMSException e) { } catch (JMSException e) {
disassociate(); disassociate();
throw toXAException(e); throw toXAException(e);
@ -726,16 +708,16 @@ public class TransactionContext implements XAResource {
// Add our self to the list of contexts that are interested in // Add our self to the list of contexts that are interested in
// post commit/rollback events. // post commit/rollback events.
synchronized(ENDED_XA_TRANSACTION_CONTEXTS) { synchronized(ENDED_XA_TRANSACTION_CONTEXTS) {
List<TransactionContext> l = ENDED_XA_TRANSACTION_CONTEXTS.get(transactionId); List<TransactionContext> l = ENDED_XA_TRANSACTION_CONTEXTS.get(transactionId);
if (l == null) { if (l == null) {
l = new ArrayList<TransactionContext>(3); l = new ArrayList<TransactionContext>(3);
ENDED_XA_TRANSACTION_CONTEXTS.put(transactionId, l); ENDED_XA_TRANSACTION_CONTEXTS.put(transactionId, l);
l.add(this); l.add(this);
} else if (!l.contains(this)) { } else if (!l.contains(this)) {
l.add(this); l.add(this);
} }
} }
} }
disassociate(); disassociate();
@ -814,7 +796,6 @@ public class TransactionContext implements XAResource {
return connection; return connection;
} }
// for RAR xa recovery where xaresource connection is per request // for RAR xa recovery where xaresource connection is per request
public ActiveMQConnection setConnection(ActiveMQConnection connection) { public ActiveMQConnection setConnection(ActiveMQConnection connection) {
ActiveMQConnection existing = this.connection; ActiveMQConnection existing = this.connection;

View File

@ -0,0 +1,89 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.activemq.util;
import static javax.transaction.xa.XAResource.TMENDRSCAN;
import static javax.transaction.xa.XAResource.TMFAIL;
import static javax.transaction.xa.XAResource.TMJOIN;
import static javax.transaction.xa.XAResource.TMNOFLAGS;
import static javax.transaction.xa.XAResource.TMONEPHASE;
import static javax.transaction.xa.XAResource.TMRESUME;
import static javax.transaction.xa.XAResource.TMSTARTRSCAN;
import static javax.transaction.xa.XAResource.TMSUCCESS;
import static javax.transaction.xa.XAResource.TMSUSPEND;
public class XASupport {
public static String toString(int flags) {
if (flags == TMNOFLAGS) {
return "TMNOFLAGS";
}
StringBuilder result = new StringBuilder();
if (hasFlag(flags, TMENDRSCAN)) {
add(result, "TMENDRSCAN");
}
if (hasFlag(flags, TMFAIL)) {
add(result, "TMFAIL");
}
if (hasFlag(flags, TMJOIN)) {
add(result, "TMJOIN");
}
if (hasFlag(flags, TMONEPHASE)) {
add(result, "TMONEPHASE");
}
if (hasFlag(flags, TMRESUME)) {
add(result, "TMRESUME");
}
if (hasFlag(flags, TMSTARTRSCAN)) {
add(result, "TMSTARTRSCAN");
}
if (hasFlag(flags, TMSUCCESS)) {
add(result, "TMSUCCESS");
}
if (hasFlag(flags, TMSUSPEND)) {
add(result, "TMSUSPEND");
}
int nonStandardFlags = flags
& ~TMENDRSCAN
& ~TMFAIL
& ~TMJOIN
& ~TMONEPHASE
& ~TMRESUME
& ~TMSTARTRSCAN
& ~TMSUCCESS
& ~TMSUSPEND;
if (nonStandardFlags != 0) {
add(result, String.format("0x%08x", nonStandardFlags));
}
return result.toString();
}
private static boolean hasFlag(int flags, int flag) {
return (flags & flag) == flag;
}
private static void add(StringBuilder result, String string) {
if (result.length() > 0) {
result.append(" | ");
}
result.append(string);
}
}

View File

@ -0,0 +1,82 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.activemq.util;
import static javax.transaction.xa.XAResource.TMENDRSCAN;
import static javax.transaction.xa.XAResource.TMFAIL;
import static javax.transaction.xa.XAResource.TMJOIN;
import static javax.transaction.xa.XAResource.TMNOFLAGS;
import static javax.transaction.xa.XAResource.TMONEPHASE;
import static javax.transaction.xa.XAResource.TMRESUME;
import static javax.transaction.xa.XAResource.TMSTARTRSCAN;
import static javax.transaction.xa.XAResource.TMSUCCESS;
import static javax.transaction.xa.XAResource.TMSUSPEND;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import java.util.LinkedList;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
public class XASupportTest {
private final int flags;
private final String expectedResult;
public XASupportTest(int flags, String expectedResult) {
this.flags = flags;
this.expectedResult = expectedResult;
}
@Parameters
public static Iterable<Object[]> parameters() {
List<Object[]> p = new LinkedList<Object[]>();
// single values from XAResource
add(p, TMENDRSCAN, "TMENDRSCAN");
add(p, TMFAIL, "TMFAIL");
add(p, TMJOIN, "TMJOIN");
add(p, TMNOFLAGS, "TMNOFLAGS");
add(p, TMONEPHASE, "TMONEPHASE");
add(p, TMRESUME, "TMRESUME");
add(p, TMSTARTRSCAN, "TMSTARTRSCAN");
add(p, TMSUCCESS, "TMSUCCESS");
add(p, TMSUSPEND, "TMSUSPEND");
// combination of multiple flags
add(p, TMONEPHASE | TMSUCCESS, "TMONEPHASE | TMSUCCESS");
// flags not specified in XAResource
add(p, TMSUCCESS | 0x00400000, "TMSUCCESS | 0x00400000");
return p;
}
private static void add(List<Object[]> p, int flags, String expectedResult) {
p.add(new Object[] { flags, expectedResult });
}
@Test
public void test() throws Exception {
assertThat(XASupport.toString(flags), is(expectedResult));
}
}