Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2011-06-08 10:54:59 +0000
committerCaspar De Groot2011-06-08 10:54:59 +0000
commit4d83e5b62819ef74f598653ca158969830d87af1 (patch)
treef7f8f0f45779818d738de4de219ef81d21602f2c /plugins/org.eclipse.emf.cdo.tests.db4o
parentc5d3ceacb3ab876418518d7b1bc81368c177975f (diff)
downloadcdo-4d83e5b62819ef74f598653ca158969830d87af1.tar.gz
cdo-4d83e5b62819ef74f598653ca158969830d87af1.tar.xz
cdo-4d83e5b62819ef74f598653ca158969830d87af1.zip
[347285] Durable locking support for db4o
https://bugs.eclipse.org/bugs/show_bug.cgi?id=347285
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests.db4o')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4O.java105
1 files changed, 104 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4O.java b/plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4O.java
index 87eb709960..16e0a77a7c 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4O.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4O.java
@@ -12,13 +12,24 @@ package org.eclipse.emf.cdo.tests.db4o;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.server.internal.db4o.DB4OStore;
import org.eclipse.emf.cdo.tests.AllConfigs;
+import org.eclipse.emf.cdo.tests.BranchingSameSessionTest;
+import org.eclipse.emf.cdo.tests.BranchingTest;
+import org.eclipse.emf.cdo.tests.BranchingWithCacheClearTest;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_261218_Test;
+import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_324585_Test;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
+import org.eclipse.net4j.util.io.TMPUtil;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.ServerSocket;
import java.util.List;
import java.util.Map;
+import java.util.Random;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -41,6 +52,12 @@ public class AllTestsDB4O extends AllConfigs
// Added here testcases to skip
// takes too much
testClasses.remove(Bugzilla_261218_Test.class);
+ testClasses.remove(Bugzilla_324585_Test.class);
+
+ // db4o doesn't support branching
+ testClasses.remove(BranchingTest.class);
+ testClasses.remove(BranchingSameSessionTest.class);
+ testClasses.remove(BranchingWithCacheClearTest.class);
}
@Override
@@ -54,10 +71,14 @@ public class AllTestsDB4O extends AllConfigs
*/
public static class DB4ORepositoryConfig extends RepositoryConfig
{
+ private static final Random RANDOM = new Random(System.currentTimeMillis());
+
public static final DB4ORepositoryConfig INSTANCE = new DB4ORepositoryConfig("DB4O");
private static final long serialVersionUID = 1L;
+ private transient boolean optimizing = true;
+
public DB4ORepositoryConfig(String name)
{
super(name);
@@ -74,8 +95,90 @@ public class AllTestsDB4O extends AllConfigs
@Override
protected IStore createStore(String repoName)
{
- MEMDB4OStore.clearContainer();
+ File tempFolder = TMPUtil.getTempFolder();
+ File file = new File(tempFolder, "cdodb_" + repoName + ".db4o");
+ if (file.exists() && !isRestarting())
+ {
+ file.delete();
+ }
+
+ int port = 0;
+ boolean ok = false;
+ do
+ {
+ ServerSocket sock = null;
+ try
+ {
+ port = 1024 + RANDOM.nextInt(65536 - 1024);
+ sock = new ServerSocket(port);
+ ok = true;
+ }
+ catch (IOException e)
+ {
+ }
+ finally
+ {
+ try
+ {
+ if (sock != null)
+ {
+ sock.close();
+ }
+ }
+ catch (IOException e)
+ {
+ }
+ }
+ } while (!ok);
+
+ IStore store = new DB4OStore(file.getPath(), port);
+ return store;
+ }
+
+ @Override
+ protected boolean isOptimizing()
+ {
+ // Do NOT replace this with a hardcoded value!
+ return optimizing;
+ }
+ }
+
+ public static class MemDB4ORepositoryConfig extends RepositoryConfig
+ {
+ public static final MemDB4ORepositoryConfig INSTANCE = new MemDB4ORepositoryConfig("DB4O");
+
+ private static final long serialVersionUID = 1L;
+
+ private transient boolean optimizing = false;
+
+ public MemDB4ORepositoryConfig(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected void initRepositoryProperties(Map<String, String> props)
+ {
+ super.initRepositoryProperties(props);
+ props.put(IRepository.Props.SUPPORTING_AUDITS, "false");
+ props.put(IRepository.Props.SUPPORTING_BRANCHES, "false");
+ }
+
+ @Override
+ protected IStore createStore(String repoName)
+ {
+ if (!isRestarting())
+ {
+ MEMDB4OStore.clearContainer();
+ }
return new MEMDB4OStore();
}
+
+ @Override
+ protected boolean isOptimizing()
+ {
+ // Do NOT replace this with a hardcoded value!
+ return optimizing;
+ }
}
}

Back to the top