Search in sources :

Example 31 with PlatformLocal

use of org.apache.openejb.test.entity.cmr.manytomany.PlatformLocal in project tomee by apache.

the class ManyToManyTests method testBSetADropExisting.

public void testBSetADropExisting() throws Exception {
    resetDB();
    beginTransaction();
    try {
        GameLocal game = findGame(new Integer(11));
        game.setPlatforms(new HashSet<PlatformLocal>());
        game = findGame(new Integer(22));
        game.setPlatforms(new HashSet<PlatformLocal>());
    } finally {
        completeTransaction();
    }
    assertAllUnlinked();
}
Also used : GameLocal(org.apache.openejb.test.entity.cmr.manytomany.GameLocal) PlatformLocal(org.apache.openejb.test.entity.cmr.manytomany.PlatformLocal)

Example 32 with PlatformLocal

use of org.apache.openejb.test.entity.cmr.manytomany.PlatformLocal in project tomee by apache.

the class ManyToManyTests method testAGetBExistingAB.

public void testAGetBExistingAB() throws Exception {
    resetDB();
    beginTransaction();
    try {
        final PlatformLocal platform = findPlatform(new Integer(1));
        final Set<GameLocal> gameSets = platform.getGames();
        assertEquals(2, gameSets.size());
        for (final Iterator iter = gameSets.iterator(); iter.hasNext(); ) {
            final GameLocal game = (GameLocal) iter.next();
            if (game.getId().equals(new Integer(11))) {
                assertEquals("value11", game.getName());
            } else if (game.getId().equals(new Integer(22))) {
                assertEquals("value22", game.getName());
            } else {
                fail();
            }
        }
    } finally {
        completeTransaction();
    }
}
Also used : Iterator(java.util.Iterator) GameLocal(org.apache.openejb.test.entity.cmr.manytomany.GameLocal) PlatformLocal(org.apache.openejb.test.entity.cmr.manytomany.PlatformLocal)

Example 33 with PlatformLocal

use of org.apache.openejb.test.entity.cmr.manytomany.PlatformLocal in project tomee by apache.

the class ManyToManyTests 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)

Example 34 with PlatformLocal

use of org.apache.openejb.test.entity.cmr.manytomany.PlatformLocal in project tomee by apache.

the class ManyToManyComplexPkTests method testASetBNewAB.

public void testASetBNewAB() throws Exception {
    resetDB();
    beginTransaction();
    try {
        final PlatformLocal platform = createPlatform(new Integer(4));
        final GameLocal game = createGame(new Integer(33));
        final Set<GameLocal> gameSets = platform.getGames();
        gameSets.add(game);
    } finally {
        completeTransaction();
    }
    assertLinked(4, 33);
}
Also used : GameLocal(org.apache.openejb.test.entity.cmr.manytomany.GameLocal) PlatformLocal(org.apache.openejb.test.entity.cmr.manytomany.PlatformLocal)

Example 35 with PlatformLocal

use of org.apache.openejb.test.entity.cmr.manytomany.PlatformLocal 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

PlatformLocal (org.apache.openejb.test.entity.cmr.manytomany.PlatformLocal)37 GameLocal (org.apache.openejb.test.entity.cmr.manytomany.GameLocal)30 ResultSet (java.sql.ResultSet)12 HashSet (java.util.HashSet)12 Iterator (java.util.Iterator)12 Set (java.util.Set)12 ConcurrentModificationException (java.util.ConcurrentModificationException)8 Connection (java.sql.Connection)2 SQLException (java.sql.SQLException)2 Statement (java.sql.Statement)2 TransactionRolledbackLocalException (javax.ejb.TransactionRolledbackLocalException)2