Search in sources :

Example 11 with OneInverseSideLocal

use of org.apache.openejb.test.entity.cmr.cmrmapping.OneInverseSideLocal 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 12 with OneInverseSideLocal

use of org.apache.openejb.test.entity.cmr.cmrmapping.OneInverseSideLocal in project tomee by apache.

the class CmrMappingTests method testOneToManySetCMROnInverseSide.

public void testOneToManySetCMROnInverseSide() throws Exception {
    beginTransaction();
    try {
        final OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
        final ManyOwningSideLocal owningLocal = createManyOwningSide(compoundPK_20_10, compoundPK_20_10_field1);
        inverseLocal.setManyOwningSide(Collections.singleton(owningLocal));
        completeTransaction();
        validateOneToManyRelationship();
    } catch (final Throwable e) {
        e.printStackTrace();
        throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
    } finally {
        completeTransaction();
        cleanDb();
    }
}
Also used : 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)

Aggregations

OneInverseSideLocal (org.apache.openejb.test.entity.cmr.cmrmapping.OneInverseSideLocal)12 AssertionFailedError (junit.framework.AssertionFailedError)9 TestFailureException (org.apache.openejb.test.TestFailureException)9 ManyOwningSideLocal (org.apache.openejb.test.entity.cmr.cmrmapping.ManyOwningSideLocal)6 OneOwningSideLocal (org.apache.openejb.test.entity.cmr.cmrmapping.OneOwningSideLocal)5 TransactionRolledbackLocalException (javax.ejb.TransactionRolledbackLocalException)4 HashSet (java.util.HashSet)1 Set (java.util.Set)1 OneInverseSideLocalHome (org.apache.openejb.test.entity.cmr.cmrmapping.OneInverseSideLocalHome)1