summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEgidijus Vaishnora2011-04-12 04:53:20 (EDT)
committerEgidijus Vaishnora2011-04-12 04:53:20 (EDT)
commitb1b4f3b15c58cd53ae96714b3322ca02004a1363 (patch)
treec2a654fbf1441157b0e05f452f3f1e9bc2d0638e
parent770fd70ee70c2fb77ac3569b3e96fa79e01cd862 (diff)
downloadcdo-b1b4f3b15c58cd53ae96714b3322ca02004a1363.zip
cdo-b1b4f3b15c58cd53ae96714b3322ca02004a1363.tar.gz
cdo-b1b4f3b15c58cd53ae96714b3322ca02004a1363.tar.bz2
[340961] Enable ReadAccessHandlers to replace revisions https://bugs.eclipse.org/bugs/show_bug.cgi?id=340961
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_340961_Test.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java25
3 files changed, 28 insertions, 15 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_340961_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_340961_Test.java
index b15f315..37fd0a8 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_340961_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_340961_Test.java
@@ -25,6 +25,8 @@ import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.LeavesCleanRepo;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.NeedsCleanRepo;
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
import org.eclipse.emf.cdo.tests.model1.Category;
import org.eclipse.emf.cdo.tests.util.TestRevisionManager;
@@ -46,6 +48,8 @@ import junit.framework.Assert;
/**
* @author Egidijus Vaisnora
*/
+@NeedsCleanRepo
+@LeavesCleanRepo
public class Bugzilla_340961_Test extends AbstractCDOTest
{
private PartialReadAccessHandler handler = new PartialReadAccessHandler();
@@ -61,6 +65,7 @@ public class Bugzilla_340961_Test extends AbstractCDOTest
@Override
protected void doSetUp() throws Exception
{
+ // setup RepositoryConfig.PROP_TEST_REVISION_MANAGER is needed for MEM store
InternalCDORevisionManager internalCDORevisionManager = (InternalCDORevisionManager)getRepositoryConfig()
.getTestProperty(RepositoryConfig.PROP_TEST_REVISION_MANAGER);
if (internalCDORevisionManager == null)
@@ -69,19 +74,11 @@ public class Bugzilla_340961_Test extends AbstractCDOTest
getRepositoryConfig().getTestProperties().put(RepositoryConfig.PROP_TEST_REVISION_MANAGER,
internalCDORevisionManager);
}
-
internalCDORevisionManager.setFactory(revisionFactory);
super.doSetUp();
getRepository().addHandler(handler);
}
- @Override
- public void tearDown() throws Exception
- {
- getRepository().removeHandler(handler);
- super.tearDown();
- }
-
/**
* @category Session
*/
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java
index 2e945be..b56393f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java
@@ -72,6 +72,11 @@ public abstract class ConfigTest extends AbstractOMTest implements IConstants
{
}
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface LeavesCleanRepo
+ {
+ }
+
public ConfigTest()
{
}
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 969af20..f99aa94 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
@@ -42,6 +42,7 @@ import org.eclipse.emf.cdo.spi.server.InternalRepositorySynchronizer;
import org.eclipse.emf.cdo.spi.server.InternalSessionManager;
import org.eclipse.emf.cdo.spi.server.InternalStore;
import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.LeavesCleanRepo;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.NeedsCleanRepo;
import org.eclipse.emf.cdo.tests.util.TestRevisionManager;
@@ -65,6 +66,7 @@ import org.eclipse.emf.spi.cdo.InternalCDOSession;
import java.io.FileOutputStream;
import java.io.PrintStream;
+import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
@@ -269,7 +271,7 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
public void tearDown() throws Exception
{
deactivateServerBrowser();
- if (!isOptimizing())
+ if (!isOptimizing() || leavesCleanRepos())
{
deactivateRepositories();
}
@@ -379,16 +381,25 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
return true;
}
- String testMethod = getCurrentTest().getName();
+ return hasAnnotation(NeedsCleanRepo.class);
+ }
+
+ protected boolean leavesCleanRepos()
+ {
+ return hasAnnotation(LeavesCleanRepo.class);
+ }
+
+ private <T extends Annotation> boolean hasAnnotation(Class<T> annotationClass)
+ {
Class<? extends ConfigTest> testClass = getCurrentTest().getClass();
- boolean needsCleanRepo = testClass.getAnnotation(NeedsCleanRepo.class) != null;
- if (!needsCleanRepo)
+ String methodName = getCurrentTest().getName();
+ Method method = ReflectUtil.getMethod(testClass, methodName, new Class[0]);
+ if (method.getAnnotation(annotationClass) != null)
{
- Method method = ReflectUtil.getMethod(testClass, testMethod, new Class[0]);
- needsCleanRepo = method.getAnnotation(NeedsCleanRepo.class) != null;
+ return true;
}
- return needsCleanRepo;
+ return testClass.getAnnotation(annotationClass) != null;
}
static