Package com.taobao.metamorphosis.network

Examples of com.taobao.metamorphosis.network.TransactionCommand


    @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);
        this.mockResponseOK();
        this.replay();
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);
        this.conn.response(new BooleanCommand(HttpStatus.Success, String.valueOf(XAResource.XA_OK), 1));
        this.mockSessionContext(sessionId, sessionId);
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();
        this.mockSessionContext(sessionId, sessionId);
        this.replay();
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();
        this.mockSessionContext(sessionId, sessionId);
        this.replay();
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();
        this.mockSessionContext(sessionId, sessionId);
        this.replay();
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();
        this.mockSessionContext(sessionId, sessionId);
        this.replay();
View Full Code Here

    @Test
    public void testRecoverTransaction() throws Exception {
        final String sessionId = "test";
        String uniqueQualifier = "unique-qualifier";
        final TransactionInfo info = new TransactionInfo(null, sessionId, TransactionType.RECOVER, uniqueQualifier);
        final TransactionCommand tc = new TransactionCommand(info, 1);
        final TransactionId[] ids = this.generateIds();
        final String resultString = this.generateIdsString(ids);
        this.mockSessionContext(SessionContextHolder.GLOBAL_SESSION_KEY, sessionId);
        EasyMock.expect(
            this.commandProcessor.getPreparedTransactions(new SessionContextImpl("test", this.conn), uniqueQualifier))
View Full Code Here

    @Test
    public void testHandleException() throws Exception {
        final String sessionId = "test";
        String uniqueQualifier = "unique-qualifier";
        final TransactionInfo info = new TransactionInfo(null, sessionId, TransactionType.RECOVER, uniqueQualifier);
        final TransactionCommand tc = new TransactionCommand(info, 1);
        this.mockSessionContext(SessionContextHolder.GLOBAL_SESSION_KEY, sessionId);

        EasyMock.expect(
            this.commandProcessor.getPreparedTransactions(new SessionContextImpl("test", this.conn), uniqueQualifier))
            .andThrow(new RuntimeException("just for test"));
View Full Code Here


    private void mockInvokeSuccess(final String serverUrl, final TransactionInfo info, final String result)
            throws InterruptedException, TimeoutException, NotifyRemotingException {
        EasyMock.expect(
            this.remotingClient.invokeToGroup(serverUrl, new TransactionCommand(info, OpaqueGenerator.getNextOpaque()),
                5000L, TimeUnit.MILLISECONDS)).andReturn(new BooleanCommand(HttpStatus.Success, result, 0));
    }
View Full Code Here

TOP

Related Classes of com.taobao.metamorphosis.network.TransactionCommand

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.