Permalink
Browse files

test uti refactoring - moving ThreadedTestHelper to cayenne-test-util…

…ities

git-svn-id: https://svn.apache.org/repos/asf/cayenne/main/trunk@1385283 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent cec1ad4 commit 1899509c6aaa25325137100cfec51e09581de953 @andrus andrus committed Sep 16, 2012
Showing with 200 additions and 200 deletions.
  1. +3 −3 .../cayenne-test-utilities/src/main/java/org/apache/cayenne/test/parallel/ParallelTestContainer.java
  2. +3 −3 ...ayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextWithDataContextTest.java
  3. +11 −11 ...-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextDataChannelEventsTest.java
  4. +7 −7 ...dk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextDelegateSharedCacheTest.java
  5. +3 −3 ...jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextSharedCacheEmpiricTest.java
  6. +21 −21 ...ayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextSharedCacheTest.java
  7. +3 −3 ...jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/NestedDataContextParentEventsTest.java
  8. +7 −7 ....5-unpublished/src/test/java/org/apache/cayenne/access/NestedDataContextParentPeerEventsTest.java
  9. +113 −113 ...e-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/NestedDataContextPeerEventsTest.java
  10. +3 −3 ...ne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/NestedDataContext_DeadlockTest.java
  11. +11 −11 framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ObjectStoreGCTest.java
  12. +5 −5 ...1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/SoftDeleteBatchQueryBuilderTest.java
  13. +5 −5 ...rk/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/event/DefaultEventManagerTest.java
  14. +5 −5 framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/event/EventBridgeTest.java
