Search in sources :

Example 11 with GameLocal

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

the class ManyToManyTests method testBGetAExistingAB.

public void testBGetAExistingAB() throws Exception {
    resetDB();
    beginTransaction();
    try {
        final GameLocal game = findGame(new Integer(22));
        final Set aSet = game.getPlatforms();
        assertEquals(3, aSet.size());
        for (final Iterator iter = aSet.iterator(); iter.hasNext(); ) {
            final PlatformLocal platform = (PlatformLocal) iter.next();
            if (platform.getId().equals(new Integer(1))) {
                assertEquals("value1", platform.getName());
            } else if (platform.getId().equals(new Integer(2))) {
                assertEquals("value2", platform.getName());
            } else if (platform.getId().equals(new Integer(3))) {
                assertEquals("value3", platform.getName());
            } else {
                fail();
            }
        }
    } finally {
        completeTransaction();
    }
}
Also used : 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 12 with GameLocal

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

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

the class ManyToManyTests method createGame.

private GameLocal createGame(final int gameId) throws CreateException {
    final GameLocal menu = gameLocalHome.create(gameId);
    menu.setName("value" + gameId);
    return menu;
}
Also used : GameLocal(org.apache.openejb.test.entity.cmr.manytomany.GameLocal)

Example 14 with GameLocal

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

the class ManyToManyTests method testASetBExistingANewB.

public void testASetBExistingANewB() throws Exception {
    resetDB();
    beginTransaction();
    try {
        final PlatformLocal platform = findPlatform(new Integer(1));
        final GameLocal game = createGame(new Integer(33));
        final Set<GameLocal> gameSets = platform.getGames();
        gameSets.add(game);
    } 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 15 with GameLocal

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

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

Aggregations

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