Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-12-30 08:43:13 +0000
committerEike Stepper2008-12-30 08:43:13 +0000
commit8347ca03ba1a9b999433ee6069fd2830540adf2c (patch)
tree92b35f64ef02943239d13bbd34e2988e59cf4162 /plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOSessionDefImplTest.java
parentd651707ba1bfdfdf696ff5517fff4722fcc592c8 (diff)
downloadcdo-8347ca03ba1a9b999433ee6069fd2830540adf2c.tar.gz
cdo-8347ca03ba1a9b999433ee6069fd2830540adf2c.tar.xz
cdo-8347ca03ba1a9b999433ee6069fd2830540adf2c.zip
[246623] Create Definition model as alternative configuration/wiring mechanism
https://bugs.eclipse.org/bugs/show_bug.cgi?id=246623
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOSessionDefImplTest.java')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOSessionDefImplTest.java101
1 files changed, 101 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOSessionDefImplTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOSessionDefImplTest.java
new file mode 100644
index 0000000000..59965f9859
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/defs/CDOSessionDefImplTest.java
@@ -0,0 +1,101 @@
+/***************************************************************************
+ * 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.defs;
+
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.cdodefs.CDODefsFactory;
+import org.eclipse.emf.cdo.cdodefs.CDOSessionDef;
+import org.eclipse.emf.cdo.cdodefs.util.CDODefsUtil;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.SessionConfig;
+
+import org.eclipse.net4j.net4jdefs.util.Net4jDefsUtil;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOSessionDefImplTest extends AbstractCDOTest
+{
+ public void testNoPackageRegistryThrows()
+ {
+ try
+ {
+ CDOSessionDef cdoSessionDef = CDODefsFactory.eINSTANCE.createCDOSessionDef();
+ cdoSessionDef.setConnectorDef(Net4jDefsUtil.createTCPConnectorDef(SessionConfig.TCP.CONNECTOR_HOST));
+ cdoSessionDef.setLegacySupportEnabled(false);
+ cdoSessionDef.setRepositoryName(IRepositoryConfig.REPOSITORY_NAME);
+ cdoSessionDef.getInstance();
+ fail("IllegalStateException expected!");
+ }
+ catch (IllegalStateException e)
+ {
+ // Success
+ }
+ }
+
+ public void testConnectorAndFailOverStrategyAreMutuallyExclusive()
+ {
+ try
+ {
+ CDOSessionDef cdoSessionDef = CDODefsFactory.eINSTANCE.createCDOSessionDef();
+ cdoSessionDef.setConnectorDef(Net4jDefsUtil.createTCPConnectorDef(SessionConfig.TCP.CONNECTOR_HOST));
+ cdoSessionDef.setFailOverStrategyDef(CDODefsFactory.eINSTANCE.createRetryFailOverStrategyDef());
+ fail("IllegalStateException expected!");
+ }
+ catch (IllegalStateException e)
+ {
+ // Success
+ }
+
+ try
+ {
+ CDOSessionDef cdoSessionDef = CDODefsFactory.eINSTANCE.createCDOSessionDef();
+ cdoSessionDef.setFailOverStrategyDef(CDODefsFactory.eINSTANCE.createRetryFailOverStrategyDef());
+ cdoSessionDef.setConnectorDef(Net4jDefsUtil.createTCPConnectorDef(SessionConfig.TCP.CONNECTOR_HOST));
+ fail("IllegalStateException expected!");
+ }
+ catch (IllegalStateException e)
+ {
+ // Success
+ }
+ }
+
+ public void testConnectorAndFailMayBeUnset()
+ {
+ {
+ CDOSessionDef cdoSessionDef = CDODefsFactory.eINSTANCE.createCDOSessionDef();
+ cdoSessionDef.setFailOverStrategyDef(CDODefsFactory.eINSTANCE.createRetryFailOverStrategyDef());
+ cdoSessionDef.unsetFailOverStrategyDef();
+ cdoSessionDef.setConnectorDef(Net4jDefsUtil.createTCPConnectorDef(SessionConfig.TCP.CONNECTOR_HOST));
+ }
+
+ {
+ CDOSessionDef cdoSessionDef = CDODefsFactory.eINSTANCE.createCDOSessionDef();
+ cdoSessionDef.setConnectorDef(Net4jDefsUtil.createTCPConnectorDef(SessionConfig.TCP.CONNECTOR_HOST));
+ cdoSessionDef.unsetConnectorDef();
+ cdoSessionDef.setFailOverStrategyDef(CDODefsFactory.eINSTANCE.createRetryFailOverStrategyDef());
+ }
+ }
+
+ public void testSessionInstanceIsActive()
+ {
+ CDOSessionDef cdoSessionDef = CDODefsFactory.eINSTANCE.createCDOSessionDef();
+ cdoSessionDef.setConnectorDef( //
+ Net4jDefsUtil.createTCPConnectorDef(SessionConfig.TCP.CONNECTOR_HOST));
+ cdoSessionDef.setLegacySupportEnabled(false);
+ cdoSessionDef.setRepositoryName(IRepositoryConfig.REPOSITORY_NAME);
+ cdoSessionDef.setCdoPackageRegistryDef(CDODefsUtil.createEagerPackageRegistryDef());
+ CDOSession cdoSession = (CDOSession)cdoSessionDef.getInstance();
+ assertTrue(LifecycleUtil.isActive(cdoSession));
+ }
+}

Back to the top