### Eclipse Workspace Patch 1.0 #P org.eclipse.emf.cdo.dawn.tests Index: src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUI.java =================================================================== --- src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUI.java (revision 8584) +++ src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUI.java (working copy) @@ -14,6 +14,7 @@ import org.eclipse.emf.cdo.dawn.tests.ui.gmf.DawnBasicGMFUITest; import org.eclipse.emf.cdo.dawn.tests.ui.gmf.DawnCreationWizardTest; import org.eclipse.emf.cdo.tests.AllTests; +import org.eclipse.emf.cdo.tests.config.IScenario; import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; import java.util.List; @@ -34,16 +35,16 @@ } @Override - protected void initTestClasses(List> testClasses) + protected void initConfigSuites(TestSuite parent) { - testClasses.add(DawnCreationWizardTest.class); - testClasses.add(DawnBasicGMFUITest.class); - testClasses.add(DawnBasicEMFUITest.class); + addScenario(parent, COMBINED, MEM, TCP, NATIVE); } @Override - protected void initConfigSuites(TestSuite parent) + protected void initTestClasses(List> testClasses, IScenario scenario) { - addScenario(parent, COMBINED, MEM, TCP, NATIVE); + testClasses.add(DawnCreationWizardTest.class); + testClasses.add(DawnBasicGMFUITest.class); + testClasses.add(DawnBasicEMFUITest.class); } } Index: src/org/eclipse/emf/cdo/dawn/tests/TCPConfigStarter.java =================================================================== --- src/org/eclipse/emf/cdo/dawn/tests/TCPConfigStarter.java (revision 8584) +++ src/org/eclipse/emf/cdo/dawn/tests/TCPConfigStarter.java (working copy) @@ -12,6 +12,7 @@ import org.eclipse.emf.cdo.tests.AllConfigs; import org.eclipse.emf.cdo.tests.InitialTest; +import org.eclipse.emf.cdo.tests.config.IScenario; import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; import java.util.List; @@ -30,14 +31,14 @@ } @Override - protected void initTestClasses(List> testClasses) + protected void initConfigSuites(TestSuite parent) { - testClasses.add(InitialTest.class); + addScenario(parent, COMBINED, MEM_BRANCHES, TCP, NATIVE); } @Override - protected void initConfigSuites(TestSuite parent) + protected void initTestClasses(List> testClasses, IScenario scenario) { - addScenario(parent, COMBINED, MEM_BRANCHES, TCP, NATIVE); + testClasses.add(InitialTest.class); } } Index: src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBot.java =================================================================== --- src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBot.java (revision 8584) +++ src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBot.java (working copy) @@ -23,6 +23,7 @@ import org.eclipse.emf.cdo.dawn.tests.ui.gmf.MultipleResourcesTest; import org.eclipse.emf.cdo.dawn.tests.ui.gmf.SimpleDiagramTest; import org.eclipse.emf.cdo.tests.AllTests; +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.ConfigTestSuite; @@ -51,9 +52,8 @@ } @Override - protected void initTestClasses(List> testClasses) + protected void initTestClasses(List> testClasses, IScenario scenario) { - /******************** GMF **********************/ testClasses.add(DawnPreferencesTest.class); testClasses.add(DawnCreationWizardSWTBotTest.class); Index: src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawn.java =================================================================== --- src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawn.java (revision 8584) +++ src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawn.java (working copy) @@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.dawn.tests.common.GMFTest; import org.eclipse.emf.cdo.dawn.tests.common.TestFrameworkTest; import org.eclipse.emf.cdo.tests.AllTests; +import org.eclipse.emf.cdo.tests.config.IScenario; import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; import java.util.List; @@ -35,17 +36,17 @@ } @Override - protected void initTestClasses(List> testClasses) + protected void initConfigSuites(TestSuite parent) { - testClasses.add(TestFrameworkTest.class); - testClasses.add(GMFTest.class); - testClasses.add(DawnWrapperResourceTest.class); - testClasses.add(DawnCodeGenGMFFragmentTest.class); + addScenario(parent, COMBINED, MEM, JVM, NATIVE); } @Override - protected void initConfigSuites(TestSuite parent) + protected void initTestClasses(List> testClasses, IScenario scenario) { - addScenario(parent, COMBINED, MEM, JVM, NATIVE); + testClasses.add(TestFrameworkTest.class); + testClasses.add(GMFTest.class); + testClasses.add(DawnWrapperResourceTest.class); + testClasses.add(DawnCodeGenGMFFragmentTest.class); } } #P org.eclipse.emf.cdo.tests.db Index: src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldbNonAudit.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldbNonAudit.java (revision 8672) +++ src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldbNonAudit.java (working copy) @@ -10,16 +10,12 @@ */ package org.eclipse.emf.cdo.tests.db; -import org.eclipse.emf.cdo.server.IRepository; -import org.eclipse.emf.cdo.server.db.CDODBUtil; -import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_261218_Test; +import org.eclipse.emf.cdo.tests.config.IScenario; import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; -import org.eclipse.emf.cdo.tests.db.verifier.DBStoreVerifier; -import org.eclipse.emf.cdo.tests.db.verifier.DBStoreVerifier.NonAudit; import java.util.List; -import java.util.Map; import junit.framework.Test; import junit.framework.TestSuite; @@ -37,59 +33,15 @@ @Override protected void initConfigSuites(TestSuite parent) { - addScenario(parent, COMBINED, AllTestsDBHsqldbNonAudit.HsqldbNonAudit.INSTANCE, TCP, NATIVE); + addScenario(parent, COMBINED, new HsqldbConfig(false, false, IDGenerationLocation.STORE), TCP, NATIVE); } @Override - protected void initTestClasses(List> testClasses) + protected void initTestClasses(List> testClasses, IScenario scenario) { - super.initTestClasses(testClasses); + super.initTestClasses(testClasses, scenario); // this takes ages - so for now, we disable it testClasses.remove(Bugzilla_261218_Test.class); } - - @Override - protected boolean hasAuditSupport() - { - return false; - } - - @Override - protected boolean hasBranchingSupport() - { - return false; - } - - public static class HsqldbNonAudit extends AllTestsDBHsqldb.Hsqldb - { - private static final long serialVersionUID = 1L; - - public static final AllTestsDBHsqldbNonAudit.HsqldbNonAudit INSTANCE = new HsqldbNonAudit( - "DBStore: Hsqldb (non audit)"); - - public HsqldbNonAudit(String name) - { - super(name); - } - - @Override - protected void initRepositoryProperties(Map props) - { - super.initRepositoryProperties(props); - props.put(IRepository.Props.SUPPORTING_AUDITS, "false"); - } - - @Override - protected IMappingStrategy createMappingStrategy() - { - return CDODBUtil.createHorizontalMappingStrategy(false); - } - - @Override - protected DBStoreVerifier getVerifier(IRepository repository) - { - return new NonAudit(repository); - } - } } Index: src/org/eclipse/emf/cdo/tests/db/DBConfig.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/DBConfig.java (revision 8672) +++ src/org/eclipse/emf/cdo/tests/db/DBConfig.java (working copy) @@ -10,6 +10,7 @@ */ package org.eclipse.emf.cdo.tests.db; +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; import org.eclipse.emf.cdo.server.IStore; import org.eclipse.emf.cdo.server.db.CDODBUtil; import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; @@ -29,13 +30,30 @@ /** * @author Eike Stepper */ -public abstract class DBStoreRepositoryConfig extends RepositoryConfig +public abstract class DBConfig extends RepositoryConfig { private static final long serialVersionUID = 1L; - public DBStoreRepositoryConfig(String name) + private boolean withRanges; + + private boolean copyOnBranch; + + public DBConfig(String name, boolean supportingAudits, boolean supportingBranches, boolean withRanges, + boolean copyOnBranch, IDGenerationLocation idGenerationLocation) + { + super(name, supportingAudits, supportingBranches, idGenerationLocation); + this.withRanges = withRanges; + this.copyOnBranch = copyOnBranch; + } + + public boolean isWithRanges() + { + return withRanges; + } + + public boolean isCopyOnBranch() { - super(name); + return copyOnBranch; } @Override @@ -65,10 +83,20 @@ { Map props = new HashMap(); props.put(IMappingStrategy.PROP_QUALIFIED_NAMES, "true"); + props.put(CDODBUtil.PROP_COPY_ON_BRANCH, Boolean.toString(copyOnBranch)); return props; } - protected abstract IMappingStrategy createMappingStrategy(); + protected IMappingStrategy createMappingStrategy() + { + return CDODBUtil.createHorizontalMappingStrategy(isSupportingAudits(), isSupportingBranches(), withRanges); + } + + @Override + protected String getMappingStrategySpecialization() + { + return (withRanges ? "-ranges" : "") + (copyOnBranch ? "-copy" : ""); + } protected abstract IDBAdapter createDBAdapter(); Index: src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2NonAudit.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2NonAudit.java (revision 8672) +++ src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2NonAudit.java (working copy) @@ -10,26 +10,7 @@ */ package org.eclipse.emf.cdo.tests.db; -import org.eclipse.emf.cdo.server.IRepository; -import org.eclipse.emf.cdo.server.db.CDODBUtil; -import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; - -import org.eclipse.net4j.db.DBUtil; -import org.eclipse.net4j.db.IDBAdapter; -import org.eclipse.net4j.db.h2.H2Adapter; -import org.eclipse.net4j.util.WrappedException; -import org.eclipse.net4j.util.io.IOUtil; -import org.eclipse.net4j.util.io.TMPUtil; - -import org.h2.jdbcx.JdbcDataSource; - -import javax.sql.DataSource; - -import java.io.File; -import java.sql.Connection; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.Map; +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; import junit.framework.Test; import junit.framework.TestSuite; @@ -47,177 +28,6 @@ @Override protected void initConfigSuites(TestSuite parent) { - addScenario(parent, COMBINED, AllTestsDBH2NonAudit.H2NonAudit.ReusableFolder.INSTANCE, JVM, NATIVE); - } - - @Override - protected boolean hasAuditSupport() - { - return false; - } - - @Override - protected boolean hasBranchingSupport() - { - return false; - } - - /** - * @author Eike Stepper - */ - public static class H2NonAudit extends DBStoreRepositoryConfig - { - private static final long serialVersionUID = 1L; - - public static final AllTestsDBH2NonAudit.H2NonAudit INSTANCE = new H2NonAudit("DBStore: H2 (non-audit)"); - - protected transient File dbFolder; - - public H2NonAudit(String name) - { - super(name); - } - - @Override - protected void initRepositoryProperties(Map props) - { - super.initRepositoryProperties(props); - props.put(IRepository.Props.SUPPORTING_AUDITS, "false"); - } - - @Override - protected IMappingStrategy createMappingStrategy() - { - return CDODBUtil.createHorizontalMappingStrategy(false); - } - - @Override - protected IDBAdapter createDBAdapter() - { - return new H2Adapter(); - } - - @Override - protected DataSource createDataSource(String repoName) - { - if (dbFolder == null) - { - dbFolder = createDBFolder(); - tearDownClean(); - } - - JdbcDataSource dataSource = new JdbcDataSource(); - dataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName); - return dataSource; - } - - protected void tearDownClean() - { - IOUtil.delete(dbFolder); - } - - protected File createDBFolder() - { - return TMPUtil.createTempFolder("h2_", "_test"); - } - - /** - * @author Eike Stepper - */ - public static class ReusableFolder extends H2NonAudit - { - private static final long serialVersionUID = 1L; - - public static final ReusableFolder INSTANCE = new ReusableFolder("DBStore: H2 (non-audit)"); - - private static File reusableFolder; - - private static JdbcDataSource defaultDataSource; - - private transient ArrayList repoNames = new ArrayList(); - - public ReusableFolder(String name) - { - super(name); - } - - @Override - protected DataSource createDataSource(String repoName) - { - if (reusableFolder == null) - { - reusableFolder = createDBFolder(); - IOUtil.delete(reusableFolder); - } - - dbFolder = reusableFolder; - if (defaultDataSource == null) - { - defaultDataSource = new JdbcDataSource(); - defaultDataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test"); - } - - Connection conn = null; - Statement stmt = null; - - try - { - conn = defaultDataSource.getConnection(); - stmt = conn.createStatement(); - - if (!isRestarting()) - { - stmt.execute("DROP SCHEMA IF EXISTS " + repoName); - } - - stmt.execute("CREATE SCHEMA IF NOT EXISTS " + repoName); - } - catch (Exception e) - { - e.printStackTrace(); - } - finally - { - DBUtil.close(conn); - DBUtil.close(stmt); - } - - JdbcDataSource dataSource = new JdbcDataSource(); - dataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName); - return dataSource; - } - - @Override - protected void tearDownClean() - { - for (String repoName : repoNames) - { - tearDownClean(repoName); - } - } - - protected void tearDownClean(String repoName) - { - reusableFolder.deleteOnExit(); - Connection connection = null; - Statement stmt = null; - - try - { - connection = defaultDataSource.getConnection(); - stmt = connection.createStatement(); - stmt.execute("DROP SCHEMA " + repoName); - } - catch (Exception ex) - { - throw WrappedException.wrap(ex); - } - finally - { - DBUtil.close(stmt); - DBUtil.close(connection); - } - } - } + addScenario(parent, COMBINED, new H2Config(false, false, false, false, IDGenerationLocation.STORE), JVM, NATIVE); } } Index: src/org/eclipse/emf/cdo/tests/db/DISABLE_AttributeTest.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/DISABLE_AttributeTest.java (revision 8672) +++ src/org/eclipse/emf/cdo/tests/db/DISABLE_AttributeTest.java (working copy) @@ -21,7 +21,7 @@ public void testByteArray() throws Exception { // XXX disabled because of Bug 289445 - skipConfig(AllTestsDBPsql.Psql.INSTANCE); + skipTest(getRepositoryConfig() instanceof PostgresqlConfig); super.testByteArray(); } @@ -29,7 +29,7 @@ public void testByteArrayEmpty() throws Exception { // XXX disabled because of Bug 289445 - skipConfig(AllTestsDBPsql.Psql.INSTANCE); + skipTest(getRepositoryConfig() instanceof PostgresqlConfig); super.testByteArrayEmpty(); } @@ -37,7 +37,7 @@ public void testByteArrayNull() throws Exception { // XXX disabled because of Bug 289445 - skipConfig(AllTestsDBPsql.Psql.INSTANCE); + skipTest(getRepositoryConfig() instanceof PostgresqlConfig); super.testByteArrayNull(); } } Index: src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Branching.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Branching.java (revision 8672) +++ src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Branching.java (working copy) @@ -10,26 +10,7 @@ */ package org.eclipse.emf.cdo.tests.db; -import org.eclipse.emf.cdo.server.IRepository; -import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; - -import org.eclipse.net4j.db.DBUtil; -import org.eclipse.net4j.db.IDBAdapter; -import org.eclipse.net4j.db.h2.H2Adapter; -import org.eclipse.net4j.util.WrappedException; -import org.eclipse.net4j.util.io.IOUtil; -import org.eclipse.net4j.util.io.TMPUtil; - -import org.h2.jdbcx.JdbcDataSource; - -import javax.sql.DataSource; - -import java.io.File; -import java.sql.Connection; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; import junit.framework.Test; import junit.framework.TestSuite; @@ -47,233 +28,8 @@ @Override protected void initConfigSuites(TestSuite parent) { - addScenario(parent, COMBINED, H2Branching.ReusableFolder.INSTANCE, JVM, NATIVE); - addScenario(parent, COMBINED, H2Branching.ReusableFolder.RANGE_INSTANCE, JVM, NATIVE); - addScenario(parent, COMBINED, H2Branching.ReusableFolder.CopyOnBranch.INSTANCE, JVM, NATIVE); - } - - @Override - protected boolean hasAuditSupport() - { - return true; - } - - @Override - protected boolean hasBranchingSupport() - { - return true; - } - - /** - * @author Eike Stepper - */ - public static class H2Branching extends DBStoreRepositoryConfig - { - private static final long serialVersionUID = 1L; - - public static final H2Branching INSTANCE = new H2Branching("DBStore: H2 (branching)", - "org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingMappingStrategy"); - - protected transient File dbFolder; - - private String mappingStrategy; - - public H2Branching(String name, String mappingStrategy) - { - super(name); - this.mappingStrategy = mappingStrategy; - } - - @Override - protected void initRepositoryProperties(Map props) - { - super.initRepositoryProperties(props); - props.put(IRepository.Props.SUPPORTING_AUDITS, "true"); - props.put(IRepository.Props.SUPPORTING_BRANCHES, "true"); - } - - @SuppressWarnings("unchecked") - @Override - protected IMappingStrategy createMappingStrategy() - { - try - { - Class clazz = (Class)Class.forName(mappingStrategy); - return clazz.newInstance(); - } - catch (Exception ex) - { - throw WrappedException.wrap(ex); - } - } - - @Override - protected IDBAdapter createDBAdapter() - { - return new H2Adapter(); - } - - @Override - protected DataSource createDataSource(String repoName) - { - if (dbFolder == null) - { - dbFolder = createDBFolder(); - tearDownClean(); - } - - JdbcDataSource dataSource = new JdbcDataSource(); - dataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName); - - return dataSource; - } - - protected void tearDownClean() - { - IOUtil.delete(dbFolder); - } - - protected File createDBFolder() - { - return TMPUtil.createTempFolder("h2_", "_test"); - } - - /** - * @author Eike Stepper - */ - public static class ReusableFolder extends H2Branching - { - private static final long serialVersionUID = 1L; - - public static final ReusableFolder INSTANCE = new ReusableFolder("DBStore: H2 (branching)", - "org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingMappingStrategy"); - - public static final ReusableFolder RANGE_INSTANCE = new ReusableFolder("DBStore: H2 (branching, range-based)", - "org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingMappingStrategyWithRanges"); - - private static File reusableFolder; - - private static JdbcDataSource defaultDataSource; - - private transient ArrayList repoNames = new ArrayList(); - - public ReusableFolder(String name, String mappingStrategy) - { - super(name, mappingStrategy); - } - - @Override - protected DataSource createDataSource(String repoName) - { - if (reusableFolder == null) - { - reusableFolder = createDBFolder(); - IOUtil.delete(reusableFolder); - } - - dbFolder = reusableFolder; - if (defaultDataSource == null) - { - defaultDataSource = new JdbcDataSource(); - defaultDataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test"); - } - - Connection conn = null; - Statement stmt = null; - - try - { - conn = defaultDataSource.getConnection(); - stmt = conn.createStatement(); - - if (!isRestarting()) - { - stmt.execute("DROP SCHEMA IF EXISTS " + repoName); - } - - stmt.execute("CREATE SCHEMA IF NOT EXISTS " + repoName); - - /* - * final WebServer webServer = new WebServer(); webServer.init(new String[] { "-webPort", "7778" }); - * webServer.start(); System.out.println("----------------------------------"); - * System.out.println("----------------------------------"); System.out.println(webServer.addSession(conn)); - * System.out.println("----------------------------------"); - * System.out.println("----------------------------------"); new Thread() { - * @Override public void run() { webServer.listen(); } }.start(); - */ - } - catch (Exception ex) - { - ex.printStackTrace(); - } - finally - { - DBUtil.close(stmt); - DBUtil.close(conn); - } - - JdbcDataSource dataSource = new JdbcDataSource(); - dataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName); - return dataSource; - } - - @Override - protected void tearDownClean() - { - for (String repoName : repoNames) - { - tearDownClean(repoName); - } - } - - protected void tearDownClean(String repoName) - { - reusableFolder.deleteOnExit(); - Connection connection = null; - Statement stmt = null; - - try - { - connection = defaultDataSource.getConnection(); - stmt = connection.createStatement(); - stmt.execute("DROP SCHEMA " + repoName); - } - catch (Exception ex) - { - throw WrappedException.wrap(ex); - } - finally - { - DBUtil.close(stmt); - DBUtil.close(connection); - } - } - - public static class CopyOnBranch extends ReusableFolder - { - private static final long serialVersionUID = 1L; - - public static final ReusableFolder INSTANCE = new CopyOnBranch( - "DBStore: H2 (branching, range-based, copyOnBranch)", - "org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingMappingStrategyWithRanges"); - - public CopyOnBranch(String name, String ms) - { - super(name, ms); - } - - @Override - protected IMappingStrategy createMappingStrategy() - { - IMappingStrategy ms = super.createMappingStrategy(); - - Map properties = new HashMap(); - properties.put("copyOnBranch", "true"); - ms.setProperties(properties); - - return ms; - } - } - } + addScenario(parent, COMBINED, new H2Config(true, true, false, false, IDGenerationLocation.STORE), JVM, NATIVE); + addScenario(parent, COMBINED, new H2Config(true, true, true, false, IDGenerationLocation.STORE), JVM, NATIVE); + addScenario(parent, COMBINED, new H2Config(true, true, true, true, IDGenerationLocation.STORE), JVM, NATIVE); } } Index: src/org/eclipse/emf/cdo/tests/db/HsqldbConfig.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/HsqldbConfig.java (revision 0) +++ src/org/eclipse/emf/cdo/tests/db/HsqldbConfig.java (revision 0) @@ -0,0 +1,153 @@ +/** + * 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.tests.db; + +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; +import org.eclipse.emf.cdo.server.IRepository; +import org.eclipse.emf.cdo.server.IRepository.Props; +import org.eclipse.emf.cdo.tests.db.bundle.OM; +import org.eclipse.emf.cdo.tests.db.verifier.DBStoreVerifier; + +import org.eclipse.net4j.db.DBUtil; +import org.eclipse.net4j.db.IDBAdapter; +import org.eclipse.net4j.db.hsqldb.HSQLDBAdapter; +import org.eclipse.net4j.db.hsqldb.HSQLDBDataSource; + +import org.eclipse.emf.common.util.WrappedException; + +import javax.sql.DataSource; + +import java.io.PrintWriter; +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.Map; + +/** + * @author Eike Stepper + */ +public class HsqldbConfig extends DBConfig +{ + private static final long serialVersionUID = 1L; + + public static boolean USE_VERIFIER = false; + + private transient ArrayList dataSources; + + public HsqldbConfig(boolean supportingAudits, boolean supportingBranches, IDGenerationLocation idGenerationLocation) + { + super("Hsqldb", supportingAudits, supportingBranches, false, false, idGenerationLocation); + } + + @Override + protected IDBAdapter createDBAdapter() + { + return new HSQLDBAdapter(); + } + + @Override + protected DataSource createDataSource(String repoName) + { + HSQLDBDataSource dataSource = new HSQLDBDataSource(); + dataSource.setDatabase("jdbc:hsqldb:mem:" + repoName); + dataSource.setUser("sa"); + + try + { + dataSource.setLogWriter(new PrintWriter(System.err)); + } + catch (SQLException ex) + { + OM.LOG.warn(ex.getMessage()); + } + + if (dataSources == null) + { + dataSources = new ArrayList(); + } + + dataSources.add(dataSource); + return dataSource; + } + + @Override + public void tearDown() throws Exception + { + try + { + if (USE_VERIFIER) + { + IRepository testRepository = getRepository(REPOSITORY_NAME); + if (testRepository != null) + { + getVerifier(testRepository).verify(); + } + } + } + finally + { + super.tearDown(); + } + } + + @Override + protected void deactivateRepositories() + { + try + { + shutDownHsqldb(); + } + catch (SQLException e) + { + throw new WrappedException(e); + } + finally + { + super.deactivateRepositories(); + } + } + + protected DBStoreVerifier getVerifier(IRepository repository) + { + return new DBStoreVerifier.Audit(repository); + } + + private void shutDownHsqldb() throws SQLException + { + for (HSQLDBDataSource ds : dataSources) + { + Connection connection = null; + Statement statement = null; + + try + { + connection = ds.getConnection(); + statement = connection.createStatement(); + statement.execute("SHUTDOWN"); + } + finally + { + DBUtil.close(statement); + DBUtil.close(connection); + } + } + + dataSources.clear(); + } + + @Override + protected void initRepositoryProperties(Map props) + { + super.initRepositoryProperties(props); + props.put(Props.SUPPORTING_AUDITS, "true"); + } +} Index: src/org/eclipse/emf/cdo/tests/db/DISABLE_ExternalReferenceTest.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/DISABLE_ExternalReferenceTest.java (revision 8672) +++ src/org/eclipse/emf/cdo/tests/db/DISABLE_ExternalReferenceTest.java (working copy) @@ -21,7 +21,7 @@ public void testOneXMIResourceManyViewsOnOneResourceSet() throws Exception { // XXX disabled because of Bug 290097 - skipConfig(AllTestsDBPsql.Psql.INSTANCE); + skipTest(getRepositoryConfig() instanceof PostgresqlConfig); super.testOneXMIResourceManyViewsOnOneResourceSet(); } @@ -29,7 +29,7 @@ public void testManyViewsOnOneResourceSet() throws Exception { // XXX disabled because of Bug 290097 - skipConfig(AllTestsDBPsql.Psql.INSTANCE); + skipTest(getRepositoryConfig() instanceof PostgresqlConfig); super.testManyViewsOnOneResourceSet(); } } Index: src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldb.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldb.java (revision 8672) +++ src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldb.java (working copy) @@ -10,31 +10,12 @@ */ package org.eclipse.emf.cdo.tests.db; -import org.eclipse.emf.cdo.server.IRepository; -import org.eclipse.emf.cdo.server.IRepository.Props; -import org.eclipse.emf.cdo.server.db.CDODBUtil; -import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_266982_Test; +import org.eclipse.emf.cdo.tests.config.IScenario; import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; -import org.eclipse.emf.cdo.tests.db.bundle.OM; -import org.eclipse.emf.cdo.tests.db.verifier.DBStoreVerifier; - -import org.eclipse.net4j.db.DBUtil; -import org.eclipse.net4j.db.IDBAdapter; -import org.eclipse.net4j.db.hsqldb.HSQLDBAdapter; -import org.eclipse.net4j.db.hsqldb.HSQLDBDataSource; - -import org.eclipse.emf.common.util.WrappedException; - -import javax.sql.DataSource; -import java.io.PrintWriter; -import java.sql.Connection; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; import java.util.List; -import java.util.Map; import junit.framework.Test; import junit.framework.TestSuite; @@ -52,154 +33,15 @@ @Override protected void initConfigSuites(TestSuite parent) { - addScenario(parent, COMBINED, AllTestsDBHsqldb.Hsqldb.INSTANCE, JVM, NATIVE); - } - - @Override - protected boolean hasAuditSupport() - { - return true; + addScenario(parent, COMBINED, new HsqldbConfig(true, false, IDGenerationLocation.STORE), JVM, NATIVE); } @Override - protected boolean hasBranchingSupport() + protected void initTestClasses(List> testClasses, IScenario scenario) { - return false; - } - - @Override - protected void initTestClasses(List> testClasses) - { - super.initTestClasses(testClasses); + super.initTestClasses(testClasses, scenario); // this takes ages ... testClasses.remove(Bugzilla_266982_Test.class); } - - /** - * @author Eike Stepper - */ - public static class Hsqldb extends DBStoreRepositoryConfig - { - private static final long serialVersionUID = 1L; - - public static final AllTestsDBHsqldb.Hsqldb INSTANCE = new Hsqldb("HSQLDB"); - - public static boolean USE_VERIFIER = false; - - private transient ArrayList dataSources; - - public Hsqldb(String name) - { - super(name); - } - - @Override - protected IMappingStrategy createMappingStrategy() - { - return CDODBUtil.createHorizontalMappingStrategy(true); - } - - @Override - protected IDBAdapter createDBAdapter() - { - return new HSQLDBAdapter(); - } - - @Override - protected DataSource createDataSource(String repoName) - { - HSQLDBDataSource dataSource = new HSQLDBDataSource(); - dataSource.setDatabase("jdbc:hsqldb:mem:" + repoName); - dataSource.setUser("sa"); - - try - { - dataSource.setLogWriter(new PrintWriter(System.err)); - } - catch (SQLException ex) - { - OM.LOG.warn(ex.getMessage()); - } - - if (dataSources == null) - { - dataSources = new ArrayList(); - } - dataSources.add(dataSource); - return dataSource; - } - - @Override - public void tearDown() throws Exception - { - try - { - if (USE_VERIFIER) - { - IRepository testRepository = getRepository(REPOSITORY_NAME); - if (testRepository != null) - { - getVerifier(testRepository).verify(); - } - } - } - finally - { - super.tearDown(); - } - } - - @Override - protected void deactivateRepositories() - { - try - { - shutDownHsqldb(); - } - catch (SQLException e) - { - throw new WrappedException(e); - } - finally - { - super.deactivateRepositories(); - } - } - - protected DBStoreVerifier getVerifier(IRepository repository) - { - return new DBStoreVerifier.Audit(repository); - } - - private void shutDownHsqldb() throws SQLException - { - for (HSQLDBDataSource ds : dataSources) - { - Connection connection = null; - Statement statement = null; - - try - { - connection = ds.getConnection(); - statement = connection.createStatement(); - statement.execute("SHUTDOWN"); - } - finally - { - DBUtil.close(statement); - DBUtil.close(connection); - } - } - - dataSources.clear(); - } - - @Override - protected void initRepositoryProperties(Map props) - { - super.initRepositoryProperties(props); - props.put(Props.SUPPORTING_AUDITS, "true"); - } - } } Index: src/org/eclipse/emf/cdo/tests/db/DISABLE_FeatureMapTest.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/DISABLE_FeatureMapTest.java (revision 8672) +++ src/org/eclipse/emf/cdo/tests/db/DISABLE_FeatureMapTest.java (working copy) @@ -21,7 +21,7 @@ @Override public void testFeatureMaps() throws Exception { - skipConfig(AllTestsDBPsql.Psql.INSTANCE); + skipTest(getRepositoryConfig() instanceof PostgresqlConfig); super.testFeatureMaps(); } } Index: src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java (revision 8725) +++ src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java (working copy) @@ -10,12 +10,8 @@ */ package org.eclipse.emf.cdo.tests.db; -import org.eclipse.emf.cdo.server.IRepository; -import org.eclipse.emf.cdo.server.IStore; -import org.eclipse.emf.cdo.server.db.CDODBUtil; -import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; +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.OfflineConfig; import org.eclipse.emf.cdo.tests.offline.Bugzilla_319552_Test; import org.eclipse.emf.cdo.tests.offline.Bugzilla_325097_Test; import org.eclipse.emf.cdo.tests.offline.Bugzilla_326047_Test; @@ -26,24 +22,7 @@ import org.eclipse.emf.cdo.tests.offline.OfflineRawTest; import org.eclipse.emf.cdo.tests.offline.OfflineTest; -import org.eclipse.net4j.db.DBUtil; -import org.eclipse.net4j.db.IDBAdapter; -import org.eclipse.net4j.db.h2.H2Adapter; -import org.eclipse.net4j.util.WrappedException; -import org.eclipse.net4j.util.container.IPluginContainer; -import org.eclipse.net4j.util.io.IOUtil; -import org.eclipse.net4j.util.io.TMPUtil; - -import org.h2.jdbcx.JdbcDataSource; - -import javax.sql.DataSource; - -import java.io.File; -import java.sql.Connection; -import java.sql.Statement; -import java.util.ArrayList; import java.util.List; -import java.util.Map; import junit.framework.Test; import junit.framework.TestSuite; @@ -59,28 +38,14 @@ } @Override - protected boolean hasAuditSupport() - { - return true; - } - - @Override - protected boolean hasBranchingSupport() - { - return true; - } - - @Override protected void initConfigSuites(TestSuite parent) { - addScenario(parent, COMBINED, H2Offline.ReusableFolder.INSTANCE, JVM, NATIVE); + addScenario(parent, COMBINED, new H2OfflineConfig(), JVM, NATIVE); } @Override - protected void initTestClasses(List> testClasses) + protected void initTestClasses(List> testClasses, IScenario scenario) { - // super.initTestClasses(testClasses); - testClasses.add(OfflineTest.class); testClasses.add(OfflineRawTest.class); testClasses.add(OfflineDelayedTest.class); @@ -93,171 +58,4 @@ testClasses.add(FailoverTest.class); } - - /** - * @author Eike Stepper - */ - public static class H2Offline extends OfflineConfig - { - public static final H2Offline INSTANCE = new H2Offline("DBStore: H2 (offline)"); - - private static final long serialVersionUID = 1L; - - protected transient File dbFolder; - - public H2Offline(String name) - { - super(name); - } - - @Override - protected void initRepositoryProperties(Map props) - { - super.initRepositoryProperties(props); - props.put(IRepository.Props.SUPPORTING_AUDITS, "true"); - props.put(IRepository.Props.SUPPORTING_BRANCHES, "true"); - } - - public IStore createStore(String repoName) - { - IMappingStrategy mappingStrategy = createMappingStrategy(); - IDBAdapter dbAdapter = createDBAdapter(); - DataSource dataSource = createDataSource(repoName); - return CDODBUtil.createStore(mappingStrategy, dbAdapter, DBUtil.createConnectionProvider(dataSource)); - } - - protected IMappingStrategy createMappingStrategy() - { - return CDODBUtil.createHorizontalMappingStrategy(true, true); - } - - protected IDBAdapter createDBAdapter() - { - return new H2Adapter(); - } - - protected DataSource createDataSource(String repoName) - { - if (dbFolder == null) - { - dbFolder = createDBFolder(); - tearDownClean(); - } - - JdbcDataSource dataSource = new JdbcDataSource(); - dataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName); - return dataSource; - } - - @Override - public void setUp() throws Exception - { - CDODBUtil.prepareContainer(IPluginContainer.INSTANCE); - super.setUp(); - } - - protected void tearDownClean() - { - IOUtil.delete(dbFolder); - } - - protected File createDBFolder() - { - return TMPUtil.createTempFolder("h2_", "_test"); - } - - /** - * @author Eike Stepper - */ - public static class ReusableFolder extends H2Offline - { - private static final long serialVersionUID = 1L; - - public static final ReusableFolder INSTANCE = new ReusableFolder("DBStore: H2 (offline)"); - - private static File reusableFolder; - - private static JdbcDataSource defaultDataSource; - - private transient ArrayList repoNames = new ArrayList(); - - public ReusableFolder(String name) - { - super(name); - } - - @Override - protected DataSource createDataSource(String repoName) - { - if (reusableFolder == null) - { - reusableFolder = createDBFolder(); - IOUtil.delete(reusableFolder); - } - - dbFolder = reusableFolder; - if (defaultDataSource == null) - { - defaultDataSource = new JdbcDataSource(); - defaultDataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test"); - } - - Connection conn = null; - Statement stmt = null; - - try - { - conn = defaultDataSource.getConnection(); - stmt = conn.createStatement(); - stmt.execute("DROP SCHEMA IF EXISTS " + repoName); - stmt.execute("CREATE SCHEMA " + repoName); - } - catch (Exception e) - { - e.printStackTrace(); - } - finally - { - DBUtil.close(conn); - DBUtil.close(stmt); - } - - JdbcDataSource dataSource = new JdbcDataSource(); - dataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName); - return dataSource; - } - - @Override - protected void tearDownClean() - { - for (String repoName : repoNames) - { - tearDownClean(repoName); - } - } - - protected void tearDownClean(String repoName) - { - reusableFolder.deleteOnExit(); - Connection connection = null; - Statement stmt = null; - - try - { - connection = defaultDataSource.getConnection(); - stmt = connection.createStatement(); - stmt.execute("DROP SCHEMA " + repoName); - } - catch (Exception ex) - { - throw WrappedException.wrap(ex); - } - finally - { - DBUtil.close(stmt); - DBUtil.close(connection); - } - } - } - } } Index: src/org/eclipse/emf/cdo/tests/db/DISABLE_XRefTest.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/DISABLE_XRefTest.java (revision 8672) +++ src/org/eclipse/emf/cdo/tests/db/DISABLE_XRefTest.java (working copy) @@ -11,7 +11,6 @@ package org.eclipse.emf.cdo.tests.db; import org.eclipse.emf.cdo.tests.XRefTest; -import org.eclipse.emf.cdo.tests.db.AllTestsDBH2.H2; /** * @author Eike Stepper @@ -22,7 +21,7 @@ protected void doSetUp() throws Exception { super.doSetUp(); - skipConfig(H2.ReusableFolder.RANGE_INSTANCE); + // skipConfig(H2Config.RANGE_INSTANCE); } // @Override Index: src/org/eclipse/emf/cdo/tests/db/AutomatedTests.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/AutomatedTests.java (revision 8672) +++ src/org/eclipse/emf/cdo/tests/db/AutomatedTests.java (working copy) @@ -22,7 +22,7 @@ { TestSuite suite = new TestSuite(AutomatedTests.class.getName()); suite.addTest(AllTestsDBH2NonAudit.suite()); - suite.addTest(AllTestsDBH2.suite()); + suite.addTest(AllTestsDBH2Audit.suite()); suite.addTest(AllTestsDBH2Branching.suite()); // suite.addTest(AllTestsDBH2Offline.suite()); // suite.addTest(AllTestsDBHsqldb.suite()); Index: src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Audit.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Audit.java (revision 8672) +++ src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Audit.java (working copy) @@ -11,25 +11,7 @@ */ package org.eclipse.emf.cdo.tests.db; -import org.eclipse.emf.cdo.server.IRepository; -import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; - -import org.eclipse.net4j.db.DBUtil; -import org.eclipse.net4j.db.IDBAdapter; -import org.eclipse.net4j.db.h2.H2Adapter; -import org.eclipse.net4j.util.WrappedException; -import org.eclipse.net4j.util.io.IOUtil; -import org.eclipse.net4j.util.io.TMPUtil; - -import org.h2.jdbcx.JdbcDataSource; - -import javax.sql.DataSource; - -import java.io.File; -import java.sql.Connection; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.Map; +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; import junit.framework.Test; import junit.framework.TestSuite; @@ -37,207 +19,17 @@ /** * @author Eike Stepper */ -public class AllTestsDBH2 extends DBConfigs +public class AllTestsDBH2Audit extends DBConfigs { public static Test suite() { - return new AllTestsDBH2().getTestSuite("CDO Tests (DBStore H2 Horizontal)"); + return new AllTestsDBH2Audit().getTestSuite("CDO Tests (DBStore H2 Horizontal)"); } @Override protected void initConfigSuites(TestSuite parent) { - addScenario(parent, COMBINED, AllTestsDBH2.H2.ReusableFolder.AUDIT_INSTANCE, JVM, NATIVE); - addScenario(parent, COMBINED, AllTestsDBH2.H2.ReusableFolder.RANGE_INSTANCE, JVM, NATIVE); - } - - @Override - protected boolean hasAuditSupport() - { - return true; - } - - @Override - protected boolean hasBranchingSupport() - { - return false; - } - - /** - * @author Eike Stepper - */ - public static class H2 extends DBStoreRepositoryConfig - { - private static final long serialVersionUID = 1L; - - public static final AllTestsDBH2.H2 INSTANCE = new H2("DBStore: H2 (audit)", - "org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategy"); - - protected transient File dbFolder; - - private String mappingStrategy; - - public H2(String name, String mappingStrategy) - { - super(name); - this.mappingStrategy = mappingStrategy; - } - - @Override - protected void initRepositoryProperties(Map props) - { - super.initRepositoryProperties(props); - props.put(IRepository.Props.SUPPORTING_AUDITS, "true"); - props.put(IRepository.Props.SUPPORTING_BRANCHES, "false"); - } - - @SuppressWarnings("unchecked") - @Override - protected IMappingStrategy createMappingStrategy() - { - try - { - Class clazz = (Class)Class.forName(mappingStrategy); - return clazz.newInstance(); - } - catch (Exception ex) - { - throw WrappedException.wrap(ex); - } - } - - @Override - protected IDBAdapter createDBAdapter() - { - return new H2Adapter(); - } - - @Override - protected DataSource createDataSource(String repoName) - { - if (dbFolder == null) - { - dbFolder = createDBFolder(); - tearDownClean(); - } - - JdbcDataSource dataSource = new JdbcDataSource(); - dataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName); - return dataSource; - } - - protected void tearDownClean() - { - IOUtil.delete(dbFolder); - } - - protected File createDBFolder() - { - return TMPUtil.createTempFolder("h2_", "_test"); - } - - /** - * @author Eike Stepper - */ - public static class ReusableFolder extends H2 - { - private static final long serialVersionUID = 1L; - - public static final ReusableFolder AUDIT_INSTANCE = new ReusableFolder("DBStore: H2 (Reusable Folder, audit), ", - "org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategy"); - - public static final ReusableFolder RANGE_INSTANCE = new ReusableFolder( - "DBStore: H2 (Reusable Folder, audit, range-based mapping strategy)", - "org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategyWithRanges"); - - private static File reusableFolder; - - private static JdbcDataSource defaultDataSource; - - private transient ArrayList repoNames = new ArrayList(); - - public ReusableFolder(String name, String mappingStrategy) - { - super(name, mappingStrategy); - } - - @Override - protected DataSource createDataSource(String repoName) - { - if (reusableFolder == null) - { - reusableFolder = createDBFolder(); - IOUtil.delete(reusableFolder); - } - - dbFolder = reusableFolder; - if (defaultDataSource == null) - { - defaultDataSource = new JdbcDataSource(); - defaultDataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test"); - } - - Connection conn = null; - Statement stmt = null; - - try - { - conn = defaultDataSource.getConnection(); - stmt = conn.createStatement(); - - if (!isRestarting()) - { - stmt.execute("DROP SCHEMA IF EXISTS " + repoName); - } - - stmt.execute("CREATE SCHEMA IF NOT EXISTS " + repoName); - } - catch (Exception e) - { - e.printStackTrace(); - } - finally - { - DBUtil.close(conn); - DBUtil.close(stmt); - } - - JdbcDataSource dataSource = new JdbcDataSource(); - dataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName); - return dataSource; - } - - @Override - protected void tearDownClean() - { - for (String repoName : repoNames) - { - tearDownClean(repoName); - } - } - - protected void tearDownClean(String repoName) - { - reusableFolder.deleteOnExit(); - Connection connection = null; - Statement stmt = null; - - try - { - connection = defaultDataSource.getConnection(); - stmt = connection.createStatement(); - stmt.execute("DROP SCHEMA " + repoName); - } - catch (Exception ex) - { - throw WrappedException.wrap(ex); - } - finally - { - DBUtil.close(stmt); - DBUtil.close(connection); - } - } - } + addScenario(parent, COMBINED, new H2Config(true, false, false, false, IDGenerationLocation.STORE), JVM, NATIVE); + addScenario(parent, COMBINED, new H2Config(true, false, true, false, IDGenerationLocation.STORE), JVM, NATIVE); } } Index: src/org/eclipse/emf/cdo/tests/db/AllTestsDBPsql.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/AllTestsDBPsql.java (revision 8672) +++ src/org/eclipse/emf/cdo/tests/db/AllTestsDBPsql.java (working copy) @@ -12,22 +12,7 @@ */ package org.eclipse.emf.cdo.tests.db; -import org.eclipse.emf.cdo.server.db.CDODBUtil; -import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; -import org.eclipse.emf.cdo.tests.db.bundle.OM; - -import org.eclipse.net4j.db.DBUtil; -import org.eclipse.net4j.db.IDBAdapter; -import org.eclipse.net4j.db.postgresql.PostgreSQLAdapter; -import org.eclipse.net4j.util.io.IOUtil; - -import org.postgresql.jdbc3.Jdbc3SimpleDataSource; - -import javax.sql.DataSource; - -import java.io.PrintWriter; -import java.sql.Connection; -import java.sql.SQLException; +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; import junit.framework.Test; import junit.framework.TestSuite; @@ -52,118 +37,6 @@ @Override protected void initConfigSuites(TestSuite parent) { - addScenario(parent, COMBINED, AllTestsDBPsql.Psql.INSTANCE, JVM, NATIVE); - } - - @Override - protected boolean hasAuditSupport() - { - return true; - } - - @Override - protected boolean hasBranchingSupport() - { - return false; - } - - /** - * @author Victor Roldan Betancort - */ - public static class Psql extends DBStoreRepositoryConfig - { - private static final long serialVersionUID = 1L; - - public static final AllTestsDBPsql.Psql INSTANCE = new Psql("PostgreSQL"); - - private transient Jdbc3SimpleDataSource dataSource; - - private transient Jdbc3SimpleDataSource setupDataSource; - - private String currentRepositoryName = "cdodb1"; - - public Psql(String name) - { - super(name); - } - - @Override - protected IMappingStrategy createMappingStrategy() - { - return CDODBUtil.createHorizontalMappingStrategy(false); - } - - @Override - protected IDBAdapter createDBAdapter() - { - return new PostgreSQLAdapter(); - } - - @Override - protected DataSource createDataSource(String repoName) - { - currentRepositoryName = repoName; - - dataSource = new Jdbc3SimpleDataSource(); - dataSource.setServerName("localhost"); - dataSource.setDatabaseName(currentRepositoryName); - dataSource.setUser("sa"); - dataSource.setPassword("sa"); - - try - { - dataSource.setLogWriter(new PrintWriter(System.err)); - } - catch (SQLException ex) - { - OM.LOG.warn(ex.getMessage()); - } - - dropDatabase(); - - return dataSource; - } - - @Override - protected void deactivateRepositories() - { - super.deactivateRepositories(); - dataSource = null; - setupDataSource = null; - dropDatabase(); - } - - private void dropDatabase() - { - Connection connection = null; - - try - { - connection = getSetupDataSource().getConnection(); - DBUtil.dropAllTables(connection, currentRepositoryName); - } - catch (SQLException ignore) - { - IOUtil.ERR().println(ignore); - } - finally - { - DBUtil.close(connection); - } - } - - private DataSource getSetupDataSource() - { - if (setupDataSource == null) - { - setupDataSource = new Jdbc3SimpleDataSource(); - setupDataSource.setServerName("localhost"); - setupDataSource.setDatabaseName(currentRepositoryName); - setupDataSource.setUser("sa"); - setupDataSource.setPassword("sa"); - } - - return setupDataSource; - } + addScenario(parent, COMBINED, new PostgresqlConfig(false, false, IDGenerationLocation.STORE), JVM, NATIVE); } } Index: src/org/eclipse/emf/cdo/tests/db/H2OfflineConfig.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/H2OfflineConfig.java (revision 0) +++ src/org/eclipse/emf/cdo/tests/db/H2OfflineConfig.java (revision 0) @@ -0,0 +1,141 @@ +/** + * 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.tests.db; + +import org.eclipse.emf.cdo.server.IStore; +import org.eclipse.emf.cdo.server.db.CDODBUtil; +import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; +import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig.OfflineConfig; + +import org.eclipse.net4j.db.DBUtil; +import org.eclipse.net4j.db.IDBAdapter; +import org.eclipse.net4j.db.h2.H2Adapter; +import org.eclipse.net4j.util.WrappedException; +import org.eclipse.net4j.util.container.IPluginContainer; +import org.eclipse.net4j.util.io.IOUtil; +import org.eclipse.net4j.util.io.TMPUtil; + +import org.h2.jdbcx.JdbcDataSource; + +import javax.sql.DataSource; + +import java.io.File; +import java.sql.Connection; +import java.sql.Statement; + +/** + * @author Eike Stepper + */ +public class H2OfflineConfig extends OfflineConfig +{ + private static final long serialVersionUID = 1L; + + private static File reusableFolder; + + private static JdbcDataSource defaultDataSource; + + public H2OfflineConfig() + { + super("H2Offline"); + } + + public IStore createStore(String repoName) + { + IMappingStrategy mappingStrategy = createMappingStrategy(); + IDBAdapter dbAdapter = createDBAdapter(); + DataSource dataSource = createDataSource(repoName); + return CDODBUtil.createStore(mappingStrategy, dbAdapter, DBUtil.createConnectionProvider(dataSource)); + } + + protected IMappingStrategy createMappingStrategy() + { + return CDODBUtil.createHorizontalMappingStrategy(); + } + + protected IDBAdapter createDBAdapter() + { + return new H2Adapter(); + } + + protected DataSource createDataSource(String repoName) + { + if (reusableFolder == null) + { + reusableFolder = createDBFolder(); + IOUtil.delete(reusableFolder); + } + + if (defaultDataSource == null) + { + defaultDataSource = new JdbcDataSource(); + defaultDataSource.setURL("jdbc:h2:" + reusableFolder.getAbsolutePath() + "/h2test"); + } + + Connection conn = null; + Statement stmt = null; + + try + { + conn = defaultDataSource.getConnection(); + stmt = conn.createStatement(); + stmt.execute("DROP SCHEMA IF EXISTS " + repoName); + stmt.execute("CREATE SCHEMA " + repoName); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + finally + { + DBUtil.close(conn); + DBUtil.close(stmt); + } + + JdbcDataSource dataSource = new JdbcDataSource(); + dataSource.setURL("jdbc:h2:" + reusableFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName); + return dataSource; + } + + @Override + public void setUp() throws Exception + { + CDODBUtil.prepareContainer(IPluginContainer.INSTANCE); + super.setUp(); + } + + protected File createDBFolder() + { + return TMPUtil.createTempFolder("h2_", "_test"); + } + + protected void tearDownClean(String repoName) + { + reusableFolder.deleteOnExit(); + Connection connection = null; + Statement stmt = null; + + try + { + connection = defaultDataSource.getConnection(); + stmt = connection.createStatement(); + stmt.execute("DROP SCHEMA " + repoName); + } + catch (Exception ex) + { + throw WrappedException.wrap(ex); + } + finally + { + DBUtil.close(stmt); + DBUtil.close(connection); + } + } +} Index: src/org/eclipse/emf/cdo/tests/db/H2Config.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/H2Config.java (revision 0) +++ src/org/eclipse/emf/cdo/tests/db/H2Config.java (revision 0) @@ -0,0 +1,104 @@ +/** + * 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.tests.db; + +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; + +import org.eclipse.net4j.db.DBUtil; +import org.eclipse.net4j.db.IDBAdapter; +import org.eclipse.net4j.db.h2.H2Adapter; +import org.eclipse.net4j.util.io.IOUtil; +import org.eclipse.net4j.util.io.TMPUtil; + +import org.h2.jdbcx.JdbcDataSource; + +import javax.sql.DataSource; + +import java.io.File; +import java.sql.Connection; +import java.sql.Statement; + +/** + * @author Eike Stepper + */ +public class H2Config extends DBConfig +{ + private static final long serialVersionUID = 1L; + + private static File reusableFolder; + + private static JdbcDataSource defaultDataSource; + + protected transient File dbFolder; + + public H2Config(boolean supportingAudits, boolean supportingBranches, boolean withRanges, boolean copyOnBranch, + IDGenerationLocation idGenerationLocation) + { + super("H2", supportingAudits, supportingBranches, withRanges, copyOnBranch, idGenerationLocation); + } + + @Override + protected IDBAdapter createDBAdapter() + { + return new H2Adapter(); + } + + @Override + protected DataSource createDataSource(String repoName) + { + if (reusableFolder == null) + { + reusableFolder = createDBFolder(); + IOUtil.delete(reusableFolder); + } + + dbFolder = reusableFolder; + if (defaultDataSource == null) + { + defaultDataSource = new JdbcDataSource(); + defaultDataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test"); + } + + Connection conn = null; + Statement stmt = null; + + try + { + conn = defaultDataSource.getConnection(); + stmt = conn.createStatement(); + + if (!isRestarting()) + { + stmt.execute("DROP SCHEMA IF EXISTS " + repoName); + } + + stmt.execute("CREATE SCHEMA IF NOT EXISTS " + repoName); + } + catch (Exception e) + { + e.printStackTrace(); + } + finally + { + DBUtil.close(conn); + DBUtil.close(stmt); + } + + JdbcDataSource dataSource = new JdbcDataSource(); + dataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName); + return dataSource; + } + + protected File createDBFolder() + { + return TMPUtil.createTempFolder("h2_", "_test"); + } +} Index: src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysql.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysql.java (revision 8672) +++ src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysql.java (working copy) @@ -11,28 +11,14 @@ */ package org.eclipse.emf.cdo.tests.db; -import org.eclipse.emf.cdo.server.IRepository.Props; -import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; -import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingMappingStrategyWithRanges; +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; import org.eclipse.emf.cdo.tests.BranchingSameSessionTest; import org.eclipse.emf.cdo.tests.BranchingTest; import org.eclipse.emf.cdo.tests.MergingTest; +import org.eclipse.emf.cdo.tests.config.IScenario; import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; -import org.eclipse.net4j.db.DBUtil; -import org.eclipse.net4j.db.IDBAdapter; -import org.eclipse.net4j.db.mysql.MYSQLAdapter; - -import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; - -import javax.sql.DataSource; - -import java.sql.Connection; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; import java.util.List; -import java.util.Map; import junit.framework.Test; import junit.framework.TestSuite; @@ -42,17 +28,6 @@ */ public class AllTestsDBMysql extends DBConfigs { - /** - * Instructions to test with MySQL: - create a mysql instance - set HOST to the host where the DB is running - * (listening on TCP) - set USER to a user who can create and drop databases (root, essentially) - set PASS to the - * password of the said user - */ - public static final String HOST = "localhost"; - - public static final String USER = "root"; - - public static final String PASS = "root"; - public static Test suite() { return new AllTestsDBMysql().getTestSuite("CDO Tests (DBStore MySql Horizontal)"); @@ -61,156 +36,17 @@ @Override protected void initConfigSuites(TestSuite parent) { - addScenario(parent, COMBINED, AllTestsDBMysql.Mysql.INSTANCE, JVM, NATIVE); - } - - @Override - protected boolean hasAuditSupport() - { - return true; + addScenario(parent, COMBINED, new MysqlConfig(false, false, IDGenerationLocation.STORE), JVM, NATIVE); } @Override - protected boolean hasBranchingSupport() - { - return true; - } - - @Override - protected void initTestClasses(List> testClasses) + protected void initTestClasses(List> testClasses, IScenario scenario) { // add branching tests for this testsuite testClasses.add(BranchingTest.class); testClasses.add(BranchingSameSessionTest.class); testClasses.add(MergingTest.class); - super.initTestClasses(testClasses); - } - - /** - * @author Simon McDuff - */ - public static class Mysql extends DBStoreRepositoryConfig - { - private static final long serialVersionUID = 1L; - - public static final AllTestsDBMysql.Mysql INSTANCE = new Mysql("DBStore: Mysql"); - - private transient DataSource setupDataSource; - - private transient List databases = new ArrayList(); - - public Mysql(String name) - { - super(name); - } - - @Override - protected IMappingStrategy createMappingStrategy() - { - return new HorizontalBranchingMappingStrategyWithRanges(); - } - - @Override - protected IDBAdapter createDBAdapter() - { - return new MYSQLAdapter(); - } - - @Override - protected DataSource createDataSource(String repoName) - { - MysqlDataSource ds = new MysqlDataSource(); - - initDatabase("test_" + repoName); - - ds.setUrl("jdbc:mysql://" + HOST + "/test_" + repoName); - ds.setUser(USER); - if (PASS != null) - { - ds.setPassword(PASS); - } - - return ds; - } - - private void initDatabase(String dbName) - { - dropDatabase(dbName); - Connection connection = null; - Statement stmt = null; - - try - { - connection = getSetupDataSource().getConnection(); - stmt = connection.createStatement(); - stmt.execute("create database " + dbName); - } - catch (SQLException ignore) - { - } - finally - { - DBUtil.close(stmt); - DBUtil.close(connection); - } - } - - @Override - protected void deactivateRepositories() - { - super.deactivateRepositories(); - for (String dbName : databases) - { - dropDatabase(dbName); - } - } - - private void dropDatabase(String dbName) - { - Connection connection = null; - Statement stmt = null; - - try - { - connection = getSetupDataSource().getConnection(); - stmt = connection.createStatement(); - stmt.execute("DROP database " + dbName); - } - catch (SQLException ignore) - { - } - finally - { - DBUtil.close(stmt); - DBUtil.close(connection); - } - } - - private DataSource getSetupDataSource() - { - if (setupDataSource == null) - { - MysqlDataSource ds = new MysqlDataSource(); - ds.setUrl("jdbc:mysql://" + HOST); - ds.setUser(USER); - if (PASS != null) - { - ds.setPassword(PASS); - } - - setupDataSource = ds; - } - - return setupDataSource; - } - - @Override - protected void initRepositoryProperties(Map props) - { - super.initRepositoryProperties(props); - props.put(Props.SUPPORTING_AUDITS, "true"); - props.put(Props.SUPPORTING_BRANCHES, "true"); - } + super.initTestClasses(testClasses, scenario); } } Index: src/org/eclipse/emf/cdo/tests/db/PostgresqlConfig.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/PostgresqlConfig.java (revision 0) +++ src/org/eclipse/emf/cdo/tests/db/PostgresqlConfig.java (revision 0) @@ -0,0 +1,120 @@ +/** + * 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.tests.db; + +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; +import org.eclipse.emf.cdo.tests.db.bundle.OM; + +import org.eclipse.net4j.db.DBUtil; +import org.eclipse.net4j.db.IDBAdapter; +import org.eclipse.net4j.db.postgresql.PostgreSQLAdapter; +import org.eclipse.net4j.util.io.IOUtil; + +import org.postgresql.jdbc3.Jdbc3SimpleDataSource; + +import javax.sql.DataSource; + +import java.io.PrintWriter; +import java.sql.Connection; +import java.sql.SQLException; + +/** + * @author Victor Roldan Betancort + */ +public class PostgresqlConfig extends DBConfig +{ + private static final long serialVersionUID = 1L; + + private transient Jdbc3SimpleDataSource dataSource; + + private transient Jdbc3SimpleDataSource setupDataSource; + + private String currentRepositoryName = "cdodb1"; + + public PostgresqlConfig(boolean supportingAudits, boolean supportingBranches, + IDGenerationLocation idGenerationLocation) + { + super("Postgresql", supportingAudits, supportingBranches, false, false, idGenerationLocation); + } + + @Override + protected IDBAdapter createDBAdapter() + { + return new PostgreSQLAdapter(); + } + + @Override + protected DataSource createDataSource(String repoName) + { + currentRepositoryName = repoName; + + dataSource = new Jdbc3SimpleDataSource(); + dataSource.setServerName("localhost"); + dataSource.setDatabaseName(currentRepositoryName); + dataSource.setUser("sa"); + dataSource.setPassword("sa"); + + try + { + dataSource.setLogWriter(new PrintWriter(System.err)); + } + catch (SQLException ex) + { + OM.LOG.warn(ex.getMessage()); + } + + dropDatabase(); + + return dataSource; + } + + @Override + protected void deactivateRepositories() + { + super.deactivateRepositories(); + dataSource = null; + setupDataSource = null; + dropDatabase(); + } + + private void dropDatabase() + { + Connection connection = null; + + try + { + connection = getSetupDataSource().getConnection(); + DBUtil.dropAllTables(connection, currentRepositoryName); + } + catch (SQLException ignore) + { + IOUtil.ERR().println(ignore); + } + finally + { + DBUtil.close(connection); + } + } + + private DataSource getSetupDataSource() + { + if (setupDataSource == null) + { + setupDataSource = new Jdbc3SimpleDataSource(); + setupDataSource.setServerName("localhost"); + setupDataSource.setDatabaseName(currentRepositoryName); + setupDataSource.setUser("sa"); + setupDataSource.setPassword("sa"); + } + + return setupDataSource; + } +} Index: CDO AllTests (H2 audit).launch =================================================================== --- CDO AllTests (H2 audit).launch (revision 8672) +++ CDO AllTests (H2 audit).launch (working copy) @@ -1,7 +1,7 @@ - + @@ -10,7 +10,7 @@ - + Index: src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2.java (revision 8672) +++ src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2.java (working copy) @@ -1,243 +0,0 @@ -/** - * 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: - * Eike Stepper - initial API and implementation - * Stefan Winkler - introduced variable mapping strategies - */ -package org.eclipse.emf.cdo.tests.db; - -import org.eclipse.emf.cdo.server.IRepository; -import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; - -import org.eclipse.net4j.db.DBUtil; -import org.eclipse.net4j.db.IDBAdapter; -import org.eclipse.net4j.db.h2.H2Adapter; -import org.eclipse.net4j.util.WrappedException; -import org.eclipse.net4j.util.io.IOUtil; -import org.eclipse.net4j.util.io.TMPUtil; - -import org.h2.jdbcx.JdbcDataSource; - -import javax.sql.DataSource; - -import java.io.File; -import java.sql.Connection; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.Map; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * @author Eike Stepper - */ -public class AllTestsDBH2 extends DBConfigs -{ - public static Test suite() - { - return new AllTestsDBH2().getTestSuite("CDO Tests (DBStore H2 Horizontal)"); - } - - @Override - protected void initConfigSuites(TestSuite parent) - { - addScenario(parent, COMBINED, AllTestsDBH2.H2.ReusableFolder.AUDIT_INSTANCE, JVM, NATIVE); - addScenario(parent, COMBINED, AllTestsDBH2.H2.ReusableFolder.RANGE_INSTANCE, JVM, NATIVE); - } - - @Override - protected boolean hasAuditSupport() - { - return true; - } - - @Override - protected boolean hasBranchingSupport() - { - return false; - } - - /** - * @author Eike Stepper - */ - public static class H2 extends DBStoreRepositoryConfig - { - private static final long serialVersionUID = 1L; - - public static final AllTestsDBH2.H2 INSTANCE = new H2("DBStore: H2 (audit)", - "org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategy"); - - protected transient File dbFolder; - - private String mappingStrategy; - - public H2(String name, String mappingStrategy) - { - super(name); - this.mappingStrategy = mappingStrategy; - } - - @Override - protected void initRepositoryProperties(Map props) - { - super.initRepositoryProperties(props); - props.put(IRepository.Props.SUPPORTING_AUDITS, "true"); - props.put(IRepository.Props.SUPPORTING_BRANCHES, "false"); - } - - @SuppressWarnings("unchecked") - @Override - protected IMappingStrategy createMappingStrategy() - { - try - { - Class clazz = (Class)Class.forName(mappingStrategy); - return clazz.newInstance(); - } - catch (Exception ex) - { - throw WrappedException.wrap(ex); - } - } - - @Override - protected IDBAdapter createDBAdapter() - { - return new H2Adapter(); - } - - @Override - protected DataSource createDataSource(String repoName) - { - if (dbFolder == null) - { - dbFolder = createDBFolder(); - tearDownClean(); - } - - JdbcDataSource dataSource = new JdbcDataSource(); - dataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName); - return dataSource; - } - - protected void tearDownClean() - { - IOUtil.delete(dbFolder); - } - - protected File createDBFolder() - { - return TMPUtil.createTempFolder("h2_", "_test"); - } - - /** - * @author Eike Stepper - */ - public static class ReusableFolder extends H2 - { - private static final long serialVersionUID = 1L; - - public static final ReusableFolder AUDIT_INSTANCE = new ReusableFolder("DBStore: H2 (Reusable Folder, audit), ", - "org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategy"); - - public static final ReusableFolder RANGE_INSTANCE = new ReusableFolder( - "DBStore: H2 (Reusable Folder, audit, range-based mapping strategy)", - "org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategyWithRanges"); - - private static File reusableFolder; - - private static JdbcDataSource defaultDataSource; - - private transient ArrayList repoNames = new ArrayList(); - - public ReusableFolder(String name, String mappingStrategy) - { - super(name, mappingStrategy); - } - - @Override - protected DataSource createDataSource(String repoName) - { - if (reusableFolder == null) - { - reusableFolder = createDBFolder(); - IOUtil.delete(reusableFolder); - } - - dbFolder = reusableFolder; - if (defaultDataSource == null) - { - defaultDataSource = new JdbcDataSource(); - defaultDataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test"); - } - - Connection conn = null; - Statement stmt = null; - - try - { - conn = defaultDataSource.getConnection(); - stmt = conn.createStatement(); - - if (!isRestarting()) - { - stmt.execute("DROP SCHEMA IF EXISTS " + repoName); - } - - stmt.execute("CREATE SCHEMA IF NOT EXISTS " + repoName); - } - catch (Exception e) - { - e.printStackTrace(); - } - finally - { - DBUtil.close(conn); - DBUtil.close(stmt); - } - - JdbcDataSource dataSource = new JdbcDataSource(); - dataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName); - return dataSource; - } - - @Override - protected void tearDownClean() - { - for (String repoName : repoNames) - { - tearDownClean(repoName); - } - } - - protected void tearDownClean(String repoName) - { - reusableFolder.deleteOnExit(); - Connection connection = null; - Statement stmt = null; - - try - { - connection = defaultDataSource.getConnection(); - stmt = connection.createStatement(); - stmt.execute("DROP SCHEMA " + repoName); - } - catch (Exception ex) - { - throw WrappedException.wrap(ex); - } - finally - { - DBUtil.close(stmt); - DBUtil.close(connection); - } - } - } - } -} Index: src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java (revision 8672) +++ src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java (working copy) @@ -68,10 +68,10 @@ public void testLengthAnnotationNegative() throws Exception { // HSQL does not support length annotations - skipConfig(AllTestsDBHsqldb.Hsqldb.INSTANCE); - skipConfig(AllTestsDBHsqldbNonAudit.HsqldbNonAudit.INSTANCE); + skipTest(getRepositoryConfig() instanceof HsqldbConfig); + // XXX PSQL fails, too - need to investigate - skipConfig(AllTestsDBPsql.Psql.INSTANCE); + skipTest(getRepositoryConfig() instanceof PostgresqlConfig); msg("Opening session"); EPackage model1 = createModel(); @@ -111,7 +111,7 @@ public void testLengthAnnotationByMetaData() throws CommitException { // XXX [PSQL] disabled because of Bug 290095 - skipConfig(AllTestsDBPsql.Psql.INSTANCE); + skipTest(getRepositoryConfig() instanceof PostgresqlConfig); msg("Opening session"); final EPackage model1 = createModel(); @@ -152,11 +152,10 @@ public void testTypeAnnotationByMetaData() throws CommitException { // XXX [PSQL] disabled because of Bug 290095 - skipConfig(AllTestsDBPsql.Psql.INSTANCE); + skipTest(getRepositoryConfig() instanceof PostgresqlConfig); // HSQL does not support type annotations - skipConfig(AllTestsDBHsqldb.Hsqldb.INSTANCE); - skipConfig(AllTestsDBHsqldbNonAudit.HsqldbNonAudit.INSTANCE); + skipTest(getRepositoryConfig() instanceof HsqldbConfig); msg("Opening session"); final EPackage model1 = createModel(); @@ -197,7 +196,7 @@ public void testTableNameAnnotationByMetaData() throws CommitException { // XXX [PSQL] disabled because of Bug 290095 - skipConfig(AllTestsDBPsql.Psql.INSTANCE); + skipTest(getRepositoryConfig() instanceof PostgresqlConfig); msg("Opening session"); EPackage model1 = createModel(); @@ -237,7 +236,7 @@ public void testColumnNameAnnotationByMetaData() throws CommitException { // XXX [PSQL] disabled because of Bug 290095 - skipConfig(AllTestsDBPsql.Psql.INSTANCE); + skipTest(getRepositoryConfig() instanceof PostgresqlConfig); msg("Opening session"); final EPackage model1 = createModel(); @@ -278,11 +277,10 @@ public void testColumnNameTypeAnnotationByMetaData() throws CommitException { // HSQL does not support type annotations - skipConfig(AllTestsDBHsqldb.Hsqldb.INSTANCE); - skipConfig(AllTestsDBHsqldbNonAudit.HsqldbNonAudit.INSTANCE); + skipTest(getRepositoryConfig() instanceof HsqldbConfig); // XXX [PSQL] disabled because of Bug 290095 - skipConfig(AllTestsDBPsql.Psql.INSTANCE); + skipTest(getRepositoryConfig() instanceof PostgresqlConfig); msg("Opening session"); final EPackage model1 = createModel(); Index: src/org/eclipse/emf/cdo/tests/db/AllTestsDBDerby.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/AllTestsDBDerby.java (revision 8672) +++ src/org/eclipse/emf/cdo/tests/db/AllTestsDBDerby.java (working copy) @@ -10,27 +10,7 @@ */ package org.eclipse.emf.cdo.tests.db; -import org.eclipse.emf.cdo.server.IRepository; -import org.eclipse.emf.cdo.server.db.CDODBUtil; -import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; - -import org.eclipse.net4j.db.DBUtil; -import org.eclipse.net4j.db.IDBAdapter; -import org.eclipse.net4j.db.derby.EmbeddedDerbyAdapter; -import org.eclipse.net4j.util.WrappedException; -import org.eclipse.net4j.util.io.IOUtil; -import org.eclipse.net4j.util.io.TMPUtil; - -import org.apache.derby.jdbc.EmbeddedDataSource; - -import javax.sql.DataSource; - -import java.io.File; -import java.sql.Connection; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; import junit.framework.Test; import junit.framework.TestSuite; @@ -48,174 +28,7 @@ @Override protected void initConfigSuites(TestSuite parent) { - addScenario(parent, COMBINED, AllTestsDBDerby.Derby.ReusableFolder.INSTANCE, JVM, NATIVE); + addScenario(parent, COMBINED, new DerbyConfig(true, true, IDGenerationLocation.STORE), JVM, NATIVE); // addScenario(parent, COMBINED, AllTestsDBDerby.Derby.INSTANCE, TCP, NATIVE); } - - @Override - protected boolean hasAuditSupport() - { - return true; - } - - @Override - protected boolean hasBranchingSupport() - { - return false; - } - - /** - * @author Eike Stepper - */ - public static class Derby extends DBStoreRepositoryConfig - { - private static final long serialVersionUID = 1L; - - public static final AllTestsDBDerby.Derby INSTANCE = new Derby("DBStore: Derby"); - - private transient ArrayList dbFolders = new ArrayList(); - - public Derby(String name) - { - super(name); - } - - @Override - protected IMappingStrategy createMappingStrategy() - { - return CDODBUtil.createHorizontalMappingStrategy(true); - } - - @Override - protected IDBAdapter createDBAdapter() - { - return new EmbeddedDerbyAdapter(); - } - - @Override - protected void initRepositoryProperties(Map props) - { - super.initRepositoryProperties(props); - props.put(IRepository.Props.SUPPORTING_AUDITS, "true"); - } - - @Override - protected DataSource createDataSource(String repoName) - { - File dbFolder = createDBFolder(repoName); - dbFolders.add(dbFolder); - - tearDownClean(dbFolder); - - EmbeddedDataSource dataSource = new EmbeddedDataSource(); - dataSource.setDatabaseName(dbFolder.getAbsolutePath()); - dataSource.setCreateDatabase("create"); - - return dataSource; - } - - public Collection getDbFolders() - { - return dbFolders; - } - - @Override - protected void deactivateRepositories() - { - for (File folder : getDbFolders()) - { - tearDownClean(folder); - } - - super.deactivateRepositories(); - } - - protected void tearDownClean(File dbFolder) - { - IOUtil.delete(dbFolder); - } - - protected File createDBFolder(String repo) - { - return TMPUtil.createTempFolder("derby_" + repo + "_", "_test"); - } - - /** - * @author Eike Stepper - */ - public static class ReusableFolder extends Derby - { - private static final long serialVersionUID = 1L; - - public static final ReusableFolder INSTANCE = new ReusableFolder("DBStore: Derby"); - - private static HashMap dbFolders = new HashMap(); - - private static HashMap dataSources = new HashMap(); - - public ReusableFolder(String name) - { - super(name); - } - - @Override - protected DataSource createDataSource(String repoName) - { - File reusableFolder = dbFolders.get(repoName); - - boolean needsNewFolder = reusableFolder == null; - if (needsNewFolder) - { - reusableFolder = createDBFolder(repoName); - IOUtil.delete(reusableFolder); - dbFolders.put(repoName, reusableFolder); - } - - EmbeddedDataSource dataSource = new EmbeddedDataSource(); - dataSource.setDatabaseName(reusableFolder.getAbsolutePath()); - dataSource.setCreateDatabase("create"); - dataSources.put(reusableFolder, dataSource); - - if (!needsNewFolder) - { - tearDownClean(reusableFolder); - } - - return dataSource; - } - - @Override - public Collection getDbFolders() - { - return dbFolders.values(); - } - - @Override - protected void tearDownClean(File folder) - { - folder.deleteOnExit(); - Connection connection = null; - - EmbeddedDataSource dataSource = dataSources.get(folder); - - try - { - connection = dataSource.getConnection(); - DBUtil.dropAllTables(connection, dataSource.getDatabaseName()); - } - catch (RuntimeException ex) - { - throw ex; - } - catch (Exception ex) - { - throw WrappedException.wrap(ex); - } - finally - { - DBUtil.close(connection); - } - } - } - } } Index: src/org/eclipse/emf/cdo/tests/db/DBStoreRepositoryConfig.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/DBStoreRepositoryConfig.java (revision 8725) +++ src/org/eclipse/emf/cdo/tests/db/DBStoreRepositoryConfig.java (working copy) @@ -1,76 +0,0 @@ -/** - * 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: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.emf.cdo.tests.db; - -import org.eclipse.emf.cdo.server.IStore; -import org.eclipse.emf.cdo.server.db.CDODBUtil; -import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; -import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping; -import org.eclipse.emf.cdo.server.internal.db.mapping.TypeMappingRegistry; -import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig; - -import org.eclipse.net4j.db.DBUtil; -import org.eclipse.net4j.db.IDBAdapter; -import org.eclipse.net4j.util.container.IPluginContainer; - -import javax.sql.DataSource; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Eike Stepper - */ -public abstract class DBStoreRepositoryConfig extends RepositoryConfig -{ - private static final long serialVersionUID = 1L; - - public DBStoreRepositoryConfig(String name) - { - super(name); - } - - @Override - public void setUp() throws Exception - { - CDODBUtil.prepareContainer(IPluginContainer.INSTANCE); - super.setUp(); - ((TypeMappingRegistry)ITypeMapping.Registry.INSTANCE).init(); - } - - @Override - protected boolean isOptimizing() - { - return true; - } - - public IStore createStore(String repoName) - { - IMappingStrategy mappingStrategy = createMappingStrategy(); - mappingStrategy.setProperties(createMappingStrategyProperties()); - IDBAdapter dbAdapter = createDBAdapter(); - DataSource dataSource = createDataSource(repoName); - return CDODBUtil.createStore(mappingStrategy, dbAdapter, DBUtil.createConnectionProvider(dataSource)); - } - - protected Map createMappingStrategyProperties() - { - Map props = new HashMap(); - props.put(IMappingStrategy.PROP_QUALIFIED_NAMES, "true"); - return props; - } - - protected abstract IMappingStrategy createMappingStrategy(); - - protected abstract IDBAdapter createDBAdapter(); - - protected abstract DataSource createDataSource(String repoName); -} Index: src/org/eclipse/emf/cdo/tests/db/DISABLE_XATransactionTest.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/DISABLE_XATransactionTest.java (revision 8672) +++ src/org/eclipse/emf/cdo/tests/db/DISABLE_XATransactionTest.java (working copy) @@ -27,7 +27,7 @@ public void testCommitFromTransactionDisabled() throws Exception { // XXX disabled because of Bug 290097 - skipConfig(AllTestsDBPsql.Psql.INSTANCE); + skipTest(getRepositoryConfig() instanceof PostgresqlConfig); super.testCommitFromTransactionDisabled(); } @@ -36,7 +36,7 @@ public void test_ExceptionInReadingStream() throws Exception { // XXX disabled because of Bug 290097 - skipConfig(AllTestsDBPsql.Psql.INSTANCE); + skipTest(getRepositoryConfig() instanceof PostgresqlConfig); super.test_ExceptionInReadingStream(); } } Index: src/org/eclipse/emf/cdo/tests/db/MysqlConfig.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/MysqlConfig.java (revision 0) +++ src/org/eclipse/emf/cdo/tests/db/MysqlConfig.java (revision 0) @@ -0,0 +1,159 @@ +/** + * 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.tests.db; + +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; +import org.eclipse.emf.cdo.server.IRepository.Props; + +import org.eclipse.net4j.db.DBUtil; +import org.eclipse.net4j.db.IDBAdapter; +import org.eclipse.net4j.db.mysql.MYSQLAdapter; + +import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; + +import javax.sql.DataSource; + +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @author Simon McDuff + */ +public class MysqlConfig extends DBConfig +{ + private static final long serialVersionUID = 1L; + + private transient DataSource setupDataSource; + + private transient List databases = new ArrayList(); + + /** + * Instructions to test with MySQL: - create a mysql instance - set HOST to the host where the DB is running + * (listening on TCP) - set USER to a user who can create and drop databases (root, essentially) - set PASS to the + * password of the said user + */ + public static final String HOST = "localhost"; + + public static final String USER = "root"; + + public static final String PASS = "root"; + + public MysqlConfig(boolean supportingAudits, boolean supportingBranches, IDGenerationLocation idGenerationLocation) + { + super("Mysql", supportingAudits, supportingBranches, false, false, idGenerationLocation); + } + + @Override + protected IDBAdapter createDBAdapter() + { + return new MYSQLAdapter(); + } + + @Override + protected DataSource createDataSource(String repoName) + { + MysqlDataSource ds = new MysqlDataSource(); + + initDatabase("test_" + repoName); + + ds.setUrl("jdbc:mysql://" + MysqlConfig.HOST + "/test_" + repoName); + ds.setUser(MysqlConfig.USER); + if (MysqlConfig.PASS != null) + { + ds.setPassword(MysqlConfig.PASS); + } + + return ds; + } + + private void initDatabase(String dbName) + { + dropDatabase(dbName); + Connection connection = null; + Statement stmt = null; + + try + { + connection = getSetupDataSource().getConnection(); + stmt = connection.createStatement(); + stmt.execute("create database " + dbName); + } + catch (SQLException ignore) + { + } + finally + { + DBUtil.close(stmt); + DBUtil.close(connection); + } + } + + @Override + protected void deactivateRepositories() + { + super.deactivateRepositories(); + for (String dbName : databases) + { + dropDatabase(dbName); + } + } + + private void dropDatabase(String dbName) + { + Connection connection = null; + Statement stmt = null; + + try + { + connection = getSetupDataSource().getConnection(); + stmt = connection.createStatement(); + stmt.execute("DROP database " + dbName); + } + catch (SQLException ignore) + { + } + finally + { + DBUtil.close(stmt); + DBUtil.close(connection); + } + } + + private DataSource getSetupDataSource() + { + if (setupDataSource == null) + { + MysqlDataSource ds = new MysqlDataSource(); + ds.setUrl("jdbc:mysql://" + MysqlConfig.HOST); + ds.setUser(MysqlConfig.USER); + if (MysqlConfig.PASS != null) + { + ds.setPassword(MysqlConfig.PASS); + } + + setupDataSource = ds; + } + + return setupDataSource; + } + + @Override + protected void initRepositoryProperties(Map props) + { + super.initRepositoryProperties(props); + props.put(Props.SUPPORTING_AUDITS, "true"); + props.put(Props.SUPPORTING_BRANCHES, "true"); + } +} Index: src/org/eclipse/emf/cdo/tests/db/DerbyConfig.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/DerbyConfig.java (revision 0) +++ src/org/eclipse/emf/cdo/tests/db/DerbyConfig.java (revision 0) @@ -0,0 +1,125 @@ +/** + * 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.tests.db; + +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; + +import org.eclipse.net4j.db.DBUtil; +import org.eclipse.net4j.db.IDBAdapter; +import org.eclipse.net4j.db.derby.EmbeddedDerbyAdapter; +import org.eclipse.net4j.util.WrappedException; +import org.eclipse.net4j.util.io.IOUtil; +import org.eclipse.net4j.util.io.TMPUtil; + +import org.apache.derby.jdbc.EmbeddedDataSource; + +import javax.sql.DataSource; + +import java.io.File; +import java.sql.Connection; +import java.util.Collection; +import java.util.HashMap; + +/** + * @author Eike Stepper + */ +public class DerbyConfig extends DBConfig +{ + private static final long serialVersionUID = 1L; + + private static HashMap dbFolders = new HashMap(); + + private static HashMap dataSources = new HashMap(); + + public DerbyConfig(boolean supportingAudits, boolean supportingBranches, IDGenerationLocation idGenerationLocation) + { + super("Derby", supportingAudits, supportingBranches, false, false, idGenerationLocation); + } + + public Collection getDBFolders() + { + return dbFolders.values(); + } + + @Override + protected IDBAdapter createDBAdapter() + { + return new EmbeddedDerbyAdapter(); + } + + @Override + protected DataSource createDataSource(String repoName) + { + File reusableFolder = dbFolders.get(repoName); + + boolean needsNewFolder = reusableFolder == null; + if (needsNewFolder) + { + reusableFolder = createDBFolder(repoName); + IOUtil.delete(reusableFolder); + dbFolders.put(repoName, reusableFolder); + } + + EmbeddedDataSource dataSource = new EmbeddedDataSource(); + dataSource.setDatabaseName(reusableFolder.getAbsolutePath()); + dataSource.setCreateDatabase("create"); + dataSources.put(reusableFolder, dataSource); + + if (!needsNewFolder) + { + tearDownClean(reusableFolder); + } + + return dataSource; + } + + @Override + protected void deactivateRepositories() + { + for (File folder : getDBFolders()) + { + tearDownClean(folder); + } + + super.deactivateRepositories(); + } + + protected void tearDownClean(File folder) + { + folder.deleteOnExit(); + Connection connection = null; + + EmbeddedDataSource dataSource = dataSources.get(folder); + + try + { + connection = dataSource.getConnection(); + DBUtil.dropAllTables(connection, dataSource.getDatabaseName()); + } + catch (RuntimeException ex) + { + throw ex; + } + catch (Exception ex) + { + throw WrappedException.wrap(ex); + } + finally + { + DBUtil.close(connection); + } + } + + protected File createDBFolder(String repo) + { + return TMPUtil.createTempFolder("derby_" + repo + "_", "_test"); + } +} Index: CDO AllTests (H2 ALL).launch =================================================================== --- CDO AllTests (H2 ALL).launch (revision 0) +++ CDO AllTests (H2 ALL).launch (revision 0) @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + Index: src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2All.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2All.java (revision 8672) +++ src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2All.java (working copy) @@ -11,6 +11,8 @@ */ package org.eclipse.emf.cdo.tests.db; +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; + import junit.framework.Test; import junit.framework.TestSuite; @@ -27,20 +29,22 @@ @Override protected void initConfigSuites(TestSuite parent) { - addScenario(parent, COMBINED, AllTestsDBH2NonAudit.H2NonAudit.ReusableFolder.INSTANCE, JVM, NATIVE); - addScenario(parent, COMBINED, AllTestsDBH2.H2.ReusableFolder.RANGE_INSTANCE, JVM, NATIVE); - addScenario(parent, COMBINED, AllTestsDBH2Branching.H2Branching.ReusableFolder.INSTANCE, JVM, NATIVE); + addScenarios(parent, IDGenerationLocation.STORE); + addScenarios(parent, IDGenerationLocation.CLIENT); } - @Override - protected boolean hasAuditSupport() + private void addScenarios(TestSuite parent, IDGenerationLocation idGenerationLocation) { - return true; - } + // Non-audit + addScenario(parent, COMBINED, new H2Config(false, false, false, false, idGenerationLocation), JVM, NATIVE); - @Override - protected boolean hasBranchingSupport() - { - return false; + // Audit + addScenario(parent, COMBINED, new H2Config(true, false, false, false, idGenerationLocation), JVM, NATIVE); + addScenario(parent, COMBINED, new H2Config(true, false, true, false, idGenerationLocation), JVM, NATIVE); + + // Branching + addScenario(parent, COMBINED, new H2Config(true, true, false, false, idGenerationLocation), JVM, NATIVE); + addScenario(parent, COMBINED, new H2Config(true, true, true, false, idGenerationLocation), JVM, NATIVE); + addScenario(parent, COMBINED, new H2Config(true, true, true, true, idGenerationLocation), JVM, NATIVE); } } Index: src/org/eclipse/emf/cdo/tests/db/DBConfigs.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db/DBConfigs.java (revision 8672) +++ src/org/eclipse/emf/cdo/tests/db/DBConfigs.java (working copy) @@ -25,6 +25,7 @@ import org.eclipse.emf.cdo.tests.XRefTest; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_252214_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_303807_Test; +import org.eclipse.emf.cdo.tests.config.IScenario; import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; import java.util.List; @@ -35,7 +36,7 @@ public abstract class DBConfigs extends AllConfigs { @Override - protected void initTestClasses(List> testClasses) + protected void initTestClasses(List> testClasses, IScenario scenario) { testClasses.add(Net4jDBTest.class); testClasses.add(DBAnnotationsTest.class); @@ -43,10 +44,10 @@ testClasses.add(CustomTypeMappingTest.class); testClasses.add(SQLQueryTest.class); - super.initTestClasses(testClasses); + super.initTestClasses(testClasses, scenario); testClasses.remove(MEMStoreQueryTest.class); - if (!hasBranchingSupport()) + if (!scenario.getRepositoryConfig().isSupportingBranches()) { testClasses.remove(BranchingTest.class); testClasses.remove(BranchingSameSessionTest.class); @@ -54,7 +55,7 @@ testClasses.remove(Bugzilla_303807_Test.class); } - if (!hasAuditSupport()) + if (!scenario.getRepositoryConfig().isSupportingAudits()) { // non-audit mode - remove audit tests testClasses.remove(AuditTest.class); @@ -87,8 +88,4 @@ testClasses.remove(ExternalReferenceTest.class); testClasses.add(DISABLE_ExternalReferenceTest.class); } - - protected abstract boolean hasBranchingSupport(); - - protected abstract boolean hasAuditSupport(); } #P org.eclipse.emf.cdo.tests.mongodb Index: src/org/eclipse/emf/cdo/tests/mongodb/MongoDBStoreRepositoryConfig.java =================================================================== --- src/org/eclipse/emf/cdo/tests/mongodb/MongoDBStoreRepositoryConfig.java (revision 8725) +++ src/org/eclipse/emf/cdo/tests/mongodb/MongoDBStoreRepositoryConfig.java (working copy) @@ -1,118 +0,0 @@ -/** - * 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: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.emf.cdo.tests.mongodb; - -import org.eclipse.emf.cdo.server.CDOServerBrowser; -import org.eclipse.emf.cdo.server.IRepository; -import org.eclipse.emf.cdo.server.IStore; -import org.eclipse.emf.cdo.server.internal.mongodb.MongoDBStore; -import org.eclipse.emf.cdo.server.mongodb.CDOMongoDBUtil; -import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig; - -import org.eclipse.net4j.util.WrappedException; -import org.eclipse.net4j.util.container.IPluginContainer; - -import com.mongodb.DB; -import com.mongodb.Mongo; -import com.mongodb.MongoURI; - -import java.util.Map; - -/** - * @author Eike Stepper - */ -public class MongoDBStoreRepositoryConfig extends RepositoryConfig -{ - public static final MongoDBStoreRepositoryConfig INSTANCE = new MongoDBStoreRepositoryConfig(false, false); - - public static final MongoDBStoreRepositoryConfig AUDITING = new MongoDBStoreRepositoryConfig(true, false); - - public static final MongoDBStoreRepositoryConfig BRANCHING = new MongoDBStoreRepositoryConfig(true, true); - - private static final long serialVersionUID = 1L; - - private boolean auditing; - - private boolean branching; - - private transient CDOServerBrowser mongoBrowser; - - public MongoDBStoreRepositoryConfig(boolean auditing, boolean branching) - { - super("MongoDBStore" + (branching ? " (branching)" : auditing ? " (auditing)" : "")); - this.auditing = auditing; - this.branching = branching; - } - - @Override - public void setUp() throws Exception - { - CDOMongoDBUtil.prepareContainer(IPluginContainer.INSTANCE); - - mongoBrowser = new CDOServerBrowser(MongoDBStore.REPOS); - mongoBrowser.setPort(7778); - mongoBrowser.activate(); - - super.setUp(); - } - - @Override - public void tearDown() throws Exception - { - mongoBrowser.deactivate(); - super.tearDown(); - } - - public IStore createStore(String repoName) - { - MongoURI mongoURI = new MongoURI("mongodb://localhost"); - if (!isRestarting()) - { - dropDatabase(mongoURI, repoName); - } - - return CDOMongoDBUtil.createStore(mongoURI.toString(), repoName); - } - - protected void dropDatabase(MongoURI mongoURI, String repoName) - { - Mongo mongo = null; - - try - { - mongo = new Mongo(mongoURI); - DB db = mongo.getDB(repoName); - if (!db.getCollectionNames().isEmpty()) - { - db.dropDatabase(); - } - } - catch (Exception ex) - { - throw WrappedException.wrap(ex); - } - finally - { - if (mongo != null) - { - mongo.close(); - } - } - } - - @Override - protected void initRepositoryProperties(Map props) - { - super.initRepositoryProperties(props); - props.put(IRepository.Props.SUPPORTING_AUDITS, Boolean.toString(auditing)); - props.put(IRepository.Props.SUPPORTING_BRANCHES, Boolean.toString(branching)); - } -} Index: src/org/eclipse/emf/cdo/tests/mongodb/AllTestsMongoDB.java =================================================================== --- src/org/eclipse/emf/cdo/tests/mongodb/AllTestsMongoDB.java (revision 8584) +++ src/org/eclipse/emf/cdo/tests/mongodb/AllTestsMongoDB.java (working copy) @@ -11,8 +11,10 @@ */ package org.eclipse.emf.cdo.tests.mongodb; +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; import org.eclipse.emf.cdo.tests.AllConfigs; import org.eclipse.emf.cdo.tests.MEMStoreQueryTest; +import org.eclipse.emf.cdo.tests.config.IScenario; import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; import java.util.List; @@ -33,16 +35,16 @@ @Override protected void initConfigSuites(TestSuite parent) { - addScenario(parent, COMBINED, MongoDBStoreRepositoryConfig.INSTANCE, JVM, NATIVE); - addScenario(parent, COMBINED, MongoDBStoreRepositoryConfig.AUDITING, JVM, NATIVE); + addScenario(parent, COMBINED, new MongoDBConfig(false, false, IDGenerationLocation.STORE), JVM, NATIVE); + addScenario(parent, COMBINED, new MongoDBConfig(true, false, IDGenerationLocation.STORE), JVM, NATIVE); // addScenario(parent, COMBINED, MongoDBStoreRepositoryConfig.BRANCHING, JVM, NATIVE); } @Override - protected void initTestClasses(List> testClasses) + protected void initTestClasses(List> testClasses, IScenario scenario) { testClasses.add(MongoDBInitialTest.class); - super.initTestClasses(testClasses); + super.initTestClasses(testClasses, scenario); testClasses.remove(MEMStoreQueryTest.class); } } Index: src/org/eclipse/emf/cdo/tests/mongodb/MongoDBConfig.java =================================================================== --- src/org/eclipse/emf/cdo/tests/mongodb/MongoDBConfig.java (revision 8584) +++ src/org/eclipse/emf/cdo/tests/mongodb/MongoDBConfig.java (working copy) @@ -10,10 +10,8 @@ */ package org.eclipse.emf.cdo.tests.mongodb; -import org.eclipse.emf.cdo.server.CDOServerBrowser; -import org.eclipse.emf.cdo.server.IRepository; +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; import org.eclipse.emf.cdo.server.IStore; -import org.eclipse.emf.cdo.server.internal.mongodb.MongoDBStore; import org.eclipse.emf.cdo.server.mongodb.CDOMongoDBUtil; import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig; @@ -24,53 +22,25 @@ import com.mongodb.Mongo; import com.mongodb.MongoURI; -import java.util.Map; - /** * @author Eike Stepper */ -public class MongoDBStoreRepositoryConfig extends RepositoryConfig +public class MongoDBConfig extends RepositoryConfig { - public static final MongoDBStoreRepositoryConfig INSTANCE = new MongoDBStoreRepositoryConfig(false, false); - - public static final MongoDBStoreRepositoryConfig AUDITING = new MongoDBStoreRepositoryConfig(true, false); - - public static final MongoDBStoreRepositoryConfig BRANCHING = new MongoDBStoreRepositoryConfig(true, true); - private static final long serialVersionUID = 1L; - private boolean auditing; - - private boolean branching; - - private transient CDOServerBrowser mongoBrowser; - - public MongoDBStoreRepositoryConfig(boolean auditing, boolean branching) + public MongoDBConfig(boolean supportingAudits, boolean supportingBranches, IDGenerationLocation idGenerationLocation) { - super("MongoDBStore" + (branching ? " (branching)" : auditing ? " (auditing)" : "")); - this.auditing = auditing; - this.branching = branching; + super("MongoDB", supportingAudits, supportingBranches, idGenerationLocation); } @Override public void setUp() throws Exception { CDOMongoDBUtil.prepareContainer(IPluginContainer.INSTANCE); - - mongoBrowser = new CDOServerBrowser(MongoDBStore.REPOS); - mongoBrowser.setPort(7778); - mongoBrowser.activate(); - super.setUp(); } - @Override - public void tearDown() throws Exception - { - mongoBrowser.deactivate(); - super.tearDown(); - } - public IStore createStore(String repoName) { MongoURI mongoURI = new MongoURI("mongodb://localhost"); @@ -107,12 +77,4 @@ } } } - - @Override - protected void initRepositoryProperties(Map props) - { - super.initRepositoryProperties(props); - props.put(IRepository.Props.SUPPORTING_AUDITS, Boolean.toString(auditing)); - props.put(IRepository.Props.SUPPORTING_BRANCHES, Boolean.toString(branching)); - } } Property changes on: src\org\eclipse\emf\cdo\tests\mongodb\MongoDBConfig.java ___________________________________________________________________ Added: svn:mime-type + text/plain #P org.eclipse.emf.cdo.tests Index: src/org/eclipse/emf/cdo/tests/config/IRepositoryConfig.java =================================================================== --- src/org/eclipse/emf/cdo/tests/config/IRepositoryConfig.java (revision 8725) +++ src/org/eclipse/emf/cdo/tests/config/IRepositoryConfig.java (working copy) @@ -10,6 +10,7 @@ */ package org.eclipse.emf.cdo.tests.config; +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; import org.eclipse.emf.cdo.server.IStore; import org.eclipse.emf.cdo.spi.server.InternalRepository; @@ -22,6 +23,12 @@ { public static final String REPOSITORY_NAME = "repo1"; + public boolean isSupportingAudits(); + + public boolean isSupportingBranches(); + + public IDGenerationLocation getIDGenerationLocation(); + public Map getRepositoryProperties(); public InternalRepository getRepository(String name, boolean activate); Index: src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java =================================================================== --- src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java (revision 8719) +++ src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java (working copy) @@ -67,7 +67,7 @@ TestSuite suite = new TestSuite(scenario.toString()); List> testClasses = new ArrayList>(); - initTestClasses(testClasses); + initTestClasses(testClasses, scenario); for (Class testClass : testClasses) { @@ -98,7 +98,7 @@ // } // } - protected abstract void initTestClasses(List> testClasses); + protected abstract void initTestClasses(List> testClasses, IScenario scenario); /** * @author Eike Stepper Index: src/org/eclipse/emf/cdo/tests/defs/AllTestsCDODefs.java =================================================================== --- src/org/eclipse/emf/cdo/tests/defs/AllTestsCDODefs.java (revision 8719) +++ src/org/eclipse/emf/cdo/tests/defs/AllTestsCDODefs.java (working copy) @@ -11,6 +11,7 @@ */ package org.eclipse.emf.cdo.tests.defs; +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.ConfigTestSuite; @@ -36,7 +37,7 @@ } @Override - protected void initTestClasses(List> testClasses) + protected void initTestClasses(List> testClasses, IScenario scenario) { testClasses.add(EGlobalPackageDefImplTest.class); testClasses.add(CDOPackageRegistryDefImplTest.class); Index: src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java =================================================================== --- src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java (revision 8725) +++ src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java (working copy) @@ -11,6 +11,7 @@ */ package org.eclipse.emf.cdo.tests.config.impl; +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; import org.eclipse.emf.cdo.common.CDOCommonView; import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; import org.eclipse.emf.cdo.common.revision.CDORevisionUtil; @@ -93,6 +94,12 @@ private static final long serialVersionUID = 1L; + private boolean supportingAudits; + + private boolean supportingBranches; + + private IDGenerationLocation idGenerationLocation; + protected transient Map repositories; /** @@ -107,9 +114,41 @@ private transient IRepository.WriteAccessHandler resourcePathChecker; - public RepositoryConfig(String name) + public RepositoryConfig(String name, boolean supportingAudits, boolean supportingBranches, + IDGenerationLocation idGenerationLocation) { super(name); + + this.supportingAudits = supportingAudits; + this.supportingBranches = supportingBranches; + this.idGenerationLocation = idGenerationLocation; + } + + public boolean isSupportingAudits() + { + return supportingAudits; + } + + public boolean isSupportingBranches() + { + return supportingBranches; + } + + public IDGenerationLocation getIDGenerationLocation() + { + return idGenerationLocation; + } + + @Override + public String getName() + { + return super.getName() + (supportingBranches ? "-branching" : supportingAudits ? "-auditing" : "") + + getMappingStrategySpecialization() + (idGenerationLocation == IDGenerationLocation.CLIENT ? "-uuids" : ""); + } + + protected String getMappingStrategySpecialization() + { + return ""; } public void setRestarting(boolean restarting) @@ -139,8 +178,6 @@ } } - // int xxx; - // repositoryProperties.put(IRepository.Props.ID_GENERATION_LOCATION, IDGenerationLocation.CLIENT.toString()); return repositoryProperties; } @@ -195,8 +232,10 @@ protected void initRepositoryProperties(Map props) { props.put(Props.OVERRIDE_UUID, ""); // UUID := name !!! - props.put(Props.SUPPORTING_AUDITS, "false"); - props.put(Props.SUPPORTING_BRANCHES, "false"); + props.put(Props.SUPPORTING_AUDITS, Boolean.toString(supportingAudits)); + props.put(Props.SUPPORTING_BRANCHES, Boolean.toString(supportingBranches)); + props.put(Props.ID_GENERATION_LOCATION, idGenerationLocation.toString()); + } public void registerRepository(final InternalRepository repository) @@ -542,7 +581,7 @@ public OfflineConfig(String name) { - super(name); + super(name, true, true, IDGenerationLocation.CLIENT); } @Override @@ -560,14 +599,6 @@ } @Override - protected void initRepositoryProperties(Map props) - { - super.initRepositoryProperties(props); - props.put(Props.SUPPORTING_AUDITS, "true"); - props.put(Props.SUPPORTING_BRANCHES, "true"); - } - - @Override protected InternalRepository createRepository(String name) { boolean failover = getTestFailover(); @@ -755,97 +786,29 @@ /** * @author Eike Stepper */ - public static class MEM extends RepositoryConfig + public static class MEMConfig extends RepositoryConfig { - public static final MEM INSTANCE = new MEM(); - private static final long serialVersionUID = 1L; - public MEM() + public MEMConfig(boolean supportingAudits, boolean supportingBranches, IDGenerationLocation idGenerationLocation) { - super("MEM"); + super("MEM", supportingAudits, supportingBranches, idGenerationLocation); } public IStore createStore(String repoName) { return MEMStoreUtil.createMEMStore(); } - - @Override - protected void initRepositoryProperties(Map props) - { - super.initRepositoryProperties(props); - props.put(Props.SUPPORTING_AUDITS, "false"); - props.put(Props.SUPPORTING_BRANCHES, "false"); - } } /** * @author Eike Stepper */ - public static class MEMAudits extends RepositoryConfig + public static class MEMOfflineConfig extends OfflineConfig { - public static final MEMAudits INSTANCE = new MEMAudits(); - private static final long serialVersionUID = 1L; - public MEMAudits() - { - super("MEMAudits"); - } - - public IStore createStore(String repoName) - { - return MEMStoreUtil.createMEMStore(); - } - - @Override - protected void initRepositoryProperties(Map props) - { - super.initRepositoryProperties(props); - props.put(Props.SUPPORTING_AUDITS, "true"); - props.put(Props.SUPPORTING_BRANCHES, "false"); - } - } - - /** - * @author Eike Stepper - */ - public static class MEMBranches extends RepositoryConfig - { - public static final MEMBranches INSTANCE = new MEMBranches(); - - private static final long serialVersionUID = 1L; - - public MEMBranches() - { - super("MEMBranches"); - } - - public IStore createStore(String repoName) - { - return MEMStoreUtil.createMEMStore(); - } - - @Override - protected void initRepositoryProperties(Map props) - { - super.initRepositoryProperties(props); - props.put(Props.SUPPORTING_AUDITS, "true"); - props.put(Props.SUPPORTING_BRANCHES, "true"); - } - } - - /** - * @author Eike Stepper - */ - public static class MEMOffline extends OfflineConfig - { - public static final MEMOffline INSTANCE = new MEMOffline(); - - private static final long serialVersionUID = 1L; - - public MEMOffline() + public MEMOfflineConfig() { super("MEMOffline"); } Index: src/org/eclipse/emf/cdo/tests/config/impl/Scenario.java =================================================================== --- src/org/eclipse/emf/cdo/tests/config/impl/Scenario.java (revision 8719) +++ src/org/eclipse/emf/cdo/tests/config/impl/Scenario.java (working copy) @@ -11,12 +11,12 @@ package org.eclipse.emf.cdo.tests.config.impl; import org.eclipse.emf.cdo.tests.config.IConfig; +import org.eclipse.emf.cdo.tests.config.IConstants; import org.eclipse.emf.cdo.tests.config.IContainerConfig; import org.eclipse.emf.cdo.tests.config.IModelConfig; import org.eclipse.emf.cdo.tests.config.IRepositoryConfig; import org.eclipse.emf.cdo.tests.config.IScenario; import org.eclipse.emf.cdo.tests.config.ISessionConfig; -import org.eclipse.emf.cdo.tests.config.impl.SessionConfig.Net4j; import org.eclipse.net4j.util.WrappedException; import org.eclipse.net4j.util.io.IOUtil; @@ -315,10 +315,10 @@ private Default() { - setContainerConfig(ContainerConfig.Combined.INSTANCE); - setRepositoryConfig(RepositoryConfig.MEMBranches.INSTANCE); - setSessionConfig(Net4j.JVM.INSTANCE); - setModelConfig(ModelConfig.Native.INSTANCE); + setContainerConfig(IConstants.COMBINED); + setRepositoryConfig(IConstants.MEM_BRANCHES); + setSessionConfig(IConstants.JVM); + setModelConfig(IConstants.NATIVE); } } } Index: src/org/eclipse/emf/cdo/tests/config/IConstants.java =================================================================== --- src/org/eclipse/emf/cdo/tests/config/IConstants.java (revision 8719) +++ src/org/eclipse/emf/cdo/tests/config/IConstants.java (working copy) @@ -10,9 +10,12 @@ */ package org.eclipse.emf.cdo.tests.config; +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; import org.eclipse.emf.cdo.tests.config.impl.ContainerConfig; import org.eclipse.emf.cdo.tests.config.impl.ModelConfig; import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig; +import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig.MEMConfig; +import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig.MEMOfflineConfig; import org.eclipse.emf.cdo.tests.config.impl.SessionConfig; import org.eclipse.emf.cdo.tests.config.impl.SessionConfig.Net4j; @@ -25,13 +28,13 @@ public static final ContainerConfig SEPARATED = ContainerConfig.Separated.INSTANCE; - public static final RepositoryConfig.MEM MEM = RepositoryConfig.MEM.INSTANCE; + public static final RepositoryConfig MEM = new MEMConfig(false, false, IDGenerationLocation.STORE); - public static final RepositoryConfig.MEMAudits MEM_AUDITS = RepositoryConfig.MEMAudits.INSTANCE; + public static final RepositoryConfig MEM_AUDITS = new MEMConfig(true, false, IDGenerationLocation.STORE); - public static final RepositoryConfig.MEMBranches MEM_BRANCHES = RepositoryConfig.MEMBranches.INSTANCE; + public static final RepositoryConfig MEM_BRANCHES = new MEMConfig(true, true, IDGenerationLocation.STORE); - public static final RepositoryConfig.MEMOffline MEM_OFFLINE = RepositoryConfig.MEMOffline.INSTANCE; + public static final RepositoryConfig MEM_OFFLINE = new MEMOfflineConfig(); public static final SessionConfig EMBEDDED = SessionConfig.Embedded.INSTANCE; Index: src/org/eclipse/emf/cdo/tests/AllConfigs.java =================================================================== --- src/org/eclipse/emf/cdo/tests/AllConfigs.java (revision 8719) +++ src/org/eclipse/emf/cdo/tests/AllConfigs.java (working copy) @@ -11,6 +11,7 @@ package org.eclipse.emf.cdo.tests; import org.eclipse.emf.cdo.tests.bugzilla.*; +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.ConfigTestSuite; @@ -22,7 +23,7 @@ public abstract class AllConfigs extends ConfigTestSuite { @Override - protected void initTestClasses(List> testClasses) + protected void initTestClasses(List> testClasses, IScenario scenario) { // General testClasses.add(InitialTest.class); Index: src/org/eclipse/emf/cdo/tests/AllTestsMEMOffline.java =================================================================== --- src/org/eclipse/emf/cdo/tests/AllTestsMEMOffline.java (revision 8719) +++ src/org/eclipse/emf/cdo/tests/AllTestsMEMOffline.java (working copy) @@ -10,6 +10,7 @@ */ package org.eclipse.emf.cdo.tests; +import org.eclipse.emf.cdo.tests.config.IScenario; import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; import org.eclipse.emf.cdo.tests.offline.FailoverTest; import org.eclipse.emf.cdo.tests.offline.OfflineDelayed2Test; @@ -31,10 +32,14 @@ } @Override - protected void initTestClasses(List> testClasses) + protected void initConfigSuites(TestSuite parent) { - // super.initTestClasses(testClasses); + addScenario(parent, COMBINED, MEM_OFFLINE, JVM, NATIVE); + } + @Override + protected void initTestClasses(List> testClasses, IScenario scenario) + { // MEM does not support raw replication // testClasses.add(OfflineRawTest.class); @@ -42,10 +47,4 @@ testClasses.add(OfflineDelayed2Test.class); testClasses.add(FailoverTest.class); } - - @Override - protected void initConfigSuites(TestSuite parent) - { - addScenario(parent, COMBINED, MEM_OFFLINE, JVM, NATIVE); - } } #P org.eclipse.emf.cdo.tests.objectivity Index: src/org/eclipse/emf/cdo/tests/objectivity/SampleTestsObjy.java =================================================================== --- src/org/eclipse/emf/cdo/tests/objectivity/SampleTestsObjy.java (revision 8720) +++ src/org/eclipse/emf/cdo/tests/objectivity/SampleTestsObjy.java (working copy) @@ -10,7 +10,6 @@ */ package org.eclipse.emf.cdo.tests.objectivity; -import org.eclipse.emf.cdo.server.IRepository; import org.eclipse.emf.cdo.tests.BranchingWithCacheClearTest; import org.eclipse.emf.cdo.tests.InitialTest; import org.eclipse.emf.cdo.tests.MergingTest; @@ -19,10 +18,10 @@ import org.eclipse.emf.cdo.tests.RevisionDeltaInBranchTest; import org.eclipse.emf.cdo.tests.UnsetTest; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_261218_Test; +import org.eclipse.emf.cdo.tests.config.IScenario; import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; import java.util.List; -import java.util.Map; import junit.framework.Test; import junit.framework.TestSuite; @@ -40,16 +39,12 @@ @Override protected void initConfigSuites(TestSuite parent) { - ObjyStoreRepositoryConfig repConfig = ObjySampleConfig.INSTANCE; - addScenario(parent, COMBINED, repConfig, JVM, NATIVE); + addScenario(parent, COMBINED, new ObjyConfig(false, false), JVM, NATIVE); } @Override - protected void initTestClasses(List> testClasses) + protected void initTestClasses(List> testClasses, IScenario scenario) { - // super.initTestClasses(testClasses); - // testClasses.remove(XATransactionTest.class); - testClasses.clear(); // testClasses.add(ComplexTest.class); @@ -110,40 +105,4 @@ // testClasses.add(Bugzilla_259949_Test.class); testClasses.add(Bugzilla_261218_Test.class); } - - @Override - protected boolean hasBranchingSupport() - { - return true; - } - - @Override - protected boolean hasAuditSupport() - { - return true; - } - - public static class ObjySampleConfig extends ObjyStoreRepositoryConfig - { - private static final long serialVersionUID = 1L; - - public static final SampleTestsObjy.ObjySampleConfig INSTANCE = new ObjySampleConfig("ObjectivityStore: (sample)"); //$NON-NLS-1$ - - public ObjySampleConfig(String name) - { - super(name); - - org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM.DEBUG.setEnabled(true); - org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM.INFO.setEnabled(true); - } - - @Override - protected void initRepositoryProperties(Map props) - { - super.initRepositoryProperties(props); - props.put(IRepository.Props.SUPPORTING_AUDITS, "true"); - props.put(IRepository.Props.SUPPORTING_BRANCHES, "true"); - } - } - } Index: src/org/eclipse/emf/cdo/tests/objectivity/AllTestsObjyNonAudit.java =================================================================== --- src/org/eclipse/emf/cdo/tests/objectivity/AllTestsObjyNonAudit.java (revision 8720) +++ src/org/eclipse/emf/cdo/tests/objectivity/AllTestsObjyNonAudit.java (working copy) @@ -11,12 +11,11 @@ */ package org.eclipse.emf.cdo.tests.objectivity; -import org.eclipse.emf.cdo.server.IRepository; import org.eclipse.emf.cdo.tests.ExternalReferenceTest; +import org.eclipse.emf.cdo.tests.config.IScenario; import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; import java.util.List; -import java.util.Map; import junit.framework.Test; import junit.framework.TestSuite; @@ -34,51 +33,14 @@ @Override protected void initConfigSuites(TestSuite parent) { - // ObjyStoreRepositoryConfig repoConfig = ObjyNonAuditConfig.INSTANCE; - ObjyStoreRepositoryConfig repoConfig = new ObjyNonAuditConfig("ObjectivityStore: (non-audit)"); //$NON-NLS-1$ - addScenario(parent, COMBINED, repoConfig, JVM, NATIVE); - } - - @Override - protected boolean hasAuditSupport() - { - return false; + addScenario(parent, COMBINED, new ObjyConfig(false, false), JVM, NATIVE); } @Override - protected boolean hasBranchingSupport() - { - return false; - } - - public static class ObjyNonAuditConfig extends ObjyStoreRepositoryConfig + protected void initTestClasses(List> testClasses, IScenario scenario) { - private static final long serialVersionUID = 1L; - - public static final AllTestsObjyNonAudit.ObjyNonAuditConfig INSTANCE = new ObjyNonAuditConfig( - "ObjectivityStore: (non-audit)"); //$NON-NLS-1$ - - public ObjyNonAuditConfig(String name) - { - super(name); - - org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM.DEBUG.setEnabled(true); - org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM.INFO.setEnabled(true); - } + super.initTestClasses(testClasses, scenario); - @Override - protected void initRepositoryProperties(Map props) - { - super.initRepositoryProperties(props); - props.put(IRepository.Props.SUPPORTING_AUDITS, "false"); //$NON-NLS-1$ - props.put(IRepository.Props.SUPPORTING_BRANCHES, "false"); //$NON-NLS-1$ - } - } - - @Override - protected void initTestClasses(List> testClasses) - { - super.initTestClasses(testClasses); // There is a problem with the root resource sharing, so for now we're commenting // out ExternalReferenceTest and Bugzilla_259869_Test testClasses.remove(ExternalReferenceTest.class); Index: src/org/eclipse/emf/cdo/tests/objectivity/AllTestsObjyAudit.java =================================================================== --- src/org/eclipse/emf/cdo/tests/objectivity/AllTestsObjyAudit.java (revision 8720) +++ src/org/eclipse/emf/cdo/tests/objectivity/AllTestsObjyAudit.java (working copy) @@ -11,12 +11,6 @@ */ package org.eclipse.emf.cdo.tests.objectivity; -import org.eclipse.emf.cdo.server.IRepository; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; - -import java.util.List; -import java.util.Map; - import junit.framework.Test; import junit.framework.TestSuite; @@ -33,48 +27,6 @@ @Override protected void initConfigSuites(TestSuite parent) { - ObjyStoreRepositoryConfig repoConfig = ObjyAuditConfig.INSTANCE; - addScenario(parent, COMBINED, repoConfig, JVM, NATIVE); - } - - @Override - protected void initTestClasses(List> testClasses) - { - super.initTestClasses(testClasses); - } - - @Override - protected boolean hasAuditSupport() - { - return true; - } - - @Override - protected boolean hasBranchingSupport() - { - return false; - } - - public static class ObjyAuditConfig extends ObjyStoreRepositoryConfig - { - private static final long serialVersionUID = 1L; - - public static final AllTestsObjyAudit.ObjyAuditConfig INSTANCE = new ObjyAuditConfig("ObjectivityStore: (audit)"); //$NON-NLS-1$ - - public ObjyAuditConfig(String name) - { - super(name); - - org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM.DEBUG.setEnabled(true); - org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM.INFO.setEnabled(true); - } - - @Override - protected void initRepositoryProperties(Map props) - { - super.initRepositoryProperties(props); - props.put(IRepository.Props.SUPPORTING_AUDITS, "true"); //$NON-NLS-1$ - props.put(IRepository.Props.SUPPORTING_BRANCHES, "false"); //$NON-NLS-1$ - } + addScenario(parent, COMBINED, new ObjyConfig(true, false), JVM, NATIVE); } } Index: src/org/eclipse/emf/cdo/tests/objectivity/ObjyDBConfigs.java =================================================================== --- src/org/eclipse/emf/cdo/tests/objectivity/ObjyDBConfigs.java (revision 8720) +++ src/org/eclipse/emf/cdo/tests/objectivity/ObjyDBConfigs.java (working copy) @@ -11,14 +11,15 @@ package org.eclipse.emf.cdo.tests.objectivity; import org.eclipse.emf.cdo.tests.AllConfigs; -import org.eclipse.emf.cdo.tests.AuditTest; import org.eclipse.emf.cdo.tests.AuditSameSessionTest; -import org.eclipse.emf.cdo.tests.BranchingTest; +import org.eclipse.emf.cdo.tests.AuditTest; import org.eclipse.emf.cdo.tests.BranchingSameSessionTest; +import org.eclipse.emf.cdo.tests.BranchingTest; import org.eclipse.emf.cdo.tests.MergingTest; import org.eclipse.emf.cdo.tests.XATransactionTest; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_252214_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_303807_Test; +import org.eclipse.emf.cdo.tests.config.IScenario; import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; import java.util.List; @@ -29,13 +30,13 @@ public abstract class ObjyDBConfigs extends AllConfigs { @Override - protected void initTestClasses(List> testClasses) + protected void initTestClasses(List> testClasses, IScenario scenario) { - super.initTestClasses(testClasses); + super.initTestClasses(testClasses, scenario); // remove BranchingTests because most mappings do not support it // Subclasses should add Banching tests if supported - if (!hasBranchingSupport()) + if (!scenario.getRepositoryConfig().isSupportingBranches()) { testClasses.remove(BranchingTest.class); testClasses.remove(BranchingSameSessionTest.class); @@ -43,7 +44,7 @@ testClasses.remove(Bugzilla_303807_Test.class); } - if (!hasAuditSupport()) + if (!scenario.getRepositoryConfig().isSupportingAudits()) { // non-audit mode - remove audit tests testClasses.remove(AuditTest.class); @@ -58,8 +59,4 @@ // sometime cause a crash (Investigate!!) testClasses.remove(XATransactionTest.class); } - - protected abstract boolean hasBranchingSupport(); - - protected abstract boolean hasAuditSupport(); } Index: src/org/eclipse/emf/cdo/tests/objectivity/ObjyStoreRepositoryConfig.java =================================================================== --- src/org/eclipse/emf/cdo/tests/objectivity/ObjyStoreRepositoryConfig.java (revision 8725) +++ src/org/eclipse/emf/cdo/tests/objectivity/ObjyStoreRepositoryConfig.java (working copy) @@ -1,57 +0,0 @@ -/** - * 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: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.emf.cdo.tests.objectivity; - -import org.eclipse.emf.cdo.server.IStore; -import org.eclipse.emf.cdo.server.internal.objectivity.ObjectivityStoreConfig; -import org.eclipse.emf.cdo.server.objectivity.ObjyStoreUtil; -import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig; - -/** - * @author Eike Stepper - */ -public abstract class ObjyStoreRepositoryConfig extends RepositoryConfig -{ - private static final long serialVersionUID = 1L; - - private static ObjectivityStoreConfig storeConfig = new ObjectivityStoreConfig(); - - public ObjyStoreRepositoryConfig(String name) - { - super(name); - } - - @Override - public void setUp() throws Exception - { - // System.out.println("ObjyStoreRepositry.setup() - STARTED"); - // long sTime = System.currentTimeMillis(); - super.setUp(); - // long eTime = System.currentTimeMillis(); - // System.out.println("ObjyStoreRepositry.setup() time: " + (eTime - sTime)); - } - - @Override - protected void deactivateRepositories() - { - super.deactivateRepositories(); - // System.out.println(">>>>IS:<<<< We need to remove all data created here...."); - storeConfig.resetFD(); - } - - public IStore createStore(String repoName) - { - // We might need to use the repoName to our advantage!!! - System.out.println("************* ObjyStore creation ****************\n"); - return ObjyStoreUtil.createStore(storeConfig); - } - -} Index: src/org/eclipse/emf/cdo/tests/objectivity/AllTestsObjyBranching.java =================================================================== --- src/org/eclipse/emf/cdo/tests/objectivity/AllTestsObjyBranching.java (revision 8720) +++ src/org/eclipse/emf/cdo/tests/objectivity/AllTestsObjyBranching.java (working copy) @@ -11,12 +11,6 @@ */ package org.eclipse.emf.cdo.tests.objectivity; -import org.eclipse.emf.cdo.server.IRepository; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; - -import java.util.List; -import java.util.Map; - import junit.framework.Test; import junit.framework.TestSuite; @@ -33,54 +27,6 @@ @Override protected void initConfigSuites(TestSuite parent) { - ObjyStoreRepositoryConfig repoConfig = ObjyBranchingConfig.INSTANCE; - addScenario(parent, COMBINED, repoConfig, JVM, NATIVE); - } - - @Override - protected void initTestClasses(List> testClasses) - { - super.initTestClasses(testClasses); - - // // add branching tests for this testsuite - // testClasses.add(BranchingTest.class); - // testClasses.add(BranchingSameSessionTest.class); - // testClasses.add(MergingTest.class); - } - - @Override - protected boolean hasAuditSupport() - { - return true; - } - - @Override - protected boolean hasBranchingSupport() - { - return true; - } - - public static class ObjyBranchingConfig extends ObjyStoreRepositoryConfig - { - private static final long serialVersionUID = 1L; - - public static final AllTestsObjyBranching.ObjyBranchingConfig INSTANCE = new ObjyBranchingConfig( - "ObjectivityStore: (branching)"); //$NON-NLS-1$ - - public ObjyBranchingConfig(String name) - { - super(name); - - org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM.DEBUG.setEnabled(true); - org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM.INFO.setEnabled(true); - } - - @Override - protected void initRepositoryProperties(Map props) - { - super.initRepositoryProperties(props); - props.put(IRepository.Props.SUPPORTING_AUDITS, "true"); //$NON-NLS-1$ - props.put(IRepository.Props.SUPPORTING_BRANCHES, "true"); //$NON-NLS-1$ - } + addScenario(parent, COMBINED, new ObjyConfig(true, true), JVM, NATIVE); } } Index: src/org/eclipse/emf/cdo/tests/objectivity/ObjyConfig.java =================================================================== --- src/org/eclipse/emf/cdo/tests/objectivity/ObjyConfig.java (revision 8720) +++ src/org/eclipse/emf/cdo/tests/objectivity/ObjyConfig.java (working copy) @@ -10,6 +10,7 @@ */ package org.eclipse.emf.cdo.tests.objectivity; +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; import org.eclipse.emf.cdo.server.IStore; import org.eclipse.emf.cdo.server.internal.objectivity.ObjectivityStoreConfig; import org.eclipse.emf.cdo.server.objectivity.ObjyStoreUtil; @@ -18,25 +19,18 @@ /** * @author Eike Stepper */ -public abstract class ObjyStoreRepositoryConfig extends RepositoryConfig +public class ObjyConfig extends RepositoryConfig { private static final long serialVersionUID = 1L; private static ObjectivityStoreConfig storeConfig = new ObjectivityStoreConfig(); - public ObjyStoreRepositoryConfig(String name) + public ObjyConfig(boolean supportingAudits, boolean supportingBranches) { - super(name); - } + super("Objy", supportingAudits, supportingBranches, IDGenerationLocation.STORE); - @Override - public void setUp() throws Exception - { - // System.out.println("ObjyStoreRepositry.setup() - STARTED"); - // long sTime = System.currentTimeMillis(); - super.setUp(); - // long eTime = System.currentTimeMillis(); - // System.out.println("ObjyStoreRepositry.setup() time: " + (eTime - sTime)); + org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM.DEBUG.setEnabled(true); + org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM.INFO.setEnabled(true); } @Override @@ -53,5 +47,4 @@ System.out.println("************* ObjyStore creation ****************\n"); return ObjyStoreUtil.createStore(storeConfig); } - } #P org.eclipse.emf.cdo.tests.db4o Index: src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4O.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4O.java (revision 8725) +++ src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4O.java (working copy) @@ -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 @@ } @Override - protected void initTestClasses(List> testClasses) + protected void initConfigSuites(TestSuite parent) + { + addScenario(parent, COMBINED, new DB4OConfig(false), JVM, NATIVE); + } + + @Override + protected void initTestClasses(List> testClasses, IScenario scenario) { - super.initTestClasses(testClasses); + super.initTestClasses(testClasses, scenario); // Added here testcases to skip // takes too much @@ -59,86 +55,4 @@ 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 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; - } - } } Index: src/org/eclipse/emf/cdo/tests/db4o/DB4OConfig.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db4o/DB4OConfig.java (revision 0) +++ src/org/eclipse/emf/cdo/tests/db4o/DB4OConfig.java (revision 0) @@ -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; + } +} Index: src/org/eclipse/emf/cdo/tests/db4o/AllTestsMEMDB4O.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db4o/AllTestsMEMDB4O.java (revision 8725) +++ src/org/eclipse/emf/cdo/tests/db4o/AllTestsMEMDB4O.java (working copy) @@ -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 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; - } - } - -} Index: CDO AllTests (MEMDB4O).launch =================================================================== --- CDO AllTests (MEMDB4O).launch (revision 8672) +++ CDO AllTests (MEMDB4O).launch (working copy) @@ -1,7 +1,7 @@ - + @@ -10,7 +10,7 @@ - + Index: src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4OMem.java =================================================================== --- src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4OMem.java (revision 8672) +++ src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4OMem.java (working copy) @@ -1,65 +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 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 +/** + * @author Victor Roldan Betancort + */ +public class AllTestsDB4OMem extends AllTestsDB4O { - public static Test suite() { - return new AllTestsMEMDB4O().getTestSuite("CDO Tests (MEMDB4O)"); + return new AllTestsDB4OMem().getTestSuite("CDO Tests (DB4OMem)"); } @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 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; - } + addScenario(parent, COMBINED, new DB4OConfig(true), JVM, NATIVE); } - } Property changes on: src\org\eclipse\emf\cdo\tests\db4o\AllTestsDB4OMem.java ___________________________________________________________________ Added: svn:mime-type + text/plain #P org.eclipse.emf.cdo.common Index: src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndVersionImpl.java =================================================================== --- src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndVersionImpl.java (revision 8724) +++ src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndVersionImpl.java (working copy) @@ -28,7 +28,7 @@ public CDOIDAndVersionImpl(CDOID id, int version) { - CheckUtil.checkNull(id, "id"); + CheckUtil.checkArg(id, "id"); this.id = id; this.version = version; Index: src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndBranchImpl.java =================================================================== --- src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndBranchImpl.java (revision 8724) +++ src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndBranchImpl.java (working copy) @@ -30,8 +30,8 @@ public CDOIDAndBranchImpl(CDOID id, CDOBranch branch) { - CheckUtil.checkNull(id, "id"); - CheckUtil.checkNull(branch, "branch"); + CheckUtil.checkArg(id, "id"); + CheckUtil.checkArg(branch, "branch"); this.id = id; this.branch = branch; Index: src/org/eclipse/emf/cdo/spi/common/revision/CDOReferenceAdjustable.java =================================================================== --- src/org/eclipse/emf/cdo/spi/common/revision/CDOReferenceAdjustable.java (revision 8724) +++ src/org/eclipse/emf/cdo/spi/common/revision/CDOReferenceAdjustable.java (working copy) @@ -11,7 +11,6 @@ */ package org.eclipse.emf.cdo.spi.common.revision; - /** * @author Simon McDuff * @since 4.0 #P org.eclipse.emf.cdo.tests.hibernate Index: src/org/eclipse/emf/cdo/tests/hibernate/AllTestsHibernate.java =================================================================== --- src/org/eclipse/emf/cdo/tests/hibernate/AllTestsHibernate.java (revision 8584) +++ src/org/eclipse/emf/cdo/tests/hibernate/AllTestsHibernate.java (working copy) @@ -44,6 +44,7 @@ import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_316444_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_319836_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_322804_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.emf.cdo.util.CommitException; @@ -72,7 +73,7 @@ } @Override - protected void initTestClasses(List> testClasses) + protected void initTestClasses(List> testClasses, IScenario scenario) { // testClasses.clear(); // testClasses.add(XRefTest.class); @@ -100,7 +101,7 @@ testClasses.add(Hibernate_PartialCommitTest.class); testClasses.add(Hibernate_Bugzilla_316444_Test.class); - super.initTestClasses(testClasses); + super.initTestClasses(testClasses, scenario); // Teneo does not yet support lists of int arrays: // https://bugs.eclipse.org/bugs/show_bug.cgi?id=330212 Index: src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java =================================================================== --- src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java (revision 8725) +++ src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java (working copy) @@ -10,7 +10,7 @@ */ package org.eclipse.emf.cdo.tests.hibernate; -import org.eclipse.emf.cdo.server.IRepository.Props; +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; import org.eclipse.emf.cdo.server.IStore; import org.eclipse.emf.cdo.server.hibernate.CDOHibernateUtil; import org.eclipse.emf.cdo.server.hibernate.IHibernateMappingProvider; @@ -38,15 +38,13 @@ public HibernateConfig() { - super("Hibernate"); + super("Hibernate", false, false, IDGenerationLocation.STORE); } @Override protected void initRepositoryProperties(Map props) { super.initRepositoryProperties(props); - props.put(Props.SUPPORTING_AUDITS, "false"); - props.put(Props.SUPPORTING_BRANCHES, "false"); try { #P org.eclipse.emf.cdo.tests.ui Index: META-INF/MANIFEST.MF =================================================================== --- META-INF/MANIFEST.MF (revision 8584) +++ META-INF/MANIFEST.MF (working copy) @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.eclipse.emf.cdo.tests.ui;singleton:=true -Bundle-Version: 4.0.0.qualifier +Bundle-Version: 4.0.100.qualifier Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -19,5 +19,5 @@ org.eclipse.emf.cdo.ui;bundle-version="[4.0.0,5.0.0)", org.eclipse.emf.cdo.tests;bundle-version="[4.0.0,5.0.0)" Eclipse-BuddyPolicy: -Export-Package: org.eclipse.emf.cdo.tests.ui;version="4.0.0";x-friends:="org.eclipse.emf.cdo.dawn.tests", - org.eclipse.emf.cdo.tests.ui.bundle;version="4.0.0";x-internal:=true +Export-Package: org.eclipse.emf.cdo.tests.ui;version="4.0.100";x-friends:="org.eclipse.emf.cdo.dawn.tests", + org.eclipse.emf.cdo.tests.ui.bundle;version="4.0.100";x-internal:=true Index: src/org/eclipse/emf/cdo/tests/ui/AllTestsCDOUISWTBot.java =================================================================== --- src/org/eclipse/emf/cdo/tests/ui/AllTestsCDOUISWTBot.java (revision 8584) +++ src/org/eclipse/emf/cdo/tests/ui/AllTestsCDOUISWTBot.java (working copy) @@ -11,6 +11,7 @@ package org.eclipse.emf.cdo.tests.ui; import org.eclipse.emf.cdo.tests.AllTests; +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.ConfigTestSuite; @@ -42,7 +43,7 @@ } @Override - protected void initTestClasses(List> testClasses) + protected void initTestClasses(List> testClasses, IScenario scenario) { testClasses.add(CDOSessionsViewTest.class); } #P org.eclipse.emf.cdo.server.db Index: src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java =================================================================== --- src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java (revision 8719) +++ src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java (working copy) @@ -12,6 +12,7 @@ */ package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal; +import org.eclipse.emf.cdo.server.db.CDODBUtil; import org.eclipse.emf.cdo.server.db.mapping.IClassMapping; import org.eclipse.emf.cdo.server.db.mapping.IListMapping; import org.eclipse.emf.cdo.server.internal.db.CDODBSchema; @@ -25,8 +26,6 @@ */ public class HorizontalBranchingMappingStrategyWithRanges extends AbstractHorizontalMappingStrategy { - private static final String PROP_COPY_ON_BRANCH = "copyOnBranch"; - private boolean copyOnBranch; public HorizontalBranchingMappingStrategyWithRanges() @@ -90,7 +89,7 @@ { super.doAfterActivate(); - String value = getProperties().get(PROP_COPY_ON_BRANCH); + String value = getProperties().get(CDODBUtil.PROP_COPY_ON_BRANCH); copyOnBranch = value == null ? false : Boolean.valueOf(value); } } Index: src/org/eclipse/emf/cdo/server/db/CDODBUtil.java =================================================================== --- src/org/eclipse/emf/cdo/server/db/CDODBUtil.java (revision 8719) +++ src/org/eclipse/emf/cdo/server/db/CDODBUtil.java (working copy) @@ -18,7 +18,10 @@ import org.eclipse.emf.cdo.server.internal.db.SmartPreparedStatementCache; import org.eclipse.emf.cdo.server.internal.db.bundle.OM; import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategy; +import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategyWithRanges; import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingMappingStrategy; +import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingMappingStrategyWithRanges; +import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalMappingStrategy; import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalNonAuditMappingStrategy; import org.eclipse.net4j.db.IDBAdapter; @@ -47,6 +50,16 @@ */ public static final String EXT_POINT_MAPPING_STRATEGIES = "mappingStrategies"; //$NON-NLS-1$ + /** + * @since 4.1 + */ + public static final String PROP_WITH_RANGES = "withRanges"; + + /** + * @since 4.1 + */ + public static final String PROP_COPY_ON_BRANCH = "copyOnBranch"; + private CDODBUtil() { } @@ -77,12 +90,7 @@ */ public static IMappingStrategy createHorizontalMappingStrategy(boolean auditing) { - if (auditing) - { - return new HorizontalAuditMappingStrategy(); - } - - return new HorizontalNonAuditMappingStrategy(); + return createHorizontalMappingStrategy(auditing, false, false); } /** @@ -90,17 +98,51 @@ */ public static IMappingStrategy createHorizontalMappingStrategy(boolean auditing, boolean branching) { + return createHorizontalMappingStrategy(auditing, branching, false); + } + + /** + * @since 4.1 + */ + public static IMappingStrategy createHorizontalMappingStrategy(boolean auditing, boolean branching, boolean withRanges) + { if (branching) { if (auditing) { + if (withRanges) + { + return new HorizontalBranchingMappingStrategyWithRanges(); + } + return new HorizontalBranchingMappingStrategy(); } throw new IllegalArgumentException("Misconfiguration: Branching requires Auditing!"); } - return createHorizontalMappingStrategy(auditing); + if (auditing) + { + if (withRanges) + { + return new HorizontalAuditMappingStrategyWithRanges(); + } + + return new HorizontalAuditMappingStrategy(); + } + + return new HorizontalNonAuditMappingStrategy(); + } + + /** + * Creates a horizontal {@link IMappingStrategy mapping strategy} that supports all valid combinations of auditing and + * branching. + * + * @since 4.1 + */ + public static IMappingStrategy createHorizontalMappingStrategy() + { + return new HorizontalMappingStrategy(); } /** Index: src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java =================================================================== --- src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java (revision 8725) +++ src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java (working copy) @@ -1321,8 +1321,14 @@ { IRepository repository = accessor.getStore().getRepository(); CDOBranchPoint base = repository.getBranchManager().getBranch(branchID).getBase(); - InternalCDORevision baseRevision = (InternalCDORevision)repository.getRevisionManager() - .getRevision(id, base, /* referenceChunk = */0, /* prefetchDepth = */CDORevision.DEPTH_NONE, true); + InternalCDORevision baseRevision = (InternalCDORevision)repository.getRevisionManager().getRevision(id, base, /* + * referenceChunk + * = + */0, /* + * prefetchDepth + * = + */ + CDORevision.DEPTH_NONE, true); IStoreChunkReader chunkReader = accessor.createChunkReader(baseRevision, getFeature()); return chunkReader; } Index: src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalMappingStrategy.java =================================================================== --- src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalMappingStrategy.java (revision 8719) +++ src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalMappingStrategy.java (working copy) @@ -240,7 +240,13 @@ boolean auditing = getBooleanProperty(Props.SUPPORTING_AUDITS); boolean branching = getBooleanProperty(Props.SUPPORTING_BRANCHES); - delegate = CDODBUtil.createHorizontalMappingStrategy(auditing, branching); + boolean withRanges = false; + if (auditing || branching) + { + withRanges = getBooleanProperty(CDODBUtil.PROP_WITH_RANGES); + } + + delegate = CDODBUtil.createHorizontalMappingStrategy(auditing, branching, withRanges); delegate.setStore(store); delegate.setProperties(properties); LifecycleUtil.activate(delegate);