fix up tck violation on xasession interface after close expectations

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1454422 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2013-03-08 15:22:17 +00:00
parent c6c3b2351a
commit 885b8c9775
2 changed files with 27 additions and 0 deletions

View File

@ -69,14 +69,17 @@ public class ActiveMQXASession extends ActiveMQSession implements QueueSession,
}
public boolean getTransacted() throws JMSException {
checkClosed();
return getTransactionContext().isInXATransaction();
}
public void rollback() throws JMSException {
checkClosed();
throw new TransactionInProgressException("Cannot rollback() inside an XASession");
}
public void commit() throws JMSException {
checkClosed();
throw new TransactionInProgressException("Cannot commit() inside an XASession");
}

View File

@ -387,6 +387,30 @@ public class ActiveMQXAConnectionFactoryTest extends CombinationTestSupport {
broker.stop();
}
public void testExceptionAfterClose() throws Exception {
ActiveMQXAConnectionFactory cf1 = new ActiveMQXAConnectionFactory("vm://localhost?broker.persistent=false");
XAConnection connection1 = (XAConnection)cf1.createConnection();
connection1.start();
XASession session = connection1.createXASession();
session.close();
try {
session.commit();
fail("expect exception after close");
} catch (javax.jms.IllegalStateException expected) {}
try {
session.rollback();
fail("expect exception after close");
} catch (javax.jms.IllegalStateException expected) {}
try {
session.getTransacted();
fail("expect exception after close");
} catch (javax.jms.IllegalStateException expected) {}
}
private void assertTransactionGoneFromFailoverState(
ActiveMQXAConnection connection1, Xid tid) throws Exception {