summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-09-24 17:31:52 (EDT)
committerEike Stepper2007-09-24 17:31:52 (EDT)
commit71f6da1a969344a8e09c7afdfff7f965bea07327 (patch)
tree0d5d62640b044c35e77bfaf30c621cd05b3e0e3f
parent18d38af00a3fb149b142621ed691ab01f1f82d0e (diff)
downloadcdo-71f6da1a969344a8e09c7afdfff7f965bea07327.zip
cdo-71f6da1a969344a8e09c7afdfff7f965bea07327.tar.gz
cdo-71f6da1a969344a8e09c7afdfff7f965bea07327.tar.bz2
[204410] CDO test needs Net4j test dependency
https://bugs.eclipse.org/bugs/show_bug.cgi?id=204410
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/.classpath1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF5
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/build.properties3
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/net4j/org/eclipse/net4j/tests/AbstractOMTest.java115
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/net4j/org/eclipse/net4j/tests/AbstractTransportTest.java99
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMFTest.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TDD.java2
7 files changed, 223 insertions, 6 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/.classpath b/plugins/org.eclipse.emf.cdo.tests/.classpath
index 304e861..81fba09 100644
--- a/plugins/org.eclipse.emf.cdo.tests/.classpath
+++ b/plugins/org.eclipse.emf.cdo.tests/.classpath
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="net4j"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
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 e6bb768..1cf9458 100644
--- a/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF
@@ -10,9 +10,10 @@ Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)",
org.eclipse.emf.ecore.xmi;bundle-version="[2.3.0,3.0.0)",
- org.eclipse.net4j.tests;bundle-version="[0.8.0,0.9.0)",
+ org.eclipse.net4j.tcp;bundle-version="[0.8.0,0.9.0)",
org.eclipse.emf.cdo.server;bundle-version="[0.8.0,0.9.0)",
org.eclipse.emf.cdo.server.db;bundle-version="[0.8.0,0.9.0)",
org.eclipse.emf.cdo;bundle-version="[0.8.0,0.9.0)",
- org.eclipse.emf.cdo.tests.model1;bundle-version="[0.8.0,0.9.0)"
+ org.eclipse.emf.cdo.tests.model1;bundle-version="[0.8.0,0.9.0)",
+ org.junit;visibility:=reexport
Eclipse-LazyStart: true
diff --git a/plugins/org.eclipse.emf.cdo.tests/build.properties b/plugins/org.eclipse.emf.cdo.tests/build.properties
index 1d0ef2f..25ace54 100644
--- a/plugins/org.eclipse.emf.cdo.tests/build.properties
+++ b/plugins/org.eclipse.emf.cdo.tests/build.properties
@@ -9,7 +9,8 @@
# NLS_MESSAGEFORMAT_VAR
-source.. = src/
+source.. = src/,\
+ net4j/
output.. = bin/
bin.includes = META-INF/,\
.,\
diff --git a/plugins/org.eclipse.emf.cdo.tests/net4j/org/eclipse/net4j/tests/AbstractOMTest.java b/plugins/org.eclipse.emf.cdo.tests/net4j/org/eclipse/net4j/tests/AbstractOMTest.java
new file mode 100644
index 0000000..9ba2e5d
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/net4j/org/eclipse/net4j/tests/AbstractOMTest.java
@@ -0,0 +1,115 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 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.net4j.tests;
+
+import org.eclipse.net4j.internal.util.om.log.PrintLogHandler;
+import org.eclipse.net4j.internal.util.om.trace.PrintTraceHandler;
+import org.eclipse.net4j.util.om.OMPlatform;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class AbstractOMTest extends TestCase
+{
+ private static boolean consoleEnabled;
+
+ protected AbstractOMTest()
+ {
+ }
+
+ @Override
+ public final void setUp() throws Exception
+ {
+ super.setUp();
+ System.out.println("************************************************");
+ System.out.println("START " + getName());
+ System.out.println("************************************************");
+
+ OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
+ OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
+ OMPlatform.INSTANCE.setDebugging(true);
+ enableConsole();
+
+ doSetUp();
+ System.out.println();
+ System.out.println("------------------------ START ------------------------");
+ }
+
+ @Override
+ public final void tearDown() throws Exception
+ {
+ Thread.sleep(200);
+ System.out.println("------------------------ END --------------------------");
+ System.out.println();
+
+ doTearDown();
+ super.tearDown();
+ System.out.println();
+ System.out.println();
+ }
+
+ @Override
+ protected void runTest() throws Throwable
+ {
+ try
+ {
+ super.runTest();
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace(System.out);
+ throw t;
+ }
+ }
+
+ protected void enableConsole()
+ {
+ if (!consoleEnabled)
+ {
+ PrintTraceHandler.CONSOLE.setShortContext(true);
+ OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
+ OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
+ OMPlatform.INSTANCE.setDebugging(true);
+ consoleEnabled = true;
+ }
+ }
+
+ @SuppressWarnings("unused")
+ protected void disableConsole()
+ {
+ if (consoleEnabled)
+ {
+ consoleEnabled = false;
+ OMPlatform.INSTANCE.setDebugging(false);
+ OMPlatform.INSTANCE.removeTraceHandler(PrintTraceHandler.CONSOLE);
+ OMPlatform.INSTANCE.removeLogHandler(PrintLogHandler.CONSOLE);
+ }
+ }
+
+ protected void doSetUp() throws Exception
+ {
+ }
+
+ protected void doTearDown() throws Exception
+ {
+ }
+
+ protected static void msg(String m)
+ {
+ if (consoleEnabled)
+ {
+ System.out.println();
+ System.out.println("--> " + m);
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.tests/net4j/org/eclipse/net4j/tests/AbstractTransportTest.java b/plugins/org.eclipse.emf.cdo.tests/net4j/org/eclipse/net4j/tests/AbstractTransportTest.java
new file mode 100644
index 0000000..bddd9f1
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/net4j/org/eclipse/net4j/tests/AbstractTransportTest.java
@@ -0,0 +1,99 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 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.net4j.tests;
+
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.internal.util.container.ManagedContainer;
+import org.eclipse.net4j.tcp.TCPUtil;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+
+import org.eclipse.internal.net4j.Acceptor;
+import org.eclipse.internal.net4j.Connector;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class AbstractTransportTest extends AbstractOMTest
+{
+ protected static final String HOST = "localhost";
+
+ protected IManagedContainer container;
+
+ private Acceptor acceptor;
+
+ private Connector connector;
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+ container = createContainer();
+ LifecycleUtil.activate(container);
+ }
+
+ @Override
+ protected void doTearDown() throws Exception
+ {
+ try
+ {
+ Thread.sleep(20);
+ LifecycleUtil.deactivate(container);
+ }
+ finally
+ {
+ connector = null;
+ acceptor = null;
+ container = null;
+ super.doTearDown();
+ }
+ }
+
+ protected IManagedContainer createContainer()
+ {
+ IManagedContainer container = new ManagedContainer();
+ Net4jUtil.prepareContainer(container);
+ TCPUtil.prepareContainer(container);
+ return container;
+ }
+
+ protected Acceptor getAcceptor()
+ {
+ if (acceptor == null)
+ {
+ acceptor = (Acceptor)TCPUtil.getAcceptor(container, null);
+ }
+
+ return acceptor;
+ }
+
+ protected Connector getConnector()
+ {
+ if (connector == null)
+ {
+ connector = (Connector)TCPUtil.getConnector(container, HOST);
+ }
+
+ return connector;
+ }
+
+ protected void startTransport() throws Exception
+ {
+ if (container != null)
+ {
+ Acceptor acceptor = getAcceptor();
+ acceptor.activate();
+
+ Connector connector = getConnector();
+ connector.activate();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMFTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMFTest.java
index 370d417..f079be1 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMFTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/EMFTest.java
@@ -12,8 +12,6 @@ package org.eclipse.emf.cdo.tests;
import org.eclipse.emf.cdo.util.EMFUtil;
-import org.eclipse.net4j.util.tests.AbstractOMTest;
-
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
@@ -21,6 +19,8 @@ import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.net4j.tests.AbstractOMTest;
+
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TDD.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TDD.java
index f17027e..4abcedc 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TDD.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TDD.java
@@ -10,7 +10,7 @@
**************************************************************************/
package org.eclipse.emf.cdo.tests;
-import org.eclipse.net4j.util.tests.AbstractOMTest;
+import org.eclipse.net4j.tests.AbstractOMTest;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;