Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2011-07-21 05:36:09 +0000
committerEike Stepper2011-07-21 05:36:09 +0000
commit64cfda3a65168e961b20afaafc7b629261bce605 (patch)
tree46713cd6f781ad76638da81e5422b4da565c0f4c /plugins/org.eclipse.emf.cdo.tests.db4o
parentaf719ba16912427971a462cf41f6245cde962ab6 (diff)
downloadcdo-64cfda3a65168e961b20afaafc7b629261bce605.tar.gz
cdo-64cfda3a65168e961b20afaafc7b629261bce605.tar.xz
cdo-64cfda3a65168e961b20afaafc7b629261bce605.zip
[352696] [Tests] Cleanup RepositoryConfigs
https://bugs.eclipse.org/bugs/show_bug.cgi?id=352696
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests.db4o')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db4o/CDO AllTests (MEMDB4O).launch4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4O.java104
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4OMem.java31
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsMEMDB4O.java65
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/DB4OConfig.java97
5 files changed, 139 insertions, 162 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests.db4o/CDO AllTests (MEMDB4O).launch b/plugins/org.eclipse.emf.cdo.tests.db4o/CDO AllTests (MEMDB4O).launch
index 4b73ac3ea6..8bcce237fc 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db4o/CDO AllTests (MEMDB4O).launch
+++ b/plugins/org.eclipse.emf.cdo.tests.db4o/CDO AllTests (MEMDB4O).launch
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsMEMDB4O.java"/>
+<listEntry value="/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4OMem.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
@@ -10,7 +10,7 @@
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db4o.AllTestsMEMDB4O"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db4o.AllTestsDB4OMem"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db4o"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-XX:MaxPermSize=128m&#10;-Xmx1024m"/>
</launchConfiguration>
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 ec0cdd3314..a41da3ff2b 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
@@ -10,26 +10,16 @@
*/
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.IScenario;
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;
@@ -45,9 +35,15 @@ public class AllTestsDB4O extends AllConfigs
}
@Override
- protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, new DB4OConfig(false), JVM, NATIVE);
+ }
+
+ @Override
+ protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
{
- super.initTestClasses(testClasses);
+ super.initTestClasses(testClasses, scenario);
// Added here testcases to skip
// takes too much
@@ -59,86 +55,4 @@ public class AllTestsDB4O extends AllConfigs
testClasses.remove(BranchingSameSessionTest.class);
testClasses.remove(BranchingWithCacheClearTest.class);
}
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, DB4ORepositoryConfig.INSTANCE, JVM, NATIVE);
- }
-
- /**
- * @author Victor Roldan Betancort
- */
- 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);
- }
-
- @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");
- }
-
- public IStore createStore(String repoName)
- {
- 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;
- }
- }
}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4OMem.java b/plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4OMem.java
new file mode 100644
index 0000000000..652a29dbdf
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4OMem.java
@@ -0,0 +1,31 @@
+/**
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Victor Roldan Betancort - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.db4o;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Victor Roldan Betancort
+ */
+public class AllTestsDB4OMem extends AllTestsDB4O
+{
+ public static Test suite()
+ {
+ return new AllTestsDB4OMem().getTestSuite("CDO Tests (DB4OMem)");
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, new DB4OConfig(true), JVM, NATIVE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsMEMDB4O.java b/plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsMEMDB4O.java
deleted file mode 100644
index 8fccfa3de0..0000000000
--- a/plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsMEMDB4O.java
+++ /dev/null
@@ -1,65 +0,0 @@
-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.tests.config.impl.RepositoryConfig;
-
-import java.util.Map;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class AllTestsMEMDB4O extends AllTestsDB4O
-{
-
- public static Test suite()
- {
- return new AllTestsMEMDB4O().getTestSuite("CDO Tests (MEMDB4O)");
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, MemDB4ORepositoryConfig.INSTANCE, JVM, NATIVE);
- }
-
- 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");
- }
-
- public 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;
- }
- }
-
-}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/DB4OConfig.java b/plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/DB4OConfig.java
new file mode 100644
index 0000000000..aa013c1e77
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/DB4OConfig.java
@@ -0,0 +1,97 @@
+package org.eclipse.emf.cdo.tests.db4o;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.server.internal.db4o.DB4OStore;
+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.Random;
+
+/**
+ * @author Victor Roldan Betancort
+ */
+public class DB4OConfig extends RepositoryConfig
+{
+ private static final Random RANDOM = new Random(System.currentTimeMillis());
+
+ private static final long serialVersionUID = 1L;
+
+ private boolean mem;
+
+ private transient boolean optimizing = true;
+
+ public DB4OConfig(boolean mem)
+ {
+ super("DB4O", false, false, IDGenerationLocation.STORE);
+ this.mem = mem;
+ }
+
+ public boolean isMem()
+ {
+ return mem;
+ }
+
+ public IStore createStore(String repoName)
+ {
+ if (mem)
+ {
+ if (!isRestarting())
+ {
+ MEMDB4OStore.clearContainer();
+ }
+
+ return new MEMDB4OStore();
+ }
+
+ 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);
+
+ return new DB4OStore(file.getPath(), port);
+ }
+
+ @Override
+ protected boolean isOptimizing()
+ {
+ // Do NOT replace this with a hardcoded value!
+ return optimizing;
+ }
+}

Back to the top