diff options
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests/src/org')
12 files changed, 501 insertions, 40 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractIntegrationTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractIntegrationTest.java new file mode 100644 index 0000000000..4522edaea2 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractIntegrationTest.java @@ -0,0 +1,83 @@ +/*************************************************************************** + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Fuggerstr. 39, 10777 Berlin, 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; + + +import org.eclipse.emf.cdo.client.ResourceManager; + +import org.eclipse.emf.ecore.resource.ResourceSet; + +import junit.framework.TestCase; + + +public class AbstractIntegrationTest extends TestCase +{ + public static final String CLIENT_SEPARATED_SERVER_MODE = "client-separated-server"; + + public static final String CLIENT_SERVER_MODE = "client-server"; + + public static final String CLIENT_MODE = "client"; + + public static final String EMBEDDED_MODE = "embedded"; + + private ITopology topology; + + @Override + protected void setUp() throws Exception + { + super.setUp(); + topology = createTopology(); + topology.start(); + } + + @Override + protected void tearDown() throws Exception + { + topology.stop(); + super.tearDown(); + } + + protected ResourceManager createResourceManager(ResourceSet resourceSet) + { + return topology.createResourceManager(resourceSet); + } + + protected ITopology createTopology() + { + String mode = getMode(); + if (EMBEDDED_MODE.equals(mode)) + { + return new EmbeddedTopology(); + } + + if (CLIENT_MODE.equals(mode)) + { + return new ClientTopology(); + } + + if (CLIENT_SERVER_MODE.equals(mode)) + { + return new ClientServerTopology(); + } + + if (CLIENT_SEPARATED_SERVER_MODE.equals(mode)) + { + return new ClientSeparatedServerTopology(); + } + + return null; + } + + protected String getMode() + { + return System.getProperty("cdo.test.mode", EMBEDDED_MODE).toLowerCase(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractTopology.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractTopology.java new file mode 100644 index 0000000000..a164f47ca3 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractTopology.java @@ -0,0 +1,91 @@ +/*************************************************************************** + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Fuggerstr. 39, 10777 Berlin, 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; + + +import org.eclipse.emf.cdo.client.ResourceManager; + +import org.eclipse.emf.ecore.resource.ResourceSet; + +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.net4j.spring.Container; +import org.eclipse.net4j.spring.impl.ContainerImpl; + +import org.osgi.framework.Bundle; + +import java.net.URL; + + +public abstract class AbstractTopology implements ITopology +{ + protected static final String NET4J_LOCATION = "META-INF/net4j/net4j.xml"; + + protected static final String NET4J_CLIENT_LOCATION = "META-INF/net4j/client/net4j-client.xml"; + + protected static final String NET4J_SERVER_LOCATION = "META-INF/net4j/server/net4j-server.xml"; + + protected static final String NET4J_EMBEDDED_LOCATION = "META-INF/net4j/embedded/net4j-embedded.xml"; + + protected static final String CDO_CLIENT_LOCATION = "META-INF/cdo/client/cdo-client.xml"; + + protected static final String CDO_SERVER_LOCATION = "META-INF/cdo/server/cdo-server.xml"; + + private String bundleLocation; + + private Container cdoClient; + + protected AbstractTopology() + { + } + + public void start() throws Exception + { + CDOTestPlugin plugin = CDOTestPlugin.getPlugin(); + Bundle bundle = plugin.getBundle(); + URL url = bundle.getEntry("/"); + bundleLocation = FileLocator.toFileURL(url).getFile(); + } + + public void stop() throws Exception + { + cdoClient.stop(); + cdoClient = null; + } + + public ResourceManager createResourceManager(ResourceSet resourceSet) + { + ResourceManager resourceManager = (ResourceManager) cdoClient.getBean("resourceManager"); + resourceManager.setResourceSet(resourceSet); + + try + { + resourceManager.start(); + } + catch (Exception ex) + { + ex.printStackTrace(); + return null; + } + + return resourceManager; + } + + protected void createCDOClient(String name, Container parent) + { + cdoClient = createContainer(name, CDO_CLIENT_LOCATION, parent); + } + + protected ContainerImpl createContainer(String name, String location, Container parent) + { + return new ContainerImpl(bundleLocation, location, name, parent, CDOTestPlugin.class + .getClassLoader()); + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllSuites.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllSuites.java index 96cecc395b..354db0b6fd 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllSuites.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllSuites.java @@ -1,20 +1,13 @@ -/** - * <copyright> - * - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials +/*************************************************************************** + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Fuggerstr. 39, 10777 Berlin, 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: - * IBM - Initial API and implementation - * - * </copyright> - * - * $Id: AllSuites.java,v 1.1 2006-05-29 23:06:29 nickb Exp $ - */ - + * Eike Stepper - initial API and implementation + **************************************************************************/ package org.eclipse.emf.cdo.tests; @@ -58,4 +51,4 @@ public class AllSuites extends TestSuite addTest(suites[i]); } } -}
\ No newline at end of file +} 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 5defe0c0b0..1b7df5c3c0 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 @@ -1,3 +1,13 @@ +/*************************************************************************** + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Fuggerstr. 39, 10777 Berlin, 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; diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CDOTestPlugin.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CDOTestPlugin.java index 83b472d937..2cc51f1173 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CDOTestPlugin.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CDOTestPlugin.java @@ -1,36 +1,31 @@ -/** - * <copyright> - * - * Copyright (c) 2002-2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials +/*************************************************************************** + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Fuggerstr. 39, 10777 Berlin, 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: - * IBM - Initial API and implementation - * - * </copyright> - * - * $Id: CDOTestPlugin.java,v 1.1 2006-05-29 23:06:29 nickb Exp $ - */ + * Eike Stepper - initial API and implementation + **************************************************************************/ package org.eclipse.emf.cdo.tests; -import org.eclipse.core.runtime.Plugin; -public class CDOTestPlugin -extends Plugin +import org.eclipse.net4j.util.eclipse.AbstractPlugin; + + +public class CDOTestPlugin extends AbstractPlugin { - private static CDOTestPlugin instance; - - public CDOTestPlugin() - { - super(); - instance = this; - } + private static CDOTestPlugin instance; + + public CDOTestPlugin() + { + super(); + instance = this; + } - public static CDOTestPlugin getPlugin() - { - return instance; - } + public static CDOTestPlugin getPlugin() + { + return instance; + } } diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ClientSeparatedServerTopology.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ClientSeparatedServerTopology.java new file mode 100644 index 0000000000..d2fd35a30d --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ClientSeparatedServerTopology.java @@ -0,0 +1,70 @@ +/*************************************************************************** + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Fuggerstr. 39, 10777 Berlin, 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; + + +import org.eclipse.net4j.core.Acceptor; +import org.eclipse.net4j.spring.Container; + + +public class ClientSeparatedServerTopology extends AbstractTopology +{ + private Container serverNet4j; + + private Container net4jServer; + + private Container cdoServer; + + private Container clientNet4j; + + private Container net4jClient; + + private Acceptor acceptor; + + public ClientSeparatedServerTopology() + { + } + + public void start() throws Exception + { + super.start(); + + // Start server + serverNet4j = createContainer("net4j", NET4J_LOCATION, null); + net4jServer = createContainer("server", NET4J_SERVER_LOCATION, serverNet4j); + cdoServer = createContainer("cdo", CDO_SERVER_LOCATION, net4jServer); + + acceptor = (Acceptor) cdoServer.getBean("acceptor", Acceptor.class); + acceptor.start(); + + // Start client + clientNet4j = createContainer("net4j", NET4J_LOCATION, null); + net4jClient = createContainer("client", NET4J_CLIENT_LOCATION, clientNet4j); + createCDOClient("cdo", net4jClient); + } + + public void stop() throws Exception + { + super.stop(); + + //Stop client + net4jClient.stop(); + clientNet4j.stop(); + + //Stop server + acceptor.stop(); + acceptor = null; + + cdoServer.stop(); + net4jServer.stop(); + serverNet4j.stop(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ClientServerTopology.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ClientServerTopology.java new file mode 100644 index 0000000000..67e5bdb7ad --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ClientServerTopology.java @@ -0,0 +1,67 @@ +/*************************************************************************** + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Fuggerstr. 39, 10777 Berlin, 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; + + +import org.eclipse.net4j.core.Acceptor; +import org.eclipse.net4j.spring.Container; + + +public class ClientServerTopology extends AbstractTopology +{ + private Container net4j; + + private Container net4jServer; + + private Container cdoServer; + + private Container net4jClient; + + private Acceptor acceptor; + + public ClientServerTopology() + { + } + + public void start() throws Exception + { + super.start(); + net4j = createContainer("net4j", NET4J_LOCATION, null); + + // Start server + net4jServer = createContainer("server", NET4J_SERVER_LOCATION, net4j); + cdoServer = createContainer("cdo", CDO_SERVER_LOCATION, net4jServer); + + acceptor = (Acceptor) cdoServer.getBean("acceptor", Acceptor.class); + acceptor.start(); + + // Start client + net4jClient = createContainer("client", NET4J_CLIENT_LOCATION, net4j); + createCDOClient("cdo", net4jClient); + } + + public void stop() throws Exception + { + super.stop(); + + //Stop client + net4jClient.stop(); + + //Stop server + acceptor.stop(); + acceptor = null; + + cdoServer.stop(); + net4jServer.stop(); + + net4j.stop(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ClientTopology.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ClientTopology.java new file mode 100644 index 0000000000..ad0e93989c --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ClientTopology.java @@ -0,0 +1,27 @@ +/*************************************************************************** + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Fuggerstr. 39, 10777 Berlin, 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; + + +public class ClientTopology extends AbstractTopology +{ + public ClientTopology() + { + } + + public void start() throws Exception + { + } + + public void stop() throws Exception + { + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EmbeddedTopology.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EmbeddedTopology.java new file mode 100644 index 0000000000..2ed0a899cd --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EmbeddedTopology.java @@ -0,0 +1,27 @@ +/*************************************************************************** + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Fuggerstr. 39, 10777 Berlin, 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; + + +public class EmbeddedTopology extends AbstractTopology +{ + public EmbeddedTopology() + { + } + + public void start() throws Exception + { + } + + public void stop() throws Exception + { + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ITopology.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ITopology.java new file mode 100644 index 0000000000..61b5e7ac06 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ITopology.java @@ -0,0 +1,26 @@ +/*************************************************************************** + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Fuggerstr. 39, 10777 Berlin, 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; + + +import org.eclipse.emf.cdo.client.ResourceManager; + +import org.eclipse.emf.ecore.resource.ResourceSet; + + +public interface ITopology +{ + public void start() throws Exception; + + public void stop() throws Exception; + + public ResourceManager createResourceManager(ResourceSet resourceSet); +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/IntegrationTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/IntegrationTest.java new file mode 100644 index 0000000000..702294f841 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/IntegrationTest.java @@ -0,0 +1,62 @@ +/*************************************************************************** + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Fuggerstr. 39, 10777 Berlin, 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; + + +import org.eclipse.emf.cdo.client.CDOResource; +import org.eclipse.emf.cdo.client.ResourceManager; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; + +import testmodel1.TestModel1Factory; +import testmodel1.TreeNode; + +import java.util.Arrays; + + +public class IntegrationTest extends AbstractIntegrationTest +{ + public void testSimple() throws Exception + { + ResourceSet resourceSet = new ResourceSetImpl(); + ResourceManager resourceManager = createResourceManager(resourceSet); + + CDOResource resource = (CDOResource) resourceSet.createResource(URI + .createURI("cdo:///test/res1")); + + TreeNode node0 = createNode("node0", null); + TreeNode node1 = createNode("node1", node0); + TreeNode node2 = createNode("node2", node0); + TreeNode node3 = createNode("node3", node0); + + resource.getContents().add(node0); + resourceManager.commit(); + resourceManager.stop(); + + } + + protected TreeNode createNode(String name, TreeNode parent) + { + TreeNode node = TestModel1Factory.eINSTANCE.createTreeNode(); + node.setStringFeature(name); + node.setParent(parent); + return node; + } + + protected TreeNode createNode(String name, TreeNode parent, TreeNode[] references) + { + TreeNode node = createNode(name, parent); + node.getReferences().add(Arrays.asList(references)); + return node; + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SampleTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SampleTest.java index e91d717e6a..dc691c8264 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SampleTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SampleTest.java @@ -1,3 +1,13 @@ +/*************************************************************************** + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Fuggerstr. 39, 10777 Berlin, 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; import junit.framework.TestCase; |