Search in sources :

Example 1 with TransactionRolledbackLocalException

use of javax.ejb.TransactionRolledbackLocalException in project tomee by apache.

the class CmrMappingTests method testOneToManySetCMROnOwningSideResetPK.

public void testOneToManySetCMROnOwningSideResetPK() throws Exception {
    beginTransaction();
    try {
        final OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
        final ManyOwningSideLocal owningLocal = createManyOwningSide(compoundPK_20_20, compoundPK_20_20_field1);
        owningLocal.setOneInverseSide(inverseLocal);
        // todo should fail when we have fk as part of pk
        //            Assert.fail();
        completeTransaction();
    } catch (final TransactionRolledbackLocalException e) {
        if (!(e.getCause() instanceof IllegalStateException)) {
            e.printStackTrace();
            throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
        }
    } catch (final Throwable e) {
        e.printStackTrace();
        throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
    } finally {
        completeTransaction();
        cleanDb();
    }
}
Also used : TransactionRolledbackLocalException(javax.ejb.TransactionRolledbackLocalException) OneInverseSideLocal(org.apache.openejb.test.entity.cmr.cmrmapping.OneInverseSideLocal) TestFailureException(org.apache.openejb.test.TestFailureException) ManyOwningSideLocal(org.apache.openejb.test.entity.cmr.cmrmapping.ManyOwningSideLocal) AssertionFailedError(junit.framework.AssertionFailedError)

Example 2 with TransactionRolledbackLocalException

use of javax.ejb.TransactionRolledbackLocalException in project tomee by apache.

the class CmrMappingTests method testOneToManySetCMROnInverseSideResetPK.

public void testOneToManySetCMROnInverseSideResetPK() throws Exception {
    beginTransaction();
    try {
        final OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
        final ManyOwningSideLocal owningLocal = createManyOwningSide(compoundPK_20_20, compoundPK_20_20_field1);
        inverseLocal.setManyOwningSide(Collections.singleton(owningLocal));
        // todo should fail when we have fk as part of pk
        //            Assert.fail();
        completeTransaction();
    } catch (final TransactionRolledbackLocalException e) {
        if (!(e.getCause() instanceof IllegalStateException)) {
            e.printStackTrace();
            throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
        }
    } catch (final Throwable e) {
        e.printStackTrace();
        throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
    } finally {
        completeTransaction();
        cleanDb();
    }
}
Also used : TransactionRolledbackLocalException(javax.ejb.TransactionRolledbackLocalException) OneInverseSideLocal(org.apache.openejb.test.entity.cmr.cmrmapping.OneInverseSideLocal) TestFailureException(org.apache.openejb.test.TestFailureException) ManyOwningSideLocal(org.apache.openejb.test.entity.cmr.cmrmapping.ManyOwningSideLocal) AssertionFailedError(junit.framework.AssertionFailedError)

Example 3 with TransactionRolledbackLocalException

use of javax.ejb.TransactionRolledbackLocalException in project tomee by apache.

the class CmrMappingTests method testOneToOneSetCMROnInverseSideResetPK.

public void testOneToOneSetCMROnInverseSideResetPK() throws Exception {
    beginTransaction();
    try {
        final OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
        final OneOwningSideLocal owningLocal = createOneOwningSide(compoundPK_20_20, compoundPK_20_20_field1);
        inverseLocal.setOneOwningSide(owningLocal);
        // todo should fail when we have fk as part of pk
        //            Assert.fail();
        completeTransaction();
    } catch (final TransactionRolledbackLocalException e) {
        if (!(e.getCause() instanceof IllegalStateException)) {
            e.printStackTrace();
            throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
        }
    } catch (final Throwable e) {
        e.printStackTrace();
        throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
    } finally {
        completeTransaction();
        cleanDb();
    }
}
Also used : TransactionRolledbackLocalException(javax.ejb.TransactionRolledbackLocalException) OneInverseSideLocal(org.apache.openejb.test.entity.cmr.cmrmapping.OneInverseSideLocal) TestFailureException(org.apache.openejb.test.TestFailureException) AssertionFailedError(junit.framework.AssertionFailedError) OneOwningSideLocal(org.apache.openejb.test.entity.cmr.cmrmapping.OneOwningSideLocal)

Example 4 with TransactionRolledbackLocalException

use of javax.ejb.TransactionRolledbackLocalException in project tomee by apache.

the class CmrMappingTests method testOneToOneSetCMROnOwningSideResetPK.

public void testOneToOneSetCMROnOwningSideResetPK() throws Exception {
    beginTransaction();
    try {
        final OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
        final OneOwningSideLocal owningLocal = createOneOwningSide(compoundPK_20_20, compoundPK_20_20_field1);
        owningLocal.setOneInverseSide(inverseLocal);
        // todo should fail when we have fk as part of pk
        //            Assert.fail();
        completeTransaction();
    } catch (final TransactionRolledbackLocalException e) {
        if (!(e.getCause() instanceof IllegalStateException)) {
            e.printStackTrace();
            throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
        }
    } catch (final Throwable e) {
        e.printStackTrace();
        throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
    } finally {
        completeTransaction();
        cleanDb();
    }
}
Also used : TransactionRolledbackLocalException(javax.ejb.TransactionRolledbackLocalException) OneInverseSideLocal(org.apache.openejb.test.entity.cmr.cmrmapping.OneInverseSideLocal) TestFailureException(org.apache.openejb.test.TestFailureException) AssertionFailedError(junit.framework.AssertionFailedError) OneOwningSideLocal(org.apache.openejb.test.entity.cmr.cmrmapping.OneOwningSideLocal)

Example 5 with TransactionRolledbackLocalException

use of javax.ejb.TransactionRolledbackLocalException in project tomee by apache.

the class ManyToManyComplexPkTests method testSetCmrNull.

public void testSetCmrNull() throws Exception {
    resetDB();
    beginTransaction();
    try {
        final PlatformLocal platform = findPlatform(new Integer(1));
        try {
            platform.setGames(null);
            fail("expected platform.setGames(null) to throw an IllegalArgumentException");
        } catch (final TransactionRolledbackLocalException e) {
            final Throwable cause = e.getCause();
            assertNotNull("cause is null", cause);
            assertTrue("cause is not a instance of IllegalArgumentException", cause instanceof IllegalArgumentException);
        }
    } finally {
        completeTransaction();
    }
}
Also used : TransactionRolledbackLocalException(javax.ejb.TransactionRolledbackLocalException) PlatformLocal(org.apache.openejb.test.entity.cmr.manytomany.PlatformLocal)

Aggregations

TransactionRolledbackLocalException (javax.ejb.TransactionRolledbackLocalException)6 AssertionFailedError (junit.framework.AssertionFailedError)4 TestFailureException (org.apache.openejb.test.TestFailureException)4 OneInverseSideLocal (org.apache.openejb.test.entity.cmr.cmrmapping.OneInverseSideLocal)4 ManyOwningSideLocal (org.apache.openejb.test.entity.cmr.cmrmapping.ManyOwningSideLocal)2 OneOwningSideLocal (org.apache.openejb.test.entity.cmr.cmrmapping.OneOwningSideLocal)2 PlatformLocal (org.apache.openejb.test.entity.cmr.manytomany.PlatformLocal)2