Package com.taobao.metamorphosis.transaction

Examples of com.taobao.metamorphosis.transaction.LocalTransactionId


    @Override
    @Before
    public void setUp() {
        super.setUp();
        this.txMap = new ConcurrentHashMap<TransactionId, Transaction>();
        this.xid = new LocalTransactionId("test", 99);
        this.context = EasyMock.createMock(SessionContext.class);
        EasyMock.expect(this.context.getTransactions()).andReturn(this.txMap).anyTimes();
        this.localTransaction =
                new LocalTransaction(this.transactionStore, (LocalTransactionId) this.xid, this.context);
        this.txMap.put(this.xid, this.localTransaction);
View Full Code Here



    @Test
    public void testHandleBeginTransaction() throws Exception {
        final String sessionId = "test";
        final LocalTransactionId transactionId = new LocalTransactionId(sessionId, 1);
        final TransactionInfo info = new TransactionInfo(transactionId, sessionId, TransactionType.BEGIN);
        final TransactionCommand tc = new TransactionCommand(info, 1);
        this.commandProcessor.beginTransaction(new SessionContextImpl(sessionId, this.conn), transactionId, 0);
        EasyMock.expectLastCall();
        this.mockSessionContext(sessionId, sessionId);
View Full Code Here


    @Test
    public void testHandleEndTransaction() throws Exception {
        final String sessionId = "test";
        final LocalTransactionId transactionId = new LocalTransactionId(sessionId, 1);
        final TransactionInfo info = new TransactionInfo(transactionId, sessionId, TransactionType.END);
        final TransactionCommand tc = new TransactionCommand(info, 1);
        this.mockSessionContext(sessionId, sessionId);
        this.replay();
        this.transactionProcessor.handleRequest(tc, this.conn);
View Full Code Here


    @Test
    public void testHandlePrepare() throws Exception {
        final String sessionId = "test";
        final LocalTransactionId transactionId = new LocalTransactionId(sessionId, 1);
        final TransactionInfo info = new TransactionInfo(transactionId, sessionId, TransactionType.PREPARE);
        final TransactionCommand tc = new TransactionCommand(info, 1);
        EasyMock.expect(
            this.commandProcessor.prepareTransaction(new SessionContextImpl(sessionId, this.conn), transactionId))
            .andReturn(XAResource.XA_OK);
View Full Code Here


    @Test
    public void testCommitOnePhase() throws Exception {
        final String sessionId = "test";
        final LocalTransactionId transactionId = new LocalTransactionId(sessionId, 1);
        final TransactionInfo info = new TransactionInfo(transactionId, sessionId, TransactionType.COMMIT_ONE_PHASE);
        final TransactionCommand tc = new TransactionCommand(info, 1);
        this.commandProcessor.commitTransaction(new SessionContextImpl(sessionId, this.conn), transactionId, true);
        EasyMock.expectLastCall();
        this.mockResponseOK();
View Full Code Here


    @Test
    public void testCommitTwoPhase() throws Exception {
        final String sessionId = "test";
        final LocalTransactionId transactionId = new LocalTransactionId(sessionId, 1);
        final TransactionInfo info = new TransactionInfo(transactionId, sessionId, TransactionType.COMMIT_TWO_PHASE);
        final TransactionCommand tc = new TransactionCommand(info, 1);
        this.commandProcessor.commitTransaction(new SessionContextImpl(sessionId, this.conn), transactionId, false);
        EasyMock.expectLastCall();
        this.mockResponseOK();
View Full Code Here


    @Test
    public void testForgetTransaction() throws Exception {
        final String sessionId = "test";
        final LocalTransactionId transactionId = new LocalTransactionId(sessionId, 1);
        final TransactionInfo info = new TransactionInfo(transactionId, sessionId, TransactionType.FORGET);
        final TransactionCommand tc = new TransactionCommand(info, 1);
        this.commandProcessor.forgetTransaction(new SessionContextImpl(sessionId, this.conn), transactionId);
        EasyMock.expectLastCall();
        this.mockResponseOK();
View Full Code Here


    @Test
    public void testRollback() throws Exception {
        final String sessionId = "test";
        final LocalTransactionId transactionId = new LocalTransactionId(sessionId, 1);
        final TransactionInfo info = new TransactionInfo(transactionId, sessionId, TransactionType.ROLLBACK);
        final TransactionCommand tc = new TransactionCommand(info, 1);
        this.commandProcessor.rollbackTransaction(new SessionContextImpl(sessionId, this.conn), transactionId);
        EasyMock.expectLastCall();
        this.mockResponseOK();
View Full Code Here

public class JournalTransactionStoreUnitTest extends BaseTransactionUnitTest {

    @Test
    public void testAddAddRollBackCloseRecover() throws Exception {
        final LocalTransactionId xid = new LocalTransactionId("test", 1);
        final MessageStore store = this.messageStoreManager.getOrCreateMessageStore("topic1", 2);
        this.transactionStore.addMessage(store, 1, new PutCommand("topic1", 2, "msg1".getBytes(), xid, 0, 1), null);
        this.transactionStore.addMessage(store, 1, new PutCommand("topic1", 2, "msg2".getBytes(), xid, 0, 2), null);

        final Tx tx = this.transactionStore.getInflyTx(xid);
View Full Code Here

    }


    @Test
    public void testAddAddCloseRecover() throws Exception {
        final LocalTransactionId xid1 = new LocalTransactionId("test", 1);
        MessageStore store = this.messageStoreManager.getOrCreateMessageStore("topic1", 2);
        this.transactionStore.addMessage(store, 1, new PutCommand("topic1", 2, "msg1".getBytes(), xid1, 0, 1), null);
        this.transactionStore.addMessage(store, 1, new PutCommand("topic1", 2, "msg2".getBytes(), xid1, 0, 2), null);

        final LocalTransactionId xid2 = new LocalTransactionId("test", 2);
        store = this.messageStoreManager.getOrCreateMessageStore("topic1", 2);
        this.transactionStore.addMessage(store, 1, new PutCommand("topic1", 2, "msg1".getBytes(), xid2, 0, 1), null);

        this.tearDown();
        this.init(this.path);
View Full Code Here

TOP

Related Classes of com.taobao.metamorphosis.transaction.LocalTransactionId

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.