Examples of MockConnection


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

        connectionFactory = null;
        defaultComponentContext = null;
    }

    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

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

    }

    public void testUserTransactionEnlistingExistingConnections() throws Throwable {
        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();
View Full Code Here

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

    public void testUnshareableConnections() throws Throwable {
        unshareableResources.add(name);
        mockComponent = new DefaultInterceptor() {
            public Object invoke(InstanceContext newInstanceContext) throws Throwable {
                MockConnection mockConnection1 = (MockConnection) connectionFactory.getConnection();
                mockManagedConnection = mockConnection1.getManagedConnection();
                MockConnection mockConnection2 = (MockConnection) connectionFactory.getConnection();
                //the 2 cx are for the same RM, so tm will call commit only one one (the first)
                //mockManagedConnection = mockConnection2.getManagedConnection();
                assertNotNull("Expected non-null managedconnection 1", mockConnection1.getManagedConnection());
                assertNotNull("Expected non-null managedconnection 2", mockConnection2.getManagedConnection());
                assertTrue("Expected different managed connections for each unshared handle", mockConnection1.getManagedConnection() != mockConnection2.getManagedConnection());

                mockConnection1.close();
                mockConnection2.close();
                return null;
            }

        };
        ContainerTransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
View Full Code Here

Examples of org.jooq.tools.jdbc.MockConnection

        byte[] b = new byte[(int) f.length()];
        f.readFully(b);
        String s = new String(b);
        s = s.replace("{version}", Constants.FULL_VERSION);

        MOCK = DSL.using(new MockConnection(new MockFileDatabase(s)), SQLDialect.POSTGRES);
    }
View Full Code Here

Examples of org.jooq.tools.jdbc.MockConnection

        MOCK = DSL.using(new MockConnection(new MockFileDatabase(s)), SQLDialect.POSTGRES);
    }

    @Test
    public void testEmptyResult() {
        DSLContext e = DSL.using(new MockConnection(new EmptyResult()), SQLDialect.H2);
        Result<Record> result = e.fetch("select ?, ? from dual", 1, 2);

        assertEquals(0, result.size());
        assertEquals(3, result.fields().length);
        for (int i = 0; i < 3; i++) {
View Full Code Here

Examples of org.jooq.tools.jdbc.MockConnection

        }
    }

    @Test
    public void testSingleResult() {
        DSLContext e = DSL.using(new MockConnection(new SingleResult()), SQLDialect.H2);
        Result<Record> result = e.fetch("select ?, ? from dual", 1, 2);

        assertEquals(1, result.size());
        assertEquals(3, result.fields().length);
View Full Code Here

Examples of org.jooq.tools.jdbc.MockConnection

        }
    }

    @Test
    public void testTripleResult() {
        DSLContext e = DSL.using(new MockConnection(new TripleResult()), SQLDialect.H2);
        List<Result<Record>> result = e.fetchMany("select ?, ? from dual", 1, 2);

        assertEquals(3, result.size());
        assertEquals(1, result.get(0).size());
        assertEquals(2, result.get(1).size());
View Full Code Here

Examples of org.jooq.tools.jdbc.MockConnection

        }
    }

    @Test
    public void testBatchSingle() {
        DSLContext e = DSL.using(new MockConnection(new BatchSingle()), SQLDialect.H2);

        int[] result =
        e.batch(
            e.query("insert into x values(1)"),
            e.query("insert into x values(2)")
View Full Code Here

Examples of org.jooq.tools.jdbc.MockConnection

        }
    }

    @Test
    public void testBatchMultiple() {
        DSLContext e = DSL.using(new MockConnection(new BatchMultiple()), SQLDialect.H2);

        Query query = e.query("insert into x values(?, ?)", null, null);

        int[] result =
        e.batch(query)
View Full Code Here

Examples of org.jooq.tools.jdbc.MockConnection

        }
    }

    @Test
    public void testException() {
        DSLContext e = DSL.using(new MockConnection(new Exceptional()), SQLDialect.H2);

        Query query = e.query("insert into x values(1)");

        try {
            query.execute();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.