You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by an...@apache.org on 2014/07/15 23:55:19 UTC
svn commit: r1610862 [28/44] - in /tomee/tomee/trunk/itests: ./ failover-ejb/
failover-ejb/src/main/java/org/apache/openejb/itest/failover/ejb/ failover/
failover/src/main/java/org/apache/openejb/itest/failover/
failover/src/main/java/org/apache/openej...
Modified: tomee/tomee/trunk/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/CmrMappingTests.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/CmrMappingTests.java?rev=1610862&r1=1610861&r2=1610862&view=diff
==============================================================================
--- tomee/tomee/trunk/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/CmrMappingTests.java (original)
+++ tomee/tomee/trunk/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/CmrMappingTests.java Tue Jul 15 21:55:09 2014
@@ -74,13 +74,13 @@ public class CmrMappingTests extends Abs
beginTransaction();
try {
- OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
- OneOwningSideLocal owningLocal = createOneOwningSide(compoundPK_20_10, compoundPK_20_10_field1);
+ final OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
+ final OneOwningSideLocal owningLocal = createOneOwningSide(compoundPK_20_10, compoundPK_20_10_field1);
owningLocal.setOneInverseSide(inverseLocal);
completeTransaction();
validateOneToOneRelationship();
- } catch (Throwable e) {
+ } catch (final Throwable e) {
e.printStackTrace();
throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
} finally {
@@ -90,43 +90,43 @@ public class CmrMappingTests extends Abs
}
private void cleanDb() {
- for (Integer id : oneOwningCreated) {
+ for (final Integer id : oneOwningCreated) {
try {
findOneOwningSide(id).remove();
- } catch (Exception e) {
+ } catch (final Exception e) {
} finally {
try {
completeTransaction();
- } catch (Exception ignored) {
+ } catch (final Exception ignored) {
}
}
}
oneOwningCreated.clear();
- for (Integer id : oneInverseCreated) {
+ for (final Integer id : oneInverseCreated) {
try {
findOneInverseSide(id).remove();
- } catch (Exception e) {
+ } catch (final Exception e) {
} finally {
try {
completeTransaction();
- } catch (Exception ignored) {
+ } catch (final Exception ignored) {
}
}
}
oneInverseCreated.clear();
- for (Integer id : manyCreated) {
+ for (final Integer id : manyCreated) {
try {
findManyOwningSide(id).remove();
- } catch (Exception e) {
+ } catch (final Exception e) {
} finally {
try {
completeTransaction();
- } catch (Exception ignored) {
+ } catch (final Exception ignored) {
}
}
}
@@ -137,18 +137,18 @@ public class CmrMappingTests extends Abs
beginTransaction();
try {
- OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
- OneOwningSideLocal owningLocal = createOneOwningSide(compoundPK_20_20, compoundPK_20_20_field1);
+ 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 (TransactionRolledbackLocalException e) {
+ } catch (final TransactionRolledbackLocalException e) {
if (!(e.getCause() instanceof IllegalStateException)) {
e.printStackTrace();
throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
}
- } catch (Throwable e) {
+ } catch (final Throwable e) {
e.printStackTrace();
throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
} finally {
@@ -161,13 +161,13 @@ public class CmrMappingTests extends Abs
beginTransaction();
try {
- OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
- OneOwningSideLocal owningLocal = createOneOwningSide(compoundPK_20_10, compoundPK_20_10_field1);
+ final OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
+ final OneOwningSideLocal owningLocal = createOneOwningSide(compoundPK_20_10, compoundPK_20_10_field1);
inverseLocal.setOneOwningSide(owningLocal);
completeTransaction();
validateOneToOneRelationship();
- } catch (Throwable e) {
+ } catch (final Throwable e) {
e.printStackTrace();
throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
} finally {
@@ -180,18 +180,18 @@ public class CmrMappingTests extends Abs
beginTransaction();
try {
- OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
- OneOwningSideLocal owningLocal = createOneOwningSide(compoundPK_20_20, compoundPK_20_20_field1);
+ 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 (TransactionRolledbackLocalException e) {
+ } catch (final TransactionRolledbackLocalException e) {
if (!(e.getCause() instanceof IllegalStateException)) {
e.printStackTrace();
throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
}
- } catch (Throwable e) {
+ } catch (final Throwable e) {
e.printStackTrace();
throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
} finally {
@@ -209,8 +209,8 @@ public class CmrMappingTests extends Abs
// todo should fail when we have fk as part of pk
// Assert.fail();
completeTransaction();
- } catch (IllegalStateException e) {
- } catch (Throwable e) {
+ } catch (final IllegalStateException e) {
+ } catch (final Throwable e) {
e.printStackTrace();
throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
} finally {
@@ -223,13 +223,13 @@ public class CmrMappingTests extends Abs
beginTransaction();
try {
- OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
- ManyOwningSideLocal owningLocal = createManyOwningSide(compoundPK_20_10, compoundPK_20_10_field1);
+ final OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
+ final ManyOwningSideLocal owningLocal = createManyOwningSide(compoundPK_20_10, compoundPK_20_10_field1);
owningLocal.setOneInverseSide(inverseLocal);
completeTransaction();
validateOneToManyRelationship();
- } catch (Throwable e) {
+ } catch (final Throwable e) {
e.printStackTrace();
throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
} finally {
@@ -242,13 +242,13 @@ public class CmrMappingTests extends Abs
beginTransaction();
try {
- OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
- ManyOwningSideLocal owningLocal = createManyOwningSide(compoundPK_20_10, compoundPK_20_10_field1);
+ final OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
+ final ManyOwningSideLocal owningLocal = createManyOwningSide(compoundPK_20_10, compoundPK_20_10_field1);
owningLocal.setOneInverseSide(inverseLocal);
completeTransaction();
owningLocal.testEJBSelect();
- } catch (Throwable e) {
+ } catch (final Throwable e) {
e.printStackTrace();
throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
} finally {
@@ -261,18 +261,18 @@ public class CmrMappingTests extends Abs
beginTransaction();
try {
- OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
- ManyOwningSideLocal owningLocal = createManyOwningSide(compoundPK_20_20, compoundPK_20_20_field1);
+ 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 (TransactionRolledbackLocalException e) {
+ } catch (final TransactionRolledbackLocalException e) {
if (!(e.getCause() instanceof IllegalStateException)) {
e.printStackTrace();
throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
}
- } catch (Throwable e) {
+ } catch (final Throwable e) {
e.printStackTrace();
throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
} finally {
@@ -285,13 +285,13 @@ public class CmrMappingTests extends Abs
beginTransaction();
try {
- OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
- ManyOwningSideLocal owningLocal = createManyOwningSide(compoundPK_20_10, compoundPK_20_10_field1);
+ 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 (Throwable e) {
+ } catch (final Throwable e) {
e.printStackTrace();
throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
} finally {
@@ -304,18 +304,18 @@ public class CmrMappingTests extends Abs
beginTransaction();
try {
- OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
- ManyOwningSideLocal owningLocal = createManyOwningSide(compoundPK_20_20, compoundPK_20_20_field1);
+ 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 (TransactionRolledbackLocalException e) {
+ } catch (final TransactionRolledbackLocalException e) {
if (!(e.getCause() instanceof IllegalStateException)) {
e.printStackTrace();
throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
}
- } catch (Throwable e) {
+ } catch (final Throwable e) {
e.printStackTrace();
throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
} finally {
@@ -333,8 +333,8 @@ public class CmrMappingTests extends Abs
// todo should fail when we have fk as part of pk
// Assert.fail();
completeTransaction();
- } catch (IllegalStateException e) {
- } catch (Throwable e) {
+ } catch (final IllegalStateException e) {
+ } catch (final Throwable e) {
e.printStackTrace();
throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
} finally {
@@ -343,27 +343,27 @@ public class CmrMappingTests extends Abs
}
}
- private OneInverseSideLocal createOneInverseSide(Integer id) throws Exception {
- OneInverseSideLocalHome home = oneInverseHome;
- OneInverseSideLocal oneInverseSideLocal = home.create(id);
+ private OneInverseSideLocal createOneInverseSide(final Integer id) throws Exception {
+ final OneInverseSideLocalHome home = oneInverseHome;
+ final OneInverseSideLocal oneInverseSideLocal = home.create(id);
oneInverseCreated.add(id);
return oneInverseSideLocal;
}
- private OneInverseSideLocal findOneInverseSide(Integer id) throws Exception {
- OneInverseSideLocalHome home = oneInverseHome;
+ private OneInverseSideLocal findOneInverseSide(final Integer id) throws Exception {
+ final OneInverseSideLocalHome home = oneInverseHome;
return home.findByPrimaryKey(id);
}
private void validateOneToOneRelationship() throws Exception {
try {
- OneInverseSideLocal inverseLocal = findOneInverseSide(compoundPK_20_10_field1);
+ final OneInverseSideLocal inverseLocal = findOneInverseSide(compoundPK_20_10_field1);
- OneOwningSideLocal oneOwningSide = inverseLocal.getOneOwningSide();
+ final OneOwningSideLocal oneOwningSide = inverseLocal.getOneOwningSide();
Assert.assertNotNull(oneOwningSide);
Assert.assertEquals(compoundPK_20_10, oneOwningSide.getPrimaryKey());
- OneInverseSideLocal inverseBackRef = oneOwningSide.getOneInverseSide();
+ final OneInverseSideLocal inverseBackRef = oneOwningSide.getOneInverseSide();
Assert.assertNotNull(inverseBackRef);
Assert.assertEquals(compoundPK_20_10_field1, inverseBackRef.getPrimaryKey());
completeTransaction();
@@ -372,43 +372,43 @@ public class CmrMappingTests extends Abs
}
}
- private OneOwningSideLocal createOneOwningSide(Integer id, Integer field1) throws Exception {
- OneOwningSideLocalHome home = oneOwningHome;
- OneOwningSideLocal oneOwningSideLocal = home.create(id, field1);
+ private OneOwningSideLocal createOneOwningSide(final Integer id, final Integer field1) throws Exception {
+ final OneOwningSideLocalHome home = oneOwningHome;
+ final OneOwningSideLocal oneOwningSideLocal = home.create(id, field1);
oneOwningCreated.add(id);
return oneOwningSideLocal;
}
- private OneOwningSideLocal findOneOwningSide(Integer id) throws Exception {
- OneOwningSideLocalHome home = oneOwningHome;
+ private OneOwningSideLocal findOneOwningSide(final Integer id) throws Exception {
+ final OneOwningSideLocalHome home = oneOwningHome;
return home.findByPrimaryKey(id);
}
- private ManyOwningSideLocal createManyOwningSide(Integer id, Integer field1) throws Exception {
- ManyOwningSideLocalHome home = manyHome;
- ManyOwningSideLocal manyOwningSideLocal = home.create(id, field1);
+ private ManyOwningSideLocal createManyOwningSide(final Integer id, final Integer field1) throws Exception {
+ final ManyOwningSideLocalHome home = manyHome;
+ final ManyOwningSideLocal manyOwningSideLocal = home.create(id, field1);
manyCreated.add(id);
return manyOwningSideLocal;
}
- private ManyOwningSideLocal findManyOwningSide(Integer id) throws Exception {
- ManyOwningSideLocalHome home = manyHome;
+ private ManyOwningSideLocal findManyOwningSide(final Integer id) throws Exception {
+ final ManyOwningSideLocalHome home = manyHome;
return home.findByPrimaryKey(id);
}
private void validateOneToManyRelationship() throws NotSupportedException, SystemException, Exception, HeuristicMixedException, HeuristicRollbackException, RollbackException {
try {
- OneInverseSideLocal inverseLocal = findOneInverseSide(compoundPK_20_10_field1);
+ final OneInverseSideLocal inverseLocal = findOneInverseSide(compoundPK_20_10_field1);
// verify one side has a set containing the many bean
- Set set = inverseLocal.getManyOwningSide();
+ final Set set = inverseLocal.getManyOwningSide();
Assert.assertEquals(1, set.size());
- ManyOwningSideLocal owningLocal = (ManyOwningSideLocal) set.iterator().next();
+ final ManyOwningSideLocal owningLocal = (ManyOwningSideLocal) set.iterator().next();
Assert.assertEquals(compoundPK_20_10, owningLocal.getPrimaryKey());
// verify the many bean has a back reference to the one
- OneInverseSideLocal oneInverseSide = owningLocal.getOneInverseSide();
+ final OneInverseSideLocal oneInverseSide = owningLocal.getOneInverseSide();
Assert.assertNotNull(oneInverseSide);
Assert.assertEquals(compoundPK_20_10_field1, oneInverseSide.getPrimaryKey());
Modified: tomee/tomee/trunk/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/ManyToManyComplexPkTests.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/ManyToManyComplexPkTests.java?rev=1610862&r1=1610861&r2=1610862&view=diff
==============================================================================
--- tomee/tomee/trunk/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/ManyToManyComplexPkTests.java (original)
+++ tomee/tomee/trunk/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/ManyToManyComplexPkTests.java Tue Jul 15 21:55:09 2014
@@ -58,11 +58,11 @@ public class ManyToManyComplexPkTests ex
resetDB();
beginTransaction();
try {
- PlatformLocal platform = findPlatform(new Integer(1));
- Set<GameLocal> gameSets = platform.getGames();
+ final PlatformLocal platform = findPlatform(new Integer(1));
+ final Set<GameLocal> gameSets = platform.getGames();
assertEquals(2, gameSets.size());
- for (Iterator iter = gameSets.iterator(); iter.hasNext();) {
- GameLocal game = (GameLocal) iter.next();
+ 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))) {
@@ -80,12 +80,12 @@ public class ManyToManyComplexPkTests ex
resetDB();
beginTransaction();
try {
- PlatformLocal platform = findPlatform(new Integer(1));
+ final PlatformLocal platform = findPlatform(new Integer(1));
try {
platform.setGames(null);
fail("expected platform.setGames(null) to throw an IllegalArgumentException");
- } catch (TransactionRolledbackLocalException e) {
- Throwable cause = e.getCause();
+ } 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);
}
@@ -98,11 +98,11 @@ public class ManyToManyComplexPkTests ex
resetDB();
beginTransaction();
try {
- GameLocal game = findGame(new Integer(22));
- Set aSet = game.getPlatforms();
+ final GameLocal game = findGame(new Integer(22));
+ final Set aSet = game.getPlatforms();
assertEquals(3, aSet.size());
- for (Iterator iter = aSet.iterator(); iter.hasNext();) {
- PlatformLocal platform = (PlatformLocal) iter.next();
+ 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))) {
@@ -154,9 +154,9 @@ public class ManyToManyComplexPkTests ex
resetDB();
beginTransaction();
try {
- PlatformLocal platform = createPlatform(new Integer(4));
- GameLocal game = createGame(new Integer(33));
- Set<GameLocal> gameSets = platform.getGames();
+ 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();
@@ -169,9 +169,9 @@ public class ManyToManyComplexPkTests ex
resetDB();
beginTransaction();
try {
- PlatformLocal platform = createPlatform(new Integer(4));
- GameLocal game = createGame(new Integer(33));
- Set<PlatformLocal> platformSets = game.getPlatforms();
+ final PlatformLocal platform = createPlatform(new Integer(4));
+ final GameLocal game = createGame(new Integer(33));
+ final Set<PlatformLocal> platformSets = game.getPlatforms();
platformSets.add(platform);
} finally {
completeTransaction();
@@ -184,9 +184,9 @@ public class ManyToManyComplexPkTests ex
resetDB();
beginTransaction();
try {
- PlatformLocal platform = createPlatform(new Integer(4));
- GameLocal game = findGame(new Integer(11));
- Set<GameLocal> gameSets = platform.getGames();
+ 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();
@@ -199,9 +199,9 @@ public class ManyToManyComplexPkTests ex
resetDB();
beginTransaction();
try {
- PlatformLocal platform = createPlatform(new Integer(4));
- GameLocal game = findGame(new Integer(11));
- Set<PlatformLocal> platformSets = game.getPlatforms();
+ final PlatformLocal platform = createPlatform(new Integer(4));
+ final GameLocal game = findGame(new Integer(11));
+ final Set<PlatformLocal> platformSets = game.getPlatforms();
platformSets.add(platform);
} finally {
completeTransaction();
@@ -214,9 +214,9 @@ public class ManyToManyComplexPkTests ex
resetDB();
beginTransaction();
try {
- PlatformLocal platform = findPlatform(new Integer(1));
- GameLocal game = createGame(new Integer(33));
- Set<GameLocal> gameSets = platform.getGames();
+ 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();
@@ -229,9 +229,9 @@ public class ManyToManyComplexPkTests ex
resetDB();
beginTransaction();
try {
- PlatformLocal platform = findPlatform(new Integer(1));
- GameLocal game = createGame(new Integer(33));
- Set<PlatformLocal> platformSets = game.getPlatforms();
+ 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();
@@ -244,7 +244,7 @@ public class ManyToManyComplexPkTests ex
resetDB();
beginTransaction();
try {
- PlatformLocal platform = findPlatform(new Integer(1));
+ final PlatformLocal platform = findPlatform(new Integer(1));
platform.remove();
} finally {
completeTransaction();
@@ -253,23 +253,23 @@ public class ManyToManyComplexPkTests ex
assertPlatformDeleted(1);
}
- public void testIllegalCmrCollectionArgument() throws Exception {
+ public void testIllegalCmrCollectionArgument() throws Exception {
resetDB();
beginTransaction();
try {
- PlatformLocal platform = findPlatform(new Integer(1));
- Set games = platform.getGames();
+ 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 (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
}
try {
games.addAll(Arrays.asList(new Object()));
fail("expected games.addAll(Arrays.asList(new Object())) to throw an IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
+ } catch (final IllegalArgumentException expected) {
}
} finally {
completeTransaction();
@@ -282,7 +282,7 @@ public class ManyToManyComplexPkTests ex
Set games;
GameLocal newGame;
try {
- PlatformLocal platform = findPlatform(new Integer(1));
+ final PlatformLocal platform = findPlatform(new Integer(1));
newGame = createGame(new Integer(33));
games = platform.getGames();
} finally {
@@ -292,8 +292,8 @@ public class ManyToManyComplexPkTests ex
// CMR collections should still be readable
assertFalse(games.isEmpty());
assertEquals(2, games.size());
- for (Iterator iter = games.iterator(); iter.hasNext();) {
- GameLocal game = (GameLocal) iter.next();
+ for (final Iterator iter = games.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))) {
@@ -307,28 +307,28 @@ public class ManyToManyComplexPkTests ex
try {
games.add(newGame);
fail("expected games.add(game) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
try {
games.addAll(Arrays.asList(newGame));
fail("expected games.addAll(Arrays.asList(game)) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
try {
games.remove(newGame);
fail("expected games.remove(game) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
try {
games.removeAll(Arrays.asList(newGame));
fail("expected games.removeAll(game) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
- Iterator iterator = games.iterator();
+ final Iterator iterator = games.iterator();
try {
iterator.remove();
fail("expected iterator.remove() to throw an ConcurrentModificationException");
- } catch (ConcurrentModificationException expected) {
+ } catch (final ConcurrentModificationException expected) {
}
}
@@ -338,7 +338,7 @@ public class ManyToManyComplexPkTests ex
Set games;
GameLocal newGame;
try {
- PlatformLocal platform = findPlatform(new Integer(1));
+ final PlatformLocal platform = findPlatform(new Integer(1));
newGame = createGame(new Integer(33));
games = platform.getGames();
} finally {
@@ -350,8 +350,8 @@ public class ManyToManyComplexPkTests ex
// CMR collections should still be readable
assertFalse(games.isEmpty());
assertEquals(2, games.size());
- for (Iterator iter = games.iterator(); iter.hasNext();) {
- GameLocal game = (GameLocal) iter.next();
+ for (final Iterator iter = games.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))) {
@@ -365,28 +365,28 @@ public class ManyToManyComplexPkTests ex
try {
games.add(newGame);
fail("expected games.add(game) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
try {
games.addAll(Arrays.asList(newGame));
fail("expected games.addAll(Arrays.asList(game)) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
try {
games.remove(newGame);
fail("expected games.remove(game) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
try {
games.removeAll(Arrays.asList(newGame));
fail("expected games.removeAll(game) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
- Iterator iterator = games.iterator();
+ final Iterator iterator = games.iterator();
try {
iterator.remove();
fail("expected iterator.remove() to throw an ConcurrentModificationException");
- } catch (ConcurrentModificationException expected) {
+ } catch (final ConcurrentModificationException expected) {
}
} finally {
completeTransaction();
@@ -396,15 +396,15 @@ public class ManyToManyComplexPkTests ex
public void testIteratorConcurrentModification() throws Exception {
resetDB();
beginTransaction();
- Set games;
+ final Set games;
try {
- PlatformLocal platform = findPlatform(new Integer(1));
- GameLocal game = findGame(new Integer(11));
+ final PlatformLocal platform = findPlatform(new Integer(1));
+ final GameLocal game = findGame(new Integer(11));
games = platform.getGames();
assertFalse(games.isEmpty());
assertEquals(2, games.size());
- Iterator iterator = games.iterator();
+ final Iterator iterator = games.iterator();
games.remove(game);
assertEquals(1, games.size());
@@ -412,7 +412,7 @@ public class ManyToManyComplexPkTests ex
try {
iterator.next();
fail("expected iterator.next() to throw an ConcurrentModificationException");
- } catch (ConcurrentModificationException expected) {
+ } catch (final ConcurrentModificationException expected) {
}
} finally {
completeTransaction();
@@ -422,15 +422,15 @@ public class ManyToManyComplexPkTests ex
public void testIteratorAndRemove() throws Exception {
resetDB();
beginTransaction();
- Set games;
+ final Set games;
try {
- PlatformLocal platform = findPlatform(new Integer(1));
- GameLocal game = findGame(new Integer(11));
+ final PlatformLocal platform = findPlatform(new Integer(1));
+ final GameLocal game = findGame(new Integer(11));
games = platform.getGames();
assertFalse(games.isEmpty());
assertEquals(2, games.size());
- Iterator iterator = games.iterator();
+ final Iterator iterator = games.iterator();
assertTrue(games.contains(game));
platform.remove();
@@ -440,16 +440,16 @@ public class ManyToManyComplexPkTests ex
try {
iterator.next();
fail("expected iterator.next() to throw an ConcurrentModificationException");
- } catch (ConcurrentModificationException expected) {
+ } catch (final ConcurrentModificationException expected) {
}
} finally {
completeTransaction();
}
}
- private void assertPlatformDeleted(int platformId) throws Exception {
- Connection c = ds.getConnection();
- Statement s = c.createStatement();
+ private void assertPlatformDeleted(final int platformId) throws Exception {
+ final Connection c = ds.getConnection();
+ final Statement s = c.createStatement();
ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM ComplexGame_ComplexPlatform WHERE Platforms_id=" + platformId);
assertTrue(rs.next());
@@ -466,10 +466,10 @@ public class ManyToManyComplexPkTests ex
}
private void assertAllUnlinked() throws Exception {
- Connection c = ds.getConnection();
- Statement s = c.createStatement();
+ final Connection c = ds.getConnection();
+ final Statement s = c.createStatement();
- ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM ComplexGame_ComplexPlatform");
+ final ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM ComplexGame_ComplexPlatform");
assertTrue(rs.next());
assertEquals(0, rs.getInt(1));
rs.close();
@@ -478,9 +478,9 @@ public class ManyToManyComplexPkTests ex
c.close();
}
- private void assertLinked(int platformId, int gameId) throws Exception {
- Connection c = ds.getConnection();
- Statement s = c.createStatement();
+ private void assertLinked(final int platformId, final int gameId) throws Exception {
+ final Connection c = ds.getConnection();
+ final Statement s = c.createStatement();
ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM ComplexGame_ComplexPlatform WHERE Platforms_id = " + platformId + " AND Games_id = " + gameId);
assertTrue(rs.next());
@@ -500,41 +500,41 @@ public class ManyToManyComplexPkTests ex
c.close();
}
- private GameLocal createGame(int gameId) throws CreateException {
- GameLocal menu = gameLocalHome.create(new GamePk(gameId, "value" + gameId));
+ private GameLocal createGame(final int gameId) throws CreateException {
+ final GameLocal menu = gameLocalHome.create(new GamePk(gameId, "value" + gameId));
return menu;
}
- private GameLocal findGame(int gameId) throws FinderException {
+ private GameLocal findGame(final int gameId) throws FinderException {
return gameLocalHome.findByPrimaryKey(new GamePk(gameId, "value" + gameId));
}
- private PlatformLocal createPlatform(int platformId) throws CreateException {
- PlatformLocal platform = platformLocalHome.create(new PlatformPk(platformId, "value" + platformId));
+ private PlatformLocal createPlatform(final int platformId) throws CreateException {
+ final PlatformLocal platform = platformLocalHome.create(new PlatformPk(platformId, "value" + platformId));
return platform;
}
- private PlatformLocal findPlatform(int platformId) throws FinderException {
+ private PlatformLocal findPlatform(final int platformId) throws FinderException {
return platformLocalHome.findByPrimaryKey(new PlatformPk(platformId, "value" + platformId));
}
private void resetDB() throws Exception {
- Connection connection = ds.getConnection();
+ final Connection connection = ds.getConnection();
Statement statement = null;
try {
statement = connection.createStatement();
try {
statement.execute("DELETE FROM ComplexGame_ComplexPlatform");
- } catch (SQLException ignored) {
+ } catch (final SQLException ignored) {
}
try {
statement.execute("DELETE FROM ComplexGame");
- } catch (SQLException ignored) {
+ } catch (final SQLException ignored) {
}
try {
statement.execute("DELETE FROM ComplexPlatform");
- } catch (SQLException ignored) {
+ } catch (final SQLException ignored) {
}
} finally {
close(statement);
@@ -543,16 +543,16 @@ public class ManyToManyComplexPkTests ex
beginTransaction();
try {
- PlatformLocal platform1 = createPlatform(1);
+ final PlatformLocal platform1 = createPlatform(1);
assertNotNull("platform1.getGames() is null", platform1.getGames());
- PlatformLocal platform2 = createPlatform(2);
+ final PlatformLocal platform2 = createPlatform(2);
assertNotNull("platform2.getGames() is null", platform2.getGames());
- PlatformLocal platform3 = createPlatform(3);
+ final PlatformLocal platform3 = createPlatform(3);
assertNotNull("platform3.getGames() is null", platform3.getGames());
- GameLocal game1 = createGame(11);
+ final GameLocal game1 = createGame(11);
assertNotNull("game1.getPlatforms() is null", game1.getPlatforms());
- GameLocal game2 = createGame(22);
+ final GameLocal game2 = createGame(22);
assertNotNull("game2.getPlatforms() is null", game2.getPlatforms());
platform1.getGames().add(game1);
Modified: tomee/tomee/trunk/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/ManyToManyTests.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/ManyToManyTests.java?rev=1610862&r1=1610861&r2=1610862&view=diff
==============================================================================
--- tomee/tomee/trunk/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/ManyToManyTests.java (original)
+++ tomee/tomee/trunk/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/ManyToManyTests.java Tue Jul 15 21:55:09 2014
@@ -56,11 +56,11 @@ public class ManyToManyTests extends Abs
resetDB();
beginTransaction();
try {
- PlatformLocal platform = findPlatform(new Integer(1));
- Set<GameLocal> gameSets = platform.getGames();
+ final PlatformLocal platform = findPlatform(new Integer(1));
+ final Set<GameLocal> gameSets = platform.getGames();
assertEquals(2, gameSets.size());
- for (Iterator iter = gameSets.iterator(); iter.hasNext();) {
- GameLocal game = (GameLocal) iter.next();
+ 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))) {
@@ -78,12 +78,12 @@ public class ManyToManyTests extends Abs
resetDB();
beginTransaction();
try {
- PlatformLocal platform = findPlatform(new Integer(1));
+ final PlatformLocal platform = findPlatform(new Integer(1));
try {
platform.setGames(null);
fail("expected platform.setGames(null) to throw an IllegalArgumentException");
- } catch (TransactionRolledbackLocalException e) {
- Throwable cause = e.getCause();
+ } 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);
}
@@ -96,11 +96,11 @@ public class ManyToManyTests extends Abs
resetDB();
beginTransaction();
try {
- GameLocal game = findGame(new Integer(22));
- Set aSet = game.getPlatforms();
+ final GameLocal game = findGame(new Integer(22));
+ final Set aSet = game.getPlatforms();
assertEquals(3, aSet.size());
- for (Iterator iter = aSet.iterator(); iter.hasNext();) {
- PlatformLocal platform = (PlatformLocal) iter.next();
+ 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))) {
@@ -152,9 +152,9 @@ public class ManyToManyTests extends Abs
resetDB();
beginTransaction();
try {
- PlatformLocal platform = createPlatform(new Integer(4));
- GameLocal game = createGame(new Integer(33));
- Set<GameLocal> gameSets = platform.getGames();
+ 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();
@@ -167,9 +167,9 @@ public class ManyToManyTests extends Abs
resetDB();
beginTransaction();
try {
- PlatformLocal platform = createPlatform(new Integer(4));
- GameLocal game = createGame(new Integer(33));
- Set<PlatformLocal> platformSets = game.getPlatforms();
+ final PlatformLocal platform = createPlatform(new Integer(4));
+ final GameLocal game = createGame(new Integer(33));
+ final Set<PlatformLocal> platformSets = game.getPlatforms();
platformSets.add(platform);
} finally {
completeTransaction();
@@ -182,9 +182,9 @@ public class ManyToManyTests extends Abs
resetDB();
beginTransaction();
try {
- PlatformLocal platform = createPlatform(new Integer(4));
- GameLocal game = findGame(new Integer(11));
- Set<GameLocal> gameSets = platform.getGames();
+ 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();
@@ -197,9 +197,9 @@ public class ManyToManyTests extends Abs
resetDB();
beginTransaction();
try {
- PlatformLocal platform = createPlatform(new Integer(4));
- GameLocal game = findGame(new Integer(11));
- Set<PlatformLocal> platformSets = game.getPlatforms();
+ final PlatformLocal platform = createPlatform(new Integer(4));
+ final GameLocal game = findGame(new Integer(11));
+ final Set<PlatformLocal> platformSets = game.getPlatforms();
platformSets.add(platform);
} finally {
completeTransaction();
@@ -212,9 +212,9 @@ public class ManyToManyTests extends Abs
resetDB();
beginTransaction();
try {
- PlatformLocal platform = findPlatform(new Integer(1));
- GameLocal game = createGame(new Integer(33));
- Set<GameLocal> gameSets = platform.getGames();
+ 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();
@@ -227,9 +227,9 @@ public class ManyToManyTests extends Abs
resetDB();
beginTransaction();
try {
- PlatformLocal platform = findPlatform(new Integer(1));
- GameLocal game = createGame(new Integer(33));
- Set<PlatformLocal> platformSets = game.getPlatforms();
+ 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();
@@ -242,7 +242,7 @@ public class ManyToManyTests extends Abs
resetDB();
beginTransaction();
try {
- PlatformLocal platform = findPlatform(new Integer(1));
+ final PlatformLocal platform = findPlatform(new Integer(1));
platform.remove();
} finally {
completeTransaction();
@@ -254,19 +254,19 @@ public class ManyToManyTests extends Abs
resetDB();
beginTransaction();
try {
- PlatformLocal platform = findPlatform(new Integer(1));
- Set games = platform.getGames();
+ 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 (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
}
try {
games.addAll(Arrays.asList(new Object()));
fail("expected games.addAll(Arrays.asList(new Object())) to throw an IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
+ } catch (final IllegalArgumentException expected) {
}
} finally {
completeTransaction();
@@ -279,7 +279,7 @@ public class ManyToManyTests extends Abs
Set games;
GameLocal newGame;
try {
- PlatformLocal platform = findPlatform(new Integer(1));
+ final PlatformLocal platform = findPlatform(new Integer(1));
newGame = createGame(new Integer(33));
games = platform.getGames();
} finally {
@@ -289,8 +289,8 @@ public class ManyToManyTests extends Abs
// CMR collections should still be readable
assertFalse(games.isEmpty());
assertEquals(2, games.size());
- for (Iterator iter = games.iterator(); iter.hasNext();) {
- GameLocal game = (GameLocal) iter.next();
+ for (final Iterator iter = games.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))) {
@@ -304,28 +304,28 @@ public class ManyToManyTests extends Abs
try {
games.add(newGame);
fail("expected games.add(game) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
try {
games.addAll(Arrays.asList(newGame));
fail("expected games.addAll(Arrays.asList(game)) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
try {
games.remove(newGame);
fail("expected games.remove(game) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
try {
games.removeAll(Arrays.asList(newGame));
fail("expected games.removeAll(game) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
- Iterator iterator = games.iterator();
+ final Iterator iterator = games.iterator();
try {
iterator.remove();
fail("expected iterator.remove() to throw an ConcurrentModificationException");
- } catch (ConcurrentModificationException expected) {
+ } catch (final ConcurrentModificationException expected) {
}
}
@@ -335,7 +335,7 @@ public class ManyToManyTests extends Abs
Set games;
GameLocal newGame;
try {
- PlatformLocal platform = findPlatform(new Integer(1));
+ final PlatformLocal platform = findPlatform(new Integer(1));
newGame = createGame(new Integer(33));
games = platform.getGames();
} finally {
@@ -347,8 +347,8 @@ public class ManyToManyTests extends Abs
// CMR collections should still be readable
assertFalse(games.isEmpty());
assertEquals(2, games.size());
- for (Iterator iter = games.iterator(); iter.hasNext();) {
- GameLocal game = (GameLocal) iter.next();
+ for (final Iterator iter = games.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))) {
@@ -362,28 +362,28 @@ public class ManyToManyTests extends Abs
try {
games.add(newGame);
fail("expected games.add(game) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
try {
games.addAll(Arrays.asList(newGame));
fail("expected games.addAll(Arrays.asList(game)) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
try {
games.remove(newGame);
fail("expected games.remove(game) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
try {
games.removeAll(Arrays.asList(newGame));
fail("expected games.removeAll(game) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
- Iterator iterator = games.iterator();
+ final Iterator iterator = games.iterator();
try {
iterator.remove();
fail("expected iterator.remove() to throw an ConcurrentModificationException");
- } catch (ConcurrentModificationException expected) {
+ } catch (final ConcurrentModificationException expected) {
}
} finally {
completeTransaction();
@@ -393,15 +393,15 @@ public class ManyToManyTests extends Abs
public void testIteratorConcurrentModification() throws Exception {
resetDB();
beginTransaction();
- Set games;
+ final Set games;
try {
- PlatformLocal platform = findPlatform(new Integer(1));
- GameLocal game = findGame(new Integer(11));
+ final PlatformLocal platform = findPlatform(new Integer(1));
+ final GameLocal game = findGame(new Integer(11));
games = platform.getGames();
assertFalse(games.isEmpty());
assertEquals(2, games.size());
- Iterator iterator = games.iterator();
+ final Iterator iterator = games.iterator();
games.remove(game);
assertEquals(1, games.size());
@@ -409,7 +409,7 @@ public class ManyToManyTests extends Abs
try {
iterator.next();
fail("expected iterator.next() to throw an ConcurrentModificationException");
- } catch (ConcurrentModificationException expected) {
+ } catch (final ConcurrentModificationException expected) {
}
} finally {
completeTransaction();
@@ -419,15 +419,15 @@ public class ManyToManyTests extends Abs
public void testIteratorAndRemove() throws Exception {
resetDB();
beginTransaction();
- Set games;
+ final Set games;
try {
- PlatformLocal platform = findPlatform(new Integer(1));
- GameLocal game = findGame(new Integer(11));
+ final PlatformLocal platform = findPlatform(new Integer(1));
+ final GameLocal game = findGame(new Integer(11));
games = platform.getGames();
assertFalse(games.isEmpty());
assertEquals(2, games.size());
- Iterator iterator = games.iterator();
+ final Iterator iterator = games.iterator();
assertTrue(games.contains(game));
platform.remove();
@@ -437,16 +437,16 @@ public class ManyToManyTests extends Abs
try {
iterator.next();
fail("expected iterator.next() to throw an ConcurrentModificationException");
- } catch (ConcurrentModificationException expected) {
+ } catch (final ConcurrentModificationException expected) {
}
} finally {
completeTransaction();
}
}
- private void assertPlatformDeleted(int platformId) throws Exception {
- Connection c = ds.getConnection();
- Statement s = c.createStatement();
+ private void assertPlatformDeleted(final int platformId) throws Exception {
+ final Connection c = ds.getConnection();
+ final Statement s = c.createStatement();
ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM Game_Platform WHERE Platforms_id=" + platformId);
assertTrue(rs.next());
@@ -463,10 +463,10 @@ public class ManyToManyTests extends Abs
}
private void assertAllUnlinked() throws Exception {
- Connection c = ds.getConnection();
- Statement s = c.createStatement();
+ final Connection c = ds.getConnection();
+ final Statement s = c.createStatement();
- ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM Game_Platform");
+ final ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM Game_Platform");
assertTrue(rs.next());
assertEquals(0, rs.getInt(1));
rs.close();
@@ -475,9 +475,9 @@ public class ManyToManyTests extends Abs
c.close();
}
- private void assertLinked(int platformId, int gameId) throws Exception {
- Connection c = ds.getConnection();
- Statement s = c.createStatement();
+ private void assertLinked(final int platformId, final int gameId) throws Exception {
+ final Connection c = ds.getConnection();
+ final Statement s = c.createStatement();
ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM Game_Platform WHERE Platforms_id = " + platformId + " AND Games_id = " + gameId);
assertTrue(rs.next());
@@ -497,43 +497,43 @@ public class ManyToManyTests extends Abs
c.close();
}
- private GameLocal createGame(int gameId) throws CreateException {
- GameLocal menu = gameLocalHome.create(gameId);
+ private GameLocal createGame(final int gameId) throws CreateException {
+ final GameLocal menu = gameLocalHome.create(gameId);
menu.setName("value" + gameId);
return menu;
}
- private GameLocal findGame(int gameId) throws FinderException {
+ private GameLocal findGame(final int gameId) throws FinderException {
return gameLocalHome.findByPrimaryKey(gameId);
}
- private PlatformLocal createPlatform(int platformId) throws CreateException {
- PlatformLocal platform = platformLocalHome.create(platformId);
+ private PlatformLocal createPlatform(final int platformId) throws CreateException {
+ final PlatformLocal platform = platformLocalHome.create(platformId);
platform.setName("value" + platformId);
return platform;
}
- private PlatformLocal findPlatform(int platformId) throws FinderException {
+ private PlatformLocal findPlatform(final int platformId) throws FinderException {
return platformLocalHome.findByPrimaryKey(platformId);
}
private void resetDB() throws Exception {
- Connection connection = ds.getConnection();
+ final Connection connection = ds.getConnection();
Statement statement = null;
try {
statement = connection.createStatement();
try {
statement.execute("DELETE FROM Game_Platform");
- } catch (SQLException ignored) {
+ } catch (final SQLException ignored) {
}
try {
statement.execute("DELETE FROM Game");
- } catch (SQLException ignored) {
+ } catch (final SQLException ignored) {
}
try {
statement.execute("DELETE FROM Platform");
- } catch (SQLException ignored) {
+ } catch (final SQLException ignored) {
}
} finally {
close(statement);
@@ -542,16 +542,16 @@ public class ManyToManyTests extends Abs
beginTransaction();
try {
- PlatformLocal platform1 = createPlatform(1);
+ final PlatformLocal platform1 = createPlatform(1);
assertNotNull("platform1.getGames() is null", platform1.getGames());
- PlatformLocal platform2 = createPlatform(2);
+ final PlatformLocal platform2 = createPlatform(2);
assertNotNull("platform2.getGames() is null", platform2.getGames());
- PlatformLocal platform3 = createPlatform(3);
+ final PlatformLocal platform3 = createPlatform(3);
assertNotNull("platform3.getGames() is null", platform3.getGames());
- GameLocal game1 = createGame(11);
+ final GameLocal game1 = createGame(11);
assertNotNull("game1.getPlatforms() is null", game1.getPlatforms());
- GameLocal game2 = createGame(22);
+ final GameLocal game2 = createGame(22);
assertNotNull("game2.getPlatforms() is null", game2.getPlatforms());
platform1.getGames().add(game1);
Modified: tomee/tomee/trunk/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/OneToManyComplexPkTests.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/OneToManyComplexPkTests.java?rev=1610862&r1=1610861&r2=1610862&view=diff
==============================================================================
--- tomee/tomee/trunk/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/OneToManyComplexPkTests.java (original)
+++ tomee/tomee/trunk/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/OneToManyComplexPkTests.java Tue Jul 15 21:55:09 2014
@@ -57,11 +57,11 @@ public class OneToManyComplexPkTests ext
resetDB();
beginTransaction();
try {
- ArtistLocal artist = findArtist(1);
- Set bSet = artist.getPerformed();
+ final ArtistLocal artist = findArtist(1);
+ final Set bSet = artist.getPerformed();
assertEquals(2, bSet.size());
- for (Object value : bSet) {
- SongLocal song = (SongLocal) value;
+ for (final Object value : bSet) {
+ final SongLocal song = (SongLocal) value;
if (song.getId().equals(11)) {
assertEquals("value11", song.getName());
} else if (song.getId().equals(22)) {
@@ -99,7 +99,7 @@ public class OneToManyComplexPkTests ext
resetDB();
beginTransaction();
try {
- ArtistLocal artist = findArtist(1);
+ final ArtistLocal artist = findArtist(1);
artist.setPerformed(new HashSet<SongLocal>());
} finally {
completeTransaction();
@@ -127,9 +127,9 @@ public class OneToManyComplexPkTests ext
resetDB();
beginTransaction();
try {
- ArtistLocal artist = findArtist(2);
- SongLocal song = findSong(22);
- Set<SongLocal> songSets = new HashSet<SongLocal>();
+ final ArtistLocal artist = findArtist(2);
+ final SongLocal song = findSong(22);
+ final Set<SongLocal> songSets = new HashSet<SongLocal>();
songSets.add(song);
artist.setPerformed(songSets);
} finally {
@@ -143,8 +143,8 @@ public class OneToManyComplexPkTests ext
resetDB();
beginTransaction();
try {
- ArtistLocal artist = findArtist(2);
- SongLocal song = findSong(22);
+ final ArtistLocal artist = findArtist(2);
+ final SongLocal song = findSong(22);
song.setPerformer(artist);
} finally {
completeTransaction();
@@ -156,9 +156,9 @@ public class OneToManyComplexPkTests ext
resetDB();
beginTransaction();
try {
- ArtistLocal artist = findArtist(2);
- SongLocal song = findSong(11);
- Set<SongLocal> songSets = artist.getPerformed();
+ final ArtistLocal artist = findArtist(2);
+ final SongLocal song = findSong(11);
+ final Set<SongLocal> songSets = artist.getPerformed();
songSets.add(song);
} finally {
completeTransaction();
@@ -171,8 +171,8 @@ public class OneToManyComplexPkTests ext
resetDB();
beginTransaction();
try {
- ArtistLocal artist = findArtist(2);
- SongLocal song = findSong(11);
+ final ArtistLocal artist = findArtist(2);
+ final SongLocal song = findSong(11);
song.setPerformer(artist);
} finally {
completeTransaction();
@@ -185,9 +185,9 @@ public class OneToManyComplexPkTests ext
resetDB();
beginTransaction();
try {
- ArtistLocal artist = findArtist(1);
- SongLocal song = createSong(33);
- Set<SongLocal> songSets = artist.getPerformed();
+ final ArtistLocal artist = findArtist(1);
+ final SongLocal song = createSong(33);
+ final Set<SongLocal> songSets = artist.getPerformed();
songSets.add(song);
} finally {
completeTransaction();
@@ -199,8 +199,8 @@ public class OneToManyComplexPkTests ext
resetDB();
beginTransaction();
try {
- ArtistLocal artist = findArtist(1);
- SongLocal song = createSong(33);
+ final ArtistLocal artist = findArtist(1);
+ final SongLocal song = createSong(33);
song.setPerformer(artist);
} finally {
completeTransaction();
@@ -213,9 +213,9 @@ public class OneToManyComplexPkTests ext
resetDB();
beginTransaction();
try {
- SongLocal song = findSong(11);
- ArtistLocal artist = song.getPerformer();
- Set<SongLocal> songs = artist.getPerformed();
+ final SongLocal song = findSong(11);
+ final ArtistLocal artist = song.getPerformer();
+ final Set<SongLocal> songs = artist.getPerformed();
assertTrue(songs.contains(song));
song.remove();
assertFalse(songs.contains(song));
@@ -231,9 +231,9 @@ public class OneToManyComplexPkTests ext
resetDB();
beginTransaction();
try {
- SongLocal song = findSong(11);
+ final SongLocal song = findSong(11);
- Integer field3 = song.getBpm();
+ final Integer field3 = song.getBpm();
assertEquals(song.getPerformer().getPrimaryKey(), field3);
} finally {
completeTransaction();
@@ -245,11 +245,11 @@ public class OneToManyComplexPkTests ext
resetDB();
beginTransaction();
try {
- SongLocal song = findSong(11);
+ final SongLocal song = findSong(11);
song.setBpm(2);
- ArtistLocal artist = song.getPerformer();
+ final ArtistLocal artist = song.getPerformer();
assertEquals(new Integer(2), artist.getId());
assertEquals("value2", artist.getName());
} finally {
@@ -262,22 +262,22 @@ public class OneToManyComplexPkTests ext
beginTransaction();
try {
- ArtistLocal artist = findArtist(1);
+ final ArtistLocal artist = findArtist(1);
artist.setPerformed(new HashSet<SongLocal>());
- Set<SongLocal> songs = artist.getComposed();
- Set<SongLocal> bsCopies = new HashSet<SongLocal>(songs);
+ final Set<SongLocal> songs = artist.getComposed();
+ final Set<SongLocal> bsCopies = new HashSet<SongLocal>(songs);
assertFalse(songs.isEmpty());
artist.remove();
assertTrue(songs.isEmpty());
- for (SongLocal songLocal : bsCopies) {
+ for (final SongLocal songLocal : bsCopies) {
assertNull(songLocal.getComposer());
}
} finally {
completeTransaction();
}
- Connection c = ds.getConnection();
- Statement s = c.createStatement();
- ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM ComplexSong");
+ final Connection c = ds.getConnection();
+ final Statement s = c.createStatement();
+ final ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM ComplexSong");
assertTrue(rs.next());
assertEquals(2, rs.getInt(1));
rs.close();
@@ -290,17 +290,17 @@ public class OneToManyComplexPkTests ext
beginTransaction();
try {
- ArtistLocal artist = findArtist(1);
- Set<SongLocal> songs = artist.getPerformed();
+ final ArtistLocal artist = findArtist(1);
+ final Set<SongLocal> songs = artist.getPerformed();
assertFalse(songs.isEmpty());
artist.remove();
assertTrue(songs.isEmpty());
} finally {
completeTransaction();
}
- Connection c = ds.getConnection();
- Statement s = c.createStatement();
- ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM ComplexSong");
+ final Connection c = ds.getConnection();
+ final Statement s = c.createStatement();
+ final ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM ComplexSong");
assertTrue(rs.next());
assertEquals(0, rs.getInt(1));
rs.close();
@@ -312,19 +312,19 @@ public class OneToManyComplexPkTests ext
resetDB();
beginTransaction();
try {
- ArtistLocal artist = findArtist(new Integer(1));
- Set songs = artist.getComposed();
+ final ArtistLocal artist = findArtist(new Integer(1));
+ final Set songs = artist.getComposed();
try {
songs.add(new Object());
fail("expected games.add(new Object()) to throw an IllegalArgumentException");
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
}
try {
songs.addAll(Arrays.asList(new Object()));
fail("expected games.addAll(Arrays.asList(new Object())) to throw an IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
+ } catch (final IllegalArgumentException expected) {
}
} finally {
completeTransaction();
@@ -337,7 +337,7 @@ public class OneToManyComplexPkTests ext
Set songs;
SongLocal newSong;
try {
- ArtistLocal artist = findArtist(new Integer(1));
+ final ArtistLocal artist = findArtist(new Integer(1));
newSong = createSong(new Integer(33));
songs = artist.getComposed();
} finally {
@@ -347,8 +347,8 @@ public class OneToManyComplexPkTests ext
// CMR collections should still be readable
assertFalse(songs.isEmpty());
assertEquals(2, songs.size());
- for (Iterator iter = songs.iterator(); iter.hasNext();) {
- SongLocal song = (SongLocal) iter.next();
+ for (final Iterator iter = songs.iterator(); iter.hasNext(); ) {
+ final SongLocal song = (SongLocal) iter.next();
if (song.getId().equals(new Integer(11))) {
assertEquals("value11", song.getName());
} else if (song.getId().equals(new Integer(22))) {
@@ -362,28 +362,28 @@ public class OneToManyComplexPkTests ext
try {
songs.add(newSong);
fail("expected songs.add(newSong) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
try {
songs.addAll(Arrays.asList(newSong));
fail("expected songs.addAll(Arrays.asList(newSong)) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
try {
songs.remove(newSong);
fail("expected songs.remove(newSong) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
try {
songs.removeAll(Arrays.asList(newSong));
fail("expected songs.removeAll(Arrays.asList(newSong)) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
- Iterator iterator = songs.iterator();
+ final Iterator iterator = songs.iterator();
try {
iterator.remove();
fail("expected iterator.remove() to throw an ConcurrentModificationException");
- } catch (ConcurrentModificationException expected) {
+ } catch (final ConcurrentModificationException expected) {
}
}
@@ -393,7 +393,7 @@ public class OneToManyComplexPkTests ext
Set songs;
SongLocal newSong;
try {
- ArtistLocal artist = findArtist(new Integer(1));
+ final ArtistLocal artist = findArtist(new Integer(1));
newSong = createSong(new Integer(33));
songs = artist.getComposed();
} finally {
@@ -405,8 +405,8 @@ public class OneToManyComplexPkTests ext
// CMR collections should still be readable
assertFalse(songs.isEmpty());
assertEquals(2, songs.size());
- for (Iterator iter = songs.iterator(); iter.hasNext();) {
- SongLocal song = (SongLocal) iter.next();
+ for (final Iterator iter = songs.iterator(); iter.hasNext(); ) {
+ final SongLocal song = (SongLocal) iter.next();
if (song.getId().equals(new Integer(11))) {
assertEquals("value11", song.getName());
} else if (song.getId().equals(new Integer(22))) {
@@ -420,28 +420,28 @@ public class OneToManyComplexPkTests ext
try {
songs.add(newSong);
fail("expected songs.add(newSong) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
try {
songs.addAll(Arrays.asList(newSong));
fail("expected songs.addAll(Arrays.asList(newSong)) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
try {
songs.remove(newSong);
fail("expected songs.remove(newSong) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
try {
songs.removeAll(Arrays.asList(newSong));
fail("expected songs.removeAll(Arrays.asList(newSong)) to throw an IllegalStateException");
- } catch (IllegalStateException expected) {
+ } catch (final IllegalStateException expected) {
}
- Iterator iterator = songs.iterator();
+ final Iterator iterator = songs.iterator();
try {
iterator.remove();
fail("expected iterator.remove() to throw an ConcurrentModificationException");
- } catch (ConcurrentModificationException expected) {
+ } catch (final ConcurrentModificationException expected) {
}
} finally {
completeTransaction();
@@ -452,13 +452,13 @@ public class OneToManyComplexPkTests ext
resetDB();
beginTransaction();
try {
- ArtistLocal artist = findArtist(new Integer(1));
- SongLocal song = findSong(new Integer(11));
- Set songs = artist.getComposed();
+ final ArtistLocal artist = findArtist(new Integer(1));
+ final SongLocal song = findSong(new Integer(11));
+ final Set songs = artist.getComposed();
assertFalse(songs.isEmpty());
assertEquals(2, songs.size());
- Iterator iterator = songs.iterator();
+ final Iterator iterator = songs.iterator();
songs.remove(song);
assertEquals(1, songs.size());
@@ -466,7 +466,7 @@ public class OneToManyComplexPkTests ext
try {
iterator.next();
fail("expected iterator.next() to throw an ConcurrentModificationException");
- } catch (ConcurrentModificationException expected) {
+ } catch (final ConcurrentModificationException expected) {
}
} finally {
completeTransaction();
@@ -477,13 +477,13 @@ public class OneToManyComplexPkTests ext
resetDB();
beginTransaction();
try {
- ArtistLocal artist = findArtist(new Integer(1));
- SongLocal song = findSong(new Integer(11));
- Set games = artist.getComposed();
+ final ArtistLocal artist = findArtist(new Integer(1));
+ final SongLocal song = findSong(new Integer(11));
+ final Set games = artist.getComposed();
assertFalse(games.isEmpty());
assertEquals(2, games.size());
- Iterator iterator = games.iterator();
+ final Iterator iterator = games.iterator();
assertTrue(games.contains(song));
artist.remove();
@@ -493,34 +493,34 @@ public class OneToManyComplexPkTests ext
try {
iterator.next();
fail("expected iterator.next() to throw an ConcurrentModificationException");
- } catch (ConcurrentModificationException expected) {
+ } catch (final ConcurrentModificationException expected) {
}
} finally {
completeTransaction();
}
}
- private ArtistLocal createArtist(int artistId) throws CreateException {
- ArtistLocal artist = artistLocalHome.create(new ArtistPk(artistId, "value" + artistId));
+ private ArtistLocal createArtist(final int artistId) throws CreateException {
+ final ArtistLocal artist = artistLocalHome.create(new ArtistPk(artistId, "value" + artistId));
return artist;
}
- private ArtistLocal findArtist(int artistId) throws FinderException {
+ private ArtistLocal findArtist(final int artistId) throws FinderException {
return artistLocalHome.findByPrimaryKey(new ArtistPk(artistId, "value" + artistId));
}
- private SongLocal createSong(int songId) throws CreateException {
- SongLocal song = songLocalHome.create(new SongPk(songId, "value" + songId));
+ private SongLocal createSong(final int songId) throws CreateException {
+ final SongLocal song = songLocalHome.create(new SongPk(songId, "value" + songId));
return song;
}
- private SongLocal findSong(int songId) throws FinderException {
+ private SongLocal findSong(final int songId) throws FinderException {
return songLocalHome.findByPrimaryKey(new SongPk(songId, "value" + songId));
}
- private void assertLinked(int artistId, int... songIds) throws Exception {
- Connection c = ds.getConnection();
- Statement s = c.createStatement();
+ private void assertLinked(final int artistId, final int... songIds) throws Exception {
+ final Connection c = ds.getConnection();
+ final Statement s = c.createStatement();
ResultSet rs = s.executeQuery("SELECT name FROM ComplexArtist WHERE id = " + artistId);
assertTrue(rs.next());
assertEquals("value" + artistId, rs.getString("name"));
@@ -533,7 +533,7 @@ public class OneToManyComplexPkTests ext
rs.close();
// assert each of the listed b pks is linked to a
- for (int songId : songIds) {
+ for (final int songId : songIds) {
rs = s.executeQuery("SELECT name, performer_id FROM ComplexSong WHERE id = " + songId);
assertTrue(rs.next());
assertEquals("value" + songId, rs.getString("name"));
@@ -544,10 +544,10 @@ public class OneToManyComplexPkTests ext
close(c);
}
- private void assertUnlinked(int aPk) throws Exception {
- Connection c = ds.getConnection();
- Statement s = c.createStatement();
- ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM ComplexSong WHERE performer_id = " + aPk);
+ private void assertUnlinked(final int aPk) throws Exception {
+ final Connection c = ds.getConnection();
+ final Statement s = c.createStatement();
+ final ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM ComplexSong WHERE performer_id = " + aPk);
assertTrue(rs.next());
assertEquals(0, rs.getInt(1));
close(rs);
@@ -556,29 +556,29 @@ public class OneToManyComplexPkTests ext
}
private void resetDB() throws Exception {
- Connection connection = ds.getConnection();
+ final Connection connection = ds.getConnection();
Statement statement = null;
try {
statement = connection.createStatement();
try {
statement.execute("DELETE FROM ComplexArtist");
- } catch (SQLException ignored) {
+ } catch (final SQLException ignored) {
}
try {
statement.execute("DELETE FROM ComplexSong");
- } catch (SQLException ignored) {
+ } catch (final SQLException ignored) {
}
} finally {
close(statement);
close(connection);
}
- ArtistLocal artist1 = createArtist(1);
+ final ArtistLocal artist1 = createArtist(1);
createArtist(2);
- SongLocal song1 = createSong(11);
- SongLocal song2 = createSong(22);
+ final SongLocal song1 = createSong(11);
+ final SongLocal song2 = createSong(22);
song1.setPerformer(artist1);
song2.setPerformer(artist1);