diff options
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java')
-rw-r--r-- | plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java | 387 |
1 files changed, 103 insertions, 284 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java index b29a90ecb9..300b95c01a 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java @@ -19,25 +19,25 @@ import org.eclipse.emf.cdo.server.IRepositoryProvider; import org.eclipse.emf.cdo.server.IStore; import org.eclipse.emf.cdo.server.IRepository.Props; import org.eclipse.emf.cdo.server.db.CDODBUtil; -import org.eclipse.emf.cdo.server.db.IJDBCDelegateProvider; import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; import org.eclipse.emf.cdo.server.mem.MEMStoreUtil; import org.eclipse.emf.cdo.tests.bundle.OM; import org.eclipse.emf.cdo.tests.config.IRepositoryConfig; -import org.eclipse.emf.cdo.tests.store.verifier.AuditDBStoreIntegrityVerifier; -import org.eclipse.emf.cdo.tests.store.verifier.NonAuditDBStoreIntegrityVerifier; import org.eclipse.net4j.db.DBUtil; import org.eclipse.net4j.db.IDBAdapter; import org.eclipse.net4j.db.derby.EmbeddedDerbyAdapter; import org.eclipse.net4j.db.hsqldb.HSQLDBAdapter; import org.eclipse.net4j.db.hsqldb.HSQLDBDataSource; +import org.eclipse.net4j.db.mysql.MYSQLAdapter; import org.eclipse.net4j.util.ObjectUtil; import org.eclipse.net4j.util.container.IManagedContainer; import org.eclipse.net4j.util.io.IOUtil; import org.eclipse.net4j.util.io.TMPUtil; import org.eclipse.net4j.util.lifecycle.LifecycleUtil; +import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; + import org.apache.derby.jdbc.EmbeddedDataSource; import javax.sql.DataSource; @@ -57,10 +57,9 @@ import java.util.Map.Entry; public abstract class RepositoryConfig extends Config implements IRepositoryConfig { public static final RepositoryConfig[] CONFIGS = { MEM.INSTANCE, // - DB.Hsqldb.Stmt.INSTANCE, DB.Hsqldb.PrepStmt.INSTANCE, // - DB.Derby.Stmt.INSTANCE, DB.Derby.PrepStmt.INSTANCE /* - * , // DB.Mysql.Stmt.INSTANCE, DB.Mysql.PrepStmt.INSTANCE - */}; + DB.Hsqldb.INSTANCE, // + DB.Derby.INSTANCE, // + DB.Mysql.INSTANCE }; public static final String PROP_TEST_REPOSITORY = "test.repository"; @@ -233,13 +232,9 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf IMappingStrategy mappingStrategy = createMappingStrategy(); IDBAdapter dbAdapter = createDBAdapter(); DataSource dataSource = createDataSource(); - IJDBCDelegateProvider delegateProvider = createDelegateProvider(); - return CDODBUtil.createStore(mappingStrategy, dbAdapter, DBUtil.createConnectionProvider(dataSource), - delegateProvider); + return CDODBUtil.createStore(mappingStrategy, dbAdapter, DBUtil.createConnectionProvider(dataSource)); } - protected abstract IJDBCDelegateProvider createDelegateProvider(); - protected abstract IMappingStrategy createMappingStrategy(); protected abstract IDBAdapter createDBAdapter(); @@ -249,10 +244,12 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf /** * @author Eike Stepper */ - public abstract static class Hsqldb extends DB + public static class Hsqldb extends DB { private static final long serialVersionUID = 1L; + public static final Hsqldb INSTANCE = new Hsqldb("HSQLDB"); + private transient HSQLDBDataSource dataSource; public Hsqldb(String name) @@ -319,143 +316,36 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf } } } + } - public static class Stmt extends Hsqldb - { - private static final long serialVersionUID = 1L; - - public static final Stmt INSTANCE = new Stmt("HsqldbHorizontalStmt"); - - public Stmt(String name) - { - super(name); - } + public static class HsqldbNonAudit extends Hsqldb + { + private static final long serialVersionUID = 1L; - @Override - protected IJDBCDelegateProvider createDelegateProvider() - { - return CDODBUtil.createStatementJDBCDelegateProvider(); - } - } + public static final HsqldbNonAudit INSTANCE = new HsqldbNonAudit("DBStore: Hsqldb (non audit)"); - public static class StmtNonAudit extends Hsqldb + public HsqldbNonAudit(String name) { - private static final long serialVersionUID = 1L; - - public static final StmtNonAudit INSTANCE = new StmtNonAudit("HsqldbHorizontalNonAudit"); - - public StmtNonAudit(String name) - { - super(name); - } - - @Override - protected void initRepositoryProperties(Map<String, String> props) - { - super.initRepositoryProperties(props); - props.put(IRepository.Props.SUPPORTING_AUDITS, "false"); - } - - @Override - protected IJDBCDelegateProvider createDelegateProvider() - { - return CDODBUtil.createStatementJDBCDelegateProvider(); - } - - @Override - public void tearDown() throws Exception - { - try - { - // verify DB integrity - new NonAuditDBStoreIntegrityVerifier(getRepository(REPOSITORY_NAME)).verify(); - } - finally - { - super.tearDown(); - } - } + super(name); } - public static class PrepStmt extends Hsqldb + @Override + protected void initRepositoryProperties(Map<String, String> props) { - private static final long serialVersionUID = 1L; - - public static final PrepStmt INSTANCE = new PrepStmt("HsqldbHorizontalPrepStmt"); - - public PrepStmt(String name) - { - super(name); - } - - @Override - public void tearDown() throws Exception - { - try - { - // verify DB integrity - new AuditDBStoreIntegrityVerifier(getRepository(REPOSITORY_NAME)).verify(); - } - finally - { - super.tearDown(); - } - } - - @Override - protected IJDBCDelegateProvider createDelegateProvider() - { - return CDODBUtil.createPreparedStatementJDBCDelegateProvider(); - } - } - - public static class PrepStmtNonAudit extends Hsqldb - { - private static final long serialVersionUID = 1L; - - public static final PrepStmtNonAudit INSTANCE = new PrepStmtNonAudit("HsqldbHorizontalPrepStmtNonAudit"); - - public PrepStmtNonAudit(String name) - { - super(name); - } - - @Override - protected void initRepositoryProperties(Map<String, String> props) - { - super.initRepositoryProperties(props); - props.put(IRepository.Props.SUPPORTING_AUDITS, "false"); - } - - @Override - protected IJDBCDelegateProvider createDelegateProvider() - { - return CDODBUtil.createPreparedStatementJDBCDelegateProvider(); - } - - @Override - public void tearDown() throws Exception - { - try - { - // verify DB integrity - new NonAuditDBStoreIntegrityVerifier(getRepository(REPOSITORY_NAME)).verify(); - } - finally - { - super.tearDown(); - } - } + super.initRepositoryProperties(props); + props.put(IRepository.Props.SUPPORTING_AUDITS, "false"); } } /** * @author Eike Stepper */ - public abstract static class Derby extends DB + public static class Derby extends DB { private static final long serialVersionUID = 1L; + public static final Derby INSTANCE = new Derby("DBStore: Derby"); + private transient File dbFolder; private transient EmbeddedDataSource dataSource; @@ -500,176 +390,105 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf { IOUtil.delete(dbFolder); } + } - public static class Stmt extends Derby + /** + * @author Simon McDuff + */ + public static class Mysql extends DB + { + private static final long serialVersionUID = 1L; + + public static final Mysql INSTANCE = new Mysql("DBStore: Mysql"); + + private transient MysqlDataSource setupDataSource; + + private transient MysqlDataSource dataSource; + + public Mysql(String name) { - private static final long serialVersionUID = 1L; + super(name); + } - public static final Stmt INSTANCE = new Stmt("DerbyHorizontalStmt"); + @Override + protected IMappingStrategy createMappingStrategy() + { + return CDODBUtil.createHorizontalMappingStrategy(); + } - public Stmt(String name) + @Override + protected IDBAdapter createDBAdapter() + { + return new MYSQLAdapter(); + } + + private MysqlDataSource getSetupDataSource() + { + if (setupDataSource == null) { - super(name); + setupDataSource = new MysqlDataSource(); + setupDataSource.setUrl("jdbc:mysql://localhost"); + setupDataSource.setUser("sa"); } - @Override - protected IJDBCDelegateProvider createDelegateProvider() + return setupDataSource; + } + + @Override + public void setUp() throws Exception + { + dropDatabase(); + Connection connection = null; + try { - return CDODBUtil.createStatementJDBCDelegateProvider(); + connection = getSetupDataSource().getConnection(); + connection.prepareStatement("create database cdodb1").execute(); } + catch (SQLException ignore) + { + + } + finally + { + connection.close(); + } + super.setUp(); } - public static class PrepStmt extends Derby + @Override + protected DataSource createDataSource() { - private static final long serialVersionUID = 1L; + dataSource = new MysqlDataSource(); + dataSource.setUrl("jdbc:mysql://localhost/cdodb1"); + dataSource.setUser("sa"); + return dataSource; + } - public static final PrepStmt INSTANCE = new PrepStmt("DerbyHorizontalPrepStmt"); + @Override + public void tearDown() throws Exception + { + super.tearDown(); + dropDatabase(); + } - public PrepStmt(String name) + private void dropDatabase() throws Exception + { + Connection connection = null; + try { - super(name); + connection = getSetupDataSource().getConnection(); + connection.prepareStatement("DROP database cdodb1").execute(); } + catch (SQLException ignore) + { - @Override - protected IJDBCDelegateProvider createDelegateProvider() + } + finally { - return CDODBUtil.createPreparedStatementJDBCDelegateProvider(); + connection.close(); } } - } - // XXX - // /** - // * @author Simon McDuff - // */ - // public static abstract class Mysql extends DB - // { - // private static final long serialVersionUID = 1L; - // - // private transient MysqlDataSource setupDataSource; - // - // private transient MysqlDataSource dataSource; - // - // public Mysql(String name) - // { - // super(name); - // } - // - // @Override - // protected IMappingStrategy createMappingStrategy() - // { - // return CDODBUtil.createHorizontalMappingStrategy(); - // } - // - // @Override - // protected IDBAdapter createDBAdapter() - // { - // return new MYSQLAdapter(); - // } - // - // private MysqlDataSource getSetupDataSource() - // { - // if (setupDataSource == null) - // { - // setupDataSource = new MysqlDataSource(); - // setupDataSource.setUrl("jdbc:mysql://localhost"); - // setupDataSource.setUser("sa"); - // } - // - // return setupDataSource; - // } - // - // @Override - // public void setUp() throws Exception - // { - // dropDatabase(); - // Connection connection = null; - // try - // { - // connection = getSetupDataSource().getConnection(); - // connection.prepareStatement("create database cdodb1").execute(); - // } - // catch (SQLException ignore) - // { - // - // } - // finally - // { - // connection.close(); - // } - // super.setUp(); - // } - // - // @Override - // protected DataSource createDataSource() - // { - // dataSource = new MysqlDataSource(); - // dataSource.setUrl("jdbc:mysql://localhost/cdodb1"); - // dataSource.setUser("sa"); - // return dataSource; - // } - // - // @Override - // public void tearDown() throws Exception - // { - // super.tearDown(); - // dropDatabase(); - // } - // - // private void dropDatabase() throws Exception - // { - // Connection connection = null; - // try - // { - // connection = getSetupDataSource().getConnection(); - // connection.prepareStatement("DROP database cdodb1").execute(); - // } - // catch (SQLException ignore) - // { - // - // } - // finally - // { - // connection.close(); - // } - // } - // - // public static class Stmt extends Mysql - // { - // private static final long serialVersionUID = 1L; - // - // public static final Stmt INSTANCE = new Stmt("MysqlHorizontalStmt"); - // - // public Stmt(String name) - // { - // super(name); - // } - // - // @Override - // protected IJDBCDelegateProvider createDelegateProvider() - // { - // return CDODBUtil.createStatementJDBCDelegateProvider(); - // } - // } - // - // public static class PrepStmt extends Mysql - // { - // private static final long serialVersionUID = 1L; - // - // public static final PrepStmt INSTANCE = new PrepStmt("MysqlHorizontalPrepStmt"); - // - // public PrepStmt(String name) - // { - // super(name); - // } - // - // @Override - // protected IJDBCDelegateProvider createDelegateProvider() - // { - // return CDODBUtil.createPreparedStatementJDBCDelegateProvider(); - // } - // } - // } + } } - } |