Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2018-03-27 01:48:42 -0400
committerEike Stepper2018-03-27 01:48:42 -0400
commit83ec3d372871d39d9dde9716d5484927ce8b57e1 (patch)
treee73752c7ddf9cdc51fe97146c53bba261dcb98fd /plugins/org.eclipse.emf.cdo.tests/src
parentbdce43ce6362d226135a789f2772f8055bed473b (diff)
downloadcdo-83ec3d372871d39d9dde9716d5484927ce8b57e1.tar.gz
cdo-83ec3d372871d39d9dde9716d5484927ce8b57e1.tar.xz
cdo-83ec3d372871d39d9dde9716d5484927ce8b57e1.zip
[Releng] Detect leaked JDBC connections in H2 tests
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests/src')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitInfoTest.java403
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java50
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java25
3 files changed, 318 insertions, 160 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitInfoTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitInfoTest.java
index c9dfdaf9ed..b769149f79 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitInfoTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitInfoTest.java
@@ -139,18 +139,25 @@ public class CommitInfoTest extends AbstractCDOTest
InternalSession serverSession = getRepository().getSessionManager().getSession(session.getSessionID());
StoreThreadLocal.setSession(serverSession);
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
+ try
+ {
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
- CDOCommitInfo commitInfo = transaction.commit();
+ CDOCommitInfo commitInfo = transaction.commit();
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getTimeStamp(), infos.get(0).getTimeStamp());
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getTimeStamp(), infos.get(0).getTimeStamp());
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
}
@Skips("MongoDB")
@@ -160,19 +167,26 @@ public class CommitInfoTest extends AbstractCDOTest
CDOSession session = openSession();
StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
+ try
+ {
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
- CDOCommitInfo commitInfo = transaction.commit();
+ CDOCommitInfo commitInfo = transaction.commit();
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
+ List<CDOCommitInfo> infos = handler.getInfos();
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getBranch().getID(), infos.get(0).getBranch().getID());
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getBranch().getID(), infos.get(0).getBranch().getID());
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
}
@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
@@ -182,19 +196,26 @@ public class CommitInfoTest extends AbstractCDOTest
CDOSession session = openSession();
StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
- CDOBranch branch = session.getBranchManager().getMainBranch().createBranch("sub");
- CDOTransaction transaction = session.openTransaction(branch);
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
+ try
+ {
+ CDOBranch branch = session.getBranchManager().getMainBranch().createBranch("sub");
+ CDOTransaction transaction = session.openTransaction(branch);
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
- CDOCommitInfo commitInfo = transaction.commit();
+ CDOCommitInfo commitInfo = transaction.commit();
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getBranch().getID(), infos.get(0).getBranch().getID());
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getBranch().getID(), infos.get(0).getBranch().getID());
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
}
@Skips("MongoDB")
@@ -214,18 +235,25 @@ public class CommitInfoTest extends AbstractCDOTest
CDOSession session = openSession(REPO_NAME);
StoreThreadLocal.setSession(getRepository(REPO_NAME).getSessionManager().getSession(session.getSessionID()));
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
+ try
+ {
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
- CDOCommitInfo commitInfo = transaction.commit();
+ CDOCommitInfo commitInfo = transaction.commit();
- Handler handler = new Handler();
- getRepository(REPO_NAME).getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
+ Handler handler = new Handler();
+ getRepository(REPO_NAME).getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getUserID(), infos.get(0).getUserID());
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getUserID(), infos.get(0).getUserID());
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
}
@Skips("MongoDB")
@@ -236,21 +264,28 @@ public class CommitInfoTest extends AbstractCDOTest
CDOSession session = openSession();
StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
+ try
+ {
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
- String comment = "Andre";
- transaction.setCommitComment(comment);
+ String comment = "Andre";
+ transaction.setCommitComment(comment);
- CDOCommitInfo commitInfo = transaction.commit();
+ CDOCommitInfo commitInfo = transaction.commit();
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(null, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getComment(), infos.get(0).getComment());
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getComment(), infos.get(0).getComment());
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
}
@Skips("MongoDB")
@@ -261,19 +296,26 @@ public class CommitInfoTest extends AbstractCDOTest
CDOSession session = openSession();
StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
+ try
+ {
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
- CDOCommitInfo commitInfo = transaction.commit();
+ CDOCommitInfo commitInfo = transaction.commit();
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(getRepository().getBranchManager().getBranch(transaction.getBranch().getID()),
- CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(getRepository().getBranchManager().getBranch(transaction.getBranch().getID()),
+ CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getTimeStamp(), infos.get(0).getTimeStamp());
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getTimeStamp(), infos.get(0).getTimeStamp());
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
}
@Skips("MongoDB")
@@ -284,19 +326,26 @@ public class CommitInfoTest extends AbstractCDOTest
CDOSession session = openSession();
StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
+ try
+ {
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
- CDOCommitInfo commitInfo = transaction.commit();
+ CDOCommitInfo commitInfo = transaction.commit();
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(getRepository().getBranchManager().getBranch(transaction.getBranch().getID()),
- CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(getRepository().getBranchManager().getBranch(transaction.getBranch().getID()),
+ CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getBranch().getID(), infos.get(0).getBranch().getID());
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getBranch().getID(), infos.get(0).getBranch().getID());
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
}
@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
@@ -305,20 +354,27 @@ public class CommitInfoTest extends AbstractCDOTest
CDOSession session = openSession();
StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
- CDOBranch branch = session.getBranchManager().getMainBranch().createBranch("sub");
- CDOTransaction transaction = session.openTransaction(branch);
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
+ try
+ {
+ CDOBranch branch = session.getBranchManager().getMainBranch().createBranch("sub");
+ CDOTransaction transaction = session.openTransaction(branch);
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
- CDOCommitInfo commitInfo = transaction.commit();
+ CDOCommitInfo commitInfo = transaction.commit();
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(getRepository().getBranchManager().getBranch(transaction.getBranch().getID()),
- CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(getRepository().getBranchManager().getBranch(transaction.getBranch().getID()),
+ CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
- assertEquals(1, infos.size());
- assertEquals(commitInfo.getBranch().getID(), infos.get(0).getBranch().getID());
+ assertEquals(1, infos.size());
+ assertEquals(commitInfo.getBranch().getID(), infos.get(0).getBranch().getID());
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
}
@Skips("MongoDB")
@@ -338,19 +394,26 @@ public class CommitInfoTest extends AbstractCDOTest
CDOSession session = openSession(REPO_NAME);
StoreThreadLocal.setSession(getRepository(REPO_NAME).getSessionManager().getSession(session.getSessionID()));
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
+ try
+ {
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
- CDOCommitInfo commitInfo = transaction.commit();
+ CDOCommitInfo commitInfo = transaction.commit();
- Handler handler = new Handler();
- getRepository(REPO_NAME).getCommitInfoManager().getCommitInfos(getRepository(REPO_NAME).getBranchManager().getBranch(transaction.getBranch().getID()),
- CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
+ Handler handler = new Handler();
+ getRepository(REPO_NAME).getCommitInfoManager().getCommitInfos(getRepository(REPO_NAME).getBranchManager().getBranch(transaction.getBranch().getID()),
+ CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getUserID(), infos.get(0).getUserID());
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getUserID(), infos.get(0).getUserID());
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
}
@Skips("MongoDB")
@@ -361,22 +424,29 @@ public class CommitInfoTest extends AbstractCDOTest
CDOSession session = openSession();
StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
+ try
+ {
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
- String comment = "Andre";
- transaction.setCommitComment(comment);
+ String comment = "Andre";
+ transaction.setCommitComment(comment);
- CDOCommitInfo commitInfo = transaction.commit();
+ CDOCommitInfo commitInfo = transaction.commit();
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(getRepository().getBranchManager().getBranch(transaction.getBranch().getID()),
- CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(getRepository().getBranchManager().getBranch(transaction.getBranch().getID()),
+ CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
- assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getComment(), infos.get(0).getComment());
+ assertEquals(2, infos.size()); // Initial root resource commit + 1
+ assertEquals(commitInfo.getComment(), infos.get(0).getComment());
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
}
@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
@@ -385,18 +455,25 @@ public class CommitInfoTest extends AbstractCDOTest
CDOSession session = openSession();
StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
- CDOBranch wrong = getRepository().getBranchManager().getMainBranch().createBranch("wrong");
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
+ try
+ {
+ CDOBranch wrong = getRepository().getBranchManager().getMainBranch().createBranch("wrong");
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
- transaction.commit();
+ transaction.commit();
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
- assertEquals(0, infos.size());
+ assertEquals(0, infos.size());
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
}
@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
@@ -405,18 +482,25 @@ public class CommitInfoTest extends AbstractCDOTest
CDOSession session = openSession();
StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
- CDOBranch wrong = getRepository().getBranchManager().getMainBranch().createBranch("wrong");
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
+ try
+ {
+ CDOBranch wrong = getRepository().getBranchManager().getMainBranch().createBranch("wrong");
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
- transaction.commit();
+ transaction.commit();
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
- assertEquals(0, infos.size());
+ assertEquals(0, infos.size());
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
}
@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
@@ -425,19 +509,26 @@ public class CommitInfoTest extends AbstractCDOTest
CDOSession session = openSession();
StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
- CDOBranch wrong = getRepository().getBranchManager().getMainBranch().createBranch("wrong");
- CDOBranch branch = session.getBranchManager().getMainBranch().createBranch("sub");
- CDOTransaction transaction = session.openTransaction(branch);
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
+ try
+ {
+ CDOBranch wrong = getRepository().getBranchManager().getMainBranch().createBranch("wrong");
+ CDOBranch branch = session.getBranchManager().getMainBranch().createBranch("sub");
+ CDOTransaction transaction = session.openTransaction(branch);
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
- transaction.commit();
+ transaction.commit();
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
- assertEquals(0, infos.size());
+ assertEquals(0, infos.size());
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
}
@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
@@ -455,18 +546,25 @@ public class CommitInfoTest extends AbstractCDOTest
CDOSession session = openSession(REPO_NAME);
StoreThreadLocal.setSession(getRepository(REPO_NAME).getSessionManager().getSession(session.getSessionID()));
- CDOBranch wrong = getRepository(REPO_NAME).getBranchManager().getMainBranch().createBranch("wrong");
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
+ try
+ {
+ CDOBranch wrong = getRepository(REPO_NAME).getBranchManager().getMainBranch().createBranch("wrong");
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
- transaction.commit();
+ transaction.commit();
- Handler handler = new Handler();
- getRepository(REPO_NAME).getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
+ Handler handler = new Handler();
+ getRepository(REPO_NAME).getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
- assertEquals(0, infos.size());
+ assertEquals(0, infos.size());
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
}
@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
@@ -475,21 +573,28 @@ public class CommitInfoTest extends AbstractCDOTest
CDOSession session = openSession();
StoreThreadLocal.setSession(getRepository().getSessionManager().getSession(session.getSessionID()));
- CDOBranch wrong = getRepository().getBranchManager().getMainBranch().createBranch("wrong");
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
- resource.getContents().add(getModel1Factory().createProduct1());
+ try
+ {
+ CDOBranch wrong = getRepository().getBranchManager().getMainBranch().createBranch("wrong");
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+ resource.getContents().add(getModel1Factory().createProduct1());
- String comment = "Andre";
- transaction.setCommitComment(comment);
+ String comment = "Andre";
+ transaction.setCommitComment(comment);
- transaction.commit();
+ transaction.commit();
- Handler handler = new Handler();
- getRepository().getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
- List<CDOCommitInfo> infos = handler.getInfos();
+ Handler handler = new Handler();
+ getRepository().getCommitInfoManager().getCommitInfos(wrong, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, handler);
+ List<CDOCommitInfo> infos = handler.getInfos();
- assertEquals(0, infos.size());
+ assertEquals(0, infos.size());
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
}
@CleanRepositoriesBefore(reason = "Commit info counting")
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java
index dae2a552c3..05efd72c7e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java
@@ -30,6 +30,7 @@ import java.util.List;
import java.util.Set;
import junit.framework.Test;
+import junit.framework.TestCase;
import junit.framework.TestResult;
import junit.framework.TestSuite;
@@ -177,7 +178,40 @@ public abstract class ConfigTestSuite implements IConstants
{
// super(testClass, testClass.getName()); // Important for the UI to set the *qualified* class name!
this.scenario = scenario;
- addTestsFromTestCase(testClass, suite);
+
+ List<Test> tests = new ArrayList<Test>();
+ addTestsFromTestCase(testClass, suite, tests);
+
+ Collections.sort(tests, new Comparator<Test>()
+ {
+ public int compare(Test t1, Test t2)
+ {
+ String n1 = getName(t1);
+ String n2 = getName(t2);
+ return n1.compareTo(n2);
+ }
+
+ private String getName(Test test)
+ {
+ if (test instanceof TestCase)
+ {
+ return ((TestCase)test).getName();
+ }
+
+ if (test instanceof TestSuite)
+ {
+ return ((TestSuite)test).getName();
+ }
+
+ return "";
+ }
+ });
+
+ for (Test test : tests)
+ {
+ // System.err.println(test);
+ addTest(test);
+ }
}
@Override
@@ -201,7 +235,7 @@ public abstract class ConfigTestSuite implements IConstants
}
}
- private void addTestsFromTestCase(final Class<?> theClass, ConfigTestSuite suite) throws ConstraintsViolatedException
+ private void addTestsFromTestCase(final Class<?> theClass, ConfigTestSuite suite, List<Test> tests) throws ConstraintsViolatedException
{
setName(theClass.getName());
@@ -211,13 +245,13 @@ public abstract class ConfigTestSuite implements IConstants
}
catch (NoSuchMethodException e)
{
- addTest(warning("Class " + theClass.getName() + " has no public constructor TestCase(String name) or TestCase()"));
+ tests.add(warning("Class " + theClass.getName() + " has no public constructor TestCase(String name) or TestCase()"));
return;
}
if (!Modifier.isPublic(theClass.getModifiers()))
{
- addTest(warning("Class " + theClass.getName() + " is not public"));
+ tests.add(warning("Class " + theClass.getName() + " is not public"));
return;
}
@@ -243,7 +277,7 @@ public abstract class ConfigTestSuite implements IConstants
{
if (validateConstraints(method, capabilities))
{
- addTestMethod(method, names, theClass, suite);
+ addTestMethod(method, names, theClass, suite, tests);
}
}
@@ -280,7 +314,7 @@ public abstract class ConfigTestSuite implements IConstants
return true;
}
- private void addTestMethod(Method m, List<String> names, Class<?> theClass, ConfigTestSuite suite)
+ private void addTestMethod(Method m, List<String> names, Class<?> theClass, ConfigTestSuite suite, List<Test> tests)
{
String name = m.getName();
if (names.contains(name))
@@ -292,7 +326,7 @@ public abstract class ConfigTestSuite implements IConstants
{
if (isTestMethod(m))
{
- addTest(warning("Test method isn't public: " + m.getName() + "(" + theClass.getCanonicalName() + ")"));
+ tests.add(warning("Test method isn't public: " + name + "(" + theClass.getCanonicalName() + ")"));
}
return;
@@ -306,7 +340,7 @@ public abstract class ConfigTestSuite implements IConstants
suite.prepareTest(configTest);
}
- addTest(test);
+ tests.add(test);
}
private boolean isPublicTestMethod(Method m)
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java
index 7931c9f11b..e3330a8d85 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java
@@ -90,6 +90,8 @@ import org.eclipse.net4j.util.tests.AbstractOMTest;
import org.eclipse.emf.spi.cdo.InternalCDOSession;
+import org.junit.Assert;
+
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.lang.annotation.Annotation;
@@ -529,6 +531,8 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
@Override
public void setUp() throws Exception
{
+ StoreThreadLocal.release();
+
super.setUp();
if (isOptimizing() && needsCleanRepos() && repositories != null && !repositories.isEmpty())
@@ -542,7 +546,6 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
if (repositories == null)
{
- StoreThreadLocal.release();
repositories = new HashMap<String, InternalRepository>();
}
@@ -567,7 +570,23 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
@Override
public void tearDown() throws Exception
{
+ if (StoreThreadLocal.hasSession())
+ {
+ Assert.fail("Test case has left a session in StoreThreadLocal: " + getCurrentTest());
+ }
+
+ if (StoreThreadLocal.hasAccessor())
+ {
+ Assert.fail("Test case has left an accessor in StoreThreadLocal: " + getCurrentTest());
+ }
+
+ if (StoreThreadLocal.hasCommitContext())
+ {
+ Assert.fail("Test case has left a commit context in StoreThreadLocal: " + getCurrentTest());
+ }
+
deactivateServerBrowser();
+
if (repositories != null)
{
if (!isOptimizing() || mustLeaveCleanRepos())
@@ -600,6 +619,8 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
protected void deactivateRepositories()
{
+ StoreThreadLocal.release();
+
for (InternalRepository repository : getRepositories())
{
LifecycleUtil.deactivate(repository);
@@ -611,8 +632,6 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
repositories = null;
}
- StoreThreadLocal.release();
-
if (serverContainer != null)
{
LifecycleUtil.deactivate(serverContainer);

Back to the top