@@ -17,7 +17,7 @@
* under the License.
****************************************************************/
-package org.apache.cayenne.unit.util;
+package org.apache.cayenne.test.parallel;
/**
* Helper class allowing unit tests to wait till a code in question executes in
@@ -32,11 +32,11 @@
* </p>
*
*/
-public abstract class ThreadedTestHelper {
+public abstract class ParallelTestContainer {
protected abstract void assertResult() throws Exception;
- public void assertWithTimeout(long timeoutMs) throws Exception {
+ public void runTest(long timeoutMs) throws Exception {
long checkEveryXMs;
int maxMumberOfChecks;
@@ -35,6 +35,7 @@
import org.apache.cayenne.remote.RemoteIncrementalFaultList;
import org.apache.cayenne.test.jdbc.DBHelper;
import org.apache.cayenne.test.jdbc.TableHelper;
+import org.apache.cayenne.test.parallel.ParallelTestContainer;
import org.apache.cayenne.testdo.mt.ClientMtMeaningfulPk;
import org.apache.cayenne.testdo.mt.ClientMtReflexive;
import org.apache.cayenne.testdo.mt.ClientMtTable1;
@@ -45,7 +46,6 @@
import org.apache.cayenne.unit.di.UnitTestClosure;
import org.apache.cayenne.unit.di.client.ClientCase;
import org.apache.cayenne.unit.di.server.UseServerRuntime;
-import org.apache.cayenne.unit.util.ThreadedTestHelper;
@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT)
public class CayenneContextWithDataContextTest extends ClientCase {
@@ -215,7 +215,7 @@ public void testPostAddOnObjectCallback() throws Exception {
final Persistent clientObject = clientContext.newObject(ClientMtTable1.class);
clientContext.commitChanges();
- new ThreadedTestHelper() {
+ new ParallelTestContainer() {
@Override
protected void assertResult() throws Exception {
@@ -226,7 +226,7 @@ protected void assertResult() throws Exception {
assertNotNull(peer);
assertTrue(peer.isPrePersisted());
}
- }.assertWithTimeout(1000);
+ }.runTest(1000);
}
@@ -25,10 +25,10 @@
import org.apache.cayenne.configuration.server.ServerRuntime;
import org.apache.cayenne.di.Inject;
import org.apache.cayenne.graph.GraphEvent;
+import org.apache.cayenne.test.parallel.ParallelTestContainer;
import org.apache.cayenne.testdo.testmap.Artist;
import org.apache.cayenne.unit.di.server.ServerCase;
import org.apache.cayenne.unit.di.server.UseServerRuntime;
-import org.apache.cayenne.unit.util.ThreadedTestHelper;
import org.apache.cayenne.util.EventUtil;
/**
@@ -57,15 +57,15 @@ public void testCommitEvent() throws Exception {
a.setArtistName("Y");
context.commitChanges();
- new ThreadedTestHelper() {
+ new ParallelTestContainer() {
@Override
protected void assertResult() throws Exception {
assertTrue(listener.graphCommitted);
assertFalse(listener.graphChanged);
assertFalse(listener.graphRolledBack);
}
- }.assertWithTimeout(1000);
+ }.runTest(1000);
}
@@ -80,15 +80,15 @@ public void testRollbackEvent() throws Exception {
a.setArtistName("Y");
context.rollbackChanges();
- new ThreadedTestHelper() {
+ new ParallelTestContainer() {
@Override
protected void assertResult() throws Exception {
assertFalse(listener.graphCommitted);
assertFalse(listener.graphChanged);
assertTrue(listener.graphRolledBack);
}
- }.assertWithTimeout(1000);
+ }.runTest(1000);
}
public void testChangeEventOnChildChange() throws Exception {
@@ -106,15 +106,15 @@ public void testChangeEventOnChildChange() throws Exception {
a1.setArtistName("Y");
childContext.commitChangesToParent();
- new ThreadedTestHelper() {
+ new ParallelTestContainer() {
@Override
protected void assertResult() throws Exception {
assertFalse(listener.graphCommitted);
assertTrue(listener.graphChanged);
assertFalse(listener.graphRolledBack);
}
- }.assertWithTimeout(1000);
+ }.runTest(1000);
}
public void testChangeEventOnPeerChange() throws Exception {
@@ -130,15 +130,15 @@ public void testChangeEventOnPeerChange() throws Exception {
a1.setArtistName("Y");
peer.commitChangesToParent();
- new ThreadedTestHelper() {
+ new ParallelTestContainer() {
@Override
protected void assertResult() throws Exception {
assertFalse(listener.graphCommitted);
assertTrue(listener.graphChanged);
assertFalse(listener.graphRolledBack);
}
- }.assertWithTimeout(1000);
+ }.runTest(1000);
}
public void testChangeEventOnPeerChangeSecondNestingLevel() throws Exception {
@@ -158,15 +158,15 @@ public void testChangeEventOnPeerChangeSecondNestingLevel() throws Exception {
a1.setArtistName("Y");
childPeer2.commitChangesToParent();
- new ThreadedTestHelper() {
+ new ParallelTestContainer() {
@Override
protected void assertResult() throws Exception {
assertFalse(listener.graphCommitted);
assertTrue(listener.graphChanged);
assertFalse(listener.graphRolledBack);
}
- }.assertWithTimeout(1000);
+ }.runTest(1000);
}
class MockChannelListener implements DataChannelListener {
@@ -25,10 +25,10 @@
import org.apache.cayenne.DataRow;
import org.apache.cayenne.PersistenceState;
import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.test.parallel.ParallelTestContainer;
import org.apache.cayenne.testdo.testmap.Artist;
import org.apache.cayenne.unit.di.server.ServerCase;
import org.apache.cayenne.unit.di.server.UseServerRuntime;
-import org.apache.cayenne.unit.util.ThreadedTestHelper;
@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
public class DataContextDelegateSharedCacheTest extends ServerCase {
@@ -83,14 +83,14 @@ public boolean shouldMergeChanges(DataObject object, DataRow snapshotInStore) {
// assert that delegate was consulted when an object store
// was refreshed
- ThreadedTestHelper helper = new ThreadedTestHelper() {
+ ParallelTestContainer helper = new ParallelTestContainer() {
@Override
protected void assertResult() throws Exception {
assertTrue("Delegate was not consulted", methodInvoked[0]);
}
};
- helper.assertWithTimeout(3000);
+ helper.runTest(3000);
}
/**
@@ -159,14 +159,14 @@ public boolean shouldProcessDelete(DataObject object) {
// assert that delegate was consulted when an object store
// was refreshed
- ThreadedTestHelper helper = new ThreadedTestHelper() {
+ ParallelTestContainer helper = new ParallelTestContainer() {
@Override
protected void assertResult() throws Exception {
assertTrue("Delegate was not consulted", methodInvoked[0]);
}
};
- helper.assertWithTimeout(3000);
+ helper.runTest(3000);
}
/**
@@ -202,14 +202,14 @@ public boolean shouldProcessDelete(DataObject object) {
// assert that delegate was consulted when an object store
// was refreshed, and actually blocked object expulsion
- ThreadedTestHelper helper = new ThreadedTestHelper() {
+ ParallelTestContainer helper = new ParallelTestContainer() {
@Override
protected void assertResult() throws Exception {
assertTrue("Delegate was not consulted", methodInvoked[0]);
}
};
- helper.assertWithTimeout(3000);
+ helper.runTest(3000);
assertEquals(PersistenceState.COMMITTED, altArtist.getPersistenceState());
assertNotNull(altArtist.getObjectContext());
}
@@ -30,10 +30,10 @@
import org.apache.cayenne.query.SelectQuery;
import org.apache.cayenne.test.jdbc.DBHelper;
import org.apache.cayenne.test.jdbc.TableHelper;
+import org.apache.cayenne.test.parallel.ParallelTestContainer;
import org.apache.cayenne.testdo.testmap.Artist;
import org.apache.cayenne.unit.di.server.ServerCase;
import org.apache.cayenne.unit.di.server.UseServerRuntime;
-import org.apache.cayenne.unit.util.ThreadedTestHelper;
@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
public class DataContextSharedCacheEmpiricTest extends ServerCase {
@@ -144,7 +144,7 @@ private void assertOnCommit(final Artist a2) throws Exception {
assertEquals(NEW_NAME, freshSnapshot.get("ARTIST_NAME"));
// check peer artist
- ThreadedTestHelper helper = new ThreadedTestHelper() {
+ ParallelTestContainer helper = new ParallelTestContainer() {
@Override
protected void assertResult() throws Exception {
@@ -154,6 +154,6 @@ protected void assertResult() throws Exception {
a2.getArtistName());
}
};
- helper.assertWithTimeout(3000);
+ helper.runTest(3000);
}
}
Oops, something went wrong.

0 comments on commit 1899509

Please sign in to comment.