diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/event/TestLifecycleEventManager.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/event/TestLifecycleEventManager.java index caeccd3a4..604a77add 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/event/TestLifecycleEventManager.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/event/TestLifecycleEventManager.java @@ -19,10 +19,12 @@ package org.apache.openjpa.persistence.event; -import org.apache.openjpa.persistence.event.common.apps.RuntimeTest1; -import org.apache.openjpa.persistence.event.common.apps.RuntimeTest2; -import org.apache.openjpa.persistence.event.common.apps.RuntimeTest4; -import org.apache.openjpa.persistence.common.utils.AbstractTestCase; +import java.lang.Thread.UncaughtExceptionHandler; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.apache.openjpa.event.LifecycleEvent; import org.apache.openjpa.event.LifecycleEventManager; import org.apache.openjpa.event.LoadListener; @@ -30,7 +32,10 @@ import org.apache.openjpa.event.StoreListener; import org.apache.openjpa.meta.ClassMetaData; import org.apache.openjpa.meta.MetaDataRepository; import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI; -import org.apache.openjpa.persistence.OpenJPAPersistence; +import org.apache.openjpa.persistence.common.utils.AbstractTestCase; +import org.apache.openjpa.persistence.event.common.apps.RuntimeTest1; +import org.apache.openjpa.persistence.event.common.apps.RuntimeTest2; +import org.apache.openjpa.persistence.event.common.apps.RuntimeTest4; /** *
Test the {@link LifecycleEventManager}.
@@ -38,18 +43,14 @@ import org.apache.openjpa.persistence.OpenJPAPersistence; * @author Abe White */ public class TestLifecycleEventManager - extends AbstractTestCase { + extends AbstractTestCase implements UncaughtExceptionHandler{ public TestLifecycleEventManager(String s) { super(s, "eventcactusapp"); } - public void testAllClassListener() { - MetaDataRepository repos = - ((OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.cast( - OpenJPAPersistence.createEntityManagerFactory("TestConv2", ""))) - . - getConfiguration().getMetaDataRepositoryInstance(); + public void atestAllClassListener() { + MetaDataRepository repos = getMDR(); ClassMetaData meta = repos.getMetaData(RuntimeTest2.class, null, true); LifecycleEventManager mgr = new LifecycleEventManager(); RuntimeTest2 pc = new RuntimeTest2(); @@ -118,12 +119,8 @@ public class TestLifecycleEventManager assertEquals(2, listener.store); } - public void testBaseClassListener() { - MetaDataRepository repos = - ((OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.cast( - OpenJPAPersistence.createEntityManagerFactory("TestConv2", ""))) - . - getConfiguration().getMetaDataRepositoryInstance(); + public void atestBaseClassListener() { + MetaDataRepository repos = getMDR(); ClassMetaData meta = repos.getMetaData(RuntimeTest2.class, null, true); LifecycleEventManager mgr = new LifecycleEventManager(); @@ -194,6 +191,62 @@ public class TestLifecycleEventManager assertEquals(3, listener.load); assertEquals(1, listener.store); } + + public void testMultiThreaded() throws Exception{ + + for(int z = 0; z < 1000; z++){ + + final LifecycleEventManager mgr = new LifecycleEventManager(); + final List