Package org.apache.geronimo.connector.mock

Examples of org.apache.geronimo.connector.mock.MockXAResource



    public void testSingleTransactionCall() throws Throwable {
        ContainerTransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
        defaultComponentInterceptor.invoke(defaultComponentContext);
        MockXAResource mockXAResource = (MockXAResource) mockManagedConnection.getXAResource();
        assertEquals("XAResource should know one xid", 1, mockXAResource.getKnownXids().size());
        assertNull("Should not be committed", mockXAResource.getCommitted());
        transactionContext.commit();
        assertNotNull("Should be committed", mockXAResource.getCommitted());
    }
View Full Code Here


    }

    public void testNoTransactionCall() throws Throwable {
        transactionContextManager.newUnspecifiedTransactionContext();
        defaultComponentInterceptor.invoke(defaultComponentContext);
        MockXAResource mockXAResource = (MockXAResource) mockManagedConnection.getXAResource();
        assertEquals("XAResource should know 0 xid", 0, mockXAResource.getKnownXids().size());
        assertNull("Should not be committed", mockXAResource.getCommitted());
    }
View Full Code Here

    }

    public void testOneTransactionTwoCalls() throws Throwable {
        ContainerTransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
        defaultComponentInterceptor.invoke(defaultComponentContext);
        MockXAResource mockXAResource = (MockXAResource) mockManagedConnection.getXAResource();
        assertEquals("XAResource should know one xid", 1, mockXAResource.getKnownXids().size());
        assertNull("Should not be committed", mockXAResource.getCommitted());
        defaultComponentInterceptor.invoke(defaultComponentContext);
        assertEquals("Expected same XAResource", mockXAResource, mockManagedConnection.getXAResource());
        assertEquals("XAResource should know one xid", 1, mockXAResource.getKnownXids().size());
        assertNull("Should not be committed", mockXAResource.getCommitted());
        transactionContext.commit();
        assertNotNull("Should be committed", mockXAResource.getCommitted());
    }
View Full Code Here

        mockComponent = new DefaultInterceptor() {
            public Object invoke(InstanceContext newInstanceContext) throws Throwable {
                MockConnection mockConnection = (MockConnection) connectionFactory.getConnection();
                mockManagedConnection = mockConnection.getManagedConnection();
                userTransaction.begin();
                MockXAResource mockXAResource = (MockXAResource) mockManagedConnection.getXAResource();
                assertEquals("XAResource should know one xid", 1, mockXAResource.getKnownXids().size());
                assertNull("Should not be committed", mockXAResource.getCommitted());
                userTransaction.commit();
                assertNotNull("Should be committed", mockXAResource.getCommitted());
                mockConnection.close();
                return null;
            }
        };
        transactionContextManager.newUnspecifiedTransactionContext();
        userTransaction = new UserTransactionImpl();
        userTransaction.setUp(transactionContextManager, connectionTrackingCoordinator);
        userTransaction.setOnline(true);
        defaultComponentInterceptor.invoke(defaultComponentContext);
        MockXAResource mockXAResource = (MockXAResource) mockManagedConnection.getXAResource();
        assertEquals("XAResource should know 1 xid", 1, mockXAResource.getKnownXids().size());
        assertNotNull("Should be committed", mockXAResource.getCommitted());
        mockXAResource.clear();
    }
View Full Code Here

            }

        };
        ContainerTransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
        defaultComponentInterceptor.invoke(defaultComponentContext);
        MockXAResource mockXAResource = (MockXAResource) mockManagedConnection.getXAResource();
        assertEquals("XAResource should know one xid", 1, mockXAResource.getKnownXids().size());
        assertNull("Should not be committed", mockXAResource.getCommitted());
        transactionContext.commit();
        assertNotNull("Should be committed", mockXAResource.getCommitted());
    }
View Full Code Here

    public Object invoke(InstanceContext newInstanceContext) throws Throwable {
        MockConnection mockConnection = (MockConnection) connectionFactory.getConnection();
        mockManagedConnection = mockConnection.getManagedConnection();
        if (userTransaction != null) {
            userTransaction.begin();
            MockXAResource mockXAResource = (MockXAResource) mockManagedConnection.getXAResource();
            assertEquals("XAResource should know one xid", 1, mockXAResource.getKnownXids().size());
            assertNull("Should not be committed", mockXAResource.getCommitted());
            userTransaction.commit();
            assertNotNull("Should be committed", mockXAResource.getCommitted());
        }
        mockConnection.close();
        return null;
    }
View Full Code Here

    public void testSingleTransactionCall() throws Throwable {
        ContainerTransactionContext transactionContext = new ContainerTransactionContext(transactionManager);
        TransactionContext.setContext(transactionContext);
        transactionContext.begin();
        defaultComponentInterceptor.invoke(defaultComponentContext);
        MockXAResource mockXAResource = (MockXAResource) mockManagedConnection.getXAResource();
        assertEquals("XAResource should know one xid", 1, mockXAResource.getKnownXids().size());
        assertNull("Should not be committed", mockXAResource.getCommitted());
        transactionManager.commit();
        assertNotNull("Should be committed", mockXAResource.getCommitted());
    }
View Full Code Here

    }

    public void testNoTransactionCall() throws Throwable {
        TransactionContext.setContext(new UnspecifiedTransactionContext());
        defaultComponentInterceptor.invoke(defaultComponentContext);
        MockXAResource mockXAResource = (MockXAResource) mockManagedConnection.getXAResource();
        assertEquals("XAResource should know 0 xid", 0, mockXAResource.getKnownXids().size());
        assertNull("Should not be committed", mockXAResource.getCommitted());
    }
View Full Code Here

    public void testOneTransactionTwoCalls() throws Throwable {
        ContainerTransactionContext transactionContext = new ContainerTransactionContext(transactionManager);
        TransactionContext.setContext(transactionContext);
        transactionContext.begin();
        defaultComponentInterceptor.invoke(defaultComponentContext);
        MockXAResource mockXAResource = (MockXAResource) mockManagedConnection.getXAResource();
        assertEquals("XAResource should know one xid", 1, mockXAResource.getKnownXids().size());
        assertNull("Should not be committed", mockXAResource.getCommitted());
        defaultComponentInterceptor.invoke(defaultComponentContext);
        assertEquals("Expected same XAResource", mockXAResource, mockManagedConnection.getXAResource());
        assertEquals("XAResource should know one xid", 1, mockXAResource.getKnownXids().size());
        assertNull("Should not be committed", mockXAResource.getCommitted());
        transactionManager.commit();
        assertNotNull("Should be committed", mockXAResource.getCommitted());
    }
View Full Code Here

        TransactionContext.setContext(new UnspecifiedTransactionContext());
        userTransaction = new UserTransactionImpl();
        userTransaction.setUp(transactionManager, connectionTrackingCoordinator);
        userTransaction.setOnline(true);
        defaultComponentInterceptor.invoke(defaultComponentContext);
        MockXAResource mockXAResource = (MockXAResource) mockManagedConnection.getXAResource();
        assertEquals("XAResource should know 1 xid", 1, mockXAResource.getKnownXids().size());
        assertNotNull("Should be committed", mockXAResource.getCommitted());
    }
View Full Code Here

TOP

Related Classes of org.apache.geronimo.connector.mock.MockXAResource

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.