Hi ManagedScheduledExecutorServiceTest doesn't need it since it just relies on SystemInstance#components map but doesn't care about other environment. So we shouldn't get leaks between these tests.
Romain Manni-Bucau Twitter: @rmannibucau Blog: http://rmannibucau.wordpress.com/ LinkedIn: http://fr.linkedin.com/in/rmannibucau Github: https://github.com/rmannibucau ---------- Forwarded message ---------- From: <[email protected]> Date: 2014-07-15 19:06 GMT+02:00 Subject: svn commit: r1610753 - in /tomee/tomee/branches/tomee-1.7.x: container/openejb-concurrency-utilities-ee/src/test/java/org/apache/openejb/concurrencyutilities/test/ itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/ To: [email protected] Author: andygumbrecht Date: Tue Jul 15 17:06:01 2014 New Revision: 1610753 URL: http://svn.apache.org/r1610753 Log: OneToManyTests, AbstractCMRTest - try synchronization ManagedScheduledExecutorServiceTest - Reset per test Modified: tomee/tomee/branches/tomee-1.7.x/container/openejb-concurrency-utilities-ee/src/test/java/org/apache/openejb/concurrencyutilities/test/ManagedScheduledExecutorServiceTest.java tomee/tomee/branches/tomee-1.7.x/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/AbstractCMRTest.java tomee/tomee/branches/tomee-1.7.x/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/OneToManyTests.java Modified: tomee/tomee/branches/tomee-1.7.x/container/openejb-concurrency-utilities-ee/src/test/java/org/apache/openejb/concurrencyutilities/test/ManagedScheduledExecutorServiceTest.java URL: http://svn.apache.org/viewvc/tomee/tomee/branches/tomee-1.7.x/container/openejb-concurrency-utilities-ee/src/test/java/org/apache/openejb/concurrencyutilities/test/ManagedScheduledExecutorServiceTest.java?rev=1610753&r1=1610752&r2=1610753&view=diff ============================================================================== --- tomee/tomee/branches/tomee-1.7.x/container/openejb-concurrency-utilities-ee/src/test/java/org/apache/openejb/concurrencyutilities/test/ManagedScheduledExecutorServiceTest.java (original) +++ tomee/tomee/branches/tomee-1.7.x/container/openejb-concurrency-utilities-ee/src/test/java/org/apache/openejb/concurrencyutilities/test/ManagedScheduledExecutorServiceTest.java Tue Jul 15 17:06:01 2014 @@ -16,12 +16,13 @@ */ package org.apache.openejb.concurrencyutilities.test; +import org.apache.openejb.OpenEJB; import org.apache.openejb.concurrencyutilities.ee.factory.ManagedScheduledExecutorServiceImplFactory; import org.apache.openejb.loader.SystemInstance; import org.apache.openejb.ri.sp.PseudoSecurityService; import org.apache.openejb.spi.SecurityService; -import org.junit.AfterClass; -import org.junit.BeforeClass; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import javax.enterprise.concurrent.LastExecution; @@ -40,14 +41,17 @@ import static org.junit.Assert.assertNot import static org.junit.Assert.assertTrue; public class ManagedScheduledExecutorServiceTest { - @BeforeClass - public static void forceSecurityService() { + + @Before + public void forceSecurityService() { + SystemInstance.reset(); SystemInstance.get().setComponent(SecurityService.class, new PseudoSecurityService()); } - @AfterClass - public static void reset() { + @After + public void reset() { SystemInstance.reset(); + OpenEJB.destroy(); } @Test Modified: tomee/tomee/branches/tomee-1.7.x/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/AbstractCMRTest.java URL: http://svn.apache.org/viewvc/tomee/tomee/branches/tomee-1.7.x/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/AbstractCMRTest.java?rev=1610753&r1=1610752&r2=1610753&view=diff ============================================================================== --- tomee/tomee/branches/tomee-1.7.x/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/AbstractCMRTest.java (original) +++ tomee/tomee/branches/tomee-1.7.x/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/AbstractCMRTest.java Tue Jul 15 17:06:01 2014 @@ -47,11 +47,11 @@ public abstract class AbstractCMRTest ex super("Entity.CMR." + name); } - protected void beginTransaction() throws Exception { + protected synchronized void beginTransaction() throws Exception { transactionManager.begin(); } - protected void completeTransaction() throws SystemException, HeuristicMixedException, HeuristicRollbackException, RollbackException { + protected synchronized void completeTransaction() throws SystemException, HeuristicMixedException, HeuristicRollbackException, RollbackException { final int status = transactionManager.getStatus(); if (status == Status.STATUS_ACTIVE) { transactionManager.commit(); @@ -66,7 +66,7 @@ public abstract class AbstractCMRTest ex * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. */ - protected void setUp() throws Exception { + protected synchronized void setUp() throws Exception { super.setUp(); final Properties properties = TestManager.getServer().getContextEnvironment(); Modified: tomee/tomee/branches/tomee-1.7.x/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/OneToManyTests.java URL: http://svn.apache.org/viewvc/tomee/tomee/branches/tomee-1.7.x/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/OneToManyTests.java?rev=1610753&r1=1610752&r2=1610753&view=diff ============================================================================== --- tomee/tomee/branches/tomee-1.7.x/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/OneToManyTests.java (original) +++ tomee/tomee/branches/tomee-1.7.x/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/OneToManyTests.java Tue Jul 15 17:06:01 2014 @@ -36,6 +36,7 @@ import java.util.ConcurrentModificationE /** * @version $Revision$ $Date$ */ +@SuppressWarnings("UnusedDeclaration") public class OneToManyTests extends AbstractCMRTest { private ArtistLocalHome artistLocalHome; private SongLocalHome songLocalHome; @@ -316,13 +317,13 @@ public class OneToManyTests extends Abst try { songs.add(new Object()); fail("expected games.add(new Object()) to throw an IllegalArgumentException"); - } catch (final IllegalArgumentException e) { + } catch (final IllegalArgumentException ignored) { } try { songs.addAll(Arrays.asList(new Object())); fail("expected games.addAll(Arrays.asList(new Object())) to throw an IllegalArgumentException"); - } catch (final IllegalArgumentException expected) { + } catch (final IllegalArgumentException ignored) { } } finally { completeTransaction(); @@ -360,28 +361,28 @@ public class OneToManyTests extends Abst try { songs.add(newSong); fail("expected songs.add(newSong) to throw an IllegalStateException"); - } catch (final IllegalStateException expected) { + } catch (final IllegalStateException ignored) { } try { songs.addAll(Arrays.asList(newSong)); fail("expected songs.addAll(Arrays.asList(newSong)) to throw an IllegalStateException"); - } catch (final IllegalStateException expected) { + } catch (final IllegalStateException ignored) { } try { songs.remove(newSong); fail("expected songs.remove(newSong) to throw an IllegalStateException"); - } catch (final IllegalStateException expected) { + } catch (final IllegalStateException ignored) { } try { songs.removeAll(Arrays.asList(newSong)); fail("expected songs.removeAll(Arrays.asList(newSong)) to throw an IllegalStateException"); - } catch (final IllegalStateException expected) { + } catch (final IllegalStateException ignored) { } final Iterator iterator = songs.iterator(); try { iterator.remove(); fail("expected iterator.remove() to throw an ConcurrentModificationException"); - } catch (final ConcurrentModificationException expected) { + } catch (final ConcurrentModificationException ignored) { } } @@ -418,28 +419,28 @@ public class OneToManyTests extends Abst try { songs.add(newSong); fail("expected songs.add(newSong) to throw an IllegalStateException"); - } catch (final IllegalStateException expected) { + } catch (final IllegalStateException ignored) { } try { songs.addAll(Arrays.asList(newSong)); fail("expected songs.addAll(Arrays.asList(newSong)) to throw an IllegalStateException"); - } catch (final IllegalStateException expected) { + } catch (final IllegalStateException ignored) { } try { songs.remove(newSong); fail("expected songs.remove(newSong) to throw an IllegalStateException"); - } catch (final IllegalStateException expected) { + } catch (final IllegalStateException ignored) { } try { songs.removeAll(Arrays.asList(newSong)); fail("expected songs.removeAll(Arrays.asList(newSong)) to throw an IllegalStateException"); - } catch (final IllegalStateException expected) { + } catch (final IllegalStateException ignored) { } final Iterator iterator = songs.iterator(); try { iterator.remove(); fail("expected iterator.remove() to throw an ConcurrentModificationException"); - } catch (final ConcurrentModificationException expected) { + } catch (final ConcurrentModificationException ignored) { } } finally { completeTransaction(); @@ -464,7 +465,7 @@ public class OneToManyTests extends Abst try { iterator.next(); fail("expected iterator.next() to throw an ConcurrentModificationException"); - } catch (final ConcurrentModificationException expected) { + } catch (final ConcurrentModificationException ignored) { } } finally { completeTransaction(); @@ -491,7 +492,7 @@ public class OneToManyTests extends Abst try { iterator.next(); fail("expected iterator.next() to throw an ConcurrentModificationException"); - } catch (final ConcurrentModificationException expected) { + } catch (final ConcurrentModificationException ignored) { } } finally { completeTransaction(); @@ -555,7 +556,7 @@ public class OneToManyTests extends Abst close(c); } - private void resetDB() throws Exception { + private synchronized void resetDB() throws Exception { final Connection connection = ds.getConnection(); Statement statement = null; try {
