Search in sources :

Example 1 with PlatformLocal

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

the class ManyToManyTests method createPlatform.

private PlatformLocal createPlatform(final int platformId) throws CreateException {
    final PlatformLocal platform = platformLocalHome.create(platformId);
    platform.setName("value" + platformId);
    return platform;
}
Also used : PlatformLocal(org.apache.openejb.test.entity.cmr.manytomany.PlatformLocal)

Example 2 with PlatformLocal

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

the class ManyToManyTests method testASetBExistingBNewA.

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

Example 3 with PlatformLocal

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

the class ManyToManyTests method testIteratorConcurrentModification.

public void testIteratorConcurrentModification() throws Exception {
    resetDB();
    beginTransaction();
    final Set games;
    try {
        final PlatformLocal platform = findPlatform(new Integer(1));
        final GameLocal game = findGame(new Integer(11));
        games = platform.getGames();
        assertFalse(games.isEmpty());
        assertEquals(2, games.size());
        final Iterator iterator = games.iterator();
        games.remove(game);
        assertEquals(1, games.size());
        try {
            iterator.next();
            fail("expected iterator.next() to throw an ConcurrentModificationException");
        } catch (final ConcurrentModificationException expected) {
        }
    } finally {
        completeTransaction();
    }
}
Also used : ConcurrentModificationException(java.util.ConcurrentModificationException) Set(java.util.Set) HashSet(java.util.HashSet) ResultSet(java.sql.ResultSet) Iterator(java.util.Iterator) GameLocal(org.apache.openejb.test.entity.cmr.manytomany.GameLocal) PlatformLocal(org.apache.openejb.test.entity.cmr.manytomany.PlatformLocal)

Example 4 with PlatformLocal

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

the class ManyToManyTests method testBSetAExistingANewB.

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

Example 5 with PlatformLocal

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

the class ManyToManyTests method testIllegalCmrCollectionArgument.

public void testIllegalCmrCollectionArgument() throws Exception {
    resetDB();
    beginTransaction();
    try {
        final PlatformLocal platform = findPlatform(new Integer(1));
        final Set games = platform.getGames();
        try {
            games.add(new Object());
            fail("expected games.add(new Object()) to throw an IllegalArgumentException");
        } catch (final IllegalArgumentException e) {
        }
        try {
            games.addAll(Arrays.asList(new Object()));
            fail("expected games.addAll(Arrays.asList(new Object())) to throw an IllegalArgumentException");
        } catch (final IllegalArgumentException expected) {
        }
    } finally {
        completeTransaction();
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ResultSet(java.sql.ResultSet) 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