Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-07-19 08:22:04 +0000
committerEike Stepper2012-07-19 08:22:04 +0000
commit1460904fd3c193ffaf809913b2983a400fce9d94 (patch)
tree72f3a17b75fedba3ae1060df1d32c9c7889be954 /plugins/org.eclipse.emf.cdo.tests.db
parent5f360965ae87478e0681899bf310a210cafc2c44 (diff)
downloadcdo-1460904fd3c193ffaf809913b2983a400fce9d94.tar.gz
cdo-1460904fd3c193ffaf809913b2983a400fce9d94.tar.xz
cdo-1460904fd3c193ffaf809913b2983a400fce9d94.zip
Fix line endings in master (dos2unix)
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests.db')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/.settings/org.eclipse.core.resources.prefs6
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/AllTestsDBDB2NonAudit.java426
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (DB2 non-audit).launch32
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (DBStore).launch32
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (Derby).launch32
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 UUIDs).launch32
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 audit).launch32
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 branching).launch32
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 non-audit).launch32
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (Mysql).launch32
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/copyright.txt14
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/plugin.properties22
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBDerby.java68
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2All.java84
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2BranchingUUIDs.java66
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2NonAudit.java78
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldb.java94
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldbNonAudit.java94
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysql.java104
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBPsql.java84
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AutomatedTests.java64
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Bugzilla_351078_DB_Test.java156
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Bugzilla_377727_Test.java208
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/CustomTypeMappingTest.java324
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java986
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfig.java278
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfigs.java174
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBStoreTest.java652
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DerbyConfig.java266
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2Config.java224
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2OfflineConfig.java254
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/HsqldbConfig.java322
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/MysqlConfig.java334
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/MysqlOfflineConfig.java312
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Net4jDBTest.java1440
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/PostgresqlConfig.java256
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/bundle/OM.java88
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/AbstractCapabilityTest.java694
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/DerbyTest.java88
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/H2Test.java80
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/MysqlTest.java80
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/performance/AllPerformanceTestsH2NonAudit.java70
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/verifier/DBStoreVerifier.java1080
43 files changed, 4913 insertions, 4913 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.emf.cdo.tests.db/.settings/org.eclipse.core.resources.prefs
index df1980e1b2..b25d9e5c5b 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/.settings/org.eclipse.core.resources.prefs
+++ b/plugins/org.eclipse.emf.cdo.tests.db/.settings/org.eclipse.core.resources.prefs
@@ -1,3 +1,3 @@
-#Mon Jul 04 13:01:38 CEST 2011
-eclipse.preferences.version=1
-encoding//model/org.eclipse.emf.cdo.defs.ecorediag=UTF-8
+#Mon Jul 04 13:01:38 CEST 2011
+eclipse.preferences.version=1
+encoding//model/org.eclipse.emf.cdo.defs.ecorediag=UTF-8
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/AllTestsDBDB2NonAudit.java b/plugins/org.eclipse.emf.cdo.tests.db/AllTestsDBDB2NonAudit.java
index 107c495b0d..f24048cf4c 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/AllTestsDBDB2NonAudit.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/AllTestsDBDB2NonAudit.java
@@ -1,213 +1,213 @@
-/*
- * Copyright (c) 2004 - 2012 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.IRepository;
-import org.eclipse.emf.cdo.server.db.CDODBUtil;
-import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
-import org.eclipse.emf.cdo.tests.AuditTest;
-import org.eclipse.emf.cdo.tests.AuditSameSessionTest;
-import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_252214_Test;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
-
-import org.eclipse.net4j.db.DBException;
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBAdapter;
-import org.eclipse.net4j.db.db2.DB2Adapter;
-import org.eclipse.net4j.db.db2.DB2SchemaDatasource;
-
-import javax.sql.DataSource;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTestsDBDB2NonAudit extends DBConfigs
-{
- public static Test suite()
- {
- return new AllTestsDBDB2NonAudit().getTestSuite("CDO Tests (DBStore H2 Horizontal - non-audit mode)"); //$NON-NLS-1$
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, AllTestsDBDB2NonAudit.DB2NonAudit.INSTANCE, JVM, NATIVE);
- }
-
- @Override
- protected boolean hasAuditSupport()
- {
- return false;
- }
-
- @Override
- protected boolean hasBranchingSupport()
- {
- return false;
- }
-
- @Override
- protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
- {
- super.initTestClasses(testClasses);
-
- // non-audit mode - remove audit tests
- testClasses.remove(AuditTest.class);
- testClasses.remove(AuditTestSameSession.class);
- testClasses.remove(Bugzilla_252214_Test.class);
- }
-
- /**
- * @author Eike Stepper
- */
- public static class DB2NonAudit extends DBStoreRepositoryConfig
- {
- private static final String DB_NAME = "SAMPLE"; //$NON-NLS-1$
-
- private static final String DB_USER = "DB2ADMIN"; //$NON-NLS-1$
-
- private static final String DB_PASSWORD = "12345"; //$NON-NLS-1$
-
- static final String DB_SCHEMA = "CDOTEST"; //$NON-NLS-1$
-
- private static final long serialVersionUID = 1L;
-
- public static final AllTestsDBDB2NonAudit.DB2NonAudit INSTANCE = new DB2NonAudit("DBStore: DB2 (non-audit)"); //$NON-NLS-1$
-
- private transient String currentRepoName;
-
- private static int tableCounter;
-
- private static int dropCounter;
-
- public DB2NonAudit(String name)
- {
- super(name);
- }
-
- @Override
- protected void initRepositoryProperties(Map<String, String> props)
- {
- super.initRepositoryProperties(props);
- props.put(IRepository.Props.SUPPORTING_AUDITS, "false"); //$NON-NLS-1$
- }
-
- @Override
- protected IMappingStrategy createMappingStrategy()
- {
- Map<String, String> properties = new HashMap<String, String>();
- properties.put("qualifiedNames", "false");
- properties.put("forceNamesWithID", "false");
-
- IMappingStrategy mappingStrategy = CDODBUtil.createHorizontalMappingStrategy(false);
- mappingStrategy.setProperties(properties);
-
- return mappingStrategy;
- }
-
- @Override
- protected IDBAdapter createDBAdapter()
- {
- return new DB2Adapter();
- }
-
- @Override
- protected DataSource createDataSource(final String repoName)
- {
- if (currentRepoName != null && !repoName.equals(currentRepoName))
- {
- throw new IllegalStateException("This test config only supports a single repository"); //$NON-NLS-1$
- }
-
- currentRepoName = repoName;
-
- DB2SchemaDatasource dataSource = new DB2SchemaDatasource(DB_SCHEMA);
- dataSource.setDatabaseName(DB_NAME);
- dataSource.setUser(DB_USER);
- dataSource.setPassword(DB_PASSWORD);
-
- if (!isRestarting())
- {
- initAllTables(dataSource);
- }
-
- return dataSource;
- }
-
- @Override
- public void tearDown() throws Exception
- {
- currentRepoName = null;
- super.tearDown();
- }
-
- private static void initAllTables(DataSource dataSource)
- {
- Connection conn = null;
- Statement statement = null;
- String sql = null;
-
- try
- {
- conn = dataSource.getConnection();
- List<String> tableNames = DBUtil.getAllTableNames(conn, DB_SCHEMA);
- if (tableCounter != 0)
- {
- if (tableCounter < tableNames.size())
- {
- dropCounter = 20;
- }
- }
-
- tableCounter = tableNames.size();
-
- boolean drop = false;
- if (dropCounter > 0)
- {
- --dropCounter;
- }
- else if (dropCounter == 0)
- {
- tableCounter = 0;
- dropCounter = -1;
- drop = true;
- }
-
- statement = conn.createStatement();
- for (String tableName : tableNames)
- {
- sql = (drop ? "DROP TABLE " : "DELETE FROM ") + tableName; //$NON-NLS-1$ //$NON-NLS-2$
- DBUtil.trace(sql);
- statement.execute(sql);
- }
- }
- catch (SQLException ex)
- {
- throw new DBException(ex, sql);
- }
- finally
- {
- DBUtil.close(statement);
- DBUtil.close(conn);
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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.IRepository;
+import org.eclipse.emf.cdo.server.db.CDODBUtil;
+import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
+import org.eclipse.emf.cdo.tests.AuditTest;
+import org.eclipse.emf.cdo.tests.AuditSameSessionTest;
+import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_252214_Test;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
+
+import org.eclipse.net4j.db.DBException;
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBAdapter;
+import org.eclipse.net4j.db.db2.DB2Adapter;
+import org.eclipse.net4j.db.db2.DB2SchemaDatasource;
+
+import javax.sql.DataSource;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTestsDBDB2NonAudit extends DBConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsDBDB2NonAudit().getTestSuite("CDO Tests (DBStore H2 Horizontal - non-audit mode)"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, AllTestsDBDB2NonAudit.DB2NonAudit.INSTANCE, JVM, NATIVE);
+ }
+
+ @Override
+ protected boolean hasAuditSupport()
+ {
+ return false;
+ }
+
+ @Override
+ protected boolean hasBranchingSupport()
+ {
+ return false;
+ }
+
+ @Override
+ protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
+ {
+ super.initTestClasses(testClasses);
+
+ // non-audit mode - remove audit tests
+ testClasses.remove(AuditTest.class);
+ testClasses.remove(AuditTestSameSession.class);
+ testClasses.remove(Bugzilla_252214_Test.class);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class DB2NonAudit extends DBStoreRepositoryConfig
+ {
+ private static final String DB_NAME = "SAMPLE"; //$NON-NLS-1$
+
+ private static final String DB_USER = "DB2ADMIN"; //$NON-NLS-1$
+
+ private static final String DB_PASSWORD = "12345"; //$NON-NLS-1$
+
+ static final String DB_SCHEMA = "CDOTEST"; //$NON-NLS-1$
+
+ private static final long serialVersionUID = 1L;
+
+ public static final AllTestsDBDB2NonAudit.DB2NonAudit INSTANCE = new DB2NonAudit("DBStore: DB2 (non-audit)"); //$NON-NLS-1$
+
+ private transient String currentRepoName;
+
+ private static int tableCounter;
+
+ private static int dropCounter;
+
+ public DB2NonAudit(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected void initRepositoryProperties(Map<String, String> props)
+ {
+ super.initRepositoryProperties(props);
+ props.put(IRepository.Props.SUPPORTING_AUDITS, "false"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected IMappingStrategy createMappingStrategy()
+ {
+ Map<String, String> properties = new HashMap<String, String>();
+ properties.put("qualifiedNames", "false");
+ properties.put("forceNamesWithID", "false");
+
+ IMappingStrategy mappingStrategy = CDODBUtil.createHorizontalMappingStrategy(false);
+ mappingStrategy.setProperties(properties);
+
+ return mappingStrategy;
+ }
+
+ @Override
+ protected IDBAdapter createDBAdapter()
+ {
+ return new DB2Adapter();
+ }
+
+ @Override
+ protected DataSource createDataSource(final String repoName)
+ {
+ if (currentRepoName != null && !repoName.equals(currentRepoName))
+ {
+ throw new IllegalStateException("This test config only supports a single repository"); //$NON-NLS-1$
+ }
+
+ currentRepoName = repoName;
+
+ DB2SchemaDatasource dataSource = new DB2SchemaDatasource(DB_SCHEMA);
+ dataSource.setDatabaseName(DB_NAME);
+ dataSource.setUser(DB_USER);
+ dataSource.setPassword(DB_PASSWORD);
+
+ if (!isRestarting())
+ {
+ initAllTables(dataSource);
+ }
+
+ return dataSource;
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ currentRepoName = null;
+ super.tearDown();
+ }
+
+ private static void initAllTables(DataSource dataSource)
+ {
+ Connection conn = null;
+ Statement statement = null;
+ String sql = null;
+
+ try
+ {
+ conn = dataSource.getConnection();
+ List<String> tableNames = DBUtil.getAllTableNames(conn, DB_SCHEMA);
+ if (tableCounter != 0)
+ {
+ if (tableCounter < tableNames.size())
+ {
+ dropCounter = 20;
+ }
+ }
+
+ tableCounter = tableNames.size();
+
+ boolean drop = false;
+ if (dropCounter > 0)
+ {
+ --dropCounter;
+ }
+ else if (dropCounter == 0)
+ {
+ tableCounter = 0;
+ dropCounter = -1;
+ drop = true;
+ }
+
+ statement = conn.createStatement();
+ for (String tableName : tableNames)
+ {
+ sql = (drop ? "DROP TABLE " : "DELETE FROM ") + tableName; //$NON-NLS-1$ //$NON-NLS-2$
+ DBUtil.trace(sql);
+ statement.execute(sql);
+ }
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex, sql);
+ }
+ finally
+ {
+ DBUtil.close(statement);
+ DBUtil.close(conn);
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (DB2 non-audit).launch b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (DB2 non-audit).launch
index 44e5ed7162..727424495c 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (DB2 non-audit).launch
+++ b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (DB2 non-audit).launch
@@ -1,16 +1,16 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/org.eclipse.emf.cdo.tests.db"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="4"/>
-</listAttribute>
-<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
-<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
-<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
-<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
-<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.6.0_22"/>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AllTestsDBDB2NonAudit"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/>
-</launchConfiguration>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.emf.cdo.tests.db"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="4"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
+<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.6.0_22"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AllTestsDBDB2NonAudit"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/>
+</launchConfiguration>
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (DBStore).launch b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (DBStore).launch
index e41f13710a..7dde1a17c0 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (DBStore).launch
+++ b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (DBStore).launch
@@ -1,16 +1,16 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AutomatedTests.java"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="1"/>
-</listAttribute>
-<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
-<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
-<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
-<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AutomatedTests"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m&#13;&#10;-Xmx1024m"/>
-</launchConfiguration>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AutomatedTests.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AutomatedTests"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m&#13;&#10;-Xmx1024m"/>
+</launchConfiguration>
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (Derby).launch b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (Derby).launch
index 2d77c0f926..87f61781c2 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (Derby).launch
+++ b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (Derby).launch
@@ -1,16 +1,16 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBDerby.java"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="1"/>
-</listAttribute>
-<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
-<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
-<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
-<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AllTestsDBDerby"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms512m&#13;&#10;-Xmx1024m"/>
-</launchConfiguration>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBDerby.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AllTestsDBDerby"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms512m&#13;&#10;-Xmx1024m"/>
+</launchConfiguration>
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 UUIDs).launch b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 UUIDs).launch
index 4274ffab3c..40f9ed5537 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 UUIDs).launch
+++ b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 UUIDs).launch
@@ -1,16 +1,16 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2BranchingUUIDs.java"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="1"/>
-</listAttribute>
-<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
-<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
-<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
-<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AllTestsDBH2BranchingUUIDs"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms512m&#13;&#10;-Xmx1536m&#13;&#10;-Dorg.eclipse.net4j.util.om.trace.disable=true"/>
-</launchConfiguration>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2BranchingUUIDs.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AllTestsDBH2BranchingUUIDs"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms512m&#13;&#10;-Xmx1536m&#13;&#10;-Dorg.eclipse.net4j.util.om.trace.disable=true"/>
+</launchConfiguration>
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 audit).launch b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 audit).launch
index 3940c37112..d00e13136c 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 audit).launch
+++ b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 audit).launch
@@ -1,16 +1,16 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Audit.java"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="1"/>
-</listAttribute>
-<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
-<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
-<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
-<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AllTestsDBH2Audit"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m&#13;&#10;-Xmx1024m&#13;&#10;-Dorg.eclipse.net4j.util.om.trace.disable=true"/>
-</launchConfiguration>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Audit.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AllTestsDBH2Audit"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m&#13;&#10;-Xmx1024m&#13;&#10;-Dorg.eclipse.net4j.util.om.trace.disable=true"/>
+</launchConfiguration>
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 branching).launch b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 branching).launch
index 6944a35a43..5cfaf6a2e0 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 branching).launch
+++ b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 branching).launch
@@ -1,16 +1,16 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Branching.java"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="1"/>
-</listAttribute>
-<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
-<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
-<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
-<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AllTestsDBH2Branching"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms512m&#13;&#10;-Xmx1536m&#13;&#10;-Dorg.eclipse.net4j.util.om.trace.disable=true"/>
-</launchConfiguration>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Branching.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AllTestsDBH2Branching"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms512m&#13;&#10;-Xmx1536m&#13;&#10;-Dorg.eclipse.net4j.util.om.trace.disable=true"/>
+</launchConfiguration>
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 non-audit).launch b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 non-audit).launch
index ece150a1bf..1f7d8aee32 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 non-audit).launch
+++ b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 non-audit).launch
@@ -1,16 +1,16 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2NonAudit.java"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="1"/>
-</listAttribute>
-<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
-<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
-<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
-<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AllTestsDBH2NonAudit"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m&#13;&#10;-Xmx1024m&#13;&#10;-Dorg.eclipse.net4j.util.om.trace.disable=true"/>
-</launchConfiguration>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2NonAudit.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AllTestsDBH2NonAudit"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m&#13;&#10;-Xmx1024m&#13;&#10;-Dorg.eclipse.net4j.util.om.trace.disable=true"/>
+</launchConfiguration>
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (Mysql).launch b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (Mysql).launch
index 23aa7d1ffa..8a8349be8b 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (Mysql).launch
+++ b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (Mysql).launch
@@ -1,16 +1,16 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysql.java"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="1"/>
-</listAttribute>
-<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
-<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
-<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
-<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AllTestsDBMysql"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms512m&#13;&#10;-Xmx1024m"/>
-</launchConfiguration>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysql.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AllTestsDBMysql"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms512m&#13;&#10;-Xmx1024m"/>
+</launchConfiguration>
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/copyright.txt b/plugins/org.eclipse.emf.cdo.tests.db/copyright.txt
index 8f6328980e..0a0f67e6d7 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/copyright.txt
+++ b/plugins/org.eclipse.emf.cdo.tests.db/copyright.txt
@@ -1,8 +1,8 @@
-Copyright (c) 2004 - 2012 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:
+Copyright (c) 2004 - 2012 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 \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/plugin.properties b/plugins/org.eclipse.emf.cdo.tests.db/plugin.properties
index 939a2bdd6e..97613de720 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/plugin.properties
+++ b/plugins/org.eclipse.emf.cdo.tests.db/plugin.properties
@@ -1,11 +1,11 @@
-# Copyright (c) 2004 - 2012 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
-
-pluginName = CDO Model Repository Tests DB
-providerName = Eclipse Modeling Project
+# Copyright (c) 2004 - 2012 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
+
+pluginName = CDO Model Repository Tests DB
+providerName = Eclipse Modeling Project
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBDerby.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBDerby.java
index 461905ed75..8e066825e4 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBDerby.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBDerby.java
@@ -1,34 +1,34 @@
-/*
- * Copyright (c) 2004 - 2012 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 junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTestsDBDerby extends DBConfigs
-{
- public static Test suite()
- {
- return new AllTestsDBDerby().getTestSuite("CDO Tests (DBStore Derby Horizontal)");
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, new DerbyConfig(true, true, IDGenerationLocation.STORE), JVM, NATIVE);
- // addScenario(parent, COMBINED, AllTestsDBDerby.Derby.INSTANCE, TCP, NATIVE);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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 junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTestsDBDerby extends DBConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsDBDerby().getTestSuite("CDO Tests (DBStore Derby Horizontal)");
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, new DerbyConfig(true, true, IDGenerationLocation.STORE), JVM, NATIVE);
+ // addScenario(parent, COMBINED, AllTestsDBDerby.Derby.INSTANCE, TCP, NATIVE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2All.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2All.java
index 279f8dc0a4..5973e08b79 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2All.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2All.java
@@ -1,42 +1,42 @@
-/*
- * Copyright (c) 2004 - 2012 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.common.CDOCommonRepository.IDGenerationLocation;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTestsDBH2All extends DBConfigs
-{
- public static Test suite()
- {
- return new AllTestsDBH2All().getTestSuite("CDO Tests (DBStore H2 All)");
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenarios(parent, IDGenerationLocation.STORE);
- addScenarios(parent, IDGenerationLocation.CLIENT);
- }
-
- private void addScenarios(TestSuite parent, IDGenerationLocation idGenerationLocation)
- {
- AllTestsDBH2NonAudit.initConfigSuites(this, parent, idGenerationLocation);
- AllTestsDBH2Audit.initConfigSuites(this, parent, idGenerationLocation);
- AllTestsDBH2Branching.initConfigSuites(this, parent, idGenerationLocation);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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.common.CDOCommonRepository.IDGenerationLocation;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTestsDBH2All extends DBConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsDBH2All().getTestSuite("CDO Tests (DBStore H2 All)");
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenarios(parent, IDGenerationLocation.STORE);
+ addScenarios(parent, IDGenerationLocation.CLIENT);
+ }
+
+ private void addScenarios(TestSuite parent, IDGenerationLocation idGenerationLocation)
+ {
+ AllTestsDBH2NonAudit.initConfigSuites(this, parent, idGenerationLocation);
+ AllTestsDBH2Audit.initConfigSuites(this, parent, idGenerationLocation);
+ AllTestsDBH2Branching.initConfigSuites(this, parent, idGenerationLocation);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2BranchingUUIDs.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2BranchingUUIDs.java
index 7eb5cc19d1..0398114056 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2BranchingUUIDs.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2BranchingUUIDs.java
@@ -1,33 +1,33 @@
-/*
- * Copyright (c) 2004 - 2012 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 junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTestsDBH2BranchingUUIDs extends DBConfigs
-{
- public static Test suite()
- {
- return new AllTestsDBH2BranchingUUIDs().getTestSuite("CDO Tests (DBStore H2 Horizontal - branching mode, UUIDs)");
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, new H2Config(true, true, false, false, IDGenerationLocation.CLIENT), JVM, NATIVE);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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 junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTestsDBH2BranchingUUIDs extends DBConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsDBH2BranchingUUIDs().getTestSuite("CDO Tests (DBStore H2 Horizontal - branching mode, UUIDs)");
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, new H2Config(true, true, false, false, IDGenerationLocation.CLIENT), JVM, NATIVE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2NonAudit.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2NonAudit.java
index d9c095c535..1adb183e45 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2NonAudit.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2NonAudit.java
@@ -1,39 +1,39 @@
-/*
- * Copyright (c) 2004 - 2012 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.config.impl.ConfigTestSuite;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTestsDBH2NonAudit extends DBConfigs
-{
- public static Test suite()
- {
- return new AllTestsDBH2NonAudit().getTestSuite("CDO Tests (DBStore H2 Horizontal - non-audit mode)");
- }
-
- public static void initConfigSuites(ConfigTestSuite suite, TestSuite parent, IDGenerationLocation idGenerationLocation)
- {
- suite.addScenario(parent, COMBINED, new H2Config(false, false, false, false, idGenerationLocation), JVM, NATIVE);
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- initConfigSuites(this, parent, IDGenerationLocation.STORE);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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.config.impl.ConfigTestSuite;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTestsDBH2NonAudit extends DBConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsDBH2NonAudit().getTestSuite("CDO Tests (DBStore H2 Horizontal - non-audit mode)");
+ }
+
+ public static void initConfigSuites(ConfigTestSuite suite, TestSuite parent, IDGenerationLocation idGenerationLocation)
+ {
+ suite.addScenario(parent, COMBINED, new H2Config(false, false, false, false, idGenerationLocation), JVM, NATIVE);
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ initConfigSuites(this, parent, IDGenerationLocation.STORE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldb.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldb.java
index b5e9d56501..9a636611be 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldb.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldb.java
@@ -1,47 +1,47 @@
-/*
- * Copyright (c) 2004 - 2012 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.bugzilla.Bugzilla_266982_Test;
-import org.eclipse.emf.cdo.tests.config.IScenario;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
-
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTestsDBHsqldb extends DBConfigs
-{
- public static Test suite()
- {
- return new AllTestsDBHsqldb().getTestSuite("CDO Tests (DBStore Hsql Horizontal)");
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, new HsqldbConfig(true, false, IDGenerationLocation.STORE), JVM, NATIVE);
- }
-
- @Override
- protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
- {
- super.initTestClasses(testClasses, scenario);
-
- // this takes ages ...
- testClasses.remove(Bugzilla_266982_Test.class);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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.bugzilla.Bugzilla_266982_Test;
+import org.eclipse.emf.cdo.tests.config.IScenario;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
+
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTestsDBHsqldb extends DBConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsDBHsqldb().getTestSuite("CDO Tests (DBStore Hsql Horizontal)");
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, new HsqldbConfig(true, false, IDGenerationLocation.STORE), JVM, NATIVE);
+ }
+
+ @Override
+ protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
+ {
+ super.initTestClasses(testClasses, scenario);
+
+ // this takes ages ...
+ testClasses.remove(Bugzilla_266982_Test.class);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldbNonAudit.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldbNonAudit.java
index 6a5019ddb9..3e57dd03b7 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldbNonAudit.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldbNonAudit.java
@@ -1,47 +1,47 @@
-/*
- * Copyright (c) 2004 - 2012 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:
- * Stefan Winkler - 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.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 junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Stefan Winkler
- */
-public class AllTestsDBHsqldbNonAudit extends DBConfigs
-{
- public static Test suite()
- {
- return new AllTestsDBHsqldbNonAudit().getTestSuite("CDO Tests (DBStore Hsql Horizontal Non-audit)");
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, new HsqldbConfig(false, false, IDGenerationLocation.STORE), TCP, NATIVE);
- }
-
- @Override
- protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
- {
- super.initTestClasses(testClasses, scenario);
-
- // this takes ages - so for now, we disable it
- testClasses.remove(Bugzilla_261218_Test.class);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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:
+ * Stefan Winkler - 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.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 junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Stefan Winkler
+ */
+public class AllTestsDBHsqldbNonAudit extends DBConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsDBHsqldbNonAudit().getTestSuite("CDO Tests (DBStore Hsql Horizontal Non-audit)");
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, new HsqldbConfig(false, false, IDGenerationLocation.STORE), TCP, NATIVE);
+ }
+
+ @Override
+ protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
+ {
+ super.initTestClasses(testClasses, scenario);
+
+ // this takes ages - so for now, we disable it
+ testClasses.remove(Bugzilla_261218_Test.class);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysql.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysql.java
index a5ade788be..d06bc38642 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysql.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysql.java
@@ -1,52 +1,52 @@
-/*
- * Copyright (c) 2004 - 2012 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:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.db;
-
-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 java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Simon McDuff
- */
-public class AllTestsDBMysql extends DBConfigs
-{
- public static Test suite()
- {
- return new AllTestsDBMysql().getTestSuite("CDO Tests (DBStore MySql Horizontal)");
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, new MysqlConfig(false, false, IDGenerationLocation.STORE), JVM, NATIVE);
- }
-
- @Override
- protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
- {
- // add branching tests for this testsuite
- testClasses.add(BranchingTest.class);
- testClasses.add(BranchingSameSessionTest.class);
- testClasses.add(MergingTest.class);
-
- super.initTestClasses(testClasses, scenario);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+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 java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Simon McDuff
+ */
+public class AllTestsDBMysql extends DBConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsDBMysql().getTestSuite("CDO Tests (DBStore MySql Horizontal)");
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, new MysqlConfig(false, false, IDGenerationLocation.STORE), JVM, NATIVE);
+ }
+
+ @Override
+ protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
+ {
+ // add branching tests for this testsuite
+ testClasses.add(BranchingTest.class);
+ testClasses.add(BranchingSameSessionTest.class);
+ testClasses.add(MergingTest.class);
+
+ super.initTestClasses(testClasses, scenario);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBPsql.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBPsql.java
index a4c84fa042..f1727851c2 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBPsql.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBPsql.java
@@ -1,42 +1,42 @@
-/*
- * Copyright (c) 2004 - 2012 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
- * Eike Stepper - maintenance
- * Stefan Winkler - maintenance
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * Database preparation before test execution:
- * <ol>
- * <li>create user sa (pass: sa)
- * <li>create databases cdodb1, authrepo, repo2
- * </ol>
- * Database creation/removal is avoided because it takes too long and makes the test-suite impractical.
- *
- * @author Victor Roldan Betancort
- */
-public class AllTestsDBPsql extends DBConfigs
-{
- public static Test suite()
- {
- return new AllTestsDBPsql().getTestSuite("CDO Tests (DBStore PSQL Horizontal)");
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, new PostgresqlConfig(false, false, IDGenerationLocation.STORE), JVM, NATIVE);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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
+ * Eike Stepper - maintenance
+ * Stefan Winkler - maintenance
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Database preparation before test execution:
+ * <ol>
+ * <li>create user sa (pass: sa)
+ * <li>create databases cdodb1, authrepo, repo2
+ * </ol>
+ * Database creation/removal is avoided because it takes too long and makes the test-suite impractical.
+ *
+ * @author Victor Roldan Betancort
+ */
+public class AllTestsDBPsql extends DBConfigs
+{
+ public static Test suite()
+ {
+ return new AllTestsDBPsql().getTestSuite("CDO Tests (DBStore PSQL Horizontal)");
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, new PostgresqlConfig(false, false, IDGenerationLocation.STORE), JVM, NATIVE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AutomatedTests.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AutomatedTests.java
index b8405b446c..7a36e4d4f8 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AutomatedTests.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AutomatedTests.java
@@ -1,32 +1,32 @@
-/*
- * Copyright (c) 2004 - 2012 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 junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AutomatedTests
-{
- public static Test suite()
- {
- TestSuite suite = new TestSuite(AutomatedTests.class.getName());
- suite.addTest(AllTestsDBH2NonAudit.suite());
- suite.addTest(AllTestsDBH2Audit.suite());
- suite.addTest(AllTestsDBH2Branching.suite());
- // suite.addTest(AllTestsDBH2Offline.suite());
- // suite.addTest(AllTestsDBHsqldb.suite());
- // suite.addTest(AllTestsDBHsqldbNonAudit.suite());
- return suite;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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 junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AutomatedTests
+{
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite(AutomatedTests.class.getName());
+ suite.addTest(AllTestsDBH2NonAudit.suite());
+ suite.addTest(AllTestsDBH2Audit.suite());
+ suite.addTest(AllTestsDBH2Branching.suite());
+ // suite.addTest(AllTestsDBH2Offline.suite());
+ // suite.addTest(AllTestsDBHsqldb.suite());
+ // suite.addTest(AllTestsDBHsqldbNonAudit.suite());
+ return suite;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Bugzilla_351078_DB_Test.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Bugzilla_351078_DB_Test.java
index 541d5a4b0f..1d7a3c68db 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Bugzilla_351078_DB_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Bugzilla_351078_DB_Test.java
@@ -1,78 +1,78 @@
-/*
- * Copyright (c) 2004 - 2012 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.db.IDBStore;
-import org.eclipse.emf.cdo.server.db.mapping.IClassMapping;
-import org.eclipse.emf.cdo.server.db.mapping.IListMapping;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.offline.Bugzilla_351078_Test;
-
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.ddl.IDBTable;
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-import java.io.ByteArrayOutputStream;
-import java.sql.Connection;
-import java.util.Arrays;
-
-/**
- * @author Eike Stepper
- */
-public class Bugzilla_351078_DB_Test extends Bugzilla_351078_Test
-{
- @Override
- protected void check(InternalRepository master, Company masterCompany, String when)
- {
- super.check(master, masterCompany, when);
-
- // XXX use capabilities?!
- DBOfflineConfig config = (DBOfflineConfig)getRepositoryConfig();
- if (config.isWithRanges())
- {
- byte[] masterTable = readTable(master);
- byte[] cloneTable = readTable(getRepository());
-
- assertEquals(true, Arrays.equals(masterTable, cloneTable));
- }
- }
-
- protected byte[] readTable(InternalRepository repository)
- {
- IDBStore store = (IDBStore)repository.getStore();
- IClassMapping classMapping = store.getMappingStrategy().getClassMapping(getModel1Package().getCompany());
- IListMapping listMapping = classMapping.getListMapping(getModel1Package().getCompany_Categories());
- IDBTable table = listMapping.getDBTables().iterator().next();
-
- Connection connection = null;
-
- try
- {
- connection = store.getConnection();
-
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- DBUtil.serializeTable(new ExtendedDataOutputStream(out), connection, table, null,
- " ORDER BY CDO_SOURCE, CDO_BRANCH, CDO_VERSION_ADDED, CDO_IDX");
-
- return out.toByteArray();
- }
- catch (Exception ex)
- {
- throw WrappedException.wrap(ex);
- }
- finally
- {
- DBUtil.close(connection);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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.db.IDBStore;
+import org.eclipse.emf.cdo.server.db.mapping.IClassMapping;
+import org.eclipse.emf.cdo.server.db.mapping.IListMapping;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.offline.Bugzilla_351078_Test;
+
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.ddl.IDBTable;
+import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+import java.io.ByteArrayOutputStream;
+import java.sql.Connection;
+import java.util.Arrays;
+
+/**
+ * @author Eike Stepper
+ */
+public class Bugzilla_351078_DB_Test extends Bugzilla_351078_Test
+{
+ @Override
+ protected void check(InternalRepository master, Company masterCompany, String when)
+ {
+ super.check(master, masterCompany, when);
+
+ // XXX use capabilities?!
+ DBOfflineConfig config = (DBOfflineConfig)getRepositoryConfig();
+ if (config.isWithRanges())
+ {
+ byte[] masterTable = readTable(master);
+ byte[] cloneTable = readTable(getRepository());
+
+ assertEquals(true, Arrays.equals(masterTable, cloneTable));
+ }
+ }
+
+ protected byte[] readTable(InternalRepository repository)
+ {
+ IDBStore store = (IDBStore)repository.getStore();
+ IClassMapping classMapping = store.getMappingStrategy().getClassMapping(getModel1Package().getCompany());
+ IListMapping listMapping = classMapping.getListMapping(getModel1Package().getCompany_Categories());
+ IDBTable table = listMapping.getDBTables().iterator().next();
+
+ Connection connection = null;
+
+ try
+ {
+ connection = store.getConnection();
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ DBUtil.serializeTable(new ExtendedDataOutputStream(out), connection, table, null,
+ " ORDER BY CDO_SOURCE, CDO_BRANCH, CDO_VERSION_ADDED, CDO_IDX");
+
+ return out.toByteArray();
+ }
+ catch (Exception ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ finally
+ {
+ DBUtil.close(connection);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Bugzilla_377727_Test.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Bugzilla_377727_Test.java
index 5a74d99886..83b2ecffbb 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Bugzilla_377727_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Bugzilla_377727_Test.java
@@ -1,104 +1,104 @@
-/*
- * Copyright (c) 2004 - 2012 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;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
-import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig.OfflineConfig;
-import org.eclipse.emf.cdo.tests.model1.Category;
-import org.eclipse.emf.cdo.tests.model3.Class1;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
-import org.eclipse.net4j.util.io.IOUtil;
-
-import java.util.Map;
-
-/**
- * @author Stefan Winkler
- */
-public class Bugzilla_377727_Test extends AbstractCDOTest
-{
- @Override
- public synchronized Map<String, Object> getTestProperties()
- {
- Map<String, Object> testProperties = super.getTestProperties();
- testProperties.put(OfflineConfig.PROP_TEST_RAW_REPLICATION, Boolean.TRUE);
- return testProperties;
- }
-
- @Requires(RepositoryConfig.CAPABILITY_OFFLINE)
- @CleanRepositoriesBefore
- public void testAsyncPackages() throws Exception
- {
- CDOID id1;
- CDOID id2;
-
- IOUtil.OUT().println("=== Disconnect clone ===");
-
- // disconnect clone from master
- ((OfflineConfig)getRepositoryConfig()).stopMasterTransport();
- ConcurrencyUtil.sleep(1000L);
- while (getRepository().getState() == CDOCommonRepository.State.ONLINE)
- {
- ConcurrencyUtil.sleep(250L);
- }
-
- IOUtil.OUT().println("=== Clone is disconnected ===");
-
- {
- // on disconnected master
- CDOSession session = openSession("master");
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("test"));
-
- Class1 c1 = getModel3Factory().createClass1();
- resource.getContents().add(c1);
- id1 = CDOUtil.getCDOObject(c1).cdoID();
-
- Category cat1 = getModel1Factory().createCategory();
- cat1.setName("Test");
- resource.getContents().add(cat1);
- id2 = CDOUtil.getCDOObject(cat1).cdoID();
-
- transaction.commit();
- transaction.close();
- session.close();
- }
-
- // reconnect clone and let sync
- IOUtil.OUT().println("=== reconnect clone ===");
-
- ((OfflineConfig)getRepositoryConfig()).startMasterTransport();
- while (getRepository().getState() != CDOCommonRepository.State.ONLINE)
- {
- ConcurrencyUtil.sleep(250L);
- }
-
- IOUtil.OUT().println("=== Clone is reconnected ===");
-
- CDOSession session = openSession();
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath("test"));
-
- Class1 c1 = (Class1)resource.getContents().get(0);
- assertEquals(id1, CDOUtil.getCDOObject(c1).cdoID());
-
- Category cat = (Category)resource.getContents().get(1);
- assertEquals(id2, CDOUtil.getCDOObject(cat).cdoID());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig.OfflineConfig;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model3.Class1;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
+import org.eclipse.net4j.util.io.IOUtil;
+
+import java.util.Map;
+
+/**
+ * @author Stefan Winkler
+ */
+public class Bugzilla_377727_Test extends AbstractCDOTest
+{
+ @Override
+ public synchronized Map<String, Object> getTestProperties()
+ {
+ Map<String, Object> testProperties = super.getTestProperties();
+ testProperties.put(OfflineConfig.PROP_TEST_RAW_REPLICATION, Boolean.TRUE);
+ return testProperties;
+ }
+
+ @Requires(RepositoryConfig.CAPABILITY_OFFLINE)
+ @CleanRepositoriesBefore
+ public void testAsyncPackages() throws Exception
+ {
+ CDOID id1;
+ CDOID id2;
+
+ IOUtil.OUT().println("=== Disconnect clone ===");
+
+ // disconnect clone from master
+ ((OfflineConfig)getRepositoryConfig()).stopMasterTransport();
+ ConcurrencyUtil.sleep(1000L);
+ while (getRepository().getState() == CDOCommonRepository.State.ONLINE)
+ {
+ ConcurrencyUtil.sleep(250L);
+ }
+
+ IOUtil.OUT().println("=== Clone is disconnected ===");
+
+ {
+ // on disconnected master
+ CDOSession session = openSession("master");
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("test"));
+
+ Class1 c1 = getModel3Factory().createClass1();
+ resource.getContents().add(c1);
+ id1 = CDOUtil.getCDOObject(c1).cdoID();
+
+ Category cat1 = getModel1Factory().createCategory();
+ cat1.setName("Test");
+ resource.getContents().add(cat1);
+ id2 = CDOUtil.getCDOObject(cat1).cdoID();
+
+ transaction.commit();
+ transaction.close();
+ session.close();
+ }
+
+ // reconnect clone and let sync
+ IOUtil.OUT().println("=== reconnect clone ===");
+
+ ((OfflineConfig)getRepositoryConfig()).startMasterTransport();
+ while (getRepository().getState() != CDOCommonRepository.State.ONLINE)
+ {
+ ConcurrencyUtil.sleep(250L);
+ }
+
+ IOUtil.OUT().println("=== Clone is reconnected ===");
+
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath("test"));
+
+ Class1 c1 = (Class1)resource.getContents().get(0);
+ assertEquals(id1, CDOUtil.getCDOObject(c1).cdoID());
+
+ Category cat = (Category)resource.getContents().get(1);
+ assertEquals(id2, CDOUtil.getCDOObject(cat).cdoID());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/CustomTypeMappingTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/CustomTypeMappingTest.java
index 3ac92291b9..2fd9bd44f4 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/CustomTypeMappingTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/CustomTypeMappingTest.java
@@ -1,162 +1,162 @@
-/*
- * Copyright (c) 2004 - 2012 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:
- * Stefan Winkler - initial API and implementation
- * Stefan Winkler - Bug 285426: [DB] Implement user-defined typeMapping support
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.server.db.mapping.AbstractTypeMapping;
-import org.eclipse.emf.cdo.server.db.mapping.AbstractTypeMappingFactory;
-import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
-import org.eclipse.emf.cdo.server.internal.db.mapping.TypeMappingUtil;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.db.verifier.DBStoreVerifier;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.net4j.db.DBType;
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.util.container.IPluginContainer;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-/**
- * @author Stefan Winkler
- */
-public class CustomTypeMappingTest extends AbstractCDOTest
-{
-
- public void testCustomTypeMapping() throws CommitException
- {
- // manually register type mapping
- MyIntToVarcharTypeMapping.Factory factory = new MyIntToVarcharTypeMapping.Factory();
- IPluginContainer.INSTANCE.registerFactory(factory);
-
- try
- {
- EPackage pkg = EMFUtil.createEPackage("underscoreTest2", "uct2",
- "http://cdo.eclipse.org/tests/underscoreTest2.ecore");
- EClass cls = EMFUtil.createEClass(pkg, "foo", false, false);
- EAttribute att = EMFUtil.createEAttribute(cls, "bar", EcorePackage.eINSTANCE.getEInt());
-
- // annotate type mapping and column type
- EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
- annotation.setSource("http://www.eclipse.org/CDO/DBStore");
- annotation.getDetails().put("typeMapping", "org.eclipse.emf.cdo.tests.db.EIntToVarchar");
- annotation.getDetails().put("columnType", DBType.VARCHAR.getKeyword());
- att.getEAnnotations().add(annotation);
-
- if (!isConfig(LEGACY))
- {
- CDOUtil.prepareDynamicEPackage(pkg);
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test"));
-
- EObject obj = EcoreUtil.create(cls);
- obj.eSet(att, 42);
-
- resource.getContents().add(obj);
- transaction.commit();
- transaction.close();
- session.close();
-
- msg("Check if type was mapped to string...");
- new DBStoreVerifier(getRepository())
- {
- @Override
- protected void doVerify() throws Exception
- {
- Statement stmt = null;
- ResultSet rset = null;
- try
- {
- stmt = getStatement();
- rset = stmt.executeQuery("SELECT bar FROM underscoreTest2_foo");
- assertEquals("java.lang.String", rset.getMetaData().getColumnClassName(1));
-
- rset.next();
- assertEquals("2a", rset.getString(1));
- }
- finally
- {
- DBUtil.close(rset);
- DBUtil.close(stmt);
- }
- }
- }.verify();
- }
- finally
- {
- IPluginContainer.INSTANCE.getFactoryRegistry().remove(factory.getKey());
- }
- }
-
- /**
- * @author Stefan Winkler
- */
- public static class MyIntToVarcharTypeMapping extends AbstractTypeMapping
- {
- public static final ITypeMapping.Descriptor DESCRIPTOR = TypeMappingUtil.createDescriptor(
- "org.eclipse.emf.cdo.tests.db.EIntToVarchar", EcorePackage.eINSTANCE.getEInt(), DBType.VARCHAR);
-
- public MyIntToVarcharTypeMapping()
- {
- }
-
- @Override
- protected void doSetValue(PreparedStatement stmt, int index, Object value) throws SQLException
- {
- Integer val = (Integer)value;
- stmt.setString(index, Integer.toHexString(val));
- }
-
- @Override
- protected Object getResultSetValue(ResultSet resultSet) throws SQLException
- {
- String stringVal = resultSet.getString(getField().getName());
- return Integer.parseInt(stringVal, 16);
- }
-
- /**
- * @author Stefan Winkler
- */
- public static class Factory extends AbstractTypeMappingFactory
- {
- public Factory()
- {
- super(DESCRIPTOR);
- }
-
- @Override
- public ITypeMapping create(String description)
- {
- return new MyIntToVarcharTypeMapping();
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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:
+ * Stefan Winkler - initial API and implementation
+ * Stefan Winkler - Bug 285426: [DB] Implement user-defined typeMapping support
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.db.mapping.AbstractTypeMapping;
+import org.eclipse.emf.cdo.server.db.mapping.AbstractTypeMappingFactory;
+import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
+import org.eclipse.emf.cdo.server.internal.db.mapping.TypeMappingUtil;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.db.verifier.DBStoreVerifier;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.net4j.db.DBType;
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.util.container.IPluginContainer;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * @author Stefan Winkler
+ */
+public class CustomTypeMappingTest extends AbstractCDOTest
+{
+
+ public void testCustomTypeMapping() throws CommitException
+ {
+ // manually register type mapping
+ MyIntToVarcharTypeMapping.Factory factory = new MyIntToVarcharTypeMapping.Factory();
+ IPluginContainer.INSTANCE.registerFactory(factory);
+
+ try
+ {
+ EPackage pkg = EMFUtil.createEPackage("underscoreTest2", "uct2",
+ "http://cdo.eclipse.org/tests/underscoreTest2.ecore");
+ EClass cls = EMFUtil.createEClass(pkg, "foo", false, false);
+ EAttribute att = EMFUtil.createEAttribute(cls, "bar", EcorePackage.eINSTANCE.getEInt());
+
+ // annotate type mapping and column type
+ EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ annotation.setSource("http://www.eclipse.org/CDO/DBStore");
+ annotation.getDetails().put("typeMapping", "org.eclipse.emf.cdo.tests.db.EIntToVarchar");
+ annotation.getDetails().put("columnType", DBType.VARCHAR.getKeyword());
+ att.getEAnnotations().add(annotation);
+
+ if (!isConfig(LEGACY))
+ {
+ CDOUtil.prepareDynamicEPackage(pkg);
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test"));
+
+ EObject obj = EcoreUtil.create(cls);
+ obj.eSet(att, 42);
+
+ resource.getContents().add(obj);
+ transaction.commit();
+ transaction.close();
+ session.close();
+
+ msg("Check if type was mapped to string...");
+ new DBStoreVerifier(getRepository())
+ {
+ @Override
+ protected void doVerify() throws Exception
+ {
+ Statement stmt = null;
+ ResultSet rset = null;
+ try
+ {
+ stmt = getStatement();
+ rset = stmt.executeQuery("SELECT bar FROM underscoreTest2_foo");
+ assertEquals("java.lang.String", rset.getMetaData().getColumnClassName(1));
+
+ rset.next();
+ assertEquals("2a", rset.getString(1));
+ }
+ finally
+ {
+ DBUtil.close(rset);
+ DBUtil.close(stmt);
+ }
+ }
+ }.verify();
+ }
+ finally
+ {
+ IPluginContainer.INSTANCE.getFactoryRegistry().remove(factory.getKey());
+ }
+ }
+
+ /**
+ * @author Stefan Winkler
+ */
+ public static class MyIntToVarcharTypeMapping extends AbstractTypeMapping
+ {
+ public static final ITypeMapping.Descriptor DESCRIPTOR = TypeMappingUtil.createDescriptor(
+ "org.eclipse.emf.cdo.tests.db.EIntToVarchar", EcorePackage.eINSTANCE.getEInt(), DBType.VARCHAR);
+
+ public MyIntToVarcharTypeMapping()
+ {
+ }
+
+ @Override
+ protected void doSetValue(PreparedStatement stmt, int index, Object value) throws SQLException
+ {
+ Integer val = (Integer)value;
+ stmt.setString(index, Integer.toHexString(val));
+ }
+
+ @Override
+ protected Object getResultSetValue(ResultSet resultSet) throws SQLException
+ {
+ String stringVal = resultSet.getString(getField().getName());
+ return Integer.parseInt(stringVal, 16);
+ }
+
+ /**
+ * @author Stefan Winkler
+ */
+ public static class Factory extends AbstractTypeMappingFactory
+ {
+ public Factory()
+ {
+ super(DESCRIPTOR);
+ }
+
+ @Override
+ public ITypeMapping create(String description)
+ {
+ return new MyIntToVarcharTypeMapping();
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java
index 338b609056..b599173e79 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java
@@ -1,493 +1,493 @@
-/*
- * Copyright (c) 2004 - 2012 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:
- * Kai Schlamp - initial API and implementation
- * Eike Stepper - maintenance
- * Stefan Winkler - Bug 285426: [DB] Implement user-defined typeMapping support
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Skips;
-import org.eclipse.emf.cdo.tests.db.verifier.DBStoreVerifier;
-import org.eclipse.emf.cdo.tests.model1.Model1Package;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.net4j.db.DBUtil;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import java.sql.ResultSet;
-
-/**
- * Test different DB annotations.
- *
- * @author Kai Schlamp
- */
-// XXX PSQL fails, too - need to investigate
-@Skips("Postgresql")
-public class DBAnnotationsTest extends AbstractCDOTest
-{
- private static int modelCounter;
-
- public void testLengthAnnotationPositive() throws Exception
- {
- msg("Opening session");
- EPackage model1 = createModel();
- addLengthAnnotation(model1, "8");
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(model1);
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Commit a product that has a name with an allowed string length.");
- EClass eClass = (EClass)model1.getEClassifier("Product1");
- EObject product = model1.getEFactoryInstance().create(eClass);
- product.eSet(eClass.getEStructuralFeature("name"), "01234567");
-
- resource.getContents().add(product);
- transaction.commit();
- transaction.close();
- session.close();
- }
-
- // HSQL does not support length annotations
- @Skips("Hsqldb")
- public void testLengthAnnotationNegative() throws Exception
- {
- msg("Opening session");
- EPackage model1 = createModel();
- addLengthAnnotation(model1, "8");
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(model1);
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Commit a product that has a name with an invalid string length.");
- EClass eClass = (EClass)model1.getEClassifier("Product1");
- EObject product = model1.getEFactoryInstance().create(eClass);
- product.eSet(eClass.getEStructuralFeature("name"), "012345678");
-
- resource.getContents().add(product);
-
- try
- {
- transaction.commit();
- fail("Committing too long data did not result in an exception");
- }
- catch (Exception success)
- {
- }
- finally
- {
- transaction.close();
- session.close();
- }
- }
-
- public void testLengthAnnotationByMetaData() throws CommitException
- {
- msg("Opening session");
- final EPackage model1 = createModel();
- addLengthAnnotation(model1, "8");
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(model1);
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Commit a product.");
- EClass eClass = (EClass)model1.getEClassifier("Product1");
- EObject product = model1.getEFactoryInstance().create(eClass);
- resource.getContents().add(product);
-
- transaction.commit();
- transaction.close();
- session.close();
-
- msg("Check if column size was correctly set.");
- new DBStoreVerifier(getRepository())
- {
- @Override
- protected void doVerify() throws Exception
- {
- String tableName = model1.getName().toUpperCase() + "_PRODUCT1";
- ResultSet rset = getMetaData().getColumns(null, null, tableName, "NAME");
-
- try
- {
- rset.next();
- assertEquals("8", rset.getString(7));
- }
- finally
- {
- DBUtil.close(rset);
- }
- }
- }.verify();
- }
-
- // HSQL does not support type annotations
- @Skips("Hsqldb")
- public void testTypeAnnotationByMetaData() throws CommitException
- {
- msg("Opening session");
- final EPackage model1 = createModel();
- addTypeAnnotation(model1, "CLOB");
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(model1);
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Commit a category.");
- EClass eClass = (EClass)model1.getEClassifier("Category");
- EObject category = model1.getEFactoryInstance().create(eClass);
-
- resource.getContents().add(category);
- transaction.commit();
- transaction.close();
- session.close();
-
- msg("Check if column type was correctly set.");
- new DBStoreVerifier(getRepository())
- {
- @Override
- protected void doVerify() throws Exception
- {
- String tableName = model1.getName().toUpperCase() + "_CATEGORY";
- ResultSet rset = getMetaData().getColumns(null, null, tableName, "NAME");
-
- try
- {
- rset.next();
- assertEquals("CLOB", rset.getString(6));
- }
- finally
- {
- DBUtil.close(rset);
- }
- }
- }.verify();
- }
-
- public void testTableNameAnnotationByMetaData() throws CommitException
- {
- msg("Opening session");
- EPackage model1 = createModel();
- addTableNameAnnotation(model1, "Subject");
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(model1);
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Commit a category.");
- EClass eClass = (EClass)model1.getEClassifier("Category");
- EObject category = model1.getEFactoryInstance().create(eClass);
-
- resource.getContents().add(category);
- transaction.commit();
- transaction.close();
- session.close();
-
- msg("Check if table name was correctly set.");
- new DBStoreVerifier(getRepository())
- {
- @Override
- protected void doVerify() throws Exception
- {
- ResultSet rset = getMetaData().getTables(null, null, "SUBJECT", null);
-
- try
- {
- rset.next();
- assertEquals("SUBJECT", rset.getString(3));
- }
- finally
- {
- DBUtil.close(rset);
- }
- }
- }.verify();
- }
-
- public void testColumnNameAnnotationByMetaData() throws CommitException
- {
- msg("Opening session");
- final EPackage model1 = createModel();
- addColumnNameAnnotation(model1, "TOPIC");
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(model1);
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Commit a category.");
- EClass eClass = (EClass)model1.getEClassifier("Category");
- EObject category = model1.getEFactoryInstance().create(eClass);
-
- resource.getContents().add(category);
- transaction.commit();
- transaction.close();
- session.close();
-
- msg("Check if table name was correctly set.");
- new DBStoreVerifier(getRepository())
- {
- @Override
- protected void doVerify() throws Exception
- {
- String tableName = model1.getName().toUpperCase() + "_CATEGORY";
- ResultSet rset = getMetaData().getColumns(null, null, tableName, "TOPIC");
-
- try
- {
- rset.next();
- assertEquals("TOPIC", rset.getString(4));
- }
- finally
- {
- DBUtil.close(rset);
- }
- }
- }.verify();
- }
-
- // HSQL does not support type annotations
- @Skips("Hsqldb")
- public void testColumnNameTypeAnnotationByMetaData() throws CommitException
- {
- msg("Opening session");
- final EPackage model1 = createModel();
- addColumnNameAndTypeAnnoation(model1, "TOPIC", "CLOB");
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(model1);
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Commit a category.");
- EClass eClass = (EClass)model1.getEClassifier("Category");
- EObject category = model1.getEFactoryInstance().create(eClass);
-
- resource.getContents().add(category);
- transaction.commit();
- transaction.close();
- session.close();
-
- msg("Check if table name was correctly set.");
- new DBStoreVerifier(getRepository())
- {
- @Override
- protected void doVerify() throws Exception
- {
- String tableName = model1.getName().toUpperCase() + "_CATEGORY";
- ResultSet rset = getMetaData().getColumns(null, null, tableName, "TOPIC");
-
- try
- {
- rset.next();
- assertEquals("TOPIC", rset.getString(4));
- assertEquals("CLOB", rset.getString(6));
- }
- finally
- {
- DBUtil.close(rset);
- }
- }
- }.verify();
- }
-
- public void testTableMappingAnnotationByMetaData() throws CommitException
- {
- msg("Opening session");
- final EPackage model1 = createModel();
- addTableMappingAnnotation(model1, "OrderDetail", "Company");
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(model1);
-
- msg("Opening transaction");
- CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
- CDOResource resource = transaction.createResource(getResourcePath("/test1"));
-
- msg("Commit a category.");
- EClass eClass = (EClass)model1.getEClassifier("Category");
- EObject category = model1.getEFactoryInstance().create(eClass);
-
- resource.getContents().add(category);
- transaction.commit();
- transaction.close();
- session.close();
-
- msg("Check if table name was correctly set.");
- new DBStoreVerifier(getRepository())
- {
- @Override
- protected void doVerify() throws Exception
- {
- ResultSet rset = getMetaData().getTables(null, null, null, null);
-
- try
- {
- boolean orderDetailTableCreated = false;
- boolean companyTableCreated = false;
- boolean categoryTableCreated = false;
-
- String prefix = model1.getName().toUpperCase() + '_';
- while (rset.next())
- {
- String tableName = rset.getString(3);
- if ((prefix + "ORDERDETAIL").equalsIgnoreCase(tableName))
- {
- orderDetailTableCreated = true;
- }
- else if ((prefix + "COMPANY").equalsIgnoreCase(tableName))
- {
- companyTableCreated = true;
- }
- else if ((prefix + "CATEGORY").equalsIgnoreCase(tableName))
- {
- categoryTableCreated = true;
- }
- }
-
- assertEquals(false, orderDetailTableCreated);
- assertEquals(false, companyTableCreated);
- assertEquals(true, categoryTableCreated);
- }
- finally
- {
- DBUtil.close(rset);
- }
- }
- }.verify();
- }
-
- private EPackage createModel()
- {
- EPackage ePackage = EcoreUtil.copy(getModel1Package());
- String suffix = "_dynamic" + modelCounter++;
- ePackage.setNsURI(ePackage.getNsURI() + suffix);
- ePackage.setName(ePackage.getName() + suffix);
- return ePackage;
- }
-
- private void addLengthAnnotation(EPackage model1, String value)
- {
- EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
- annotation.setSource("http://www.eclipse.org/CDO/DBStore");
- annotation.getDetails().put("columnLength", value);
-
- EClass product1 = (EClass)model1.getEClassifier("Product1");
- EStructuralFeature element = product1.getEStructuralFeature(Model1Package.PRODUCT1__NAME);
- element.getEAnnotations().add(annotation);
- }
-
- private void addTypeAnnotation(EPackage model1, String value)
- {
- EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
- annotation.setSource("http://www.eclipse.org/CDO/DBStore");
- annotation.getDetails().put("columnType", value);
-
- EClass category = (EClass)model1.getEClassifier("Category");
- EStructuralFeature element = category.getEStructuralFeature(Model1Package.CATEGORY__NAME);
- element.getEAnnotations().add(annotation);
- }
-
- private void addTableNameAnnotation(EPackage model1, String value)
- {
- EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
- annotation.setSource("http://www.eclipse.org/CDO/DBStore");
- annotation.getDetails().put("tableName", value);
-
- EClass category = (EClass)model1.getEClassifier("Category");
- category.getEAnnotations().add(annotation);
- }
-
- private void addColumnNameAnnotation(EPackage model1, String value)
- {
- EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
- annotation.setSource("http://www.eclipse.org/CDO/DBStore");
- annotation.getDetails().put("columnName", value);
-
- EClass category = (EClass)model1.getEClassifier("Category");
- EStructuralFeature element = category.getEStructuralFeature(Model1Package.CATEGORY__NAME);
- element.getEAnnotations().add(annotation);
- }
-
- private void addColumnNameAndTypeAnnoation(EPackage model1, String name, String type)
- {
- EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
- annotation.setSource("http://www.eclipse.org/CDO/DBStore");
- annotation.getDetails().put("columnName", name);
- annotation.getDetails().put("columnType", type);
-
- EClass category = (EClass)model1.getEClassifier("Category");
- EStructuralFeature element = category.getEStructuralFeature(Model1Package.CATEGORY__NAME);
- element.getEAnnotations().add(annotation);
- }
-
- private void addTableMappingAnnotation(EPackage model1, String... unmappedTables)
- {
- for (String unmappedTable : unmappedTables)
- {
- EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
- annotation.setSource("http://www.eclipse.org/CDO/DBStore");
- annotation.getDetails().put("tableMapping", "NONE");
-
- // ID is defined in plugin.xml
- annotation.getDetails().put("typeMapping", "org.eclipse.emf.cdo.tests.db.EIntToVarchar");
-
- EClass orderDetail = (EClass)model1.getEClassifier(unmappedTable);
- orderDetail.getEAnnotations().add(annotation);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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:
+ * Kai Schlamp - initial API and implementation
+ * Eike Stepper - maintenance
+ * Stefan Winkler - Bug 285426: [DB] Implement user-defined typeMapping support
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Skips;
+import org.eclipse.emf.cdo.tests.db.verifier.DBStoreVerifier;
+import org.eclipse.emf.cdo.tests.model1.Model1Package;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.net4j.db.DBUtil;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import java.sql.ResultSet;
+
+/**
+ * Test different DB annotations.
+ *
+ * @author Kai Schlamp
+ */
+// XXX PSQL fails, too - need to investigate
+@Skips("Postgresql")
+public class DBAnnotationsTest extends AbstractCDOTest
+{
+ private static int modelCounter;
+
+ public void testLengthAnnotationPositive() throws Exception
+ {
+ msg("Opening session");
+ EPackage model1 = createModel();
+ addLengthAnnotation(model1, "8");
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model1);
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Commit a product that has a name with an allowed string length.");
+ EClass eClass = (EClass)model1.getEClassifier("Product1");
+ EObject product = model1.getEFactoryInstance().create(eClass);
+ product.eSet(eClass.getEStructuralFeature("name"), "01234567");
+
+ resource.getContents().add(product);
+ transaction.commit();
+ transaction.close();
+ session.close();
+ }
+
+ // HSQL does not support length annotations
+ @Skips("Hsqldb")
+ public void testLengthAnnotationNegative() throws Exception
+ {
+ msg("Opening session");
+ EPackage model1 = createModel();
+ addLengthAnnotation(model1, "8");
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model1);
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Commit a product that has a name with an invalid string length.");
+ EClass eClass = (EClass)model1.getEClassifier("Product1");
+ EObject product = model1.getEFactoryInstance().create(eClass);
+ product.eSet(eClass.getEStructuralFeature("name"), "012345678");
+
+ resource.getContents().add(product);
+
+ try
+ {
+ transaction.commit();
+ fail("Committing too long data did not result in an exception");
+ }
+ catch (Exception success)
+ {
+ }
+ finally
+ {
+ transaction.close();
+ session.close();
+ }
+ }
+
+ public void testLengthAnnotationByMetaData() throws CommitException
+ {
+ msg("Opening session");
+ final EPackage model1 = createModel();
+ addLengthAnnotation(model1, "8");
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model1);
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Commit a product.");
+ EClass eClass = (EClass)model1.getEClassifier("Product1");
+ EObject product = model1.getEFactoryInstance().create(eClass);
+ resource.getContents().add(product);
+
+ transaction.commit();
+ transaction.close();
+ session.close();
+
+ msg("Check if column size was correctly set.");
+ new DBStoreVerifier(getRepository())
+ {
+ @Override
+ protected void doVerify() throws Exception
+ {
+ String tableName = model1.getName().toUpperCase() + "_PRODUCT1";
+ ResultSet rset = getMetaData().getColumns(null, null, tableName, "NAME");
+
+ try
+ {
+ rset.next();
+ assertEquals("8", rset.getString(7));
+ }
+ finally
+ {
+ DBUtil.close(rset);
+ }
+ }
+ }.verify();
+ }
+
+ // HSQL does not support type annotations
+ @Skips("Hsqldb")
+ public void testTypeAnnotationByMetaData() throws CommitException
+ {
+ msg("Opening session");
+ final EPackage model1 = createModel();
+ addTypeAnnotation(model1, "CLOB");
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model1);
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Commit a category.");
+ EClass eClass = (EClass)model1.getEClassifier("Category");
+ EObject category = model1.getEFactoryInstance().create(eClass);
+
+ resource.getContents().add(category);
+ transaction.commit();
+ transaction.close();
+ session.close();
+
+ msg("Check if column type was correctly set.");
+ new DBStoreVerifier(getRepository())
+ {
+ @Override
+ protected void doVerify() throws Exception
+ {
+ String tableName = model1.getName().toUpperCase() + "_CATEGORY";
+ ResultSet rset = getMetaData().getColumns(null, null, tableName, "NAME");
+
+ try
+ {
+ rset.next();
+ assertEquals("CLOB", rset.getString(6));
+ }
+ finally
+ {
+ DBUtil.close(rset);
+ }
+ }
+ }.verify();
+ }
+
+ public void testTableNameAnnotationByMetaData() throws CommitException
+ {
+ msg("Opening session");
+ EPackage model1 = createModel();
+ addTableNameAnnotation(model1, "Subject");
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model1);
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Commit a category.");
+ EClass eClass = (EClass)model1.getEClassifier("Category");
+ EObject category = model1.getEFactoryInstance().create(eClass);
+
+ resource.getContents().add(category);
+ transaction.commit();
+ transaction.close();
+ session.close();
+
+ msg("Check if table name was correctly set.");
+ new DBStoreVerifier(getRepository())
+ {
+ @Override
+ protected void doVerify() throws Exception
+ {
+ ResultSet rset = getMetaData().getTables(null, null, "SUBJECT", null);
+
+ try
+ {
+ rset.next();
+ assertEquals("SUBJECT", rset.getString(3));
+ }
+ finally
+ {
+ DBUtil.close(rset);
+ }
+ }
+ }.verify();
+ }
+
+ public void testColumnNameAnnotationByMetaData() throws CommitException
+ {
+ msg("Opening session");
+ final EPackage model1 = createModel();
+ addColumnNameAnnotation(model1, "TOPIC");
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model1);
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Commit a category.");
+ EClass eClass = (EClass)model1.getEClassifier("Category");
+ EObject category = model1.getEFactoryInstance().create(eClass);
+
+ resource.getContents().add(category);
+ transaction.commit();
+ transaction.close();
+ session.close();
+
+ msg("Check if table name was correctly set.");
+ new DBStoreVerifier(getRepository())
+ {
+ @Override
+ protected void doVerify() throws Exception
+ {
+ String tableName = model1.getName().toUpperCase() + "_CATEGORY";
+ ResultSet rset = getMetaData().getColumns(null, null, tableName, "TOPIC");
+
+ try
+ {
+ rset.next();
+ assertEquals("TOPIC", rset.getString(4));
+ }
+ finally
+ {
+ DBUtil.close(rset);
+ }
+ }
+ }.verify();
+ }
+
+ // HSQL does not support type annotations
+ @Skips("Hsqldb")
+ public void testColumnNameTypeAnnotationByMetaData() throws CommitException
+ {
+ msg("Opening session");
+ final EPackage model1 = createModel();
+ addColumnNameAndTypeAnnoation(model1, "TOPIC", "CLOB");
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model1);
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Commit a category.");
+ EClass eClass = (EClass)model1.getEClassifier("Category");
+ EObject category = model1.getEFactoryInstance().create(eClass);
+
+ resource.getContents().add(category);
+ transaction.commit();
+ transaction.close();
+ session.close();
+
+ msg("Check if table name was correctly set.");
+ new DBStoreVerifier(getRepository())
+ {
+ @Override
+ protected void doVerify() throws Exception
+ {
+ String tableName = model1.getName().toUpperCase() + "_CATEGORY";
+ ResultSet rset = getMetaData().getColumns(null, null, tableName, "TOPIC");
+
+ try
+ {
+ rset.next();
+ assertEquals("TOPIC", rset.getString(4));
+ assertEquals("CLOB", rset.getString(6));
+ }
+ finally
+ {
+ DBUtil.close(rset);
+ }
+ }
+ }.verify();
+ }
+
+ public void testTableMappingAnnotationByMetaData() throws CommitException
+ {
+ msg("Opening session");
+ final EPackage model1 = createModel();
+ addTableMappingAnnotation(model1, "OrderDetail", "Company");
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(model1);
+
+ msg("Opening transaction");
+ CDOTransaction transaction = session.openTransaction();
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource(getResourcePath("/test1"));
+
+ msg("Commit a category.");
+ EClass eClass = (EClass)model1.getEClassifier("Category");
+ EObject category = model1.getEFactoryInstance().create(eClass);
+
+ resource.getContents().add(category);
+ transaction.commit();
+ transaction.close();
+ session.close();
+
+ msg("Check if table name was correctly set.");
+ new DBStoreVerifier(getRepository())
+ {
+ @Override
+ protected void doVerify() throws Exception
+ {
+ ResultSet rset = getMetaData().getTables(null, null, null, null);
+
+ try
+ {
+ boolean orderDetailTableCreated = false;
+ boolean companyTableCreated = false;
+ boolean categoryTableCreated = false;
+
+ String prefix = model1.getName().toUpperCase() + '_';
+ while (rset.next())
+ {
+ String tableName = rset.getString(3);
+ if ((prefix + "ORDERDETAIL").equalsIgnoreCase(tableName))
+ {
+ orderDetailTableCreated = true;
+ }
+ else if ((prefix + "COMPANY").equalsIgnoreCase(tableName))
+ {
+ companyTableCreated = true;
+ }
+ else if ((prefix + "CATEGORY").equalsIgnoreCase(tableName))
+ {
+ categoryTableCreated = true;
+ }
+ }
+
+ assertEquals(false, orderDetailTableCreated);
+ assertEquals(false, companyTableCreated);
+ assertEquals(true, categoryTableCreated);
+ }
+ finally
+ {
+ DBUtil.close(rset);
+ }
+ }
+ }.verify();
+ }
+
+ private EPackage createModel()
+ {
+ EPackage ePackage = EcoreUtil.copy(getModel1Package());
+ String suffix = "_dynamic" + modelCounter++;
+ ePackage.setNsURI(ePackage.getNsURI() + suffix);
+ ePackage.setName(ePackage.getName() + suffix);
+ return ePackage;
+ }
+
+ private void addLengthAnnotation(EPackage model1, String value)
+ {
+ EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ annotation.setSource("http://www.eclipse.org/CDO/DBStore");
+ annotation.getDetails().put("columnLength", value);
+
+ EClass product1 = (EClass)model1.getEClassifier("Product1");
+ EStructuralFeature element = product1.getEStructuralFeature(Model1Package.PRODUCT1__NAME);
+ element.getEAnnotations().add(annotation);
+ }
+
+ private void addTypeAnnotation(EPackage model1, String value)
+ {
+ EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ annotation.setSource("http://www.eclipse.org/CDO/DBStore");
+ annotation.getDetails().put("columnType", value);
+
+ EClass category = (EClass)model1.getEClassifier("Category");
+ EStructuralFeature element = category.getEStructuralFeature(Model1Package.CATEGORY__NAME);
+ element.getEAnnotations().add(annotation);
+ }
+
+ private void addTableNameAnnotation(EPackage model1, String value)
+ {
+ EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ annotation.setSource("http://www.eclipse.org/CDO/DBStore");
+ annotation.getDetails().put("tableName", value);
+
+ EClass category = (EClass)model1.getEClassifier("Category");
+ category.getEAnnotations().add(annotation);
+ }
+
+ private void addColumnNameAnnotation(EPackage model1, String value)
+ {
+ EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ annotation.setSource("http://www.eclipse.org/CDO/DBStore");
+ annotation.getDetails().put("columnName", value);
+
+ EClass category = (EClass)model1.getEClassifier("Category");
+ EStructuralFeature element = category.getEStructuralFeature(Model1Package.CATEGORY__NAME);
+ element.getEAnnotations().add(annotation);
+ }
+
+ private void addColumnNameAndTypeAnnoation(EPackage model1, String name, String type)
+ {
+ EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ annotation.setSource("http://www.eclipse.org/CDO/DBStore");
+ annotation.getDetails().put("columnName", name);
+ annotation.getDetails().put("columnType", type);
+
+ EClass category = (EClass)model1.getEClassifier("Category");
+ EStructuralFeature element = category.getEStructuralFeature(Model1Package.CATEGORY__NAME);
+ element.getEAnnotations().add(annotation);
+ }
+
+ private void addTableMappingAnnotation(EPackage model1, String... unmappedTables)
+ {
+ for (String unmappedTable : unmappedTables)
+ {
+ EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ annotation.setSource("http://www.eclipse.org/CDO/DBStore");
+ annotation.getDetails().put("tableMapping", "NONE");
+
+ // ID is defined in plugin.xml
+ annotation.getDetails().put("typeMapping", "org.eclipse.emf.cdo.tests.db.EIntToVarchar");
+
+ EClass orderDetail = (EClass)model1.getEClassifier(unmappedTable);
+ orderDetail.getEAnnotations().add(annotation);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfig.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfig.java
index 0a502f8609..0db52c1187 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfig.java
@@ -1,139 +1,139 @@
-/*
- * Copyright (c) 2004 - 2012 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.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.db.IDBConnectionProvider;
-import org.eclipse.net4j.util.container.IPluginContainer;
-
-import javax.sql.DataSource;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public abstract class DBConfig extends RepositoryConfig
-{
- public static final String CAPABILITY_RANGES = "DB.ranges";
-
- public static final String CAPABILITY_COPY_ON_BRANCH = "DB.copy.on.branch";
-
- private static final long serialVersionUID = 1L;
-
- 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;
- }
-
- @Override
- public void initCapabilities(Set<String> capabilities)
- {
- super.initCapabilities(capabilities);
- capabilities.add(getDBAdapterName());
-
- if (isWithRanges())
- {
- capabilities.add(CAPABILITY_RANGES);
- }
-
- if (isCopyOnBranch())
- {
- capabilities.add(CAPABILITY_COPY_ON_BRANCH);
- }
- }
-
- protected abstract String getDBAdapterName();
-
- @Override
- protected String getStoreName()
- {
- return "DB";
- }
-
- public boolean isWithRanges()
- {
- return withRanges;
- }
-
- public boolean isCopyOnBranch()
- {
- return copyOnBranch;
- }
-
- @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);
- IDBConnectionProvider connectionProvider = DBUtil.createConnectionProvider(dataSource);
-
- return CDODBUtil.createStore(mappingStrategy, dbAdapter, connectionProvider);
- }
-
- protected Map<String, String> createMappingStrategyProperties()
- {
- Map<String, String> props = new HashMap<String, String>();
- props.put(IMappingStrategy.PROP_QUALIFIED_NAMES, "true");
- props.put(CDODBUtil.PROP_COPY_ON_BRANCH, Boolean.toString(copyOnBranch));
- return props;
- }
-
- protected IMappingStrategy createMappingStrategy()
- {
- return CDODBUtil.createHorizontalMappingStrategy(isSupportingAudits(), isSupportingBranches(), withRanges);
- }
-
- @Override
- protected String getMappingStrategySpecialization()
- {
- return (withRanges ? "-ranges" : "") + (copyOnBranch ? "-copy" : "");
- }
-
- protected abstract IDBAdapter createDBAdapter();
-
- protected abstract DataSource createDataSource(String repoName);
-}
+/*
+ * Copyright (c) 2004 - 2012 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.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.db.IDBConnectionProvider;
+import org.eclipse.net4j.util.container.IPluginContainer;
+
+import javax.sql.DataSource;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class DBConfig extends RepositoryConfig
+{
+ public static final String CAPABILITY_RANGES = "DB.ranges";
+
+ public static final String CAPABILITY_COPY_ON_BRANCH = "DB.copy.on.branch";
+
+ private static final long serialVersionUID = 1L;
+
+ 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;
+ }
+
+ @Override
+ public void initCapabilities(Set<String> capabilities)
+ {
+ super.initCapabilities(capabilities);
+ capabilities.add(getDBAdapterName());
+
+ if (isWithRanges())
+ {
+ capabilities.add(CAPABILITY_RANGES);
+ }
+
+ if (isCopyOnBranch())
+ {
+ capabilities.add(CAPABILITY_COPY_ON_BRANCH);
+ }
+ }
+
+ protected abstract String getDBAdapterName();
+
+ @Override
+ protected String getStoreName()
+ {
+ return "DB";
+ }
+
+ public boolean isWithRanges()
+ {
+ return withRanges;
+ }
+
+ public boolean isCopyOnBranch()
+ {
+ return copyOnBranch;
+ }
+
+ @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);
+ IDBConnectionProvider connectionProvider = DBUtil.createConnectionProvider(dataSource);
+
+ return CDODBUtil.createStore(mappingStrategy, dbAdapter, connectionProvider);
+ }
+
+ protected Map<String, String> createMappingStrategyProperties()
+ {
+ Map<String, String> props = new HashMap<String, String>();
+ props.put(IMappingStrategy.PROP_QUALIFIED_NAMES, "true");
+ props.put(CDODBUtil.PROP_COPY_ON_BRANCH, Boolean.toString(copyOnBranch));
+ return props;
+ }
+
+ protected IMappingStrategy createMappingStrategy()
+ {
+ return CDODBUtil.createHorizontalMappingStrategy(isSupportingAudits(), isSupportingBranches(), withRanges);
+ }
+
+ @Override
+ protected String getMappingStrategySpecialization()
+ {
+ return (withRanges ? "-ranges" : "") + (copyOnBranch ? "-copy" : "");
+ }
+
+ protected abstract IDBAdapter createDBAdapter();
+
+ protected abstract DataSource createDataSource(String repoName);
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfigs.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfigs.java
index 99485349f0..31741ff6a0 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfigs.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfigs.java
@@ -1,87 +1,87 @@
-/*
- * Copyright (c) 2004 - 2012 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 - Bug 285426: [DB] Implement user-defined typeMapping support
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.tests.AllConfigs;
-import org.eclipse.emf.cdo.tests.AuditSameSessionTest;
-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.MEMStoreQueryTest;
-import org.eclipse.emf.cdo.tests.MergingTest;
-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;
-
-/**
- * @author Eike Stepper
- */
-public abstract class DBConfigs extends AllConfigs
-{
- @Override
- protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
- {
- testClasses.add(Net4jDBTest.class);
- testClasses.add(DBAnnotationsTest.class);
- testClasses.add(DBStoreTest.class);
- testClasses.add(CustomTypeMappingTest.class);
- testClasses.add(SQLQueryTest.class);
-
- super.initTestClasses(testClasses, scenario);
- testClasses.remove(MEMStoreQueryTest.class);
-
- if (!scenario.getRepositoryConfig().isSupportingBranches())
- {
- testClasses.remove(BranchingTest.class);
- testClasses.remove(BranchingSameSessionTest.class);
- testClasses.remove(MergingTest.class);
- testClasses.remove(Bugzilla_303807_Test.class);
- }
-
- if (!scenario.getRepositoryConfig().isSupportingAudits())
- {
- // non-audit mode - remove audit tests
- testClasses.remove(AuditTest.class);
- testClasses.remove(AuditSameSessionTest.class);
- testClasses.remove(Bugzilla_252214_Test.class);
- }
-
- // // fails because of Bug 284109
- // testClasses.remove(XATransactionTest.class);
- // testClasses.add(DISABLE_XATransactionTest.class);
-
- // XXX Range-based audit mapping does not support queryXRefs for now
- // testClasses.remove(XRefTest.class);
- // testClasses.add(DISABLE_XRefTest.class);
-
- // ------------ tests below only fail for PostgreSQL
- // ------------ therefore they are overridden and
- // ------------ skipConfig for PSQL is used temporarily
-
- // // XXX [PSQL] disabled because of Bug 289445
- // testClasses.remove(AttributeTest.class);
- // testClasses.add(DISABLE_AttributeTest.class);
-
- // testClasses.remove(FeatureMapTest.class);
- // testClasses.add(DISABLE_FeatureMapTest.class);
-
- // XXX [PSQL] disabled because of Bug 290095
- // using skipconfig in DBAnnotationTest
-
- // // XXX [PSQL] disabled because of Bug 290097
- // testClasses.remove(ExternalReferenceTest.class);
- // testClasses.add(DISABLE_ExternalReferenceTest.class);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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 - Bug 285426: [DB] Implement user-defined typeMapping support
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.tests.AllConfigs;
+import org.eclipse.emf.cdo.tests.AuditSameSessionTest;
+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.MEMStoreQueryTest;
+import org.eclipse.emf.cdo.tests.MergingTest;
+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;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class DBConfigs extends AllConfigs
+{
+ @Override
+ protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
+ {
+ testClasses.add(Net4jDBTest.class);
+ testClasses.add(DBAnnotationsTest.class);
+ testClasses.add(DBStoreTest.class);
+ testClasses.add(CustomTypeMappingTest.class);
+ testClasses.add(SQLQueryTest.class);
+
+ super.initTestClasses(testClasses, scenario);
+ testClasses.remove(MEMStoreQueryTest.class);
+
+ if (!scenario.getRepositoryConfig().isSupportingBranches())
+ {
+ testClasses.remove(BranchingTest.class);
+ testClasses.remove(BranchingSameSessionTest.class);
+ testClasses.remove(MergingTest.class);
+ testClasses.remove(Bugzilla_303807_Test.class);
+ }
+
+ if (!scenario.getRepositoryConfig().isSupportingAudits())
+ {
+ // non-audit mode - remove audit tests
+ testClasses.remove(AuditTest.class);
+ testClasses.remove(AuditSameSessionTest.class);
+ testClasses.remove(Bugzilla_252214_Test.class);
+ }
+
+ // // fails because of Bug 284109
+ // testClasses.remove(XATransactionTest.class);
+ // testClasses.add(DISABLE_XATransactionTest.class);
+
+ // XXX Range-based audit mapping does not support queryXRefs for now
+ // testClasses.remove(XRefTest.class);
+ // testClasses.add(DISABLE_XRefTest.class);
+
+ // ------------ tests below only fail for PostgreSQL
+ // ------------ therefore they are overridden and
+ // ------------ skipConfig for PSQL is used temporarily
+
+ // // XXX [PSQL] disabled because of Bug 289445
+ // testClasses.remove(AttributeTest.class);
+ // testClasses.add(DISABLE_AttributeTest.class);
+
+ // testClasses.remove(FeatureMapTest.class);
+ // testClasses.add(DISABLE_FeatureMapTest.class);
+
+ // XXX [PSQL] disabled because of Bug 290095
+ // using skipconfig in DBAnnotationTest
+
+ // // XXX [PSQL] disabled because of Bug 290097
+ // testClasses.remove(ExternalReferenceTest.class);
+ // testClasses.add(DISABLE_ExternalReferenceTest.class);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBStoreTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBStoreTest.java
index a582f46d14..30ddd7fd31 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBStoreTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBStoreTest.java
@@ -1,326 +1,326 @@
-/*
- * Copyright (c) 2004 - 2012 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:
- * Stefan Winkler - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.tests.db;
-
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.model1.Model1Factory;
-import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.WrappedException;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import java.util.GregorianCalendar;
-
-/**
- * @author Stefan Winkler
- */
-public class DBStoreTest extends AbstractCDOTest
-{
- // Bug 256462
- public void testInsertNull() throws Exception
- {
- CDOSession s = openSession();
- CDOTransaction t = s.openTransaction();
- CDOResource r = t.createResource(getResourcePath("/dbStoreTest"));
-
- Company c = Model1Factory.eINSTANCE.createCompany();
- c.setName(null);
- r.getContents().add(c);
-
- t.commit();
- }
-
- public void testStoreStringTrailingBackslash()
- {
- storeRetrieve("foobar\\");
- }
-
- public void testStoreStringContainingBackslash()
- {
- storeRetrieve("foo\\bar");
- }
-
- public void testStoreStringTrailingSingleQuote()
- {
- storeRetrieve("foobar'");
- }
-
- public void testStoreStringContainingSingleQuote()
- {
- storeRetrieve("foo'bar");
- }
-
- public void testStoreStringTrailingDoubleQuote()
- {
- storeRetrieve("foobar\"");
- }
-
- public void testStoreStringContainingDoubleQuote()
- {
- storeRetrieve("foo\"bar");
- }
-
- public void testStoreStringTrailingTwoSingleQuote()
- {
- storeRetrieve("foobar''");
- }
-
- public void testStoreStringContainingTwoSingleQuote()
- {
- storeRetrieve("foo''bar");
- }
-
- // Bug 217255
- public void testStoreDate() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test"));
-
- PurchaseOrder o = Model1Factory.eINSTANCE.createPurchaseOrder();
- o.setDate(new GregorianCalendar(2008, 11, 24, 12, 34, 56).getTime());
-
- resource.getContents().add(o);
- transaction.commit();
-
- transaction.close();
- session.close();
- clearCache(getRepository().getRevisionManager());
-
- session = openSession();
- CDOView view = session.openView();
- resource = view.getResource(getResourcePath("/test"));
-
- assertEquals(1, resource.getContents().size());
- o = (PurchaseOrder)resource.getContents().get(0);
- assertEquals(new GregorianCalendar(2008, 11, 24, 12, 34, 56).getTime(), o.getDate());
- }
-
- public void testStoreCustom() throws CommitException
- {
- EPackage pkg = EMFUtil.createEPackage("customTest", "ct", "http://tests.cdo.emf.eclipse.org/customTest");
-
- EDataType dt = EcoreFactory.eINSTANCE.createEDataType();
- dt.setName("custom");
- dt.setInstanceClass(Custom.class);
- pkg.getEClassifiers().add(dt);
-
- EClass clz = EMFUtil.createEClass(pkg, "customClass", false, false);
- EAttribute att = EMFUtil.createEAttribute(clz, "customAtt", dt);
-
- Custom cust1 = new Custom(2, 5);
- Custom cust1ref = new Custom(2, 5);
- Custom cust2 = new Custom(5, 2);
- Custom cust2ref = new Custom(5, 2);
-
- assertEquals(cust1ref, cust1);
- assertEquals(cust2ref, cust2);
- if (!isConfig(LEGACY))
- {
- CDOUtil.prepareDynamicEPackage(pkg);
- }
-
- {
- EObject obj1 = EcoreUtil.create(clz);
- EObject obj2 = EcoreUtil.create(clz);
-
- obj1.eSet(att, cust1);
- obj2.eSet(att, cust2);
-
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test"));
- resource.getContents().add(obj1);
- resource.getContents().add(obj2);
- transaction.commit();
- transaction.close();
- session.close();
- }
-
- clearCache(getRepository().getRevisionManager());
-
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(pkg);
- CDOView view = session.openView();
- CDOResource resource = view.getResource(getResourcePath("/test"));
-
- assertEquals(2, resource.getContents().size());
-
- EObject obj1 = resource.getContents().get(0);
- EObject obj2 = resource.getContents().get(1);
-
- assertEquals(cust1ref, obj1.eGet(att));
- assertEquals(cust2ref, obj2.eGet(att));
-
- view.close();
- session.close();
- }
-
- }
-
- public static class Custom
- {
- private int first;
-
- private int second;
-
- public Custom(String emfString)
- {
- int sep = emfString.indexOf('!');
- first = Integer.parseInt(emfString.substring(0, sep));
- second = Integer.parseInt(emfString.substring(sep + 1));
- }
-
- public Custom(int first, int second)
- {
- this.first = first;
- this.second = second;
- }
-
- public int getFirst()
- {
- return first;
- }
-
- public int getSecond()
- {
- return second;
- }
-
- @Override
- public boolean equals(Object other)
- {
- if (other instanceof Custom)
- {
- return first == ((Custom)other).first && second == ((Custom)other).second;
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return (first + 3 * second) % 65536;
- }
-
- // -------------------------------------------
- // - EMF String serialization
- @Override
- public String toString()
- {
- return Integer.valueOf(first) + "!" + Integer.valueOf(second);
- }
-
- public static Custom valueOf(String s)
- {
- return new Custom(s);
- }
- }
-
- private void storeRetrieve(String s)
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test"));
-
- Company e = Model1Factory.eINSTANCE.createCompany();
- e.setName(s);
- // this escapes only the string!
- // resulting string only contains one backslash
-
- resource.getContents().add(e);
-
- try
- {
- transaction.commit();
- }
- catch (CommitException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- transaction.close();
- session.close();
- clearCache(getRepository().getRevisionManager());
-
- session = openSession();
- CDOView view = session.openView();
- resource = view.getResource(getResourcePath("/test"));
-
- assertEquals(1, resource.getContents().size());
- e = (Company)resource.getContents().get(0);
- assertEquals(s, e.getName());
- }
-
- public void testUnderscoreFeature() throws Exception
- {
- EPackage pkg = EMFUtil.createEPackage("underscoreTest", "uct", "http://cdo.eclipse.org/tests/underscoreTest.ecore");
- EClass cls = EMFUtil.createEClass(pkg, "foo", false, false);
- EAttribute att = EMFUtil.createEAttribute(cls, "_bar", EcorePackage.eINSTANCE.getEString());
-
- if (!isConfig(LEGACY))
- {
- CDOUtil.prepareDynamicEPackage(pkg);
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test"));
-
- EObject foo = EcoreUtil.create(cls);
- foo.eSet(att, "foobar");
- resource.getContents().add(foo);
- transaction.commit();
- session.close();
- }
-
- public void testUnderscoreClass() throws Exception
- {
- EPackage pkg = EMFUtil.createEPackage("underscoreTest", "uct", "http://cdo.eclipse.org/tests/underscoreTest.ecore");
- EClass cls = EMFUtil.createEClass(pkg, "foo", false, false);
- EAttribute att = EMFUtil.createEAttribute(cls, "_bar", EcorePackage.eINSTANCE.getEString());
-
- if (!isConfig(LEGACY))
- {
- CDOUtil.prepareDynamicEPackage(pkg);
- }
-
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/test"));
-
- EObject foo = EcoreUtil.create(cls);
- foo.eSet(att, "foobar");
- resource.getContents().add(foo);
- transaction.commit();
- session.close();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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:
+ * Stefan Winkler - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.tests.db;
+
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.WrappedException;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import java.util.GregorianCalendar;
+
+/**
+ * @author Stefan Winkler
+ */
+public class DBStoreTest extends AbstractCDOTest
+{
+ // Bug 256462
+ public void testInsertNull() throws Exception
+ {
+ CDOSession s = openSession();
+ CDOTransaction t = s.openTransaction();
+ CDOResource r = t.createResource(getResourcePath("/dbStoreTest"));
+
+ Company c = Model1Factory.eINSTANCE.createCompany();
+ c.setName(null);
+ r.getContents().add(c);
+
+ t.commit();
+ }
+
+ public void testStoreStringTrailingBackslash()
+ {
+ storeRetrieve("foobar\\");
+ }
+
+ public void testStoreStringContainingBackslash()
+ {
+ storeRetrieve("foo\\bar");
+ }
+
+ public void testStoreStringTrailingSingleQuote()
+ {
+ storeRetrieve("foobar'");
+ }
+
+ public void testStoreStringContainingSingleQuote()
+ {
+ storeRetrieve("foo'bar");
+ }
+
+ public void testStoreStringTrailingDoubleQuote()
+ {
+ storeRetrieve("foobar\"");
+ }
+
+ public void testStoreStringContainingDoubleQuote()
+ {
+ storeRetrieve("foo\"bar");
+ }
+
+ public void testStoreStringTrailingTwoSingleQuote()
+ {
+ storeRetrieve("foobar''");
+ }
+
+ public void testStoreStringContainingTwoSingleQuote()
+ {
+ storeRetrieve("foo''bar");
+ }
+
+ // Bug 217255
+ public void testStoreDate() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test"));
+
+ PurchaseOrder o = Model1Factory.eINSTANCE.createPurchaseOrder();
+ o.setDate(new GregorianCalendar(2008, 11, 24, 12, 34, 56).getTime());
+
+ resource.getContents().add(o);
+ transaction.commit();
+
+ transaction.close();
+ session.close();
+ clearCache(getRepository().getRevisionManager());
+
+ session = openSession();
+ CDOView view = session.openView();
+ resource = view.getResource(getResourcePath("/test"));
+
+ assertEquals(1, resource.getContents().size());
+ o = (PurchaseOrder)resource.getContents().get(0);
+ assertEquals(new GregorianCalendar(2008, 11, 24, 12, 34, 56).getTime(), o.getDate());
+ }
+
+ public void testStoreCustom() throws CommitException
+ {
+ EPackage pkg = EMFUtil.createEPackage("customTest", "ct", "http://tests.cdo.emf.eclipse.org/customTest");
+
+ EDataType dt = EcoreFactory.eINSTANCE.createEDataType();
+ dt.setName("custom");
+ dt.setInstanceClass(Custom.class);
+ pkg.getEClassifiers().add(dt);
+
+ EClass clz = EMFUtil.createEClass(pkg, "customClass", false, false);
+ EAttribute att = EMFUtil.createEAttribute(clz, "customAtt", dt);
+
+ Custom cust1 = new Custom(2, 5);
+ Custom cust1ref = new Custom(2, 5);
+ Custom cust2 = new Custom(5, 2);
+ Custom cust2ref = new Custom(5, 2);
+
+ assertEquals(cust1ref, cust1);
+ assertEquals(cust2ref, cust2);
+ if (!isConfig(LEGACY))
+ {
+ CDOUtil.prepareDynamicEPackage(pkg);
+ }
+
+ {
+ EObject obj1 = EcoreUtil.create(clz);
+ EObject obj2 = EcoreUtil.create(clz);
+
+ obj1.eSet(att, cust1);
+ obj2.eSet(att, cust2);
+
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test"));
+ resource.getContents().add(obj1);
+ resource.getContents().add(obj2);
+ transaction.commit();
+ transaction.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath("/test"));
+
+ assertEquals(2, resource.getContents().size());
+
+ EObject obj1 = resource.getContents().get(0);
+ EObject obj2 = resource.getContents().get(1);
+
+ assertEquals(cust1ref, obj1.eGet(att));
+ assertEquals(cust2ref, obj2.eGet(att));
+
+ view.close();
+ session.close();
+ }
+
+ }
+
+ public static class Custom
+ {
+ private int first;
+
+ private int second;
+
+ public Custom(String emfString)
+ {
+ int sep = emfString.indexOf('!');
+ first = Integer.parseInt(emfString.substring(0, sep));
+ second = Integer.parseInt(emfString.substring(sep + 1));
+ }
+
+ public Custom(int first, int second)
+ {
+ this.first = first;
+ this.second = second;
+ }
+
+ public int getFirst()
+ {
+ return first;
+ }
+
+ public int getSecond()
+ {
+ return second;
+ }
+
+ @Override
+ public boolean equals(Object other)
+ {
+ if (other instanceof Custom)
+ {
+ return first == ((Custom)other).first && second == ((Custom)other).second;
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return (first + 3 * second) % 65536;
+ }
+
+ // -------------------------------------------
+ // - EMF String serialization
+ @Override
+ public String toString()
+ {
+ return Integer.valueOf(first) + "!" + Integer.valueOf(second);
+ }
+
+ public static Custom valueOf(String s)
+ {
+ return new Custom(s);
+ }
+ }
+
+ private void storeRetrieve(String s)
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getOrCreateResource(getResourcePath("/test"));
+
+ Company e = Model1Factory.eINSTANCE.createCompany();
+ e.setName(s);
+ // this escapes only the string!
+ // resulting string only contains one backslash
+
+ resource.getContents().add(e);
+
+ try
+ {
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ transaction.close();
+ session.close();
+ clearCache(getRepository().getRevisionManager());
+
+ session = openSession();
+ CDOView view = session.openView();
+ resource = view.getResource(getResourcePath("/test"));
+
+ assertEquals(1, resource.getContents().size());
+ e = (Company)resource.getContents().get(0);
+ assertEquals(s, e.getName());
+ }
+
+ public void testUnderscoreFeature() throws Exception
+ {
+ EPackage pkg = EMFUtil.createEPackage("underscoreTest", "uct", "http://cdo.eclipse.org/tests/underscoreTest.ecore");
+ EClass cls = EMFUtil.createEClass(pkg, "foo", false, false);
+ EAttribute att = EMFUtil.createEAttribute(cls, "_bar", EcorePackage.eINSTANCE.getEString());
+
+ if (!isConfig(LEGACY))
+ {
+ CDOUtil.prepareDynamicEPackage(pkg);
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test"));
+
+ EObject foo = EcoreUtil.create(cls);
+ foo.eSet(att, "foobar");
+ resource.getContents().add(foo);
+ transaction.commit();
+ session.close();
+ }
+
+ public void testUnderscoreClass() throws Exception
+ {
+ EPackage pkg = EMFUtil.createEPackage("underscoreTest", "uct", "http://cdo.eclipse.org/tests/underscoreTest.ecore");
+ EClass cls = EMFUtil.createEClass(pkg, "foo", false, false);
+ EAttribute att = EMFUtil.createEAttribute(cls, "_bar", EcorePackage.eINSTANCE.getEString());
+
+ if (!isConfig(LEGACY))
+ {
+ CDOUtil.prepareDynamicEPackage(pkg);
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test"));
+
+ EObject foo = EcoreUtil.create(cls);
+ foo.eSet(att, "foobar");
+ resource.getContents().add(foo);
+ transaction.commit();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DerbyConfig.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DerbyConfig.java
index 2c3aac7b05..e507afa861 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DerbyConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DerbyConfig.java
@@ -1,133 +1,133 @@
-/*
- * Copyright (c) 2004 - 2012 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
-{
- public static final String DB_ADAPTER_NAME = "Derby";
-
- private static final long serialVersionUID = 1L;
-
- private static HashMap<String, File> dbFolders = new HashMap<String, File>();
-
- private static HashMap<File, EmbeddedDataSource> dataSources = new HashMap<File, EmbeddedDataSource>();
-
- public DerbyConfig(boolean supportingAudits, boolean supportingBranches, IDGenerationLocation idGenerationLocation)
- {
- super(DB_ADAPTER_NAME, supportingAudits, supportingBranches, false, false, idGenerationLocation);
- }
-
- @Override
- protected String getDBAdapterName()
- {
- return DB_ADAPTER_NAME;
- }
-
- public Collection<File> 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");
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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
+{
+ public static final String DB_ADAPTER_NAME = "Derby";
+
+ private static final long serialVersionUID = 1L;
+
+ private static HashMap<String, File> dbFolders = new HashMap<String, File>();
+
+ private static HashMap<File, EmbeddedDataSource> dataSources = new HashMap<File, EmbeddedDataSource>();
+
+ public DerbyConfig(boolean supportingAudits, boolean supportingBranches, IDGenerationLocation idGenerationLocation)
+ {
+ super(DB_ADAPTER_NAME, supportingAudits, supportingBranches, false, false, idGenerationLocation);
+ }
+
+ @Override
+ protected String getDBAdapterName()
+ {
+ return DB_ADAPTER_NAME;
+ }
+
+ public Collection<File> 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");
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2Config.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2Config.java
index c997cb5f47..2ab6f0bda2 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2Config.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2Config.java
@@ -1,112 +1,112 @@
-/*
- * Copyright (c) 2004 - 2012 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
-{
- public static final String DB_ADAPTER_NAME = "H2";
-
- 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(DB_ADAPTER_NAME, supportingAudits, supportingBranches, withRanges, copyOnBranch, idGenerationLocation);
- }
-
- @Override
- protected String getDBAdapterName()
- {
- return DB_ADAPTER_NAME;
- }
-
- @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");
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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
+{
+ public static final String DB_ADAPTER_NAME = "H2";
+
+ 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(DB_ADAPTER_NAME, supportingAudits, supportingBranches, withRanges, copyOnBranch, idGenerationLocation);
+ }
+
+ @Override
+ protected String getDBAdapterName()
+ {
+ return DB_ADAPTER_NAME;
+ }
+
+ @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");
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2OfflineConfig.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2OfflineConfig.java
index 3c2d918762..d4ca986eec 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2OfflineConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/H2OfflineConfig.java
@@ -1,127 +1,127 @@
-/*
- * Copyright (c) 2004 - 2012 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.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.Set;
-
-/**
- * @author Eike Stepper
- */
-public class H2OfflineConfig extends DBOfflineConfig
-{
- private static final long serialVersionUID = 1L;
-
- private static File reusableFolder;
-
- private static JdbcDataSource defaultDataSource;
-
- public H2OfflineConfig(boolean withRanges, boolean copyOnBranch, IDGenerationLocation idGenerationLocation)
- {
- super("H2Offline", withRanges, copyOnBranch, idGenerationLocation);
- }
-
- @Override
- public void initCapabilities(Set<String> capabilities)
- {
- super.initCapabilities(capabilities);
- capabilities.add(H2Config.DB_ADAPTER_NAME);
- }
-
- @Override
- protected IDBAdapter createDBAdapter()
- {
- return new H2Adapter();
- }
-
- @Override
- 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;
- }
-
- 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);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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.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.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class H2OfflineConfig extends DBOfflineConfig
+{
+ private static final long serialVersionUID = 1L;
+
+ private static File reusableFolder;
+
+ private static JdbcDataSource defaultDataSource;
+
+ public H2OfflineConfig(boolean withRanges, boolean copyOnBranch, IDGenerationLocation idGenerationLocation)
+ {
+ super("H2Offline", withRanges, copyOnBranch, idGenerationLocation);
+ }
+
+ @Override
+ public void initCapabilities(Set<String> capabilities)
+ {
+ super.initCapabilities(capabilities);
+ capabilities.add(H2Config.DB_ADAPTER_NAME);
+ }
+
+ @Override
+ protected IDBAdapter createDBAdapter()
+ {
+ return new H2Adapter();
+ }
+
+ @Override
+ 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;
+ }
+
+ 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);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/HsqldbConfig.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/HsqldbConfig.java
index 93446d15b9..c5073b891a 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/HsqldbConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/HsqldbConfig.java
@@ -1,161 +1,161 @@
-/*
- * Copyright (c) 2004 - 2012 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
-{
- public static final String DB_ADAPTER_NAME = "Hsqldb";
-
- private static final long serialVersionUID = 1L;
-
- public static boolean USE_VERIFIER = false;
-
- private transient ArrayList<HSQLDBDataSource> dataSources;
-
- public HsqldbConfig(boolean supportingAudits, boolean supportingBranches, IDGenerationLocation idGenerationLocation)
- {
- super(DB_ADAPTER_NAME, supportingAudits, supportingBranches, false, false, idGenerationLocation);
- }
-
- @Override
- protected String getDBAdapterName()
- {
- return DB_ADAPTER_NAME;
- }
-
- @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<HSQLDBDataSource>();
- }
-
- 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<String, String> props)
- {
- super.initRepositoryProperties(props);
- props.put(Props.SUPPORTING_AUDITS, "true");
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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
+{
+ public static final String DB_ADAPTER_NAME = "Hsqldb";
+
+ private static final long serialVersionUID = 1L;
+
+ public static boolean USE_VERIFIER = false;
+
+ private transient ArrayList<HSQLDBDataSource> dataSources;
+
+ public HsqldbConfig(boolean supportingAudits, boolean supportingBranches, IDGenerationLocation idGenerationLocation)
+ {
+ super(DB_ADAPTER_NAME, supportingAudits, supportingBranches, false, false, idGenerationLocation);
+ }
+
+ @Override
+ protected String getDBAdapterName()
+ {
+ return DB_ADAPTER_NAME;
+ }
+
+ @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<HSQLDBDataSource>();
+ }
+
+ 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<String, String> props)
+ {
+ super.initRepositoryProperties(props);
+ props.put(Props.SUPPORTING_AUDITS, "true");
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/MysqlConfig.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/MysqlConfig.java
index 82a25e567f..61dbc5af9f 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/MysqlConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/MysqlConfig.java
@@ -1,167 +1,167 @@
-/*
- * Copyright (c) 2004 - 2012 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
-{
- public static final String DB_ADAPTER_NAME = "Mysql";
-
- /**
- * 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";
-
- private static final long serialVersionUID = 1L;
-
- private transient DataSource setupDataSource;
-
- private transient List<String> databases = new ArrayList<String>();
-
- public MysqlConfig(boolean supportingAudits, boolean supportingBranches, IDGenerationLocation idGenerationLocation)
- {
- super(DB_ADAPTER_NAME, supportingAudits, supportingBranches, false, false, idGenerationLocation);
- }
-
- @Override
- protected String getDBAdapterName()
- {
- return DB_ADAPTER_NAME;
- }
-
- @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<String, String> props)
- {
- super.initRepositoryProperties(props);
- props.put(Props.SUPPORTING_AUDITS, "true");
- props.put(Props.SUPPORTING_BRANCHES, "true");
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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
+{
+ public static final String DB_ADAPTER_NAME = "Mysql";
+
+ /**
+ * 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";
+
+ private static final long serialVersionUID = 1L;
+
+ private transient DataSource setupDataSource;
+
+ private transient List<String> databases = new ArrayList<String>();
+
+ public MysqlConfig(boolean supportingAudits, boolean supportingBranches, IDGenerationLocation idGenerationLocation)
+ {
+ super(DB_ADAPTER_NAME, supportingAudits, supportingBranches, false, false, idGenerationLocation);
+ }
+
+ @Override
+ protected String getDBAdapterName()
+ {
+ return DB_ADAPTER_NAME;
+ }
+
+ @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<String, String> props)
+ {
+ super.initRepositoryProperties(props);
+ props.put(Props.SUPPORTING_AUDITS, "true");
+ props.put(Props.SUPPORTING_BRANCHES, "true");
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/MysqlOfflineConfig.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/MysqlOfflineConfig.java
index 833103e028..a476455b3e 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/MysqlOfflineConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/MysqlOfflineConfig.java
@@ -1,156 +1,156 @@
-/*
- * Copyright (c) 2004 - 2012 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.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.Set;
-
-/**
- * @author Eike Stepper
- * @author Stefan Winkler
- */
-public class MysqlOfflineConfig extends DBOfflineConfig
-{
- private static final long serialVersionUID = 1L;
-
- /**
- * 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 = "10.211.55.7:3306";
-
- public static final String USER = "root";
-
- public static final String PASS = null;
-
- private transient DataSource setupDataSource;
-
- private transient List<String> databases = new ArrayList<String>();
-
- public MysqlOfflineConfig(boolean withRanges, boolean copyOnBranch, IDGenerationLocation idGenerationLocation)
- {
- super("MySqlOffline", withRanges, copyOnBranch, idGenerationLocation);
- }
-
- @Override
- public void initCapabilities(Set<String> capabilities)
- {
- super.initCapabilities(capabilities);
- capabilities.add(MysqlConfig.DB_ADAPTER_NAME);
- }
-
- @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);
- }
- }
-
- 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;
- }
-
- protected void tearDownClean(String repoName)
- {
- for (String dbName : databases)
- {
- dropDatabase(dbName);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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.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.Set;
+
+/**
+ * @author Eike Stepper
+ * @author Stefan Winkler
+ */
+public class MysqlOfflineConfig extends DBOfflineConfig
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 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 = "10.211.55.7:3306";
+
+ public static final String USER = "root";
+
+ public static final String PASS = null;
+
+ private transient DataSource setupDataSource;
+
+ private transient List<String> databases = new ArrayList<String>();
+
+ public MysqlOfflineConfig(boolean withRanges, boolean copyOnBranch, IDGenerationLocation idGenerationLocation)
+ {
+ super("MySqlOffline", withRanges, copyOnBranch, idGenerationLocation);
+ }
+
+ @Override
+ public void initCapabilities(Set<String> capabilities)
+ {
+ super.initCapabilities(capabilities);
+ capabilities.add(MysqlConfig.DB_ADAPTER_NAME);
+ }
+
+ @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);
+ }
+ }
+
+ 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;
+ }
+
+ protected void tearDownClean(String repoName)
+ {
+ for (String dbName : databases)
+ {
+ dropDatabase(dbName);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Net4jDBTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Net4jDBTest.java
index 5583c0134d..31bd7d6987 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Net4jDBTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Net4jDBTest.java
@@ -1,720 +1,720 @@
-/*
- * Copyright (c) 2004 - 2012 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.internal.db.DBStore;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-
-import org.eclipse.net4j.db.DBType;
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.ddl.IDBSchema;
-import org.eclipse.net4j.db.ddl.IDBTable;
-import org.eclipse.net4j.util.collection.Pair;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import org.eclipse.net4j.util.io.IOUtil;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.GregorianCalendar;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @author Eike Stepper
- */
-public class Net4jDBTest extends AbstractCDOTest
-{
- private static final String FIELD_NAME = "testField";
-
- private DBStore store;
-
- private ArrayList<Pair<DBType, Object>> columns = new ArrayList<Pair<DBType, Object>>();
-
- private Connection connection;
-
- public void testBigInt() throws Exception
- {
- registerColumn(DBType.BIGINT, Long.MAX_VALUE);
- registerColumn(DBType.BIGINT, Long.MIN_VALUE);
- registerColumn(DBType.BIGINT, 0L);
- registerColumn(DBType.BIGINT, 42L);
- doTest(getName());
- }
-
- public void testBinary() throws Exception
- {
- registerColumn(DBType.BINARY, new byte[0]);
-
- byte[] data = new byte[100];
- for (int i = 0; i < data.length; i++)
- {
- data[i] = (byte)(Math.random() * (Byte.MAX_VALUE - Byte.MIN_VALUE) + Byte.MIN_VALUE);
- }
-
- registerColumn(DBType.BINARY, data);
- doTest(getName());
- }
-
- public void testVarBinary() throws Exception
- {
- registerColumn(DBType.VARBINARY, new byte[0]);
-
- byte[] data = new byte[100];
- for (int i = 0; i < data.length; i++)
- {
- data[i] = (byte)(Math.random() * (Byte.MAX_VALUE - Byte.MIN_VALUE) + Byte.MIN_VALUE);
- }
-
- registerColumn(DBType.VARBINARY, data);
- doTest(getName());
- }
-
- public void testLongVarBinary() throws Exception
- {
- registerColumn(DBType.LONGVARBINARY, new byte[0]);
-
- byte[] data = new byte[100];
- for (int i = 0; i < data.length; i++)
- {
- data[i] = (byte)(Math.random() * (Byte.MAX_VALUE - Byte.MIN_VALUE) + Byte.MIN_VALUE);
- }
-
- registerColumn(DBType.LONGVARBINARY, data);
- doTest(getName());
- }
-
- public void testBit() throws Exception
- {
- registerColumn(DBType.BIT, true);
- registerColumn(DBType.BIT, false);
- doTest(getName());
- }
-
- public void testBlob() throws Exception
- {
- byte[] data = new byte[1000000];
- for (int i = 0; i < data.length; i++)
- {
- data[i] = (byte)(Math.random() * (Byte.MAX_VALUE - Byte.MIN_VALUE) + Byte.MIN_VALUE);
- }
-
- registerColumn(DBType.BLOB, data);
- doTest(getName());
- }
-
- public void testBlobLength0() throws Exception
- {
- registerColumn(DBType.BLOB, new byte[0]);
- doTest(getName());
- }
-
- public void testBoolean() throws Exception
- {
- registerColumn(DBType.BOOLEAN, true);
- registerColumn(DBType.BOOLEAN, false);
- doTest(getName());
- }
-
- public void testChar() throws Exception
- {
- registerColumn(DBType.CHAR, "0");
- registerColumn(DBType.CHAR, "a");
- registerColumn(DBType.CHAR, "\255"); // Fails for DB2
- registerColumn(DBType.CHAR, "\u1234"); // Fails for DB2
- doTest(getName());
- }
-
- public void testClob() throws Exception
- {
- registerColumn(DBType.CLOB, "Test");
-
- StringBuffer b = new StringBuffer();
- for (int i = 0; i < 1000000; i++)
- {
- b.append("x");
- }
-
- registerColumn(DBType.CLOB, b.toString());
- doTest(getName());
- }
-
- public void testClobLength0() throws Exception
- {
- registerColumn(DBType.CLOB, "");
- doTest(getName());
- }
-
- public void testTinyInt() throws Exception
- {
- registerColumn(DBType.TINYINT, Byte.MAX_VALUE);
- registerColumn(DBType.TINYINT, Byte.MIN_VALUE);
- registerColumn(DBType.TINYINT, new Byte("0"));
- registerColumn(DBType.TINYINT, new Integer(42).byteValue());
- doTest(getName());
- }
-
- public void testSmallInt() throws Exception
- {
- registerColumn(DBType.SMALLINT, Short.MAX_VALUE);
- registerColumn(DBType.SMALLINT, Short.MIN_VALUE);
- registerColumn(DBType.SMALLINT, (short)-1);
- registerColumn(DBType.SMALLINT, (short)5);
- doTest(getName());
- }
-
- public void testInteger() throws Exception
- {
- registerColumn(DBType.INTEGER, Integer.MAX_VALUE);
- registerColumn(DBType.INTEGER, Integer.MIN_VALUE);
- registerColumn(DBType.INTEGER, -1);
- registerColumn(DBType.INTEGER, 5);
- doTest(getName());
- }
-
- public void testFloat() throws Exception
- {
- registerColumn(DBType.FLOAT, Float.MAX_VALUE);
- registerColumn(DBType.FLOAT, Float.MIN_VALUE); // Fails for DB2
- registerColumn(DBType.FLOAT, -.1f);
- registerColumn(DBType.FLOAT, 3.33333f);
- doTest(getName());
- }
-
- public void testReal() throws Exception
- {
- registerColumn(DBType.REAL, Float.MAX_VALUE);
- registerColumn(DBType.REAL, Float.MIN_VALUE); // Fails for DB2
- registerColumn(DBType.REAL, -.1f);
- registerColumn(DBType.REAL, 3.33333f);
- doTest(getName());
- }
-
- public void testDouble() throws Exception
- {
- registerColumn(DBType.DOUBLE, new Double(Double.MAX_VALUE));
- // registerColumn(DBType.DOUBLE, new Double(Double.MIN_VALUE));
- registerColumn(DBType.DOUBLE, -.1d);
- registerColumn(DBType.DOUBLE, 3.33333d);
- doTest(getName());
- }
-
- public void _testNumeric() throws Exception
- {
- String numberLiteral1 = "12345678901234567890123456789012";
- String numberLiteral2 = "10000000000000000000000000000000";
-
- for (int precision = 1; precision < 32; precision++)
- {
- BigInteger numberInteger1 = new BigInteger(numberLiteral1.substring(0, precision));
- BigInteger numberInteger2 = new BigInteger(numberLiteral2.substring(0, precision));
-
- for (int scale = 0; scale <= precision; scale++)
- {
- BigDecimal numberDecimal1 = new BigDecimal(numberInteger1, scale);
- BigDecimal numberDecimal2 = new BigDecimal(numberInteger2, scale);
-
- registerColumn(DBType.NUMERIC, numberDecimal1);
- registerColumn(DBType.NUMERIC, numberDecimal2);
-
- doTest(getName() + precision + "_" + scale);
- columns.clear();
- }
- }
- }
-
- public void _testDecimal() throws Exception
- {
- String numberLiteral1 = "12345678901234567890123456789012";
- String numberLiteral2 = "10000000000000000000000000000000";
-
- for (int precision = 1; precision < 32; precision++)
- {
- BigInteger numberInteger1 = new BigInteger(numberLiteral1.substring(0, precision));
- BigInteger numberInteger2 = new BigInteger(numberLiteral2.substring(0, precision));
-
- for (int scale = 0; scale <= precision; scale++)
- {
- BigDecimal numberDecimal1 = new BigDecimal(numberInteger1, scale);
- BigDecimal numberDecimal2 = new BigDecimal(numberInteger2, scale);
-
- registerColumn(DBType.DECIMAL, numberDecimal1);
- registerColumn(DBType.DECIMAL, numberDecimal2);
-
- doTest(getName() + precision + "_" + scale);
- columns.clear();
- }
- }
- }
-
- public void testVarChar() throws Exception
- {
- registerColumn(DBType.VARCHAR, "");
- registerColumn(DBType.VARCHAR, "\n");
- registerColumn(DBType.VARCHAR, "\t");
- registerColumn(DBType.VARCHAR, "\r");
- registerColumn(DBType.VARCHAR, "\u1234");
- registerColumn(DBType.VARCHAR, "The quick brown fox jumps over the lazy dog.");
- registerColumn(DBType.VARCHAR, "\\,:\",\'");
-
- doTest(getName());
- }
-
- public void testLongVarChar() throws Exception
- {
- registerColumn(DBType.LONGVARCHAR, "");
- registerColumn(DBType.LONGVARCHAR, "\n");
- registerColumn(DBType.LONGVARCHAR, "\t");
- registerColumn(DBType.LONGVARCHAR, "\r");
- registerColumn(DBType.LONGVARCHAR, "\u1234");
- registerColumn(DBType.LONGVARCHAR, "The quick brown fox jumps over the lazy dog.");
- registerColumn(DBType.LONGVARCHAR, "\\,:\",\'");
-
- doTest(getName());
- }
-
- public void testDate() throws Exception
- {
- registerColumn(DBType.DATE, new GregorianCalendar(2010, 04, 21).getTimeInMillis());
- registerColumn(DBType.DATE, new GregorianCalendar(1950, 04, 21).getTimeInMillis());
- registerColumn(DBType.DATE, new GregorianCalendar(2030, 12, 31).getTimeInMillis());
- registerColumn(DBType.DATE, new GregorianCalendar(0, 0, 0).getTimeInMillis()); // Fails for DB2
-
- doTest(getName());
- }
-
- public void testTime() throws Exception
- {
- registerColumn(DBType.TIME, HOURS_toMillis(10));
- registerColumn(DBType.TIME, 0l);
- registerColumn(DBType.TIME, HOURS_toMillis(11) + MINUTES_toMillis(59) + TimeUnit.SECONDS.toMillis(59));
-
- // Following tests fail on H2 as 24h == 1 day => 0
- registerColumn(DBType.TIME, HOURS_toMillis(24));
-
- doTest(getName());
- }
-
- public void testTimestamp() throws Exception
- {
- registerColumn(DBType.TIME, HOURS_toMillis(10));
- registerColumn(DBType.TIME, 0l);
- registerColumn(DBType.TIME, HOURS_toMillis(11) + MINUTES_toMillis(59) + TimeUnit.SECONDS.toMillis(59));
-
- // Following tests fail on H2 as 24h == 1 day => 0
- registerColumn(DBType.TIME, HOURS_toMillis(24));
-
- doTest(getName());
- }
-
- private void registerColumn(DBType type, Object value)
- {
- Pair<DBType, Object> column = new Pair<DBType, Object>(type, value);
- columns.add(column);
- }
-
- private void prepareTable(String tableName)
- {
- IDBSchema schema = store.getDBSchema();
- IDBTable table = schema.addTable(tableName);
- int c = 0;
-
- for (Pair<DBType, Object> column : columns)
- {
- switch (column.getElement1())
- {
- case NUMERIC:
- case DECIMAL:
- BigDecimal value = (BigDecimal)column.getElement2();
- table.addField(FIELD_NAME + c++, column.getElement1(), value.precision(), value.scale());
- break;
-
- default:
- table.addField(FIELD_NAME + c++, column.getElement1());
- break;
- }
- }
-
- store.getDBAdapter().createTables(Arrays.asList(table), connection);
- }
-
- private void writeValues(String tableName) throws Exception
- {
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- ExtendedDataOutputStream outs = new ExtendedDataOutputStream(output);
-
- boolean first = true;
- StringBuilder builder = new StringBuilder("INSERT INTO " + tableName + " VALUES (");
- for (Pair<DBType, Object> column : columns)
- {
- writeTypeValue(outs, column.getElement1(), column.getElement2());
- if (first)
- {
- builder.append("?");
- first = false;
- }
- else
- {
- builder.append(", ?");
- }
- }
-
- builder.append(")");
- String sql = builder.toString();
-
- outs.close();
- output.flush();
- byte[] buffer = output.toByteArray();
- output.close();
-
- ByteArrayInputStream input = new ByteArrayInputStream(buffer);
- ExtendedDataInputStream ins = new ExtendedDataInputStream(input);
-
- PreparedStatement stmt = connection.prepareStatement(sql);
- int c = 1;
-
- for (Pair<DBType, Object> column : columns)
- {
- column.getElement1().readValueWithResult(ins, stmt, c++, false);
- }
-
- stmt.executeUpdate();
-
- stmt.close();
- ins.close();
- input.close();
- }
-
- private void checkValues(String tableName) throws Exception
- {
- Statement stmt = connection.createStatement();
- ResultSet resultSet = stmt.executeQuery("SELECT * FROM " + tableName);
- assertEquals(true, resultSet.next());
-
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- ExtendedDataOutputStream outs = new ExtendedDataOutputStream(output);
-
- int c = 1;
- for (Pair<DBType, Object> column : columns)
- {
- column.getElement1().writeValue(outs, resultSet, c++, false);
- }
-
- resultSet.close();
- stmt.close();
-
- outs.close();
- output.flush();
- byte[] buffer = output.toByteArray();
- output.close();
-
- ByteArrayInputStream input = new ByteArrayInputStream(buffer);
- ExtendedDataInputStream ins = new ExtendedDataInputStream(input);
-
- c = 1;
- for (Pair<DBType, Object> column : columns)
- {
- DBType dbType = column.getElement1();
- Object expected = column.getElement2();
-
- Object actual = readTypeValue(ins, dbType);
- Class<? extends Object> type = expected.getClass();
- if (type.isArray())
- {
- Class<?> componentType = type.getComponentType();
- if (componentType == byte.class)
- {
- assertEquals("Error in column " + c + " of type " + dbType, true,
- Arrays.equals((byte[])expected, (byte[])actual));
- }
- else if (componentType == char.class)
- {
- assertEquals("Error in column " + c + " with type " + dbType, true,
- Arrays.equals((char[])expected, (char[])actual));
- }
- else
- {
- throw new IllegalStateException("Unexpected component type: " + componentType);
- }
- }
- else
- {
- if (dbType == DBType.TIME)
- {
- actual = (Long)actual % 86400000L;
- expected = (Long)expected % 86400000L;
- }
-
- assertEquals("Error in column " + c + " with type " + dbType, expected, actual);
- }
-
- ++c;
- }
- }
-
- private void doTest(String tableName) throws Exception
- {
- store = (DBStore)getRepository().getStore();
- connection = store.getConnection();
-
- try
- {
- prepareTable(tableName);
- writeValues(tableName);
- checkValues(tableName);
- }
- finally
- {
- try
- {
- connection.commit();
- }
- finally
- {
- DBUtil.close(connection);
- connection = null;
- store = null;
- }
- }
- }
-
- private void writeTypeValue(ExtendedDataOutputStream outs, DBType type, Object value) throws IOException
- {
- switch (type)
- {
- case BOOLEAN:
- case BIT:
- outs.writeBoolean((Boolean)value);
- return;
-
- case TINYINT:
- outs.writeByte((Byte)value);
- return;
-
- case CHAR:
- outs.writeString((String)value);
- return;
-
- case SMALLINT:
- outs.writeShort((Short)value);
- return;
-
- case INTEGER:
- outs.writeInt((Integer)value);
- return;
-
- case FLOAT:
- outs.writeFloat((Float)value);
- return;
-
- case REAL:
- outs.writeFloat((Float)value);
- return;
-
- case DOUBLE:
- outs.writeDouble((Double)value);
- return;
-
- case NUMERIC:
- case DECIMAL:
- {
- BigDecimal bigDecimal = (BigDecimal)value;
- outs.writeByteArray(bigDecimal.unscaledValue().toByteArray());
- outs.writeInt(bigDecimal.scale());
- return;
- }
-
- case VARCHAR:
- case LONGVARCHAR:
- outs.writeString((String)value);
- return;
-
- case CLOB:
- {
- long length = ((String)value).length();
- StringReader source = new StringReader((String)value);
- try
- {
- outs.writeLong(length);
- while (length-- > 0)
- {
- int c = source.read();
- outs.writeChar(c);
- }
- }
- finally
- {
- IOUtil.close(source);
- }
-
- return;
- }
-
- case BIGINT:
- case DATE:
- case TIME:
- case TIMESTAMP:
- outs.writeLong((Long)value);
- return;
-
- case BINARY:
- case VARBINARY:
- case LONGVARBINARY:
- outs.writeByteArray((byte[])value);
- return;
-
- case BLOB:
- {
- long length = ((byte[])value).length;
- ByteArrayInputStream source = new ByteArrayInputStream((byte[])value);
- try
- {
- outs.writeLong(length);
- while (length-- > 0)
- {
- int b = source.read();
- outs.writeByte(b + Byte.MIN_VALUE);
- }
- }
- finally
- {
- IOUtil.close(source);
- }
-
- return;
- }
-
- default:
- throw new UnsupportedOperationException("not implemented");
- }
- }
-
- private Object readTypeValue(ExtendedDataInputStream ins, DBType type) throws IOException
- {
- switch (type)
- {
- case BOOLEAN:
- case BIT:
- return ins.readBoolean();
-
- case CHAR:
- return ins.readString();
-
- case TINYINT:
- return ins.readByte();
-
- case SMALLINT:
- return ins.readShort();
-
- case INTEGER:
- return ins.readInt();
-
- case FLOAT:
- case REAL:
- return ins.readFloat();
-
- case DOUBLE:
- return ins.readDouble();
-
- case NUMERIC:
- case DECIMAL:
- {
- byte[] array = ins.readByteArray();
- if (array == null)
- {
- return null;
- }
-
- BigInteger unscaled = new BigInteger(array);
- int scale = ins.readInt();
- return new BigDecimal(unscaled, scale);
- }
-
- case VARCHAR:
- case LONGVARCHAR:
- return ins.readString();
-
- case CLOB:
- {
- StringWriter result = new StringWriter();
- try
- {
- long length = ins.readLong();
- while (length-- > 0)
- {
- char c = ins.readChar();
- result.append(c);
- }
- }
- finally
- {
- IOUtil.close(result);
- }
- return result.toString();
- }
-
- case DATE:
- case BIGINT:
- case TIME:
- case TIMESTAMP:
- return ins.readLong();
-
- case BINARY:
- case VARBINARY:
- case LONGVARBINARY:
- return ins.readByteArray();
-
- case BLOB:
- {
- ByteArrayOutputStream result = new ByteArrayOutputStream();
-
- try
- {
- long length = ins.readLong();
- while (length-- > 0)
- {
- int b = ins.readByte();
- result.write(b - Byte.MIN_VALUE);
- }
- }
- finally
- {
- IOUtil.close(result);
- }
-
- return result.toByteArray();
- }
-
- default:
- throw new UnsupportedOperationException("not implemented");
- }
- }
-
- private long HOURS_toMillis(int hours)
- {
- return MINUTES_toMillis(60 * hours);
- }
-
- private long MINUTES_toMillis(int minutes)
- {
- return 1000L * 60L * minutes;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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.internal.db.DBStore;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+
+import org.eclipse.net4j.db.DBType;
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.ddl.IDBSchema;
+import org.eclipse.net4j.db.ddl.IDBTable;
+import org.eclipse.net4j.util.collection.Pair;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.net4j.util.io.IOUtil;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.GregorianCalendar;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author Eike Stepper
+ */
+public class Net4jDBTest extends AbstractCDOTest
+{
+ private static final String FIELD_NAME = "testField";
+
+ private DBStore store;
+
+ private ArrayList<Pair<DBType, Object>> columns = new ArrayList<Pair<DBType, Object>>();
+
+ private Connection connection;
+
+ public void testBigInt() throws Exception
+ {
+ registerColumn(DBType.BIGINT, Long.MAX_VALUE);
+ registerColumn(DBType.BIGINT, Long.MIN_VALUE);
+ registerColumn(DBType.BIGINT, 0L);
+ registerColumn(DBType.BIGINT, 42L);
+ doTest(getName());
+ }
+
+ public void testBinary() throws Exception
+ {
+ registerColumn(DBType.BINARY, new byte[0]);
+
+ byte[] data = new byte[100];
+ for (int i = 0; i < data.length; i++)
+ {
+ data[i] = (byte)(Math.random() * (Byte.MAX_VALUE - Byte.MIN_VALUE) + Byte.MIN_VALUE);
+ }
+
+ registerColumn(DBType.BINARY, data);
+ doTest(getName());
+ }
+
+ public void testVarBinary() throws Exception
+ {
+ registerColumn(DBType.VARBINARY, new byte[0]);
+
+ byte[] data = new byte[100];
+ for (int i = 0; i < data.length; i++)
+ {
+ data[i] = (byte)(Math.random() * (Byte.MAX_VALUE - Byte.MIN_VALUE) + Byte.MIN_VALUE);
+ }
+
+ registerColumn(DBType.VARBINARY, data);
+ doTest(getName());
+ }
+
+ public void testLongVarBinary() throws Exception
+ {
+ registerColumn(DBType.LONGVARBINARY, new byte[0]);
+
+ byte[] data = new byte[100];
+ for (int i = 0; i < data.length; i++)
+ {
+ data[i] = (byte)(Math.random() * (Byte.MAX_VALUE - Byte.MIN_VALUE) + Byte.MIN_VALUE);
+ }
+
+ registerColumn(DBType.LONGVARBINARY, data);
+ doTest(getName());
+ }
+
+ public void testBit() throws Exception
+ {
+ registerColumn(DBType.BIT, true);
+ registerColumn(DBType.BIT, false);
+ doTest(getName());
+ }
+
+ public void testBlob() throws Exception
+ {
+ byte[] data = new byte[1000000];
+ for (int i = 0; i < data.length; i++)
+ {
+ data[i] = (byte)(Math.random() * (Byte.MAX_VALUE - Byte.MIN_VALUE) + Byte.MIN_VALUE);
+ }
+
+ registerColumn(DBType.BLOB, data);
+ doTest(getName());
+ }
+
+ public void testBlobLength0() throws Exception
+ {
+ registerColumn(DBType.BLOB, new byte[0]);
+ doTest(getName());
+ }
+
+ public void testBoolean() throws Exception
+ {
+ registerColumn(DBType.BOOLEAN, true);
+ registerColumn(DBType.BOOLEAN, false);
+ doTest(getName());
+ }
+
+ public void testChar() throws Exception
+ {
+ registerColumn(DBType.CHAR, "0");
+ registerColumn(DBType.CHAR, "a");
+ registerColumn(DBType.CHAR, "\255"); // Fails for DB2
+ registerColumn(DBType.CHAR, "\u1234"); // Fails for DB2
+ doTest(getName());
+ }
+
+ public void testClob() throws Exception
+ {
+ registerColumn(DBType.CLOB, "Test");
+
+ StringBuffer b = new StringBuffer();
+ for (int i = 0; i < 1000000; i++)
+ {
+ b.append("x");
+ }
+
+ registerColumn(DBType.CLOB, b.toString());
+ doTest(getName());
+ }
+
+ public void testClobLength0() throws Exception
+ {
+ registerColumn(DBType.CLOB, "");
+ doTest(getName());
+ }
+
+ public void testTinyInt() throws Exception
+ {
+ registerColumn(DBType.TINYINT, Byte.MAX_VALUE);
+ registerColumn(DBType.TINYINT, Byte.MIN_VALUE);
+ registerColumn(DBType.TINYINT, new Byte("0"));
+ registerColumn(DBType.TINYINT, new Integer(42).byteValue());
+ doTest(getName());
+ }
+
+ public void testSmallInt() throws Exception
+ {
+ registerColumn(DBType.SMALLINT, Short.MAX_VALUE);
+ registerColumn(DBType.SMALLINT, Short.MIN_VALUE);
+ registerColumn(DBType.SMALLINT, (short)-1);
+ registerColumn(DBType.SMALLINT, (short)5);
+ doTest(getName());
+ }
+
+ public void testInteger() throws Exception
+ {
+ registerColumn(DBType.INTEGER, Integer.MAX_VALUE);
+ registerColumn(DBType.INTEGER, Integer.MIN_VALUE);
+ registerColumn(DBType.INTEGER, -1);
+ registerColumn(DBType.INTEGER, 5);
+ doTest(getName());
+ }
+
+ public void testFloat() throws Exception
+ {
+ registerColumn(DBType.FLOAT, Float.MAX_VALUE);
+ registerColumn(DBType.FLOAT, Float.MIN_VALUE); // Fails for DB2
+ registerColumn(DBType.FLOAT, -.1f);
+ registerColumn(DBType.FLOAT, 3.33333f);
+ doTest(getName());
+ }
+
+ public void testReal() throws Exception
+ {
+ registerColumn(DBType.REAL, Float.MAX_VALUE);
+ registerColumn(DBType.REAL, Float.MIN_VALUE); // Fails for DB2
+ registerColumn(DBType.REAL, -.1f);
+ registerColumn(DBType.REAL, 3.33333f);
+ doTest(getName());
+ }
+
+ public void testDouble() throws Exception
+ {
+ registerColumn(DBType.DOUBLE, new Double(Double.MAX_VALUE));
+ // registerColumn(DBType.DOUBLE, new Double(Double.MIN_VALUE));
+ registerColumn(DBType.DOUBLE, -.1d);
+ registerColumn(DBType.DOUBLE, 3.33333d);
+ doTest(getName());
+ }
+
+ public void _testNumeric() throws Exception
+ {
+ String numberLiteral1 = "12345678901234567890123456789012";
+ String numberLiteral2 = "10000000000000000000000000000000";
+
+ for (int precision = 1; precision < 32; precision++)
+ {
+ BigInteger numberInteger1 = new BigInteger(numberLiteral1.substring(0, precision));
+ BigInteger numberInteger2 = new BigInteger(numberLiteral2.substring(0, precision));
+
+ for (int scale = 0; scale <= precision; scale++)
+ {
+ BigDecimal numberDecimal1 = new BigDecimal(numberInteger1, scale);
+ BigDecimal numberDecimal2 = new BigDecimal(numberInteger2, scale);
+
+ registerColumn(DBType.NUMERIC, numberDecimal1);
+ registerColumn(DBType.NUMERIC, numberDecimal2);
+
+ doTest(getName() + precision + "_" + scale);
+ columns.clear();
+ }
+ }
+ }
+
+ public void _testDecimal() throws Exception
+ {
+ String numberLiteral1 = "12345678901234567890123456789012";
+ String numberLiteral2 = "10000000000000000000000000000000";
+
+ for (int precision = 1; precision < 32; precision++)
+ {
+ BigInteger numberInteger1 = new BigInteger(numberLiteral1.substring(0, precision));
+ BigInteger numberInteger2 = new BigInteger(numberLiteral2.substring(0, precision));
+
+ for (int scale = 0; scale <= precision; scale++)
+ {
+ BigDecimal numberDecimal1 = new BigDecimal(numberInteger1, scale);
+ BigDecimal numberDecimal2 = new BigDecimal(numberInteger2, scale);
+
+ registerColumn(DBType.DECIMAL, numberDecimal1);
+ registerColumn(DBType.DECIMAL, numberDecimal2);
+
+ doTest(getName() + precision + "_" + scale);
+ columns.clear();
+ }
+ }
+ }
+
+ public void testVarChar() throws Exception
+ {
+ registerColumn(DBType.VARCHAR, "");
+ registerColumn(DBType.VARCHAR, "\n");
+ registerColumn(DBType.VARCHAR, "\t");
+ registerColumn(DBType.VARCHAR, "\r");
+ registerColumn(DBType.VARCHAR, "\u1234");
+ registerColumn(DBType.VARCHAR, "The quick brown fox jumps over the lazy dog.");
+ registerColumn(DBType.VARCHAR, "\\,:\",\'");
+
+ doTest(getName());
+ }
+
+ public void testLongVarChar() throws Exception
+ {
+ registerColumn(DBType.LONGVARCHAR, "");
+ registerColumn(DBType.LONGVARCHAR, "\n");
+ registerColumn(DBType.LONGVARCHAR, "\t");
+ registerColumn(DBType.LONGVARCHAR, "\r");
+ registerColumn(DBType.LONGVARCHAR, "\u1234");
+ registerColumn(DBType.LONGVARCHAR, "The quick brown fox jumps over the lazy dog.");
+ registerColumn(DBType.LONGVARCHAR, "\\,:\",\'");
+
+ doTest(getName());
+ }
+
+ public void testDate() throws Exception
+ {
+ registerColumn(DBType.DATE, new GregorianCalendar(2010, 04, 21).getTimeInMillis());
+ registerColumn(DBType.DATE, new GregorianCalendar(1950, 04, 21).getTimeInMillis());
+ registerColumn(DBType.DATE, new GregorianCalendar(2030, 12, 31).getTimeInMillis());
+ registerColumn(DBType.DATE, new GregorianCalendar(0, 0, 0).getTimeInMillis()); // Fails for DB2
+
+ doTest(getName());
+ }
+
+ public void testTime() throws Exception
+ {
+ registerColumn(DBType.TIME, HOURS_toMillis(10));
+ registerColumn(DBType.TIME, 0l);
+ registerColumn(DBType.TIME, HOURS_toMillis(11) + MINUTES_toMillis(59) + TimeUnit.SECONDS.toMillis(59));
+
+ // Following tests fail on H2 as 24h == 1 day => 0
+ registerColumn(DBType.TIME, HOURS_toMillis(24));
+
+ doTest(getName());
+ }
+
+ public void testTimestamp() throws Exception
+ {
+ registerColumn(DBType.TIME, HOURS_toMillis(10));
+ registerColumn(DBType.TIME, 0l);
+ registerColumn(DBType.TIME, HOURS_toMillis(11) + MINUTES_toMillis(59) + TimeUnit.SECONDS.toMillis(59));
+
+ // Following tests fail on H2 as 24h == 1 day => 0
+ registerColumn(DBType.TIME, HOURS_toMillis(24));
+
+ doTest(getName());
+ }
+
+ private void registerColumn(DBType type, Object value)
+ {
+ Pair<DBType, Object> column = new Pair<DBType, Object>(type, value);
+ columns.add(column);
+ }
+
+ private void prepareTable(String tableName)
+ {
+ IDBSchema schema = store.getDBSchema();
+ IDBTable table = schema.addTable(tableName);
+ int c = 0;
+
+ for (Pair<DBType, Object> column : columns)
+ {
+ switch (column.getElement1())
+ {
+ case NUMERIC:
+ case DECIMAL:
+ BigDecimal value = (BigDecimal)column.getElement2();
+ table.addField(FIELD_NAME + c++, column.getElement1(), value.precision(), value.scale());
+ break;
+
+ default:
+ table.addField(FIELD_NAME + c++, column.getElement1());
+ break;
+ }
+ }
+
+ store.getDBAdapter().createTables(Arrays.asList(table), connection);
+ }
+
+ private void writeValues(String tableName) throws Exception
+ {
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+ ExtendedDataOutputStream outs = new ExtendedDataOutputStream(output);
+
+ boolean first = true;
+ StringBuilder builder = new StringBuilder("INSERT INTO " + tableName + " VALUES (");
+ for (Pair<DBType, Object> column : columns)
+ {
+ writeTypeValue(outs, column.getElement1(), column.getElement2());
+ if (first)
+ {
+ builder.append("?");
+ first = false;
+ }
+ else
+ {
+ builder.append(", ?");
+ }
+ }
+
+ builder.append(")");
+ String sql = builder.toString();
+
+ outs.close();
+ output.flush();
+ byte[] buffer = output.toByteArray();
+ output.close();
+
+ ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+ ExtendedDataInputStream ins = new ExtendedDataInputStream(input);
+
+ PreparedStatement stmt = connection.prepareStatement(sql);
+ int c = 1;
+
+ for (Pair<DBType, Object> column : columns)
+ {
+ column.getElement1().readValueWithResult(ins, stmt, c++, false);
+ }
+
+ stmt.executeUpdate();
+
+ stmt.close();
+ ins.close();
+ input.close();
+ }
+
+ private void checkValues(String tableName) throws Exception
+ {
+ Statement stmt = connection.createStatement();
+ ResultSet resultSet = stmt.executeQuery("SELECT * FROM " + tableName);
+ assertEquals(true, resultSet.next());
+
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+ ExtendedDataOutputStream outs = new ExtendedDataOutputStream(output);
+
+ int c = 1;
+ for (Pair<DBType, Object> column : columns)
+ {
+ column.getElement1().writeValue(outs, resultSet, c++, false);
+ }
+
+ resultSet.close();
+ stmt.close();
+
+ outs.close();
+ output.flush();
+ byte[] buffer = output.toByteArray();
+ output.close();
+
+ ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+ ExtendedDataInputStream ins = new ExtendedDataInputStream(input);
+
+ c = 1;
+ for (Pair<DBType, Object> column : columns)
+ {
+ DBType dbType = column.getElement1();
+ Object expected = column.getElement2();
+
+ Object actual = readTypeValue(ins, dbType);
+ Class<? extends Object> type = expected.getClass();
+ if (type.isArray())
+ {
+ Class<?> componentType = type.getComponentType();
+ if (componentType == byte.class)
+ {
+ assertEquals("Error in column " + c + " of type " + dbType, true,
+ Arrays.equals((byte[])expected, (byte[])actual));
+ }
+ else if (componentType == char.class)
+ {
+ assertEquals("Error in column " + c + " with type " + dbType, true,
+ Arrays.equals((char[])expected, (char[])actual));
+ }
+ else
+ {
+ throw new IllegalStateException("Unexpected component type: " + componentType);
+ }
+ }
+ else
+ {
+ if (dbType == DBType.TIME)
+ {
+ actual = (Long)actual % 86400000L;
+ expected = (Long)expected % 86400000L;
+ }
+
+ assertEquals("Error in column " + c + " with type " + dbType, expected, actual);
+ }
+
+ ++c;
+ }
+ }
+
+ private void doTest(String tableName) throws Exception
+ {
+ store = (DBStore)getRepository().getStore();
+ connection = store.getConnection();
+
+ try
+ {
+ prepareTable(tableName);
+ writeValues(tableName);
+ checkValues(tableName);
+ }
+ finally
+ {
+ try
+ {
+ connection.commit();
+ }
+ finally
+ {
+ DBUtil.close(connection);
+ connection = null;
+ store = null;
+ }
+ }
+ }
+
+ private void writeTypeValue(ExtendedDataOutputStream outs, DBType type, Object value) throws IOException
+ {
+ switch (type)
+ {
+ case BOOLEAN:
+ case BIT:
+ outs.writeBoolean((Boolean)value);
+ return;
+
+ case TINYINT:
+ outs.writeByte((Byte)value);
+ return;
+
+ case CHAR:
+ outs.writeString((String)value);
+ return;
+
+ case SMALLINT:
+ outs.writeShort((Short)value);
+ return;
+
+ case INTEGER:
+ outs.writeInt((Integer)value);
+ return;
+
+ case FLOAT:
+ outs.writeFloat((Float)value);
+ return;
+
+ case REAL:
+ outs.writeFloat((Float)value);
+ return;
+
+ case DOUBLE:
+ outs.writeDouble((Double)value);
+ return;
+
+ case NUMERIC:
+ case DECIMAL:
+ {
+ BigDecimal bigDecimal = (BigDecimal)value;
+ outs.writeByteArray(bigDecimal.unscaledValue().toByteArray());
+ outs.writeInt(bigDecimal.scale());
+ return;
+ }
+
+ case VARCHAR:
+ case LONGVARCHAR:
+ outs.writeString((String)value);
+ return;
+
+ case CLOB:
+ {
+ long length = ((String)value).length();
+ StringReader source = new StringReader((String)value);
+ try
+ {
+ outs.writeLong(length);
+ while (length-- > 0)
+ {
+ int c = source.read();
+ outs.writeChar(c);
+ }
+ }
+ finally
+ {
+ IOUtil.close(source);
+ }
+
+ return;
+ }
+
+ case BIGINT:
+ case DATE:
+ case TIME:
+ case TIMESTAMP:
+ outs.writeLong((Long)value);
+ return;
+
+ case BINARY:
+ case VARBINARY:
+ case LONGVARBINARY:
+ outs.writeByteArray((byte[])value);
+ return;
+
+ case BLOB:
+ {
+ long length = ((byte[])value).length;
+ ByteArrayInputStream source = new ByteArrayInputStream((byte[])value);
+ try
+ {
+ outs.writeLong(length);
+ while (length-- > 0)
+ {
+ int b = source.read();
+ outs.writeByte(b + Byte.MIN_VALUE);
+ }
+ }
+ finally
+ {
+ IOUtil.close(source);
+ }
+
+ return;
+ }
+
+ default:
+ throw new UnsupportedOperationException("not implemented");
+ }
+ }
+
+ private Object readTypeValue(ExtendedDataInputStream ins, DBType type) throws IOException
+ {
+ switch (type)
+ {
+ case BOOLEAN:
+ case BIT:
+ return ins.readBoolean();
+
+ case CHAR:
+ return ins.readString();
+
+ case TINYINT:
+ return ins.readByte();
+
+ case SMALLINT:
+ return ins.readShort();
+
+ case INTEGER:
+ return ins.readInt();
+
+ case FLOAT:
+ case REAL:
+ return ins.readFloat();
+
+ case DOUBLE:
+ return ins.readDouble();
+
+ case NUMERIC:
+ case DECIMAL:
+ {
+ byte[] array = ins.readByteArray();
+ if (array == null)
+ {
+ return null;
+ }
+
+ BigInteger unscaled = new BigInteger(array);
+ int scale = ins.readInt();
+ return new BigDecimal(unscaled, scale);
+ }
+
+ case VARCHAR:
+ case LONGVARCHAR:
+ return ins.readString();
+
+ case CLOB:
+ {
+ StringWriter result = new StringWriter();
+ try
+ {
+ long length = ins.readLong();
+ while (length-- > 0)
+ {
+ char c = ins.readChar();
+ result.append(c);
+ }
+ }
+ finally
+ {
+ IOUtil.close(result);
+ }
+ return result.toString();
+ }
+
+ case DATE:
+ case BIGINT:
+ case TIME:
+ case TIMESTAMP:
+ return ins.readLong();
+
+ case BINARY:
+ case VARBINARY:
+ case LONGVARBINARY:
+ return ins.readByteArray();
+
+ case BLOB:
+ {
+ ByteArrayOutputStream result = new ByteArrayOutputStream();
+
+ try
+ {
+ long length = ins.readLong();
+ while (length-- > 0)
+ {
+ int b = ins.readByte();
+ result.write(b - Byte.MIN_VALUE);
+ }
+ }
+ finally
+ {
+ IOUtil.close(result);
+ }
+
+ return result.toByteArray();
+ }
+
+ default:
+ throw new UnsupportedOperationException("not implemented");
+ }
+ }
+
+ private long HOURS_toMillis(int hours)
+ {
+ return MINUTES_toMillis(60 * hours);
+ }
+
+ private long MINUTES_toMillis(int minutes)
+ {
+ return 1000L * 60L * minutes;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/PostgresqlConfig.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/PostgresqlConfig.java
index b30ed034c5..23ea0dee39 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/PostgresqlConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/PostgresqlConfig.java
@@ -1,128 +1,128 @@
-/*
- * Copyright (c) 2004 - 2012 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
-{
- public static final String DB_ADAPTER_NAME = "Postgresql";
-
- 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(DB_ADAPTER_NAME, supportingAudits, supportingBranches, false, false, idGenerationLocation);
- }
-
- @Override
- protected String getDBAdapterName()
- {
- return DB_ADAPTER_NAME;
- }
-
- @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;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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
+{
+ public static final String DB_ADAPTER_NAME = "Postgresql";
+
+ 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(DB_ADAPTER_NAME, supportingAudits, supportingBranches, false, false, idGenerationLocation);
+ }
+
+ @Override
+ protected String getDBAdapterName()
+ {
+ return DB_ADAPTER_NAME;
+ }
+
+ @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;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/bundle/OM.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/bundle/OM.java
index fbe8bd553e..78fd6cd69a 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/bundle/OM.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/bundle/OM.java
@@ -1,44 +1,44 @@
-/*
- * Copyright (c) 2004 - 2012 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.bundle;
-
-import org.eclipse.net4j.util.om.OMBundle;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.OSGiActivator;
-import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.trace.OMTracer;
-
-/**
- * The <em>Operations & Maintenance</em> class of this bundle.
- *
- * @author Eike Stepper
- */
-public abstract class OM
-{
- public static final String BUNDLE_ID = "org.eclipse.emf.cdo.tests.db"; //$NON-NLS-1$
-
- public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
-
- public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
-
- public static final OMLogger LOG = BUNDLE.logger();
-
- /**
- * @author Eike Stepper
- */
- public static final class Activator extends OSGiActivator
- {
- public Activator()
- {
- super(BUNDLE);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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.bundle;
+
+import org.eclipse.net4j.util.om.OMBundle;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.OSGiActivator;
+import org.eclipse.net4j.util.om.log.OMLogger;
+import org.eclipse.net4j.util.om.trace.OMTracer;
+
+/**
+ * The <em>Operations & Maintenance</em> class of this bundle.
+ *
+ * @author Eike Stepper
+ */
+public abstract class OM
+{
+ public static final String BUNDLE_ID = "org.eclipse.emf.cdo.tests.db"; //$NON-NLS-1$
+
+ public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
+
+ public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
+
+ public static final OMLogger LOG = BUNDLE.logger();
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Activator extends OSGiActivator
+ {
+ public Activator()
+ {
+ super(BUNDLE);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/AbstractCapabilityTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/AbstractCapabilityTest.java
index f7527bb5f7..d0af76f769 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/AbstractCapabilityTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/AbstractCapabilityTest.java
@@ -1,347 +1,347 @@
-/*
- * Copyright (c) 2004 - 2012 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.capabilities;
-
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBConnectionProvider;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import junit.framework.TestCase;
-
-/**
- * This is a simple test case that can be used to analyze how a DBMS handles DML in the middle of a transaction.
- *
- * @author Stefan Winkler
- */
-public abstract class AbstractCapabilityTest extends TestCase
-{
- public AbstractCapabilityTest(String name)
- {
- super(name);
- }
-
- public void testDirtyRead() throws Exception
- {
- msg("TEST " + getClass().getSimpleName() + " - DIRTY READ");
- msg("----------------------------------------------------------");
- msg("Transaction 1 changes a value, transaction 2 will read the value.");
- msg("The value of transaction 2 should be UNCHANGED (else we have a dirty read)");
-
- Thread t = new Thread()
- {
- @Override
- public void run()
- {
- try
- {
- IDBConnectionProvider provider = getConnectionProvider();
- Connection transaction1 = provider.getConnection();
- transaction1.setAutoCommit(false);
-
- Statement tx1stmt = transaction1.createStatement();
- tx1stmt.executeUpdate("update status_table set status = 'changed' where trans = 'transaction1'");
- msg("Read value (transaction 1) is "
- + select(transaction1, "select status from status_table where trans = 'transaction1'").toUpperCase());
- sleep(1000);
-
- transaction1.rollback();
- transaction1.close();
- }
- catch (Exception e)
- {
- throw new Error(e);
- }
- }
- };
-
- t.start();
- Thread.sleep(300);
-
- IDBConnectionProvider provider = getConnectionProvider();
- Connection transaction2 = provider.getConnection();
-
- transaction2.setAutoCommit(false);
-
- msg("Read value (transaction 2) is "
- + select(transaction2, "select status from status_table where trans = 'transaction1'").toUpperCase());
- msg("----------------------------------------------------------");
- transaction2.rollback();
- transaction2.close();
- }
-
- public void testRollback() throws Exception
- {
- msg("TEST " + getClass().getSimpleName() + " - ROLLBACK");
- msg("----------------------------------------------------------");
- msg("Transaction changes a value and does a rollback.");
- msg("The value of after rollback should be UNCHANGED.");
-
- IDBConnectionProvider provider = getConnectionProvider();
- Connection transaction1 = provider.getConnection();
- transaction1.setAutoCommit(false);
-
- Statement tx1stmt = transaction1.createStatement();
-
- try
- {
- tx1stmt.executeUpdate("update status_table set status = 'changed' where trans = 'transaction1'");
- }
- finally
- {
- DBUtil.close(tx1stmt);
- }
-
- msg("Read value before rollback is "
- + select(transaction1, "select status from status_table where trans = 'transaction1'").toUpperCase());
-
- transaction1.rollback();
- transaction1.close();
-
- Connection view = provider.getConnection();
- msg("Read value after rollback is "
- + select(view, "select status from status_table where trans = 'transaction1'").toUpperCase());
- view.close();
- msg("----------------------------------------------------------");
- }
-
- public void testDml() throws Exception
- {
- msg("TEST " + getClass().getSimpleName() + " - DML");
- msg("----------------------------------------------------------");
- msg("Transaction 1 will execute DML, transaction 2 will just change its data.");
-
- Thread t = new Thread()
- {
- @Override
- public void run()
- {
- try
- {
- IDBConnectionProvider provider = getConnectionProvider();
- Connection transaction2 = provider.getConnection();
- Statement tx2stmt = transaction2.createStatement();
- transaction2.setAutoCommit(false);
- tx2stmt.executeUpdate("update status_table set status = 'changed' where trans = 'transaction2'");
- tx2stmt.executeUpdate("update change_table set status = 'changed' where trans = 'transaction2'");
- tx2stmt.close();
- sleep(1000);
- transaction2.rollback();
- transaction2.close();
- }
- catch (Exception e)
- {
- throw new Error(e);
- }
- }
- };
-
- t.start();
- Thread.sleep(100);
-
- IDBConnectionProvider provider = getConnectionProvider();
- Connection transaction1 = provider.getConnection();
- transaction1.setAutoCommit(false);
-
- Statement tx1stmt = transaction1.createStatement();
-
- tx1stmt.executeUpdate("update status_table set status = 'changed' where trans = 'transaction1'");
- tx1stmt.executeUpdate("update change_table set status = 'changed' where trans = 'transaction1'");
-
- tx1stmt.execute("alter table change_table add new_column varchar(255) default 'added column present'");
-
- tx1stmt.close();
-
- transaction1.rollback();
- transaction1.close();
-
- t.join();
-
- Connection view = provider.getConnection();
-
- msg("transaction1: unchanged table record is "
- + select(view, "select status from status_table where trans = 'transaction1'").toUpperCase());
- msg("transaction2: unchanged table record is "
- + select(view, "select status from status_table where trans = 'transaction2'").toUpperCase());
-
- msg("transaction1: changed table record is "
- + select(view, "select status from change_table where trans = 'transaction1'").toUpperCase());
- msg("transaction2: changed table record is "
- + select(view, "select status from change_table where trans = 'transaction2'").toUpperCase());
-
- String present = "present";
- try
- {
- select(view, "select new_column from change_table where trans = 'transaction2'");
- }
- catch (SQLException e)
- {
- present = "not present";
- }
-
- msg("Added column is " + present.toUpperCase());
- view.close();
-
- msg("----------------------------------------------------------");
- }
-
- @Override
- protected void setUp() throws Exception
- {
- // create table
- Connection conn = getConnectionProvider().getConnection();
- conn.setAutoCommit(false);
- Statement stmt = conn.createStatement();
-
- // make sure tables don't exist!
- try
- {
- stmt.execute("drop table status_table");
- }
- catch (Exception e)
- {
- }
-
- try
- {
- stmt.execute("drop table change_table");
- }
- catch (Exception e)
- {
- }
-
- stmt.execute("create table status_table (trans varchar(255), status varchar(255))");
- stmt.execute("insert into status_table values ('transaction1', 'unchanged')");
- stmt.execute("insert into status_table values ('transaction2', 'unchanged')");
-
- stmt.execute("create table change_table (trans varchar(255), status varchar(255))");
- stmt.execute("insert into change_table values ('transaction1', 'unchanged')");
- stmt.execute("insert into change_table values ('transaction2', 'unchanged')");
-
- conn.commit();
- stmt.close();
- conn.close();
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- Connection conn = getConnectionProvider().getConnection();
- conn.setAutoCommit(true);
- Statement stmt = conn.createStatement();
-
- stmt.execute("drop table status_table");
- stmt.execute("drop table change_table");
-
- stmt.close();
- conn.close();
- }
-
- protected abstract IDBConnectionProvider getConnectionProvider();
-
- private void msg(String string)
- {
- System.out.println(string);
- }
-
- private String select(Connection conn, String sql) throws SQLException
- {
- ResultSet rs = null;
- try
- {
- rs = conn.createStatement().executeQuery(sql);
- rs.next();
- return rs.getString(1);
- }
- finally
- {
- if (rs != null)
- {
- try
- {
- rs.close();
- }
- catch (SQLException ex)
- {
- // NOP
- }
- }
- }
- }
-
- @SuppressWarnings("unused")
- private void sqlDump(Connection conn, String sql)
- {
- ResultSet rs = null;
- try
- {
- System.out.format("Dumping output of %s\n", sql); //$NON-NLS-1$
- rs = conn.createStatement().executeQuery(sql);
- int numCol = rs.getMetaData().getColumnCount();
-
- StringBuilder row = new StringBuilder(" ");
- for (int c = 1; c <= numCol; c++)
- {
- row.append(String.format("%15s | ", rs.getMetaData().getColumnLabel(c))); //$NON-NLS-1$
- }
-
- System.out.println(row.toString());
-
- row = new StringBuilder();
- for (int c = 1; c <= numCol; c++)
- {
- row.append("-----------------+"); //$NON-NLS-1$
- }
-
- System.out.println(row.toString());
-
- while (rs.next())
- {
- row = new StringBuilder(" ");
- for (int c = 1; c <= numCol; c++)
- {
- row.append(String.format("%15s | ", rs.getString(c))); //$NON-NLS-1$
- }
-
- System.out.println(row.toString());
- }
-
- row = new StringBuilder();
- for (int c = 1; c <= numCol; c++)
- {
- row.append("-----------------+"); //$NON-NLS-1$
- }
-
- System.out.println(row.toString());
- }
- catch (SQLException ex)
- {
- // NOP
- }
- finally
- {
- if (rs != null)
- {
- try
- {
- rs.close();
- }
- catch (SQLException ex)
- {
- // NOP
- }
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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.capabilities;
+
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBConnectionProvider;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import junit.framework.TestCase;
+
+/**
+ * This is a simple test case that can be used to analyze how a DBMS handles DML in the middle of a transaction.
+ *
+ * @author Stefan Winkler
+ */
+public abstract class AbstractCapabilityTest extends TestCase
+{
+ public AbstractCapabilityTest(String name)
+ {
+ super(name);
+ }
+
+ public void testDirtyRead() throws Exception
+ {
+ msg("TEST " + getClass().getSimpleName() + " - DIRTY READ");
+ msg("----------------------------------------------------------");
+ msg("Transaction 1 changes a value, transaction 2 will read the value.");
+ msg("The value of transaction 2 should be UNCHANGED (else we have a dirty read)");
+
+ Thread t = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ IDBConnectionProvider provider = getConnectionProvider();
+ Connection transaction1 = provider.getConnection();
+ transaction1.setAutoCommit(false);
+
+ Statement tx1stmt = transaction1.createStatement();
+ tx1stmt.executeUpdate("update status_table set status = 'changed' where trans = 'transaction1'");
+ msg("Read value (transaction 1) is "
+ + select(transaction1, "select status from status_table where trans = 'transaction1'").toUpperCase());
+ sleep(1000);
+
+ transaction1.rollback();
+ transaction1.close();
+ }
+ catch (Exception e)
+ {
+ throw new Error(e);
+ }
+ }
+ };
+
+ t.start();
+ Thread.sleep(300);
+
+ IDBConnectionProvider provider = getConnectionProvider();
+ Connection transaction2 = provider.getConnection();
+
+ transaction2.setAutoCommit(false);
+
+ msg("Read value (transaction 2) is "
+ + select(transaction2, "select status from status_table where trans = 'transaction1'").toUpperCase());
+ msg("----------------------------------------------------------");
+ transaction2.rollback();
+ transaction2.close();
+ }
+
+ public void testRollback() throws Exception
+ {
+ msg("TEST " + getClass().getSimpleName() + " - ROLLBACK");
+ msg("----------------------------------------------------------");
+ msg("Transaction changes a value and does a rollback.");
+ msg("The value of after rollback should be UNCHANGED.");
+
+ IDBConnectionProvider provider = getConnectionProvider();
+ Connection transaction1 = provider.getConnection();
+ transaction1.setAutoCommit(false);
+
+ Statement tx1stmt = transaction1.createStatement();
+
+ try
+ {
+ tx1stmt.executeUpdate("update status_table set status = 'changed' where trans = 'transaction1'");
+ }
+ finally
+ {
+ DBUtil.close(tx1stmt);
+ }
+
+ msg("Read value before rollback is "
+ + select(transaction1, "select status from status_table where trans = 'transaction1'").toUpperCase());
+
+ transaction1.rollback();
+ transaction1.close();
+
+ Connection view = provider.getConnection();
+ msg("Read value after rollback is "
+ + select(view, "select status from status_table where trans = 'transaction1'").toUpperCase());
+ view.close();
+ msg("----------------------------------------------------------");
+ }
+
+ public void testDml() throws Exception
+ {
+ msg("TEST " + getClass().getSimpleName() + " - DML");
+ msg("----------------------------------------------------------");
+ msg("Transaction 1 will execute DML, transaction 2 will just change its data.");
+
+ Thread t = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ IDBConnectionProvider provider = getConnectionProvider();
+ Connection transaction2 = provider.getConnection();
+ Statement tx2stmt = transaction2.createStatement();
+ transaction2.setAutoCommit(false);
+ tx2stmt.executeUpdate("update status_table set status = 'changed' where trans = 'transaction2'");
+ tx2stmt.executeUpdate("update change_table set status = 'changed' where trans = 'transaction2'");
+ tx2stmt.close();
+ sleep(1000);
+ transaction2.rollback();
+ transaction2.close();
+ }
+ catch (Exception e)
+ {
+ throw new Error(e);
+ }
+ }
+ };
+
+ t.start();
+ Thread.sleep(100);
+
+ IDBConnectionProvider provider = getConnectionProvider();
+ Connection transaction1 = provider.getConnection();
+ transaction1.setAutoCommit(false);
+
+ Statement tx1stmt = transaction1.createStatement();
+
+ tx1stmt.executeUpdate("update status_table set status = 'changed' where trans = 'transaction1'");
+ tx1stmt.executeUpdate("update change_table set status = 'changed' where trans = 'transaction1'");
+
+ tx1stmt.execute("alter table change_table add new_column varchar(255) default 'added column present'");
+
+ tx1stmt.close();
+
+ transaction1.rollback();
+ transaction1.close();
+
+ t.join();
+
+ Connection view = provider.getConnection();
+
+ msg("transaction1: unchanged table record is "
+ + select(view, "select status from status_table where trans = 'transaction1'").toUpperCase());
+ msg("transaction2: unchanged table record is "
+ + select(view, "select status from status_table where trans = 'transaction2'").toUpperCase());
+
+ msg("transaction1: changed table record is "
+ + select(view, "select status from change_table where trans = 'transaction1'").toUpperCase());
+ msg("transaction2: changed table record is "
+ + select(view, "select status from change_table where trans = 'transaction2'").toUpperCase());
+
+ String present = "present";
+ try
+ {
+ select(view, "select new_column from change_table where trans = 'transaction2'");
+ }
+ catch (SQLException e)
+ {
+ present = "not present";
+ }
+
+ msg("Added column is " + present.toUpperCase());
+ view.close();
+
+ msg("----------------------------------------------------------");
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ // create table
+ Connection conn = getConnectionProvider().getConnection();
+ conn.setAutoCommit(false);
+ Statement stmt = conn.createStatement();
+
+ // make sure tables don't exist!
+ try
+ {
+ stmt.execute("drop table status_table");
+ }
+ catch (Exception e)
+ {
+ }
+
+ try
+ {
+ stmt.execute("drop table change_table");
+ }
+ catch (Exception e)
+ {
+ }
+
+ stmt.execute("create table status_table (trans varchar(255), status varchar(255))");
+ stmt.execute("insert into status_table values ('transaction1', 'unchanged')");
+ stmt.execute("insert into status_table values ('transaction2', 'unchanged')");
+
+ stmt.execute("create table change_table (trans varchar(255), status varchar(255))");
+ stmt.execute("insert into change_table values ('transaction1', 'unchanged')");
+ stmt.execute("insert into change_table values ('transaction2', 'unchanged')");
+
+ conn.commit();
+ stmt.close();
+ conn.close();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ Connection conn = getConnectionProvider().getConnection();
+ conn.setAutoCommit(true);
+ Statement stmt = conn.createStatement();
+
+ stmt.execute("drop table status_table");
+ stmt.execute("drop table change_table");
+
+ stmt.close();
+ conn.close();
+ }
+
+ protected abstract IDBConnectionProvider getConnectionProvider();
+
+ private void msg(String string)
+ {
+ System.out.println(string);
+ }
+
+ private String select(Connection conn, String sql) throws SQLException
+ {
+ ResultSet rs = null;
+ try
+ {
+ rs = conn.createStatement().executeQuery(sql);
+ rs.next();
+ return rs.getString(1);
+ }
+ finally
+ {
+ if (rs != null)
+ {
+ try
+ {
+ rs.close();
+ }
+ catch (SQLException ex)
+ {
+ // NOP
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unused")
+ private void sqlDump(Connection conn, String sql)
+ {
+ ResultSet rs = null;
+ try
+ {
+ System.out.format("Dumping output of %s\n", sql); //$NON-NLS-1$
+ rs = conn.createStatement().executeQuery(sql);
+ int numCol = rs.getMetaData().getColumnCount();
+
+ StringBuilder row = new StringBuilder(" ");
+ for (int c = 1; c <= numCol; c++)
+ {
+ row.append(String.format("%15s | ", rs.getMetaData().getColumnLabel(c))); //$NON-NLS-1$
+ }
+
+ System.out.println(row.toString());
+
+ row = new StringBuilder();
+ for (int c = 1; c <= numCol; c++)
+ {
+ row.append("-----------------+"); //$NON-NLS-1$
+ }
+
+ System.out.println(row.toString());
+
+ while (rs.next())
+ {
+ row = new StringBuilder(" ");
+ for (int c = 1; c <= numCol; c++)
+ {
+ row.append(String.format("%15s | ", rs.getString(c))); //$NON-NLS-1$
+ }
+
+ System.out.println(row.toString());
+ }
+
+ row = new StringBuilder();
+ for (int c = 1; c <= numCol; c++)
+ {
+ row.append("-----------------+"); //$NON-NLS-1$
+ }
+
+ System.out.println(row.toString());
+ }
+ catch (SQLException ex)
+ {
+ // NOP
+ }
+ finally
+ {
+ if (rs != null)
+ {
+ try
+ {
+ rs.close();
+ }
+ catch (SQLException ex)
+ {
+ // NOP
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/DerbyTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/DerbyTest.java
index 3ad7f94747..34f250fd46 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/DerbyTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/DerbyTest.java
@@ -1,44 +1,44 @@
-/*
- * Copyright (c) 2004 - 2012 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.capabilities;
-
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBConnectionProvider;
-import org.eclipse.net4j.util.io.TMPUtil;
-
-import org.apache.derby.jdbc.EmbeddedDataSource;
-
-import java.io.File;
-
-/**
- * @author Stefan Winkler
- */
-public class DerbyTest extends AbstractCapabilityTest
-{
- private IDBConnectionProvider provider;
-
- public DerbyTest()
- {
- super("derby");
- File dbFolder = TMPUtil.createTempFolder("derby_", "_test");
- dbFolder.delete();
- EmbeddedDataSource derbyds = new EmbeddedDataSource();
- derbyds.setDatabaseName(dbFolder.getAbsolutePath());
- derbyds.setCreateDatabase("create");
- provider = DBUtil.createConnectionProvider(derbyds);
- }
-
- @Override
- protected IDBConnectionProvider getConnectionProvider()
- {
- return provider;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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.capabilities;
+
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBConnectionProvider;
+import org.eclipse.net4j.util.io.TMPUtil;
+
+import org.apache.derby.jdbc.EmbeddedDataSource;
+
+import java.io.File;
+
+/**
+ * @author Stefan Winkler
+ */
+public class DerbyTest extends AbstractCapabilityTest
+{
+ private IDBConnectionProvider provider;
+
+ public DerbyTest()
+ {
+ super("derby");
+ File dbFolder = TMPUtil.createTempFolder("derby_", "_test");
+ dbFolder.delete();
+ EmbeddedDataSource derbyds = new EmbeddedDataSource();
+ derbyds.setDatabaseName(dbFolder.getAbsolutePath());
+ derbyds.setCreateDatabase("create");
+ provider = DBUtil.createConnectionProvider(derbyds);
+ }
+
+ @Override
+ protected IDBConnectionProvider getConnectionProvider()
+ {
+ return provider;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/H2Test.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/H2Test.java
index 1405e2a57a..efd1e2ae31 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/H2Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/H2Test.java
@@ -1,40 +1,40 @@
-/*
- * Copyright (c) 2004 - 2012 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.capabilities;
-
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBConnectionProvider;
-
-import org.h2.jdbcx.JdbcDataSource;
-
-/**
- * @author Stefan Winkler
- */
-public class H2Test extends AbstractCapabilityTest
-{
- public H2Test()
- {
- super("h2");
- JdbcDataSource h2ds = new JdbcDataSource();
- h2ds = new JdbcDataSource();
- h2ds.setURL("jdbc:h2:file:c:/temp/h2test");
- h2ds.setUser("sa");
- provider = DBUtil.createConnectionProvider(h2ds);
- }
-
- IDBConnectionProvider provider = null;
-
- @Override
- protected IDBConnectionProvider getConnectionProvider()
- {
- return provider;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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.capabilities;
+
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBConnectionProvider;
+
+import org.h2.jdbcx.JdbcDataSource;
+
+/**
+ * @author Stefan Winkler
+ */
+public class H2Test extends AbstractCapabilityTest
+{
+ public H2Test()
+ {
+ super("h2");
+ JdbcDataSource h2ds = new JdbcDataSource();
+ h2ds = new JdbcDataSource();
+ h2ds.setURL("jdbc:h2:file:c:/temp/h2test");
+ h2ds.setUser("sa");
+ provider = DBUtil.createConnectionProvider(h2ds);
+ }
+
+ IDBConnectionProvider provider = null;
+
+ @Override
+ protected IDBConnectionProvider getConnectionProvider()
+ {
+ return provider;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/MysqlTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/MysqlTest.java
index cc8902e81b..1db27f9789 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/MysqlTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/capabilities/MysqlTest.java
@@ -1,40 +1,40 @@
-/*
- * Copyright (c) 2004 - 2012 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.capabilities;
-
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBConnectionProvider;
-
-import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
-
-/**
- * @author Stefan Winkler
- */
-public class MysqlTest extends AbstractCapabilityTest
-{
- private IDBConnectionProvider provider;
-
- public MysqlTest()
- {
- super("mysql");
- MysqlDataSource mysqlds = new MysqlDataSource();
- mysqlds.setUrl("jdbc:mysql://localhost:33306/winkler_r2");
- mysqlds.setUser("winkler");
- mysqlds.setPassword("winkler");
- provider = DBUtil.createConnectionProvider(mysqlds);
- }
-
- @Override
- protected IDBConnectionProvider getConnectionProvider()
- {
- return provider;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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.capabilities;
+
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBConnectionProvider;
+
+import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
+
+/**
+ * @author Stefan Winkler
+ */
+public class MysqlTest extends AbstractCapabilityTest
+{
+ private IDBConnectionProvider provider;
+
+ public MysqlTest()
+ {
+ super("mysql");
+ MysqlDataSource mysqlds = new MysqlDataSource();
+ mysqlds.setUrl("jdbc:mysql://localhost:33306/winkler_r2");
+ mysqlds.setUser("winkler");
+ mysqlds.setPassword("winkler");
+ provider = DBUtil.createConnectionProvider(mysqlds);
+ }
+
+ @Override
+ protected IDBConnectionProvider getConnectionProvider()
+ {
+ return provider;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/performance/AllPerformanceTestsH2NonAudit.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/performance/AllPerformanceTestsH2NonAudit.java
index cc13c52d26..6ab3eef220 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/performance/AllPerformanceTestsH2NonAudit.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/performance/AllPerformanceTestsH2NonAudit.java
@@ -1,35 +1,35 @@
-/*
- * Copyright (c) 2004 - 2012 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:
- * Stefan Winkler - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.db.performance;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
-import org.eclipse.emf.cdo.tests.db.H2Config;
-import org.eclipse.emf.cdo.tests.performance.AllPerformanceTests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Stefan Winkler
- */
-public class AllPerformanceTestsH2NonAudit extends AllPerformanceTests
-{
- public static Test suite()
- {
- return new AllPerformanceTestsH2NonAudit().getTestSuite(AllPerformanceTestsH2NonAudit.class.getName());
- }
-
- @Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, COMBINED, new H2Config(false, false, false, false, IDGenerationLocation.STORE), JVM, NATIVE);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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:
+ * Stefan Winkler - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.db.performance;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+import org.eclipse.emf.cdo.tests.db.H2Config;
+import org.eclipse.emf.cdo.tests.performance.AllPerformanceTests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Stefan Winkler
+ */
+public class AllPerformanceTestsH2NonAudit extends AllPerformanceTests
+{
+ public static Test suite()
+ {
+ return new AllPerformanceTestsH2NonAudit().getTestSuite(AllPerformanceTestsH2NonAudit.class.getName());
+ }
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, COMBINED, new H2Config(false, false, false, false, IDGenerationLocation.STORE), JVM, NATIVE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/verifier/DBStoreVerifier.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/verifier/DBStoreVerifier.java
index 7ab611d97a..6501c8f4f5 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/verifier/DBStoreVerifier.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/verifier/DBStoreVerifier.java
@@ -1,540 +1,540 @@
-/*
- * Copyright (c) 2004 - 2012 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:
- * Stefan Winkler - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.db.verifier;
-
-import static junit.framework.Assert.assertEquals;
-
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.server.IStore;
-import org.eclipse.emf.cdo.server.db.IDBStore;
-import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
-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;
-import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditClassMapping;
-import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategy;
-import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalNonAuditClassMapping;
-import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalNonAuditMappingStrategy;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
-import org.eclipse.emf.cdo.tests.db.bundle.OM;
-
-import org.eclipse.net4j.util.collection.Pair;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EClass;
-
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.AssertionFailedError;
-
-/**
- * @author Stefan Winkler
- */
-public abstract class DBStoreVerifier
-{
- protected static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, DBStoreVerifier.class);
-
- private IRepository repository;
-
- private IDBStoreAccessor accessor;
-
- public DBStoreVerifier(IRepository repository)
- {
- this.repository = repository;
- if (repository != null)
- {
- assertEquals(true, repository.getStore() instanceof IDBStore);
- }
- }
-
- protected IRepository getRepository()
- {
- return repository;
- }
-
- protected IDBStore getStore()
- {
- return (IDBStore)repository.getStore();
- }
-
- protected Statement getStatement()
- {
- if (accessor == null)
- {
- accessor = (IDBStoreAccessor)repository.getStore().getReader(null);
- }
-
- try
- {
- return accessor.getConnection().createStatement();
- }
- catch (SQLException ex)
- {
- ex.printStackTrace();
- return null;
- }
- }
-
- protected Connection getConnection() throws SQLException
- {
- return getStatement().getConnection();
- }
-
- protected DatabaseMetaData getMetaData() throws SQLException
- {
- return getConnection().getMetaData();
- }
-
- protected List<IClassMapping> getClassMappings()
- {
- ArrayList<IClassMapping> result = new ArrayList<IClassMapping>();
- InternalCDOPackageRegistry packageRegistry = (InternalCDOPackageRegistry)repository.getPackageRegistry();
- for (InternalCDOPackageInfo packageInfo : packageRegistry.getPackageInfos())
- {
- // CDO core package is not mapped in horizontal mapping
- if (!packageInfo.isCorePackage())
- {
- for (EClass cls : EMFUtil.getPersistentClasses(packageInfo.getEPackage()))
- {
- result.add(getStore().getMappingStrategy().getClassMapping(cls));
- }
- }
- }
-
- return result;
- }
-
- protected void cleanUp()
- {
- if (accessor != null)
- {
- accessor.release();
- }
- }
-
- public void verify() throws VerificationException
- {
- try
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Starting {0}...", getClass().getSimpleName());
- }
-
- doVerify();
-
- if (TRACER.isEnabled())
- {
- TRACER.format("{0} completed without complaints...", getClass().getSimpleName());
- }
- }
- catch (Exception e)
- {
- throw new VerificationException(e);
- }
- finally
- {
- cleanUp();
- }
- }
-
- protected void sqlDump(String sql)
- {
- ResultSet rs = null;
-
- try
- {
- TRACER.format("Dumping output of {0}", sql);
- rs = getStatement().executeQuery(sql);
- int numCol = rs.getMetaData().getColumnCount();
-
- StringBuilder row = new StringBuilder();
- for (int c = 1; c <= numCol; c++)
- {
- row.append(String.format("%10s | ", rs.getMetaData().getColumnLabel(c)));
- }
-
- TRACER.trace(row.toString());
-
- row = new StringBuilder();
- for (int c = 1; c <= numCol; c++)
- {
- row.append("-----------+--");
- }
-
- TRACER.trace(row.toString());
-
- while (rs.next())
- {
- row = new StringBuilder();
- for (int c = 1; c <= numCol; c++)
- {
- row.append(String.format("%10s | ", rs.getString(c)));
- }
-
- TRACER.trace(row.toString());
- }
-
- row = new StringBuilder();
- for (int c = 1; c <= numCol; c++)
- {
- row.append("-----------+-");
- }
-
- TRACER.trace(row.toString());
- }
- catch (SQLException ex)
- {
- // NOP
- }
- finally
- {
- if (rs != null)
- {
- try
- {
- rs.close();
- }
- catch (SQLException ex)
- {
- // NOP
- }
- }
- }
- }
-
- protected abstract void doVerify() throws Exception;
-
- /**
- * @author Stefan Winkler
- */
- public static class VerificationException extends RuntimeException
- {
- private static final long serialVersionUID = 1L;
-
- public VerificationException(String message)
- {
- super(message);
- }
-
- public VerificationException(String message, Throwable t)
- {
- super(message, t);
- }
-
- public VerificationException(Throwable t)
- {
- super(t);
- }
- }
-
- /**
- * @author Stefan Winkler
- */
- public static class Audit extends DBStoreVerifier
- {
- public Audit(IRepository repo)
- {
- super(repo);
-
- // this is a verifier for auditing mode
- assertEquals(true, getStore().getMappingStrategy() instanceof HorizontalAuditMappingStrategy);
- }
-
- @Override
- protected void doVerify() throws Exception
- {
- for (IClassMapping mapping : getClassMappings())
- {
- if (mapping != null && mapping.getDBTables() != null)
- {
- verifyClassMapping(mapping);
- }
- }
- }
-
- private void verifyClassMapping(IClassMapping mapping) throws Exception
- {
- verifyAtMostOneUnrevised(mapping);
- verifyUniqueIdVersion(mapping);
- verifyReferences(mapping);
- }
-
- private void verifyAtMostOneUnrevised(IClassMapping mapping) throws Exception
- {
- String tableName = mapping.getDBTables().iterator().next().getName();
- TRACER.format("verifyAtMostOneUnrevised: {0} ...", tableName);
-
- String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", count(1) FROM " + tableName + " WHERE "
- + CDODBSchema.ATTRIBUTES_REVISED + "= 0 GROUP BY " + CDODBSchema.ATTRIBUTES_ID;
- TRACER.format(" Executing SQL: {0} ", sql);
-
- ResultSet resultSet = getStatement().executeQuery(sql);
- try
- {
- while (resultSet.next())
- {
- assertEquals("Multiple unrevised rows for ID " + resultSet.getLong(1), true, resultSet.getInt(2) <= 1);
- }
- }
- finally
- {
- resultSet.close();
- }
- }
-
- /**
- * Verify that the pair (id,version) is unique.
- */
- private void verifyUniqueIdVersion(IClassMapping mapping) throws Exception
- {
- String tableName = mapping.getDBTables().iterator().next().getName();
- TRACER.format("verifyUniqueIdVersion: {0} ...", tableName);
-
- String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + "," + CDODBSchema.ATTRIBUTES_VERSION + ", count(1) FROM "
- + tableName + " GROUP BY " + CDODBSchema.ATTRIBUTES_ID + "," + CDODBSchema.ATTRIBUTES_VERSION;
-
- TRACER.format(" Executing SQL: {0} ", sql);
-
- ResultSet resultSet = getStatement().executeQuery(sql);
- try
- {
- while (resultSet.next())
- {
- assertEquals("Multiple rows for ID " + resultSet.getLong(1) + "v" + resultSet.getInt(2), true,
- resultSet.getInt(3) <= 1);
- }
- }
- catch (AssertionFailedError e)
- {
- TRACER.trace(e.getMessage());
- sqlDump("SELECT * FROM " + tableName + " WHERE " + CDODBSchema.ATTRIBUTES_REVISED + "=0");
- throw e;
- }
- finally
- {
- resultSet.close();
- }
- }
-
- private void verifyReferences(IClassMapping mapping) throws Exception
- {
- List<IListMapping> listMappings = ((HorizontalAuditClassMapping)mapping).getListMappings();
- if (listMappings == null)
- {
- return;
- }
-
- String tableName = mapping.getDBTables().iterator().next().getName();
- String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", " + CDODBSchema.ATTRIBUTES_VERSION + " FROM " + tableName;
-
- ArrayList<Pair<Long, Integer>> idVersions = new ArrayList<Pair<Long, Integer>>();
-
- ResultSet resultSet = getStatement().executeQuery(sql);
- try
- {
- while (resultSet.next())
- {
- idVersions.add(new Pair<Long, Integer>(resultSet.getLong(1), resultSet.getInt(2)));
- }
- }
- finally
- {
- resultSet.close();
- }
-
- for (IListMapping listMapping : listMappings)
- {
- for (Pair<Long, Integer> idVersion : idVersions)
- {
- verifyCorrectIndices(listMapping, idVersion.getElement1(), idVersion.getElement2());
- }
- }
- }
-
- private void verifyCorrectIndices(IListMapping refMapping, long id, int version) throws Exception
- {
- String tableName = refMapping.getDBTables().iterator().next().getName();
-
- TRACER.format("verifyUniqueIdVersion: {0} for ID{1}v{2} ...", tableName, id, version);
-
- String sql = "SELECT " + CDODBSchema.LIST_IDX + " FROM " + tableName + " WHERE " + CDODBSchema.LIST_REVISION_ID
- + "=" + id + " AND " + CDODBSchema.LIST_REVISION_VERSION + "=" + version + " ORDER BY "
- + CDODBSchema.LIST_IDX;
-
- TRACER.format(" Executing SQL: {0} ", sql);
-
- ResultSet resultSet = getStatement().executeQuery(sql);
- int indexShouldBe = 0;
-
- try
- {
- while (resultSet.next())
- {
- assertEquals("Index " + indexShouldBe + " missing for ID" + id + "v" + version, indexShouldBe++,
- resultSet.getInt(1));
- }
- }
- catch (AssertionFailedError e)
- {
- sqlDump("SELECT * FROM " + tableName + " WHERE " + CDODBSchema.LIST_REVISION_ID + "=" + id + " AND "
- + CDODBSchema.LIST_REVISION_VERSION + "=" + version + " ORDER BY " + CDODBSchema.LIST_IDX);
- throw e;
- }
- finally
- {
- resultSet.close();
- }
- }
- }
-
- /**
- * @author Stefan Winkler
- */
- public static class NonAudit extends DBStoreVerifier
- {
- public NonAudit(IRepository repo)
- {
- super(repo);
-
- // this is a verifier for non-auditing mode
- assertEquals(true, getStore().getRevisionTemporality() == IStore.RevisionTemporality.NONE);
- // ... and for horizontal class mapping
- assertEquals(true, getStore().getMappingStrategy() instanceof HorizontalNonAuditMappingStrategy);
- }
-
- @Override
- protected void doVerify() throws Exception
- {
- for (IClassMapping mapping : getClassMappings())
- {
- if (mapping != null && mapping.getDBTables().size() > 0)
- {
- verifyClassMapping(mapping);
- }
- }
- }
-
- private void verifyClassMapping(IClassMapping mapping) throws Exception
- {
- verifyNoUnrevisedRevisions(mapping);
- verifyUniqueId(mapping);
- verifyReferences(mapping);
- }
-
- /**
- * Verify that there is no row with cdo_revised == 0.
- */
- private void verifyNoUnrevisedRevisions(IClassMapping mapping) throws Exception
- {
- String tableName = mapping.getDBTables().iterator().next().getName();
- String sql = "SELECT count(1) FROM " + tableName + " WHERE " + CDODBSchema.ATTRIBUTES_REVISED + " <> 0";
- ResultSet resultSet = getStatement().executeQuery(sql);
- try
- {
- assertEquals(true, resultSet.next());
- assertEquals("Revised revision in table " + tableName, 0, resultSet.getInt(1));
- }
- finally
- {
- resultSet.close();
- }
- }
-
- /**
- * Verify that the id is unique.
- */
- private void verifyUniqueId(IClassMapping mapping) throws Exception
- {
- String tableName = mapping.getDBTables().iterator().next().getName();
- String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", count(1) FROM " + tableName + " GROUP BY "
- + CDODBSchema.ATTRIBUTES_ID;
-
- ResultSet resultSet = getStatement().executeQuery(sql);
-
- try
- {
- while (resultSet.next())
- {
- assertEquals("Multiple rows for ID " + resultSet.getLong(1), 1, resultSet.getInt(2));
- }
- }
- finally
- {
- resultSet.close();
- }
- }
-
- private void verifyReferences(IClassMapping mapping) throws Exception
- {
- List<IListMapping> referenceMappings = ((HorizontalNonAuditClassMapping)mapping).getListMappings();
- if (referenceMappings == null)
- {
- return;
- }
-
- String tableName = mapping.getDBTables().iterator().next().getName();
- String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", " + CDODBSchema.ATTRIBUTES_VERSION + " FROM " + tableName;
-
- ArrayList<Pair<Long, Integer>> idVersions = new ArrayList<Pair<Long, Integer>>();
-
- ResultSet resultSet = getStatement().executeQuery(sql);
- try
- {
- while (resultSet.next())
- {
- idVersions.add(new Pair<Long, Integer>(resultSet.getLong(1), resultSet.getInt(2)));
- }
- }
- finally
- {
- resultSet.close();
- }
-
- for (IListMapping refMapping : referenceMappings)
- {
- for (Pair<Long, Integer> idVersion : idVersions)
- {
- verifyCorrectIndices(refMapping, idVersion.getElement1());
- }
- }
- }
-
- private void verifyCorrectIndices(IListMapping refMapping, long id) throws Exception
- {
- String tableName = refMapping.getDBTables().iterator().next().getName();
- String sql = "SELECT " + CDODBSchema.LIST_IDX + " FROM " + tableName + " WHERE " + CDODBSchema.LIST_REVISION_ID
- + "=" + id + " ORDER BY " + CDODBSchema.LIST_IDX;
-
- ResultSet resultSet = getStatement().executeQuery(sql);
- int indexShouldBe = 0;
- try
- {
- while (resultSet.next())
- {
- assertEquals("Index " + indexShouldBe + " missing for ID" + id, indexShouldBe++, resultSet.getInt(1));
- }
- }
- finally
- {
- resultSet.close();
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 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:
+ * Stefan Winkler - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.db.verifier;
+
+import static junit.framework.Assert.assertEquals;
+
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.server.db.IDBStore;
+import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
+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;
+import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditClassMapping;
+import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategy;
+import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalNonAuditClassMapping;
+import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalNonAuditMappingStrategy;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
+import org.eclipse.emf.cdo.tests.db.bundle.OM;
+
+import org.eclipse.net4j.util.collection.Pair;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.ecore.EClass;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.AssertionFailedError;
+
+/**
+ * @author Stefan Winkler
+ */
+public abstract class DBStoreVerifier
+{
+ protected static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, DBStoreVerifier.class);
+
+ private IRepository repository;
+
+ private IDBStoreAccessor accessor;
+
+ public DBStoreVerifier(IRepository repository)
+ {
+ this.repository = repository;
+ if (repository != null)
+ {
+ assertEquals(true, repository.getStore() instanceof IDBStore);
+ }
+ }
+
+ protected IRepository getRepository()
+ {
+ return repository;
+ }
+
+ protected IDBStore getStore()
+ {
+ return (IDBStore)repository.getStore();
+ }
+
+ protected Statement getStatement()
+ {
+ if (accessor == null)
+ {
+ accessor = (IDBStoreAccessor)repository.getStore().getReader(null);
+ }
+
+ try
+ {
+ return accessor.getConnection().createStatement();
+ }
+ catch (SQLException ex)
+ {
+ ex.printStackTrace();
+ return null;
+ }
+ }
+
+ protected Connection getConnection() throws SQLException
+ {
+ return getStatement().getConnection();
+ }
+
+ protected DatabaseMetaData getMetaData() throws SQLException
+ {
+ return getConnection().getMetaData();
+ }
+
+ protected List<IClassMapping> getClassMappings()
+ {
+ ArrayList<IClassMapping> result = new ArrayList<IClassMapping>();
+ InternalCDOPackageRegistry packageRegistry = (InternalCDOPackageRegistry)repository.getPackageRegistry();
+ for (InternalCDOPackageInfo packageInfo : packageRegistry.getPackageInfos())
+ {
+ // CDO core package is not mapped in horizontal mapping
+ if (!packageInfo.isCorePackage())
+ {
+ for (EClass cls : EMFUtil.getPersistentClasses(packageInfo.getEPackage()))
+ {
+ result.add(getStore().getMappingStrategy().getClassMapping(cls));
+ }
+ }
+ }
+
+ return result;
+ }
+
+ protected void cleanUp()
+ {
+ if (accessor != null)
+ {
+ accessor.release();
+ }
+ }
+
+ public void verify() throws VerificationException
+ {
+ try
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Starting {0}...", getClass().getSimpleName());
+ }
+
+ doVerify();
+
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("{0} completed without complaints...", getClass().getSimpleName());
+ }
+ }
+ catch (Exception e)
+ {
+ throw new VerificationException(e);
+ }
+ finally
+ {
+ cleanUp();
+ }
+ }
+
+ protected void sqlDump(String sql)
+ {
+ ResultSet rs = null;
+
+ try
+ {
+ TRACER.format("Dumping output of {0}", sql);
+ rs = getStatement().executeQuery(sql);
+ int numCol = rs.getMetaData().getColumnCount();
+
+ StringBuilder row = new StringBuilder();
+ for (int c = 1; c <= numCol; c++)
+ {
+ row.append(String.format("%10s | ", rs.getMetaData().getColumnLabel(c)));
+ }
+
+ TRACER.trace(row.toString());
+
+ row = new StringBuilder();
+ for (int c = 1; c <= numCol; c++)
+ {
+ row.append("-----------+--");
+ }
+
+ TRACER.trace(row.toString());
+
+ while (rs.next())
+ {
+ row = new StringBuilder();
+ for (int c = 1; c <= numCol; c++)
+ {
+ row.append(String.format("%10s | ", rs.getString(c)));
+ }
+
+ TRACER.trace(row.toString());
+ }
+
+ row = new StringBuilder();
+ for (int c = 1; c <= numCol; c++)
+ {
+ row.append("-----------+-");
+ }
+
+ TRACER.trace(row.toString());
+ }
+ catch (SQLException ex)
+ {
+ // NOP
+ }
+ finally
+ {
+ if (rs != null)
+ {
+ try
+ {
+ rs.close();
+ }
+ catch (SQLException ex)
+ {
+ // NOP
+ }
+ }
+ }
+ }
+
+ protected abstract void doVerify() throws Exception;
+
+ /**
+ * @author Stefan Winkler
+ */
+ public static class VerificationException extends RuntimeException
+ {
+ private static final long serialVersionUID = 1L;
+
+ public VerificationException(String message)
+ {
+ super(message);
+ }
+
+ public VerificationException(String message, Throwable t)
+ {
+ super(message, t);
+ }
+
+ public VerificationException(Throwable t)
+ {
+ super(t);
+ }
+ }
+
+ /**
+ * @author Stefan Winkler
+ */
+ public static class Audit extends DBStoreVerifier
+ {
+ public Audit(IRepository repo)
+ {
+ super(repo);
+
+ // this is a verifier for auditing mode
+ assertEquals(true, getStore().getMappingStrategy() instanceof HorizontalAuditMappingStrategy);
+ }
+
+ @Override
+ protected void doVerify() throws Exception
+ {
+ for (IClassMapping mapping : getClassMappings())
+ {
+ if (mapping != null && mapping.getDBTables() != null)
+ {
+ verifyClassMapping(mapping);
+ }
+ }
+ }
+
+ private void verifyClassMapping(IClassMapping mapping) throws Exception
+ {
+ verifyAtMostOneUnrevised(mapping);
+ verifyUniqueIdVersion(mapping);
+ verifyReferences(mapping);
+ }
+
+ private void verifyAtMostOneUnrevised(IClassMapping mapping) throws Exception
+ {
+ String tableName = mapping.getDBTables().iterator().next().getName();
+ TRACER.format("verifyAtMostOneUnrevised: {0} ...", tableName);
+
+ String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", count(1) FROM " + tableName + " WHERE "
+ + CDODBSchema.ATTRIBUTES_REVISED + "= 0 GROUP BY " + CDODBSchema.ATTRIBUTES_ID;
+ TRACER.format(" Executing SQL: {0} ", sql);
+
+ ResultSet resultSet = getStatement().executeQuery(sql);
+ try
+ {
+ while (resultSet.next())
+ {
+ assertEquals("Multiple unrevised rows for ID " + resultSet.getLong(1), true, resultSet.getInt(2) <= 1);
+ }
+ }
+ finally
+ {
+ resultSet.close();
+ }
+ }
+
+ /**
+ * Verify that the pair (id,version) is unique.
+ */
+ private void verifyUniqueIdVersion(IClassMapping mapping) throws Exception
+ {
+ String tableName = mapping.getDBTables().iterator().next().getName();
+ TRACER.format("verifyUniqueIdVersion: {0} ...", tableName);
+
+ String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + "," + CDODBSchema.ATTRIBUTES_VERSION + ", count(1) FROM "
+ + tableName + " GROUP BY " + CDODBSchema.ATTRIBUTES_ID + "," + CDODBSchema.ATTRIBUTES_VERSION;
+
+ TRACER.format(" Executing SQL: {0} ", sql);
+
+ ResultSet resultSet = getStatement().executeQuery(sql);
+ try
+ {
+ while (resultSet.next())
+ {
+ assertEquals("Multiple rows for ID " + resultSet.getLong(1) + "v" + resultSet.getInt(2), true,
+ resultSet.getInt(3) <= 1);
+ }
+ }
+ catch (AssertionFailedError e)
+ {
+ TRACER.trace(e.getMessage());
+ sqlDump("SELECT * FROM " + tableName + " WHERE " + CDODBSchema.ATTRIBUTES_REVISED + "=0");
+ throw e;
+ }
+ finally
+ {
+ resultSet.close();
+ }
+ }
+
+ private void verifyReferences(IClassMapping mapping) throws Exception
+ {
+ List<IListMapping> listMappings = ((HorizontalAuditClassMapping)mapping).getListMappings();
+ if (listMappings == null)
+ {
+ return;
+ }
+
+ String tableName = mapping.getDBTables().iterator().next().getName();
+ String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", " + CDODBSchema.ATTRIBUTES_VERSION + " FROM " + tableName;
+
+ ArrayList<Pair<Long, Integer>> idVersions = new ArrayList<Pair<Long, Integer>>();
+
+ ResultSet resultSet = getStatement().executeQuery(sql);
+ try
+ {
+ while (resultSet.next())
+ {
+ idVersions.add(new Pair<Long, Integer>(resultSet.getLong(1), resultSet.getInt(2)));
+ }
+ }
+ finally
+ {
+ resultSet.close();
+ }
+
+ for (IListMapping listMapping : listMappings)
+ {
+ for (Pair<Long, Integer> idVersion : idVersions)
+ {
+ verifyCorrectIndices(listMapping, idVersion.getElement1(), idVersion.getElement2());
+ }
+ }
+ }
+
+ private void verifyCorrectIndices(IListMapping refMapping, long id, int version) throws Exception
+ {
+ String tableName = refMapping.getDBTables().iterator().next().getName();
+
+ TRACER.format("verifyUniqueIdVersion: {0} for ID{1}v{2} ...", tableName, id, version);
+
+ String sql = "SELECT " + CDODBSchema.LIST_IDX + " FROM " + tableName + " WHERE " + CDODBSchema.LIST_REVISION_ID
+ + "=" + id + " AND " + CDODBSchema.LIST_REVISION_VERSION + "=" + version + " ORDER BY "
+ + CDODBSchema.LIST_IDX;
+
+ TRACER.format(" Executing SQL: {0} ", sql);
+
+ ResultSet resultSet = getStatement().executeQuery(sql);
+ int indexShouldBe = 0;
+
+ try
+ {
+ while (resultSet.next())
+ {
+ assertEquals("Index " + indexShouldBe + " missing for ID" + id + "v" + version, indexShouldBe++,
+ resultSet.getInt(1));
+ }
+ }
+ catch (AssertionFailedError e)
+ {
+ sqlDump("SELECT * FROM " + tableName + " WHERE " + CDODBSchema.LIST_REVISION_ID + "=" + id + " AND "
+ + CDODBSchema.LIST_REVISION_VERSION + "=" + version + " ORDER BY " + CDODBSchema.LIST_IDX);
+ throw e;
+ }
+ finally
+ {
+ resultSet.close();
+ }
+ }
+ }
+
+ /**
+ * @author Stefan Winkler
+ */
+ public static class NonAudit extends DBStoreVerifier
+ {
+ public NonAudit(IRepository repo)
+ {
+ super(repo);
+
+ // this is a verifier for non-auditing mode
+ assertEquals(true, getStore().getRevisionTemporality() == IStore.RevisionTemporality.NONE);
+ // ... and for horizontal class mapping
+ assertEquals(true, getStore().getMappingStrategy() instanceof HorizontalNonAuditMappingStrategy);
+ }
+
+ @Override
+ protected void doVerify() throws Exception
+ {
+ for (IClassMapping mapping : getClassMappings())
+ {
+ if (mapping != null && mapping.getDBTables().size() > 0)
+ {
+ verifyClassMapping(mapping);
+ }
+ }
+ }
+
+ private void verifyClassMapping(IClassMapping mapping) throws Exception
+ {
+ verifyNoUnrevisedRevisions(mapping);
+ verifyUniqueId(mapping);
+ verifyReferences(mapping);
+ }
+
+ /**
+ * Verify that there is no row with cdo_revised == 0.
+ */
+ private void verifyNoUnrevisedRevisions(IClassMapping mapping) throws Exception
+ {
+ String tableName = mapping.getDBTables().iterator().next().getName();
+ String sql = "SELECT count(1) FROM " + tableName + " WHERE " + CDODBSchema.ATTRIBUTES_REVISED + " <> 0";
+ ResultSet resultSet = getStatement().executeQuery(sql);
+ try
+ {
+ assertEquals(true, resultSet.next());
+ assertEquals("Revised revision in table " + tableName, 0, resultSet.getInt(1));
+ }
+ finally
+ {
+ resultSet.close();
+ }
+ }
+
+ /**
+ * Verify that the id is unique.
+ */
+ private void verifyUniqueId(IClassMapping mapping) throws Exception
+ {
+ String tableName = mapping.getDBTables().iterator().next().getName();
+ String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", count(1) FROM " + tableName + " GROUP BY "
+ + CDODBSchema.ATTRIBUTES_ID;
+
+ ResultSet resultSet = getStatement().executeQuery(sql);
+
+ try
+ {
+ while (resultSet.next())
+ {
+ assertEquals("Multiple rows for ID " + resultSet.getLong(1), 1, resultSet.getInt(2));
+ }
+ }
+ finally
+ {
+ resultSet.close();
+ }
+ }
+
+ private void verifyReferences(IClassMapping mapping) throws Exception
+ {
+ List<IListMapping> referenceMappings = ((HorizontalNonAuditClassMapping)mapping).getListMappings();
+ if (referenceMappings == null)
+ {
+ return;
+ }
+
+ String tableName = mapping.getDBTables().iterator().next().getName();
+ String sql = "SELECT " + CDODBSchema.ATTRIBUTES_ID + ", " + CDODBSchema.ATTRIBUTES_VERSION + " FROM " + tableName;
+
+ ArrayList<Pair<Long, Integer>> idVersions = new ArrayList<Pair<Long, Integer>>();
+
+ ResultSet resultSet = getStatement().executeQuery(sql);
+ try
+ {
+ while (resultSet.next())
+ {
+ idVersions.add(new Pair<Long, Integer>(resultSet.getLong(1), resultSet.getInt(2)));
+ }
+ }
+ finally
+ {
+ resultSet.close();
+ }
+
+ for (IListMapping refMapping : referenceMappings)
+ {
+ for (Pair<Long, Integer> idVersion : idVersions)
+ {
+ verifyCorrectIndices(refMapping, idVersion.getElement1());
+ }
+ }
+ }
+
+ private void verifyCorrectIndices(IListMapping refMapping, long id) throws Exception
+ {
+ String tableName = refMapping.getDBTables().iterator().next().getName();
+ String sql = "SELECT " + CDODBSchema.LIST_IDX + " FROM " + tableName + " WHERE " + CDODBSchema.LIST_REVISION_ID
+ + "=" + id + " ORDER BY " + CDODBSchema.LIST_IDX;
+
+ ResultSet resultSet = getStatement().executeQuery(sql);
+ int indexShouldBe = 0;
+ try
+ {
+ while (resultSet.next())
+ {
+ assertEquals("Index " + indexShouldBe + " missing for ID" + id, indexShouldBe++, resultSet.getInt(1));
+ }
+ }
+ finally
+ {
+ resultSet.close();
+ }
+ }
+ }
+}

Back to the top