diff options
author | Eike Stepper | 2008-10-30 10:53:11 +0000 |
---|---|---|
committer | Eike Stepper | 2008-10-30 10:53:11 +0000 |
commit | 5aedf281cca3845d98e4fec88d5e125918698b7d (patch) | |
tree | d5b1769c3a797e1bf9e10176234505533eb9ad35 /plugins | |
parent | ddf65fa351e489500ace95f91006916c1cd3d0c8 (diff) | |
download | cdo-5aedf281cca3845d98e4fec88d5e125918698b7d.tar.gz cdo-5aedf281cca3845d98e4fec88d5e125918698b7d.tar.xz cdo-5aedf281cca3845d98e4fec88d5e125918698b7d.zip |
[251307] [Hibernate] Implement resources in a hierarchical structure
https://bugs.eclipse.org/bugs/show_bug.cgi?id=251307
Diffstat (limited to 'plugins')
38 files changed, 701 insertions, 640 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTestsHibernate.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTestsHibernate.java index 6b1fdea384..3eb4c5f8a1 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTestsHibernate.java +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTestsHibernate.java @@ -11,7 +11,7 @@ package org.eclipse.emf.cdo.tests.hibernate; import org.eclipse.emf.cdo.tests.AllTestsAllConfigs; -import org.eclipse.emf.cdo.tests.config.RepositoryConfig; +import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig; import junit.framework.Test; import junit.framework.TestSuite; @@ -31,6 +31,6 @@ public class AllTestsHibernate extends AllTestsAllConfigs @Override protected void initConfigSuites(TestSuite parent) { - initConfigSuite(parent, COMBINED, HIBERNATE, TCP, NATIVE); + addScenario(parent, COMBINED, HIBERNATE, TCP, NATIVE); } } diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HbRevisionDeltaTest.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HbRevisionDeltaTest.java index 9ef60f5b84..f861593807 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HbRevisionDeltaTest.java +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HbRevisionDeltaTest.java @@ -12,7 +12,7 @@ package org.eclipse.emf.cdo.tests.hibernate; import org.eclipse.emf.cdo.tests.RevisionDeltaWithoutDeltaSupportTest; -import org.eclipse.emf.cdo.tests.config.RepositoryConfig; +import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig; import java.util.Map; diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java index 365f92e691..009eb17b60 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java @@ -5,7 +5,7 @@ import org.eclipse.emf.cdo.server.IRepository.Props; import org.eclipse.emf.cdo.server.hibernate.CDOHibernateUtil; import org.eclipse.emf.cdo.server.hibernate.IHibernateMappingProvider; import org.eclipse.emf.cdo.server.hibernate.teneo.TeneoUtil; -import org.eclipse.emf.cdo.tests.config.RepositoryConfig; +import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig; import org.eclipse.net4j.util.WrappedException; @@ -21,6 +21,8 @@ public class HibernateConfig extends RepositoryConfig public static final String MAPPING_FILE = "mappingfile"; + private static final long serialVersionUID = 1L; + public HibernateConfig() { super("Hibernate"); diff --git a/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF index 03abc3c522..a869f86ddd 100644 --- a/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF @@ -39,6 +39,7 @@ Export-Package: base;version="2.0.0", org.eclipse.emf.cdo.tests.bugzilla;version="2.0.0", org.eclipse.emf.cdo.tests.bundle;version="2.0.0", org.eclipse.emf.cdo.tests.config;version="2.0.0", + org.eclipse.emf.cdo.tests.config.impl;version="2.0.0", org.eclipse.emf.cdo.tests.store.logic;version="2.0.0", org.eclipse.net4j.tests;version="2.0.0", reference;version="2.0.0", @@ -51,3 +52,4 @@ Import-Package: org.apache.commons.collections;version="[3.2.0,4.0.0)", org.hsqldb;version="[1.8.0,2.0.0)", org.hsqldb.jdbc;version="[1.8.0,2.0.0)", com.mysql.jdbc.jdbc2.optional;version="5.1.6" +Eclipse-BuddyPolicy: dependent diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java index 55f2ae3217..a770fd9646 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java @@ -15,7 +15,7 @@ import org.eclipse.emf.cdo.CDOState; import org.eclipse.emf.cdo.CDOTransaction; import org.eclipse.emf.cdo.CDOView; import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.tests.config.ConfigTest; +import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; import org.eclipse.emf.cdo.util.CDOUtil; import org.eclipse.emf.internal.cdo.CDOLegacyWrapper; diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java index a0f57e05c2..73e6642603 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java @@ -26,6 +26,6 @@ public class AllTests extends AllTestsAllConfigs @Override protected void initConfigSuites(TestSuite parent) { - initConfigSuite(parent, COMBINED, MEM, TCP, NATIVE); + addScenario(parent, COMBINED, MEM, TCP, NATIVE); } } diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java index 6112ea3f41..3d6ee4c3d9 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java @@ -27,23 +27,16 @@ import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_251263_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_251544_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_251752_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_252214_Test; -import org.eclipse.emf.cdo.tests.config.ConfigTest; -import org.eclipse.emf.cdo.tests.config.ConfigTestSuite; +import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; +import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite; import java.util.List; -import junit.framework.Test; - /** * @author Eike Stepper */ -public class AllTestsAllConfigs extends ConfigTestSuite +public abstract class AllTestsAllConfigs extends ConfigTestSuite { - public static Test suite() - { - return new AllTestsAllConfigs().getTestSuite("CDO Tests (All Configs)"); - } - @Override protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses) { @@ -71,7 +64,7 @@ public class AllTestsAllConfigs extends ConfigTestSuite testClasses.add(RevisionHolderTest.class); testClasses.add(IndexReconstructionTest.class); testClasses.add(AutoAttacherTest.class); - testClasses.add(SavepointTest.class); + testClasses.add(SavePointTest.class); testClasses.add(ChangeSubscriptionTest.class); testClasses.add(DetachTest.class); testClasses.add(ExternalReferenceTest.class); @@ -80,7 +73,7 @@ public class AllTestsAllConfigs extends ConfigTestSuite testClasses.add(RepositoryTest.class); // Specific for MEMStore - testClasses.add(QueryTest.class); + testClasses.add(MEMStoreQueryTest.class); // Bugzilla verifications testClasses.add(Bugzilla_241464_Test.class); diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsDBHsqldb.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsDBHsqldb.java index 81ae9a7226..f779be5fd5 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsDBHsqldb.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsDBHsqldb.java @@ -26,6 +26,6 @@ public class AllTestsDBHsqldb extends AllTestsAllConfigs @Override protected void initConfigSuites(TestSuite parent) { - initConfigSuite(parent, COMBINED, DB_HSQL_HORIZONTAL, TCP, NATIVE); + addScenario(parent, COMBINED, DB_HSQL_HORIZONTAL, TCP, NATIVE); } } diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsDBMysql.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsDBMysql.java index 8152db71a0..5dfab4f181 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsDBMysql.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsDBMysql.java @@ -26,6 +26,6 @@ public class AllTestsDBMysql extends AllTestsAllConfigs @Override protected void initConfigSuites(TestSuite parent) { - initConfigSuite(parent, COMBINED, DB_MYSQL_HORIZONTAL, TCP, NATIVE); + addScenario(parent, COMBINED, DB_MYSQL_HORIZONTAL, TCP, NATIVE); } } diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChunkingWithMEMTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChunkingWithMEMTest.java index cb3d1afcc1..80df708aa0 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChunkingWithMEMTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChunkingWithMEMTest.java @@ -16,7 +16,7 @@ import org.eclipse.emf.cdo.CDOTransaction; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.eresource.CDOResource; import org.eclipse.emf.cdo.internal.server.RevisionManager; -import org.eclipse.emf.cdo.tests.config.RepositoryConfig; +import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig; import org.eclipse.emf.cdo.tests.model1.Customer; import org.eclipse.emf.cdo.tests.model1.SalesOrder; import org.eclipse.emf.cdo.util.CDOUtil; diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/QueryTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MEMStoreQueryTest.java index 5446e8dfd8..857ebc2d50 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/QueryTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MEMStoreQueryTest.java @@ -29,7 +29,7 @@ import java.util.Set; /** * @author Simon McDuff */ -public class QueryTest extends AbstractCDOTest +public class MEMStoreQueryTest extends AbstractCDOTest { private static final String LANGUAGE = "TEST"; diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java index b163e6fe22..0308ed8b7f 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java @@ -17,6 +17,7 @@ import org.eclipse.emf.cdo.CDOTransaction; import org.eclipse.emf.cdo.common.model.CDOPackage; import org.eclipse.emf.cdo.eresource.CDOResource; import org.eclipse.emf.cdo.tests.bundle.OM; +import org.eclipse.emf.cdo.tests.config.IRepositoryConfig; import org.eclipse.emf.cdo.tests.mango.Value; import org.eclipse.emf.cdo.tests.model1.Company; import org.eclipse.emf.cdo.tests.model1.PurchaseOrder; @@ -238,7 +239,7 @@ public class PackageRegistryTest extends AbstractCDOTest // Create resource in session 1 CDOSessionConfiguration configuration = CDOUtil.createSessionConfiguration(); configuration.setConnector(getConnector()); - configuration.setRepositoryName(REPOSITORY_NAME); + configuration.setRepositoryName(IRepositoryConfig.REPOSITORY_NAME); configuration.setEagerPackageRegistry(); CDOSession session = configuration.openSession(); @@ -271,7 +272,7 @@ public class PackageRegistryTest extends AbstractCDOTest // Create resource in session 1 CDOSessionConfiguration configuration = CDOUtil.createSessionConfiguration(); configuration.setConnector(getConnector()); - configuration.setRepositoryName(REPOSITORY_NAME); + configuration.setRepositoryName(IRepositoryConfig.REPOSITORY_NAME); configuration.setLazyPackageRegistry(); CDOSession session = configuration.openSession(); diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaWithDeltaSupportTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaWithDeltaSupportTest.java index cd8a838b48..273683ccfc 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaWithDeltaSupportTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaWithDeltaSupportTest.java @@ -11,7 +11,7 @@ **************************************************************************/ package org.eclipse.emf.cdo.tests; -import org.eclipse.emf.cdo.tests.config.RepositoryConfig; +import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig; import java.util.Map; diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaWithoutDeltaSupportTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaWithoutDeltaSupportTest.java index eb5ce2ee37..d5192c1fa5 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaWithoutDeltaSupportTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaWithoutDeltaSupportTest.java @@ -11,7 +11,7 @@ **************************************************************************/ package org.eclipse.emf.cdo.tests; -import org.eclipse.emf.cdo.tests.config.RepositoryConfig; +import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig; import java.util.Map; diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SavepointTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SavePointTest.java index 77522ef56d..0fe35f510f 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SavepointTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SavePointTest.java @@ -26,7 +26,7 @@ import org.eclipse.emf.internal.cdo.util.FSMUtil; /** * @author Simon McDuff */ -public class SavepointTest extends AbstractCDOTest +public class SavePointTest extends AbstractCDOTest { public void testRollbackWithNewObject_Collection() throws Exception { diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/StateMachineTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/StateMachineTest.java index d0c910c2ac..94374ac611 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/StateMachineTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/StateMachineTest.java @@ -17,7 +17,7 @@ import org.eclipse.emf.cdo.CDOTransaction; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.tests.config.SessionConfig; +import org.eclipse.emf.cdo.tests.config.impl.SessionConfig; import org.eclipse.emf.cdo.tests.model1.Category; import org.eclipse.emf.cdo.tests.model1.Product1; import org.eclipse.emf.cdo.tests.model1.Supplier; diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ConfigTestSuite.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ConfigTestSuite.java deleted file mode 100644 index 2a57d76bd7..0000000000 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ConfigTestSuite.java +++ /dev/null @@ -1,152 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.config; - -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import junit.framework.Test; -import junit.framework.TestResult; -import junit.framework.TestSuite; - -/** - * @author Eike Stepper - */ -public abstract class ConfigTestSuite implements ConfigConstants -{ - public ConfigTestSuite() - { - } - - protected Test getTestSuite(String name) - { - TestSuite suite = new TestSuite(name); - initConfigSuites(suite); - return suite; - } - - protected void initConfigSuites(TestSuite parent) - { - for (ContainerConfig containerConfig : ContainerConfig.CONFIGS) - { - for (RepositoryConfig repositoryConfig : RepositoryConfig.CONFIGS) - { - for (SessionConfig sessionConfig : SessionConfig.CONFIGS) - { - for (ModelConfig modelConfig : ModelConfig.CONFIGS) - { - initConfigSuite(parent, containerConfig, repositoryConfig, sessionConfig, modelConfig); - } - } - } - } - } - - protected void initConfigSuite(TestSuite parent, ContainerConfig containerConfig, RepositoryConfig repositoryConfig, - SessionConfig sessionConfig, ModelConfig modelConfig) - { - Set<Config> configs = new HashSet<Config>(); - configs.add(containerConfig); - configs.add(repositoryConfig); - configs.add(sessionConfig); - configs.add(modelConfig); - - if (containerConfig.isValid(configs) && repositoryConfig.isValid(configs) && sessionConfig.isValid(configs) - && modelConfig.isValid(configs)) - { - String name = MessageFormat.format("Config = [{0}, {1}, {2}, {3}]", containerConfig, repositoryConfig, - sessionConfig, modelConfig); - TestSuite suite = new TestSuite(name); - - List<Class<? extends ConfigTest>> testClasses = new ArrayList<Class<? extends ConfigTest>>(); - initTestClasses(testClasses); - - for (Class<? extends ConfigTest> testClass : testClasses) - { - ConfigSuite configSuite = new ConfigSuite(testClass, containerConfig, repositoryConfig, sessionConfig, - modelConfig); - suite.addTest(configSuite); - } - - parent.addTest(suite); - } - } - - protected abstract void initTestClasses(List<Class<? extends ConfigTest>> testClasses); - - /** - * @author Eike Stepper - */ - private static final class ConfigSuite extends TestSuite - { - private ContainerConfig containerConfig; - - private RepositoryConfig repositoryConfig; - - private SessionConfig sessionConfig; - - private ModelConfig modelConfig; - - public ConfigSuite(Class<? extends ConfigTest> testClass, ContainerConfig containerConfig, - RepositoryConfig repositoryConfig, SessionConfig sessionConfig, ModelConfig modelConfig) - { - super(testClass, testClass.getName()); // Important for the UI to set the *qualified* class name! - this.containerConfig = containerConfig; - this.repositoryConfig = repositoryConfig; - this.sessionConfig = sessionConfig; - this.modelConfig = modelConfig; - } - - public ContainerConfig getContainerConfig() - { - return containerConfig; - } - - public RepositoryConfig getRepositoryConfig() - { - return repositoryConfig; - } - - public SessionConfig getSessionConfig() - { - return sessionConfig; - } - - public ModelConfig getModelConfig() - { - return modelConfig; - } - - @Override - public void runTest(Test test, TestResult result) - { - if (test instanceof ConfigTest) - { - ConfigTest configTest = (ConfigTest)test; - configTest.setContainerConfig(containerConfig); - configTest.setRepositoryConfig(repositoryConfig); - configTest.setSessionConfig(sessionConfig); - configTest.setModelConfig(modelConfig); - if (configTest.isValid()) - { - super.runTest(configTest, result); - } - } - else - { - super.runTest(test, result); - } - } - } -} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConfig.java new file mode 100644 index 0000000000..5df2494bab --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConfig.java @@ -0,0 +1,29 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2008 Eike Stepper, Germany. + * 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.config; + +import java.io.Serializable; +import java.util.Map; +import java.util.Set; + +/** + * @author Eike Stepper + */ +public interface IConfig extends ITestLifecycle, Serializable +{ + public String getName(); + + public Map<String, Object> getTestProperties(); + + public Object getTestProperty(String key); + + public boolean isValid(Set<IConfig> configs); +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ConfigConstants.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConstants.java index ce82c0170d..142b2e01c9 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ConfigConstants.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConstants.java @@ -10,11 +10,17 @@ **************************************************************************/ package org.eclipse.emf.cdo.tests.config; +import org.eclipse.emf.cdo.tests.config.impl.Config; +import org.eclipse.emf.cdo.tests.config.impl.ContainerConfig; +import org.eclipse.emf.cdo.tests.config.impl.ModelConfig; +import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig; +import org.eclipse.emf.cdo.tests.config.impl.SessionConfig; + /** * @author Eike Stepper */ -public interface ConfigConstants +public interface IConstants { public static final Config[][] CONFIGS = { // ContainerConfig.CONFIGS, // diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ContainerProvider.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IContainerConfig.java index 638a3351bd..d103e2e2f8 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ContainerProvider.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IContainerConfig.java @@ -15,7 +15,7 @@ import org.eclipse.net4j.util.container.IManagedContainer; /** * @author Eike Stepper */ -public interface ContainerProvider +public interface IContainerConfig extends IConfig { public boolean hasClientContainer(); diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ModelProvider.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IModelConfig.java index 48dbd30a16..f44ed6e5c2 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ModelProvider.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IModelConfig.java @@ -25,7 +25,7 @@ import org.eclipse.emf.cdo.tests.model4interfaces.model4interfacesPackage; /** * @author Eike Stepper */ -public interface ModelProvider +public interface IModelConfig extends IConfig { public MangoFactory getMangoFactory(); diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/RepositoryProvider.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IRepositoryConfig.java index 9460cb95e5..3a84a417d0 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/RepositoryProvider.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IRepositoryConfig.java @@ -17,7 +17,7 @@ import java.util.Map; /** * @author Eike Stepper */ -public interface RepositoryProvider +public interface IRepositoryConfig extends IConfig { public static final String REPOSITORY_NAME = "repo1"; diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IScenario.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IScenario.java new file mode 100644 index 0000000000..edfc04e147 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IScenario.java @@ -0,0 +1,42 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2008 Eike Stepper, Germany. + * 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.config; + +import java.io.Serializable; +import java.util.Set; + +/** + * @author Eike Stepper + */ +public interface IScenario extends ITestLifecycle, Serializable +{ + public IContainerConfig getContainerConfig(); + + public void setContainerConfig(IContainerConfig containerConfig); + + public IRepositoryConfig getRepositoryConfig(); + + public void setRepositoryConfig(IRepositoryConfig repositoryConfig); + + public ISessionConfig getSessionConfig(); + + public void setSessionConfig(ISessionConfig sessionConfig); + + public IModelConfig getModelConfig(); + + public void setModelConfig(IModelConfig modelConfig); + + public Set<IConfig> getConfigs(); + + public boolean isValid(); + + public void save(); +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/SessionProvider.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ISessionConfig.java index 4722bdaba7..21e2a046a1 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/SessionProvider.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ISessionConfig.java @@ -20,7 +20,7 @@ import org.eclipse.emf.ecore.EPackage; /** * @author Eike Stepper */ -public interface SessionProvider +public interface ISessionConfig extends IConfig { public void startTransport() throws Exception; diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/proto/IConfigScenario.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ITestLifecycle.java index 00e5bc2cb9..f49765f1f2 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/proto/IConfigScenario.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ITestLifecycle.java @@ -8,20 +8,20 @@ * Contributors: * Eike Stepper - initial API and implementation **************************************************************************/ -package org.eclipse.emf.cdo.tests.config.proto; +package org.eclipse.emf.cdo.tests.config; -import org.eclipse.emf.cdo.tests.config.Config; - -import org.eclipse.net4j.util.lifecycle.ILifecycle; +import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; /** * @author Eike Stepper */ -public interface IConfigScenario extends ILifecycle +public interface ITestLifecycle { - public Config[] getConfigs(); + public ConfigTest getCurrentTest(); + + public void setCurrentTest(ConfigTest currentTest); - public void setConfigs(Config[] configs); + public void setUp() throws Exception; - public boolean isValid(); + public void tearDown() throws Exception; } diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/dummy/AllTests.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/dummy/AllTests.java deleted file mode 100644 index 55eac0aacd..0000000000 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/dummy/AllTests.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.eclipse.emf.cdo.tests.config.dummy; - -import org.eclipse.emf.cdo.tests.config.ConfigTest; -import org.eclipse.emf.cdo.tests.config.ConfigTestSuite; - -import java.util.List; - -import junit.framework.Test; - -/** - * TODO Remove me - * - * @author Eike Stepper - */ -public class AllTests extends ConfigTestSuite -{ - public static Test suite() - { - return new AllTests().getTestSuite("Dummy Tests"); - } - - @Override - protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses) - { - testClasses.add(DummyTest1.class); - testClasses.add(DummyTest2.class); - testClasses.add(DummyTest3.class); - } -} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/dummy/DummyTest1.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/dummy/DummyTest1.java deleted file mode 100644 index c51c7fca51..0000000000 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/dummy/DummyTest1.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.eclipse.emf.cdo.tests.config.dummy; - -import org.eclipse.emf.cdo.tests.config.ConfigTest; -import org.eclipse.emf.cdo.tests.config.SessionConfig; - -/** - * TODO Remove me - * - * @author Eike Stepper - */ -public class DummyTest1 extends ConfigTest -{ - public void test11() throws Exception - { - } - - public void test12() throws Exception - { - } - - public void test13() throws Exception - { - skipConfig(SessionConfig.JVM.INSTANCE); - } -} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/dummy/DummyTest2.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/dummy/DummyTest2.java deleted file mode 100644 index 414087e354..0000000000 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/dummy/DummyTest2.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.eclipse.emf.cdo.tests.config.dummy; - -import org.eclipse.emf.cdo.tests.config.ConfigTest; - -/** - * TODO Remove me - * - * @author Eike Stepper - */ -public class DummyTest2 extends ConfigTest -{ - public void test21() throws Exception - { - } - - public void test22() throws Exception - { - } - - public void test23() throws Exception - { - } -} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/dummy/DummyTest3.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/dummy/DummyTest3.java deleted file mode 100644 index f605c4800e..0000000000 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/dummy/DummyTest3.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.eclipse.emf.cdo.tests.config.dummy; - -import org.eclipse.emf.cdo.tests.config.ConfigTest; - -/** - * TODO Remove me - * - * @author Eike Stepper - */ -public class DummyTest3 extends ConfigTest -{ - public void test31() throws Exception - { - } - - public void test32() throws Exception - { - } - - public void test33() throws Exception - { - } -} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/Config.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Config.java index 345f8013a7..1bbd86f480 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/Config.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Config.java @@ -8,7 +8,9 @@ * Contributors: * Eike Stepper - initial API and implementation **************************************************************************/ -package org.eclipse.emf.cdo.tests.config; +package org.eclipse.emf.cdo.tests.config.impl; + +import org.eclipse.emf.cdo.tests.config.IConfig; import java.util.Map; import java.util.Set; @@ -16,11 +18,13 @@ import java.util.Set; /** * @author Eike Stepper */ -public abstract class Config +public abstract class Config implements IConfig { + private static final long serialVersionUID = 1L; + private String name; - private ConfigTest currentTest; + private transient ConfigTest currentTest; public Config(String name) { @@ -35,15 +39,15 @@ public abstract class Config @Override public String toString() { - return name; + return getName(); } - protected ConfigTest getCurrentTest() + public ConfigTest getCurrentTest() { return currentTest; } - protected void setCurrentTest(ConfigTest currentTest) + public void setCurrentTest(ConfigTest currentTest) { this.currentTest = currentTest; } @@ -64,12 +68,12 @@ public abstract class Config return null; } - protected boolean isValid(Set<Config> configs) + public boolean isValid(Set<IConfig> configs) { return true; } - protected void setUp() throws Exception + public void setUp() throws Exception { if (currentTest == null) { @@ -77,7 +81,7 @@ public abstract class Config } } - protected void tearDown() throws Exception + public void tearDown() throws Exception { } } diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ConfigTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java index defed61311..9807c6d72b 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ConfigTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java @@ -8,12 +8,18 @@ * Contributors: * Eike Stepper - initial API and implementation **************************************************************************/ -package org.eclipse.emf.cdo.tests.config; +package org.eclipse.emf.cdo.tests.config.impl; import org.eclipse.emf.cdo.CDOSession; import org.eclipse.emf.cdo.internal.server.RevisionManager; import org.eclipse.emf.cdo.server.IRepository; import org.eclipse.emf.cdo.server.IRevisionManager; +import org.eclipse.emf.cdo.tests.config.IConstants; +import org.eclipse.emf.cdo.tests.config.IContainerConfig; +import org.eclipse.emf.cdo.tests.config.IModelConfig; +import org.eclipse.emf.cdo.tests.config.IRepositoryConfig; +import org.eclipse.emf.cdo.tests.config.IScenario; +import org.eclipse.emf.cdo.tests.config.ISessionConfig; import org.eclipse.emf.cdo.tests.mango.MangoFactory; import org.eclipse.emf.cdo.tests.mango.MangoPackage; import org.eclipse.emf.cdo.tests.model1.Model1Factory; @@ -46,17 +52,34 @@ import java.util.Properties; /** * @author Eike Stepper */ -public abstract class ConfigTest extends AbstractOMTest implements ConfigConstants, ContainerProvider, - RepositoryProvider, SessionProvider, ModelProvider +public abstract class ConfigTest extends AbstractOMTest implements IConstants { public ConfigTest() { } - private Properties homeProperties; + private IScenario scenario; - // ///////////////////////////////////////////////////////////////////////// - // //////////////////////// Container ////////////////////////////////////// + public synchronized IScenario getScenario() + { + if (scenario == null) + { + setScenario(getDefaultScenario()); + } + + return scenario; + } + + public synchronized void setScenario(IScenario scenario) + { + this.scenario = scenario; + if (scenario != null) + { + scenario.setCurrentTest(this); + } + } + + private Properties homeProperties; public synchronized Properties getHomeProperties() { @@ -90,41 +113,20 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan return homeProperties; } - public ContainerConfig getLastContainerConfig() - { - String name = getHomeProperties().getProperty("org.eclipse.emf.cdo.tests.config.ContainerConfig"); - return ContainerConfig.getInstance(name); - } - public synchronized void setHomeProperties(Properties homeProperties) { this.homeProperties = homeProperties; } - /** - *@category Container - */ - public static final ContainerConfig DEFAULT_CONTAINER_CONFIG = COMBINED; - - /** - *@category Container - */ - private ContainerConfig containerConfig; - - /** - *@category Container - */ - public ContainerConfig getContainerConfig() - { - return containerConfig; - } + // ///////////////////////////////////////////////////////////////////////// + // //////////////////////// Container ////////////////////////////////////// /** *@category Container */ - public void setContainerConfig(ContainerConfig containerConfig) + public IContainerConfig getContainerConfig() { - this.containerConfig = containerConfig; + return getScenario().getContainerConfig(); } /** @@ -132,7 +134,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public boolean hasClientContainer() { - return containerConfig.hasClientContainer(); + return getContainerConfig().hasClientContainer(); } /** @@ -140,7 +142,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public boolean hasServerContainer() { - return containerConfig.hasServerContainer(); + return getContainerConfig().hasServerContainer(); } /** @@ -148,7 +150,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public IManagedContainer getClientContainer() { - return containerConfig.getClientContainer(); + return getContainerConfig().getClientContainer(); } /** @@ -156,7 +158,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public IManagedContainer getServerContainer() { - return containerConfig.getServerContainer(); + return getContainerConfig().getServerContainer(); } // ///////////////////////////////////////////////////////////////////////// @@ -165,27 +167,9 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan /** *@category Repository */ - public static final RepositoryConfig DEFAULT_REPOSITORY_CONFIG = MEM; - - /** - *@category Repository - */ - private RepositoryConfig repositoryConfig; - - /** - *@category Repository - */ - public RepositoryConfig getRepositoryConfig() - { - return repositoryConfig; - } - - /** - *@category Repository - */ - public void setRepositoryConfig(RepositoryConfig repositoryConfig) + public IRepositoryConfig getRepositoryConfig() { - this.repositoryConfig = repositoryConfig; + return getScenario().getRepositoryConfig(); } /** @@ -193,7 +177,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public Map<String, String> getRepositoryProperties() { - return repositoryConfig.getRepositoryProperties(); + return getRepositoryConfig().getRepositoryProperties(); } /** @@ -201,7 +185,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public IRepository getRepository(String name) { - return repositoryConfig.getRepository(name); + return getRepositoryConfig().getRepository(name); } /** @@ -209,7 +193,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public IRepository getRepository() { - return repositoryConfig.getRepository(REPOSITORY_NAME); + return getRepositoryConfig().getRepository(IRepositoryConfig.REPOSITORY_NAME); } // ///////////////////////////////////////////////////////////////////////// @@ -218,27 +202,9 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan /** *@category Session */ - public static final SessionConfig DEFAULT_SESSION_CONFIG = TCP; - - /** - *@category Session - */ - private SessionConfig sessionConfig; - - /** - *@category Session - */ - public SessionConfig getSessionConfig() + public ISessionConfig getSessionConfig() { - return sessionConfig; - } - - /** - *@category Session - */ - public void setSessionConfig(SessionConfig sessionConfig) - { - this.sessionConfig = sessionConfig; + return getScenario().getSessionConfig(); } /** @@ -246,7 +212,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public void startTransport() throws Exception { - sessionConfig.startTransport(); + getSessionConfig().startTransport(); } /** @@ -254,7 +220,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public void stopTransport() throws Exception { - sessionConfig.stopTransport(); + getSessionConfig().stopTransport(); } /** @@ -262,7 +228,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public IAcceptor getAcceptor() { - return sessionConfig.getAcceptor(); + return getSessionConfig().getAcceptor(); } /** @@ -270,7 +236,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public IConnector getConnector() { - return sessionConfig.getConnector(); + return getSessionConfig().getConnector(); } /** @@ -278,7 +244,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public CDOSession openMangoSession() { - return sessionConfig.openMangoSession(); + return getSessionConfig().openMangoSession(); } /** @@ -286,7 +252,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public CDOSession openModel1Session() { - return sessionConfig.openModel1Session(); + return getSessionConfig().openModel1Session(); } /** @@ -294,7 +260,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public CDOSession openModel2Session() { - return sessionConfig.openModel2Session(); + return getSessionConfig().openModel2Session(); } /** @@ -302,7 +268,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public CDOSession openModel3Session() { - return sessionConfig.openModel3Session(); + return getSessionConfig().openModel3Session(); } /** @@ -310,7 +276,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public CDOSession openEagerSession() { - return sessionConfig.openEagerSession(); + return getSessionConfig().openEagerSession(); } /** @@ -318,7 +284,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public CDOSession openLazySession() { - return sessionConfig.openLazySession(); + return getSessionConfig().openLazySession(); } /** @@ -326,7 +292,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public CDOSession openSession(EPackage ePackage) { - return sessionConfig.openSession(ePackage); + return getSessionConfig().openSession(ePackage); } /** @@ -334,7 +300,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public CDOSession openSession(String repositoryName) { - return sessionConfig.openSession(repositoryName); + return getSessionConfig().openSession(repositoryName); } /** @@ -342,7 +308,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public CDOSession openSession() { - return sessionConfig.openSession(); + return getSessionConfig().openSession(); } // ///////////////////////////////////////////////////////////////////////// @@ -351,27 +317,9 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan /** *@category Model */ - public static final ModelConfig DEFAULT_MODEL_CONFIG = NATIVE; - - /** - *@category Model - */ - private ModelConfig modelConfig; - - /** - *@category Model - */ - public ModelConfig getModelConfig() - { - return modelConfig; - } - - /** - *@category Model - */ - public void setModelConfig(ModelConfig modelConfig) + public IModelConfig getModelConfig() { - this.modelConfig = modelConfig; + return getScenario().getModelConfig(); } /** @@ -379,7 +327,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public MangoFactory getMangoFactory() { - return modelConfig.getMangoFactory(); + return getModelConfig().getMangoFactory(); } /** @@ -387,7 +335,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public MangoPackage getMangoPackage() { - return modelConfig.getMangoPackage(); + return getModelConfig().getMangoPackage(); } /** @@ -395,7 +343,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public Model1Factory getModel1Factory() { - return modelConfig.getModel1Factory(); + return getModelConfig().getModel1Factory(); } /** @@ -403,7 +351,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public Model1Package getModel1Package() { - return modelConfig.getModel1Package(); + return getModelConfig().getModel1Package(); } /** @@ -411,7 +359,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public Model2Factory getModel2Factory() { - return modelConfig.getModel2Factory(); + return getModelConfig().getModel2Factory(); } /** @@ -419,7 +367,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public Model2Package getModel2Package() { - return modelConfig.getModel2Package(); + return getModelConfig().getModel2Package(); } /** @@ -427,7 +375,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public Model3Factory getModel3Factory() { - return modelConfig.getModel3Factory(); + return getModelConfig().getModel3Factory(); } /** @@ -435,7 +383,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public Model3Package getModel3Package() { - return modelConfig.getModel3Package(); + return getModelConfig().getModel3Package(); } /** @@ -443,7 +391,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public model4Factory getModel4Factory() { - return modelConfig.getModel4Factory(); + return getModelConfig().getModel4Factory(); } /** @@ -451,7 +399,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public model4Package getModel4Package() { - return modelConfig.getModel4Package(); + return getModelConfig().getModel4Package(); } /** @@ -459,7 +407,7 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan */ public model4interfacesPackage getModel4InterfacesPackage() { - return modelConfig.getModel4InterfacesPackage(); + return getModelConfig().getModel4InterfacesPackage(); } // ///////////////////////////////////////////////////////////////////////// @@ -478,60 +426,20 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan @Override public String toString() { - return MessageFormat.format("{0}.{1} [{2}, {3}, {4}, {5}]", getClass().getSimpleName(), getName(), containerConfig, - repositoryConfig, sessionConfig, modelConfig); - } - - protected ContainerConfig filterContainerConfig(ContainerConfig config) - { - if (config == null) - { - config = DEFAULT_CONTAINER_CONFIG; - } - - return config; - } - - protected RepositoryConfig filterRepositoryConfig(RepositoryConfig config) - { - if (config == null) - { - config = DEFAULT_REPOSITORY_CONFIG; - } - - return config; - } - - protected SessionConfig filterSessionConfig(SessionConfig config) - { - if (config == null) - { - config = DEFAULT_SESSION_CONFIG; - } - - return config; - } - - protected ModelConfig filterModelConfig(ModelConfig config) - { - if (config == null) - { - config = DEFAULT_MODEL_CONFIG; - } - - return config; + return MessageFormat.format("{0}.{1} [{2}, {3}, {4}, {5}]", getClass().getSimpleName(), getName(), + getContainerConfig(), getRepositoryConfig(), getSessionConfig(), getModelConfig()); } protected void skipConfig(Config config) { - skipTest(containerConfig == config || repositoryConfig == config || sessionConfig == config - || modelConfig == config); + skipTest(getContainerConfig() == config || getRepositoryConfig() == config || getSessionConfig() == config + || getModelConfig() == config); } protected void skipUnlessConfig(Config config) { - skipTest(containerConfig != config && repositoryConfig != config && sessionConfig != config - && modelConfig != config); + skipTest(getContainerConfig() != config && getRepositoryConfig() != config && getSessionConfig() != config + && getModelConfig() != config); } protected void clearCache(IRevisionManager revisionManager) @@ -539,23 +447,34 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan ((RevisionManager)revisionManager).getCache().clear(); } - public void restartConfigs() throws Exception + public void restartScenario() throws Exception { - IOUtil.OUT().println("RESTARTING CONFIGURATIONS"); + IOUtil.OUT().println("RESTARTING SCENARIO"); stopTransport(); - tearDownConfigs(); - setupConfigs(); + + IScenario scenario = getScenario(); + scenario.tearDown(); + scenario.setUp(); + startTransport(); - IOUtil.OUT().println("RESTARTING CONFIGURATIONS - FINISHED"); + IOUtil.OUT().println("RESTARTING SCENARIO - FINISHED"); + } + + protected IScenario getDefaultScenario() + { + IScenario scenario = Scenario.load(); + if (scenario == null) + { + scenario = Scenario.getDefault(); + } + + return scenario; } @Override public void setUp() throws Exception { - containerConfig = filterContainerConfig(containerConfig); - repositoryConfig = filterRepositoryConfig(repositoryConfig); - sessionConfig = filterSessionConfig(sessionConfig); - modelConfig = filterModelConfig(modelConfig); + getScenario(); super.setUp(); } @@ -563,41 +482,13 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan protected void doSetUp() throws Exception { super.doSetUp(); - setupConfigs(); + getScenario().setUp(); } @Override protected void doTearDown() throws Exception { - tearDownConfigs(); + getScenario().tearDown(); super.doTearDown(); } - - private void setupConfigs() throws Exception - { - setUpConfig(containerConfig); - setUpConfig(repositoryConfig); - setUpConfig(sessionConfig); - setUpConfig(modelConfig); - } - - private void setUpConfig(Config config) throws Exception - { - config.setCurrentTest(this); - config.setUp(); - } - - private void tearDownConfigs() throws Exception - { - tearDownConfig(modelConfig); - tearDownConfig(sessionConfig); - tearDownConfig(repositoryConfig); - tearDownConfig(containerConfig); - } - - private void tearDownConfig(Config config) throws Exception - { - config.tearDown(); - config.setCurrentTest(null); - } } diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java new file mode 100644 index 0000000000..50c4644673 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java @@ -0,0 +1,135 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2008 Eike Stepper, Germany. + * 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.config.impl; + +import org.eclipse.emf.cdo.tests.config.IConstants; +import org.eclipse.emf.cdo.tests.config.IScenario; + +import java.util.ArrayList; +import java.util.List; + +import junit.framework.Test; +import junit.framework.TestResult; +import junit.framework.TestSuite; + +/** + * @author Eike Stepper + */ +public abstract class ConfigTestSuite implements IConstants +{ + public ConfigTestSuite() + { + } + + protected Test getTestSuite(String name) + { + TestSuite suite = new TestSuite(name); + initConfigSuites(suite); + return suite; + } + + // protected void initConfigSuites(TestSuite parent) + // { + // for (ContainerConfig containerConfig : ContainerConfig.CONFIGS) + // { + // for (RepositoryConfig repositoryConfig : RepositoryConfig.CONFIGS) + // { + // for (SessionConfig sessionConfig : SessionConfig.CONFIGS) + // { + // for (ModelConfig modelConfig : ModelConfig.CONFIGS) + // { + // initConfigSuite(parent, containerConfig, repositoryConfig, sessionConfig, modelConfig); + // } + // } + // } + // } + // } + + protected void addScenario(TestSuite parent, ContainerConfig containerConfig, RepositoryConfig repositoryConfig, + SessionConfig sessionConfig, ModelConfig modelConfig) + { + IScenario scenario = new Scenario(); + scenario.setContainerConfig(containerConfig); + scenario.setRepositoryConfig(repositoryConfig); + scenario.setSessionConfig(sessionConfig); + scenario.setModelConfig(modelConfig); + + if (scenario.isValid()) + { + TestSuite suite = new TestSuite(scenario.toString()); + + List<Class<? extends ConfigTest>> testClasses = new ArrayList<Class<? extends ConfigTest>>(); + initTestClasses(testClasses); + + for (Class<? extends ConfigTest> testClass : testClasses) + { + TestWrapper configSuite = new TestWrapper(testClass, scenario); + suite.addTest(configSuite); + } + + parent.addTest(suite); + } + } + + protected abstract void initConfigSuites(TestSuite parent); + + // protected void initConfigSuites(TestSuite parent) + // { + // for (ContainerConfig containerConfig : ContainerConfig.CONFIGS) + // { + // for (RepositoryConfig repositoryConfig : RepositoryConfig.CONFIGS) + // { + // for (SessionConfig sessionConfig : SessionConfig.CONFIGS) + // { + // for (ModelConfig modelConfig : ModelConfig.CONFIGS) + // { + // initConfigSuite(parent, containerConfig, repositoryConfig, sessionConfig, modelConfig); + // } + // } + // } + // } + // } + + protected abstract void initTestClasses(List<Class<? extends ConfigTest>> testClasses); + + /** + * @author Eike Stepper + */ + private static final class TestWrapper extends TestSuite + { + private IScenario scenario; + + public TestWrapper(Class<? extends ConfigTest> testClass, IScenario scenario) + { + super(testClass, testClass.getName()); // Important for the UI to set the *qualified* class name! + this.scenario = scenario; + } + + @Override + public void runTest(Test test, TestResult result) + { + if (test instanceof ConfigTest) + { + scenario.save(); + ConfigTest configTest = (ConfigTest)test; + configTest.setScenario(scenario); + if (configTest.isValid()) + { + super.runTest(configTest, result); + } + } + else + { + super.runTest(test, result); + } + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ContainerConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ContainerConfig.java index b6faff912d..31d08613a4 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ContainerConfig.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ContainerConfig.java @@ -8,9 +8,10 @@ * Contributors: * Eike Stepper - initial API and implementation **************************************************************************/ -package org.eclipse.emf.cdo.tests.config; +package org.eclipse.emf.cdo.tests.config.impl; import org.eclipse.emf.cdo.server.CDOServerUtil; +import org.eclipse.emf.cdo.tests.config.IContainerConfig; import org.eclipse.emf.cdo.util.CDOUtil; import org.eclipse.net4j.Net4jUtil; @@ -21,32 +22,21 @@ import org.eclipse.net4j.util.lifecycle.LifecycleUtil; /** * @author Eike Stepper */ -public abstract class ContainerConfig extends Config implements ContainerProvider +public abstract class ContainerConfig extends Config implements IContainerConfig { public static final ContainerConfig[] CONFIGS = { Combined.INSTANCE, Separated.INSTANCE }; - public static ContainerConfig getInstance(String name) - { - for (ContainerConfig config : CONFIGS) - { - if (config.equals(name)) - { - return config; - } - } + private static final long serialVersionUID = 1L; - return null; - } + protected transient IManagedContainer clientContainer; + + protected transient IManagedContainer serverContainer; public ContainerConfig(String name) { super(name); } - protected IManagedContainer clientContainer; - - protected IManagedContainer serverContainer; - public boolean hasClientContainer() { return clientContainer != null; @@ -58,7 +48,7 @@ public abstract class ContainerConfig extends Config implements ContainerProvide } @Override - protected void tearDown() throws Exception + public void tearDown() throws Exception { LifecycleUtil.deactivate(clientContainer); clientContainer = null; @@ -78,6 +68,8 @@ public abstract class ContainerConfig extends Config implements ContainerProvide public static final Combined INSTANCE = new Combined(); + private static final long serialVersionUID = 1L; + public Combined() { super(NAME); @@ -119,6 +111,8 @@ public abstract class ContainerConfig extends Config implements ContainerProvide public static final Separated INSTANCE = new Separated(); + private static final long serialVersionUID = 1L; + public Separated() { super(NAME); diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ModelConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ModelConfig.java index 61d4d05e56..78f0f2e77c 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ModelConfig.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ModelConfig.java @@ -8,8 +8,9 @@ * Contributors: * Eike Stepper - initial API and implementation **************************************************************************/ -package org.eclipse.emf.cdo.tests.config; +package org.eclipse.emf.cdo.tests.config.impl; +import org.eclipse.emf.cdo.tests.config.IModelConfig; import org.eclipse.emf.cdo.tests.mango.MangoFactory; import org.eclipse.emf.cdo.tests.mango.MangoPackage; import org.eclipse.emf.cdo.tests.model1.Model1Factory; @@ -25,11 +26,13 @@ import org.eclipse.emf.cdo.tests.model4interfaces.model4interfacesPackage; /** * @author Eike Stepper */ -public abstract class ModelConfig extends Config implements ModelProvider +public abstract class ModelConfig extends Config implements IModelConfig { // TODO LEGACY public static final ModelConfig[] CONFIGS = { Native.INSTANCE /* , Legacy.INSTANCE */}; + private static final long serialVersionUID = 1L; + public ModelConfig(String name) { super(name); @@ -44,6 +47,8 @@ public abstract class ModelConfig extends Config implements ModelProvider public static final Native INSTANCE = new Native(); + private static final long serialVersionUID = 1L; + public Native() { super(NAME); diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/RepositoryConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java index 9ad411790a..daa80e64d0 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/RepositoryConfig.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java @@ -8,7 +8,7 @@ * Contributors: * Eike Stepper - initial API and implementation **************************************************************************/ -package org.eclipse.emf.cdo.tests.config; +package org.eclipse.emf.cdo.tests.config.impl; import org.eclipse.emf.cdo.internal.server.Repository; import org.eclipse.emf.cdo.internal.server.RevisionManager; @@ -21,6 +21,7 @@ import org.eclipse.emf.cdo.server.IRepository.Props; import org.eclipse.emf.cdo.server.db.CDODBUtil; import org.eclipse.emf.cdo.server.db.IMappingStrategy; import org.eclipse.emf.cdo.tests.bundle.OM; +import org.eclipse.emf.cdo.tests.config.IRepositoryConfig; import org.eclipse.net4j.db.DBUtil; import org.eclipse.net4j.db.IDBAdapter; @@ -52,7 +53,7 @@ import java.util.Map.Entry; /** * @author Eike Stepper */ -public abstract class RepositoryConfig extends Config implements RepositoryProvider +public abstract class RepositoryConfig extends Config implements IRepositoryConfig { public static final RepositoryConfig[] CONFIGS = { MEM.INSTANCE, DBHsqldb.HSQLDB_HORIZONTAL, DBDerby.DERBY_HORIZONTAL, DBMysql.MYSQL_HORIZONTAL }; @@ -63,7 +64,9 @@ public abstract class RepositoryConfig extends Config implements RepositoryProvi public static final String PROP_TEST_STORE = "test.repository.store"; - private Map<String, IRepository> repositories = new HashMap<String, IRepository>(); + private static final long serialVersionUID = 1L; + + private transient Map<String, IRepository> repositories; public RepositoryConfig(String name) { @@ -121,9 +124,10 @@ public abstract class RepositoryConfig extends Config implements RepositoryProvi } @Override - protected void setUp() throws Exception + public void setUp() throws Exception { super.setUp(); + repositories = new HashMap<String, IRepository>(); IManagedContainer serverContainer = getCurrentTest().getServerContainer(); CDOServerUtil.prepareContainer(serverContainer, new IRepositoryProvider() { @@ -138,7 +142,7 @@ public abstract class RepositoryConfig extends Config implements RepositoryProvi } @Override - protected void tearDown() throws Exception + public void tearDown() throws Exception { for (Object repository : repositories.values().toArray()) { @@ -146,6 +150,7 @@ public abstract class RepositoryConfig extends Config implements RepositoryProvi } repositories.clear(); + repositories = null; super.tearDown(); } @@ -192,6 +197,8 @@ public abstract class RepositoryConfig extends Config implements RepositoryProvi { public static final MEM INSTANCE = new MEM(); + private static final long serialVersionUID = 1L; + public MEM() { super("MEM"); @@ -209,6 +216,8 @@ public abstract class RepositoryConfig extends Config implements RepositoryProvi */ public static abstract class DB extends RepositoryConfig { + private static final long serialVersionUID = 1L; + public DB(String name) { super(name); @@ -237,7 +246,9 @@ public abstract class RepositoryConfig extends Config implements RepositoryProvi { public static final DBHsqldb HSQLDB_HORIZONTAL = new DBHsqldb("HsqldbHorizontal"); - private HSQLDBDataSource dataSource; + private static final long serialVersionUID = 1L; + + private transient HSQLDBDataSource dataSource; public DBHsqldb(String name) { @@ -276,7 +287,7 @@ public abstract class RepositoryConfig extends Config implements RepositoryProvi } @Override - protected void tearDown() throws Exception + public void tearDown() throws Exception { super.tearDown(); shutDownHsqldb(); @@ -312,9 +323,11 @@ public abstract class RepositoryConfig extends Config implements RepositoryProvi { public static final DBDerby DERBY_HORIZONTAL = new DBDerby("DerbyHorizontal"); - private File dbFolder; + private static final long serialVersionUID = 1L; + + private transient File dbFolder; - private EmbeddedDataSource dataSource; + private transient EmbeddedDataSource dataSource; public DBDerby(String name) { @@ -346,7 +359,7 @@ public abstract class RepositoryConfig extends Config implements RepositoryProvi } @Override - protected void tearDown() throws Exception + public void tearDown() throws Exception { deleteDBFolder(); super.tearDown(); @@ -365,9 +378,11 @@ public abstract class RepositoryConfig extends Config implements RepositoryProvi { public static final DBMysql MYSQL_HORIZONTAL = new DBMysql("MysqlHorizontal"); - private MysqlDataSource setupDataSource; + private static final long serialVersionUID = 1L; + + private transient MysqlDataSource setupDataSource; - private MysqlDataSource dataSource; + private transient MysqlDataSource dataSource; public DBMysql(String name) { @@ -399,7 +414,7 @@ public abstract class RepositoryConfig extends Config implements RepositoryProvi } @Override - protected void setUp() throws Exception + public void setUp() throws Exception { dropDatabase(); Connection connection = null; @@ -429,7 +444,7 @@ public abstract class RepositoryConfig extends Config implements RepositoryProvi } @Override - protected void tearDown() throws Exception + public void tearDown() throws Exception { super.tearDown(); dropDatabase(); diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Scenario.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Scenario.java new file mode 100644 index 0000000000..9c42fde9ab --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Scenario.java @@ -0,0 +1,273 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2008 Eike Stepper, Germany. + * 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.config.impl; + +import org.eclipse.emf.cdo.tests.config.IConfig; +import org.eclipse.emf.cdo.tests.config.IContainerConfig; +import org.eclipse.emf.cdo.tests.config.IModelConfig; +import org.eclipse.emf.cdo.tests.config.IRepositoryConfig; +import org.eclipse.emf.cdo.tests.config.IScenario; +import org.eclipse.emf.cdo.tests.config.ISessionConfig; + +import org.eclipse.net4j.util.WrappedException; +import org.eclipse.net4j.util.io.IOUtil; + +import java.io.File; +import java.io.FileInputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.text.MessageFormat; +import java.util.HashSet; +import java.util.Set; + +/** + * @author Eike Stepper + */ +public class Scenario implements IScenario +{ + public static final String STATE_FILE = "cdo_config_test.state"; + + private static final long serialVersionUID = 1L; + + private IContainerConfig containerConfig; + + private IRepositoryConfig repositoryConfig; + + private ISessionConfig sessionConfig; + + private IModelConfig modelConfig; + + private transient Set<IConfig> configs; + + private transient ConfigTest currentTest; + + public Scenario() + { + } + + public synchronized IContainerConfig getContainerConfig() + { + return containerConfig; + } + + public synchronized void setContainerConfig(IContainerConfig containerConfig) + { + configs = null; + this.containerConfig = containerConfig; + if (containerConfig != null) + { + containerConfig.setCurrentTest(currentTest); + } + } + + public synchronized IRepositoryConfig getRepositoryConfig() + { + return repositoryConfig; + } + + public synchronized void setRepositoryConfig(IRepositoryConfig repositoryConfig) + { + configs = null; + this.repositoryConfig = repositoryConfig; + if (repositoryConfig != null) + { + repositoryConfig.setCurrentTest(currentTest); + } + } + + public synchronized ISessionConfig getSessionConfig() + { + return sessionConfig; + } + + public synchronized void setSessionConfig(ISessionConfig sessionConfig) + { + configs = null; + this.sessionConfig = sessionConfig; + if (sessionConfig != null) + { + sessionConfig.setCurrentTest(currentTest); + } + } + + public synchronized IModelConfig getModelConfig() + { + return modelConfig; + } + + public synchronized void setModelConfig(IModelConfig modelConfig) + { + configs = null; + this.modelConfig = modelConfig; + if (modelConfig != null) + { + modelConfig.setCurrentTest(currentTest); + } + } + + @Override + public synchronized String toString() + { + return MessageFormat.format("Scenario[{0}, {1}, {2}, {3}]", // + getContainerConfig(), getRepositoryConfig(), getSessionConfig(), getModelConfig()); + } + + public synchronized Set<IConfig> getConfigs() + { + if (configs == null) + { + configs = new HashSet<IConfig>(); + configs.add(getContainerConfig()); + configs.add(getRepositoryConfig()); + configs.add(getSessionConfig()); + configs.add(getModelConfig()); + } + + return configs; + } + + public synchronized boolean isValid() + { + Set<IConfig> configs = getConfigs(); + for (IConfig config : configs) + { + if (!config.isValid(configs)) + { + return false; + } + } + + return true; + } + + public synchronized ConfigTest getCurrentTest() + { + return currentTest; + } + + public synchronized void setCurrentTest(ConfigTest currentTest) + { + this.currentTest = currentTest; + if (containerConfig != null) + { + containerConfig.setCurrentTest(currentTest); + } + + if (repositoryConfig != null) + { + repositoryConfig.setCurrentTest(currentTest); + } + + if (sessionConfig != null) + { + sessionConfig.setCurrentTest(currentTest); + } + + if (modelConfig != null) + { + modelConfig.setCurrentTest(currentTest); + } + } + + public synchronized void setUp() throws Exception + { + getContainerConfig().setUp(); + getRepositoryConfig().setUp(); + getSessionConfig().setUp(); + getModelConfig().setUp(); + } + + public synchronized void tearDown() throws Exception + { + getModelConfig().tearDown(); + getSessionConfig().tearDown(); + getRepositoryConfig().tearDown(); + getContainerConfig().tearDown(); + } + + public synchronized void save() + { + File file = getStateFile(); + ObjectOutputStream stream = null; + + try + { + stream = new ObjectOutputStream(IOUtil.openOutputStream(file)); + stream.writeObject(this); + } + catch (Exception ex) + { + throw WrappedException.wrap(ex); + } + finally + { + IOUtil.close(stream); + } + } + + public static IScenario load() + { + File file = getStateFile(); + if (file.exists()) + { + FileInputStream stream = IOUtil.openInputStream(file); + + try + { + return (IScenario)new ObjectInputStream(stream).readObject(); + } + catch (Exception ex) + { + throw WrappedException.wrap(ex); + } + finally + { + IOUtil.close(stream); + } + } + + return null; + } + + public static File getStateFile() + { + String home = System.getProperty("user.home"); + if (home != null) + { + return new File(home, STATE_FILE); + } + + return new File(STATE_FILE); + } + + public static IScenario getDefault() + { + return Default.INSTANCE; + } + + /** + * @author Eike Stepper + */ + private static final class Default extends Scenario + { + public static final IScenario INSTANCE = new Default(); + + private static final long serialVersionUID = 1L; + + private Default() + { + setContainerConfig(ContainerConfig.Combined.INSTANCE); + setRepositoryConfig(RepositoryConfig.MEM.INSTANCE); + setSessionConfig(SessionConfig.TCP.INSTANCE); + setModelConfig(ModelConfig.Native.INSTANCE); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/SessionConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java index 52765ae5b6..392ff96f70 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/SessionConfig.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java @@ -8,10 +8,13 @@ * Contributors: * Eike Stepper - initial API and implementation **************************************************************************/ -package org.eclipse.emf.cdo.tests.config; +package org.eclipse.emf.cdo.tests.config.impl; import org.eclipse.emf.cdo.CDOSession; import org.eclipse.emf.cdo.CDOSessionConfiguration; +import org.eclipse.emf.cdo.tests.config.IConfig; +import org.eclipse.emf.cdo.tests.config.IRepositoryConfig; +import org.eclipse.emf.cdo.tests.config.ISessionConfig; import org.eclipse.emf.cdo.util.CDOUtil; import org.eclipse.net4j.acceptor.IAcceptor; @@ -27,10 +30,12 @@ import java.util.Set; /** * @author Eike Stepper */ -public abstract class SessionConfig extends Config implements SessionProvider +public abstract class SessionConfig extends Config implements ISessionConfig { public static final SessionConfig[] CONFIGS = { TCP.INSTANCE, JVM.INSTANCE }; + private static final long serialVersionUID = 1L; + public SessionConfig(String name) { super(name); @@ -85,14 +90,14 @@ public abstract class SessionConfig extends Config implements SessionProvider public CDOSession openEagerSession() { - CDOSessionConfiguration configuration = createSessionConfiguration(RepositoryProvider.REPOSITORY_NAME); + CDOSessionConfiguration configuration = createSessionConfiguration(IRepositoryConfig.REPOSITORY_NAME); configuration.setEagerPackageRegistry(); return configuration.openSession(); } public CDOSession openLazySession() { - CDOSessionConfiguration configuration = createSessionConfiguration(RepositoryProvider.REPOSITORY_NAME); + CDOSessionConfiguration configuration = createSessionConfiguration(IRepositoryConfig.REPOSITORY_NAME); configuration.setLazyPackageRegistry(); return configuration.openSession(); } @@ -112,11 +117,11 @@ public abstract class SessionConfig extends Config implements SessionProvider public CDOSession openSession() { - return openSession(RepositoryProvider.REPOSITORY_NAME); + return openSession(IRepositoryConfig.REPOSITORY_NAME); } @Override - protected void tearDown() throws Exception + public void tearDown() throws Exception { stopTransport(); super.tearDown(); @@ -141,6 +146,8 @@ public abstract class SessionConfig extends Config implements SessionProvider public static final String CONNECTOR_HOST = "localhost"; + private static final long serialVersionUID = 1L; + public TCP() { super(NAME); @@ -157,7 +164,7 @@ public abstract class SessionConfig extends Config implements SessionProvider } @Override - protected void setUp() throws Exception + public void setUp() throws Exception { super.setUp(); TCPUtil.prepareContainer(getCurrentTest().getClientContainer()); @@ -176,6 +183,8 @@ public abstract class SessionConfig extends Config implements SessionProvider public static final String ACCEPTOR_NAME = "default"; + private static final long serialVersionUID = 1L; + public JVM() { super(NAME); @@ -192,7 +201,7 @@ public abstract class SessionConfig extends Config implements SessionProvider } @Override - protected void setUp() throws Exception + public void setUp() throws Exception { super.setUp(); JVMUtil.prepareContainer(getCurrentTest().getClientContainer()); @@ -200,7 +209,7 @@ public abstract class SessionConfig extends Config implements SessionProvider } @Override - protected boolean isValid(Set<Config> configs) + public boolean isValid(Set<IConfig> configs) { return !configs.contains(ContainerConfig.Separated.INSTANCE); } diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/proto/ConfigScenario.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/proto/ConfigScenario.java deleted file mode 100644 index 63f301e3cd..0000000000 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/proto/ConfigScenario.java +++ /dev/null @@ -1,88 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.config.proto; - -import org.eclipse.emf.cdo.tests.config.Config; -import org.eclipse.emf.cdo.tests.config.ContainerConfig; -import org.eclipse.emf.cdo.tests.config.ModelConfig; -import org.eclipse.emf.cdo.tests.config.RepositoryConfig; -import org.eclipse.emf.cdo.tests.config.SessionConfig; - -import java.text.MessageFormat; - -/** - * @author Eike Stepper - */ -public class ConfigScenario -{ - private ContainerConfig containerConfig; - - private RepositoryConfig repositoryConfig; - - private SessionConfig sessionConfig; - - private ModelConfig modelConfig; - - public ConfigScenario() - { - } - - public ContainerConfig getContainerConfig() - { - return containerConfig; - } - - public void setContainerConfig(ContainerConfig containerConfig) - { - this.containerConfig = containerConfig; - } - - public RepositoryConfig getRepositoryConfig() - { - return repositoryConfig; - } - - public void setRepositoryConfig(RepositoryConfig repositoryConfig) - { - this.repositoryConfig = repositoryConfig; - } - - public SessionConfig getSessionConfig() - { - return sessionConfig; - } - - public void setSessionConfig(SessionConfig sessionConfig) - { - this.sessionConfig = sessionConfig; - } - - public ModelConfig getModelConfig() - { - return modelConfig; - } - - public void setModelConfig(ModelConfig modelConfig) - { - this.modelConfig = modelConfig; - } - - public Config[] getConfigs() - { - return new Config[] { containerConfig, repositoryConfig, sessionConfig, modelConfig }; - } - - @Override - public String toString() - { - return MessageFormat.format("[{0}, {1}, {2}, {3}]", containerConfig, repositoryConfig, sessionConfig, modelConfig); - } -} |