Package org.apache.geronimo.persistence.mockjpa

Examples of org.apache.geronimo.persistence.mockjpa.MockEntityManager


     * when a SFSB/extended context starts a UserTransaction or a CMT tx starts the EM must join the transaction
     */
    public void testExtendedEntityManagerJoinsNewTransactions() throws Exception {
        CMPEntityManagerExtended entityManager1 = new CMPEntityManagerExtended(tm, persistenceUnit, entityManagerFactory, null);
        tm.begin();
        MockEntityManager pc1 = (MockEntityManager) entityManager1.find(EntityManager.class, "this");

        assertTrue("EntityManager was supposed to join the tx", pc1.isJoined());
    }
View Full Code Here


     * close or cleared is called when tx commits
     */
    public void testCloseOnCommit() throws Exception {
        tm.begin();
        CMPEntityManagerTxScoped entityManager1 = new CMPEntityManagerTxScoped(tm, persistenceUnit, entityManagerFactory, null);
        MockEntityManager pc1 = (MockEntityManager) entityManager1.find(EntityManager.class, "this");
        assertTrue("entityManager should not be closed or cleared", !pc1.isClosed() & !pc1.isCleared());
        tm.commit();
        assertTrue("entityManager should be closed or cleared", pc1.isClosed() || pc1.isCleared());
        tm.begin();
        CMPEntityManagerTxScoped entityManager2 = new CMPEntityManagerTxScoped(tm, persistenceUnit, entityManagerFactory, null);
        MockEntityManager pc2 = (MockEntityManager) entityManager2.find(EntityManager.class, "this");
        assertTrue("entityManager should not be closed or cleared", !pc2.isClosed() & !pc2.isCleared());
        tm.rollback();
        assertTrue("entityManager should be closed or cleared", pc2.isClosed() || pc2.isCleared());
    }
View Full Code Here

     * close or cleared is called when tx commits
     */
    public void testCloseOnCommit() throws Exception {
        tm.begin();
        CMPEntityManagerTxScoped entityManager1 = new CMPEntityManagerTxScoped(tm, persistenceUnit, entityManagerFactory, null);
        MockEntityManager pc1 = (MockEntityManager) entityManager1.find(EntityManager.class, "this");
        assertTrue("entityManager should not be closed or cleared", !pc1.isClosed() & !pc1.isCleared());
        tm.commit();
        assertTrue("entityManager should be closed or cleared", pc1.isClosed() || pc1.isCleared());
        tm.begin();
        CMPEntityManagerTxScoped entityManager2 = new CMPEntityManagerTxScoped(tm, persistenceUnit, entityManagerFactory, null);
        MockEntityManager pc2 = (MockEntityManager) entityManager2.find(EntityManager.class, "this");
        assertTrue("entityManager should not be closed or cleared", !pc2.isClosed() & !pc2.isCleared());
        tm.rollback();
        assertTrue("entityManager should be closed or cleared", pc2.isClosed() || pc2.isCleared());
    }
View Full Code Here

TOP

Related Classes of org.apache.geronimo.persistence.mockjpa.MockEntityManager

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.