Package com.taobao.metamorphosis.transaction

Examples of com.taobao.metamorphosis.transaction.TransactionInfo



    @Test
    public void testEncodeWithTimeout() {
        final TransactionId id = new LocalTransactionId("sessionId", 99);
        final TransactionInfo info = new TransactionInfo(id, "sessionId", TransactionType.BEGIN, null, 3);

        final TransactionCommand cmd = new TransactionCommand(info, 100);
        final IoBuffer buf = cmd.encode();
        assertEquals("transaction TX:sessionId:99 sessionId BEGIN 3 100\r\n", new String(buf.array()));
    }
View Full Code Here



    @Test
    public void testEncodeWithUniqueQualifier() {
        final TransactionId id = new LocalTransactionId("sessionId", 99);
        final TransactionInfo info = new TransactionInfo(id, "sessionId", TransactionType.BEGIN, "unique-qualifier");

        final TransactionCommand cmd = new TransactionCommand(info, 100);
        final IoBuffer buf = cmd.encode();
        assertEquals("transaction TX:sessionId:99 sessionId BEGIN unique-qualifier 100\r\n", new String(buf.array()));
    }
View Full Code Here


    @Test
    public void testEncodeWithUniqueQualifierAndTimeout() {
        final TransactionId id = new LocalTransactionId("sessionId", 99);
        final TransactionInfo info = new TransactionInfo(id, "sessionId", TransactionType.BEGIN, "unique-qualifier", 3);

        final TransactionCommand cmd = new TransactionCommand(info, 100);
        final IoBuffer buf = cmd.encode();
        assertEquals("transaction TX:sessionId:99 sessionId BEGIN 3 unique-qualifier 100\r\n", new String(buf.array()));
    }
View Full Code Here

    @Test
    public void testBeginTransactionCommit() throws Exception {
        this.producer.beginTransaction();
        final String serverUrl = "meta://localhost:8123";
        this.mockIsConnected(serverUrl, true);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(new LocalTransactionId(this.sessionId, 1),
            this.sessionId, TransactionType.BEGIN), null);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(new LocalTransactionId(this.sessionId, 1),
            this.sessionId, TransactionType.COMMIT_ONE_PHASE), null);
        this.mocksControl.replay();
        OpaqueGenerator.resetOpaque();
        this.producer.beforeSendMessageFirstTime(serverUrl);
        assertTrue(this.producer.isInTransaction());
View Full Code Here

    @Test
    public void testBeginTransactionRollback() throws Exception {
        this.producer.beginTransaction();
        final String serverUrl = "meta://localhost:8123";
        this.mockIsConnected(serverUrl, true);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(new LocalTransactionId(this.sessionId, 1),
            this.sessionId, TransactionType.BEGIN), null);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(new LocalTransactionId(this.sessionId, 1),
            this.sessionId, TransactionType.ROLLBACK), null);
        this.mocksControl.replay();
        OpaqueGenerator.resetOpaque();
        this.producer.beforeSendMessageFirstTime(serverUrl);
        assertTrue(this.producer.isInTransaction());
View Full Code Here

    public void testLocalBeginCommit() throws Exception {
        final String serverUrl = "meta://localhost:8123";
        this.mockIsConnected(serverUrl, true);
        this.context.setServerUrl(serverUrl);
        final TransactionId id = new LocalTransactionId(this.sessionId, 1);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.BEGIN), null);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.COMMIT_ONE_PHASE),
            null);
        assertNull(this.context.getTransactionId());
        assertFalse(this.context.isInTransaction());
        OpaqueGenerator.resetOpaque();
        this.replay();
View Full Code Here

        final String serverUrl = "meta://localhost:8123";
        this.mockIsConnected(serverUrl, true);
        this.context.setServerUrl(serverUrl);
        final XATransactionId id = XIDGenerator.createXID(1);
        this.context.setTransactionTimeout(3);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.BEGIN, null, 3), null);
        // this.mockSend(serverUrl, new TransactionInfo(id, this.sessionId,
        // TransactionType.SET_TIMEOUT, 3));
        OpaqueGenerator.resetOpaque();
        this.replay();
        this.context.start(id, XAResource.TMNOFLAGS);
View Full Code Here

    public void testLocalBeginRollback() throws Exception {
        final String serverUrl = "meta://localhost:8123";
        this.mockIsConnected(serverUrl, true);
        this.context.setServerUrl(serverUrl);
        final TransactionId id = new LocalTransactionId(this.sessionId, 1);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.BEGIN), null);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.ROLLBACK), null);
        assertNull(this.context.getTransactionId());
        assertFalse(this.context.isInTransaction());
        OpaqueGenerator.resetOpaque();
        this.replay();
        this.context.begin();
View Full Code Here

        final String serverUrl = "meta://localhost:8123";
        this.mockIsConnected(serverUrl, true);
        this.context.setServerUrl(serverUrl);

        final XATransactionId id = XIDGenerator.createXID(1);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.BEGIN), null);

        assertNull(this.context.getTransactionId());
        assertFalse(this.context.isInTransaction());
        OpaqueGenerator.resetOpaque();
        this.replay();
View Full Code Here

        final String serverUrl = "meta://localhost:8123";
        this.mockIsConnected(serverUrl, true);
        this.context.setServerUrl(serverUrl);

        final XATransactionId id = XIDGenerator.createXID(1);
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.BEGIN), null);
        this.mockSend(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.END));
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.PREPARE),
            String.valueOf(XAResource.XA_OK));
        this.mockInvokeSuccess(serverUrl, new TransactionInfo(id, this.sessionId, TransactionType.COMMIT_TWO_PHASE),
            null);

        OpaqueGenerator.resetOpaque();
        this.replay();
        this.context.start(id, XAResource.TMNOFLAGS);
View Full Code Here

TOP

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

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.