Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-07-19 08:22:04 +0000
committerEike Stepper2012-07-19 08:22:04 +0000
commit1460904fd3c193ffaf809913b2983a400fce9d94 (patch)
tree72f3a17b75fedba3ae1060df1d32c9c7889be954 /plugins/org.eclipse.net4j.tests/src
parent5f360965ae87478e0681899bf310a210cafc2c44 (diff)
downloadcdo-1460904fd3c193ffaf809913b2983a400fce9d94.tar.gz
cdo-1460904fd3c193ffaf809913b2983a400fce9d94.tar.xz
cdo-1460904fd3c193ffaf809913b2983a400fce9d94.zip
Fix line endings in master (dos2unix)
Diffstat (limited to 'plugins/org.eclipse.net4j.tests/src')
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AbstractProtocolTest.java64
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AbstractTransportTest.java408
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllSSLTests.java74
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java154
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ChannelTest.java742
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ExceptionTest.java334
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SelectorTest.java74
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalMonitorTest.java436
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalStreamWrappingTest.java176
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java350
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPUnitTest.java54
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/apps/Performance.java288
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/apps/TCPConnectivityLoss.java204
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla_241463_Test.java424
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla_262875_Test.java420
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bundle/OM.java88
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/data/HugeData.java490
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/data/TinyData.java82
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/defs/JVMAcceptorDefImplTest.java190
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/defs/JVMConnectorDefImplTest.java160
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/defs/Util.java276
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ArrayIndication.java80
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ArrayRequest.java84
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/AsyncIndication.java78
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/AsyncRequest.java70
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ExceptionIndication.java114
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ExceptionRequest.java108
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntFailIndication.java90
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntFailRequest.java82
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntIndication.java80
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntRequest.java82
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/StringIndication.java80
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/StringRequest.java84
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalProtocol.java240
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java1544
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/ConcurrentRunner.java280
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/ExtendedIOTest.java314
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/FastListTest.java588
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/MonitorTest.java604
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/MultiMapTest.java582
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/OMTest.java94
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/ReferenceValueMapTest.java86
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/SecurityTest.java482
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/StreamWrapperTest.java92
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/SynchronizingCorrelatorTest.java302
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/UTFTest.java130
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/ZipTest.java68
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/cache/CacheTest.java108
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/cache/Revision.java134
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/cache/RevisionManager.java294
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/cache/SensitiveProtoTest.java168
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/DefsFactory.java96
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/DefsPackage.java362
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/TestDef.java154
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/TestDefTest.java522
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/TestDefsFactory.java96
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/TestDefsPackage.java362
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/DefsFactoryImpl.java228
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/DefsPackageImpl.java452
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/TestDefImpl.java472
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/TestDefsFactoryImpl.java228
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/TestDefsPackageImpl.java444
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/util/DefsAdapterFactory.java308
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/util/DefsSwitch.java324
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/util/TestDefsAdapterFactory.java308
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/util/TestDefsSwitch.java324
66 files changed, 8655 insertions, 8655 deletions
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AbstractProtocolTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AbstractProtocolTest.java
index 5d523f69b3..f5f795ddf6 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AbstractProtocolTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AbstractProtocolTest.java
@@ -1,32 +1,32 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.tests.signal.TestSignalProtocol;
-import org.eclipse.net4j.util.container.IManagedContainer;
-
-/**
- * @author Eike Stepper
- */
-public abstract class AbstractProtocolTest extends AbstractTransportTest
-{
- protected AbstractProtocolTest()
- {
- }
-
- @Override
- protected IManagedContainer createContainer()
- {
- IManagedContainer container = super.createContainer();
- container.registerFactory(new TestSignalProtocol.Factory());
- return container;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.tests.signal.TestSignalProtocol;
+import org.eclipse.net4j.util.container.IManagedContainer;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class AbstractProtocolTest extends AbstractTransportTest
+{
+ protected AbstractProtocolTest()
+ {
+ }
+
+ @Override
+ protected IManagedContainer createContainer()
+ {
+ IManagedContainer container = super.createContainer();
+ container.registerFactory(new TestSignalProtocol.Factory());
+ return container;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AbstractTransportTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AbstractTransportTest.java
index f8706a6d42..d6fa89d0c4 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AbstractTransportTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AbstractTransportTest.java
@@ -1,204 +1,204 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Teerawat Chaiyakijpichet (No Magic Asia Ltd.) - SSL
- */
-package org.eclipse.net4j.tests;
-
-import org.eclipse.net4j.Net4jUtil;
-import org.eclipse.net4j.acceptor.IAcceptor;
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.jvm.JVMUtil;
-import org.eclipse.net4j.tcp.TCPUtil;
-import org.eclipse.net4j.tcp.ssl.SSLUtil;
-import org.eclipse.net4j.util.container.ContainerUtil;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.tests.AbstractOMTest;
-
-/**
- * @author Eike Stepper
- * @author Teerawat Chaiyakijpichet (No Magic Asia Ltd.)
- */
-public abstract class AbstractTransportTest extends AbstractOMTest
-{
- protected static final String HOST = "localhost"; //$NON-NLS-1$
-
- protected IManagedContainer container;
-
- // SSL, the server and client need separate container in order to operate handshake.
- protected IManagedContainer separateContainer;
-
- private IAcceptor acceptor;
-
- private IConnector connector;
-
- protected AbstractTransportTest()
- {
- }
-
- @Override
- protected void doSetUp() throws Exception
- {
- super.doSetUp();
- // create container for JVM or TCP only.
- container = createContainer();
- LifecycleUtil.activate(container);
-
- if (!useJVMTransport() && useSSLTransport())
- {
- // the SSL need separate container between client and server
- separateContainer = createContainer();
- LifecycleUtil.activate(separateContainer);
- }
- }
-
- @Override
- protected void doTearDown() throws Exception
- {
- try
- {
- sleep(20);
- LifecycleUtil.deactivate(container);
- }
- finally
- {
- connector = null;
- acceptor = null;
- container = null;
- if (!useJVMTransport() && useSSLTransport())
- {
- separateContainer = null;
- }
- super.doTearDown();
- }
- }
-
- protected boolean useJVMTransport()
- {
- return false;
- }
-
- protected boolean useSSLTransport()
- {
- return false;
- }
-
- protected IManagedContainer createContainer()
- {
- IManagedContainer container = ContainerUtil.createContainer();
- Net4jUtil.prepareContainer(container);
- if (useJVMTransport())
- {
- JVMUtil.prepareContainer(container);
- }
- else
- {
- if (useSSLTransport())
- {
- SSLUtil.prepareContainer(container);
- }
- else
- {
- TCPUtil.prepareContainer(container);
- }
- }
-
- return container;
- }
-
- protected IAcceptor getAcceptor()
- {
- if (acceptor == null)
- {
- if (useJVMTransport())
- {
- acceptor = JVMUtil.getAcceptor(container, "default"); //$NON-NLS-1$
- }
- else
- {
- if (useSSLTransport())
- {
- acceptor = SSLUtil.getAcceptor(container, null);
- }
- else
- {
- acceptor = TCPUtil.getAcceptor(container, null);
- }
- }
- }
-
- return acceptor;
- }
-
- protected IConnector getConnector()
- {
- if (connector == null)
- {
- if (useJVMTransport())
- {
- connector = JVMUtil.getConnector(container, "default"); //$NON-NLS-1$
- }
- else
- {
- if (useSSLTransport())
- {
- // cannot use same container with the acceptor.
- connector = SSLUtil.getConnector(separateContainer, HOST);
- }
- else
- {
- connector = TCPUtil.getConnector(container, HOST);
- }
- }
- }
-
- return connector;
- }
-
- protected void startTransport() throws Exception
- {
- if (container != null)
- {
- IAcceptor acceptor = getAcceptor();
- LifecycleUtil.activate(acceptor);
-
- IConnector connector = getConnector();
- LifecycleUtil.activate(connector);
- }
- }
-
- protected void stopTransport() throws Exception
- {
- connector.close();
- connector = null;
-
- acceptor.close();
- acceptor = null;
- }
-
- protected void restartContainer() throws Exception
- {
- msg("RESTARTING CONTAINER"); //$NON-NLS-1$
- stopTransport();
-
- LifecycleUtil.deactivate(container);
- container = createContainer();
- LifecycleUtil.activate(container);
-
- if (!useJVMTransport() && useSSLTransport())
- {
- LifecycleUtil.deactivate(separateContainer);
- separateContainer = createContainer();
- LifecycleUtil.activate(separateContainer);
- }
- startTransport();
- msg("RESTARTING CONTAINER - FINISHED"); //$NON-NLS-1$
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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
+ * Teerawat Chaiyakijpichet (No Magic Asia Ltd.) - SSL
+ */
+package org.eclipse.net4j.tests;
+
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.acceptor.IAcceptor;
+import org.eclipse.net4j.connector.IConnector;
+import org.eclipse.net4j.jvm.JVMUtil;
+import org.eclipse.net4j.tcp.TCPUtil;
+import org.eclipse.net4j.tcp.ssl.SSLUtil;
+import org.eclipse.net4j.util.container.ContainerUtil;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.tests.AbstractOMTest;
+
+/**
+ * @author Eike Stepper
+ * @author Teerawat Chaiyakijpichet (No Magic Asia Ltd.)
+ */
+public abstract class AbstractTransportTest extends AbstractOMTest
+{
+ protected static final String HOST = "localhost"; //$NON-NLS-1$
+
+ protected IManagedContainer container;
+
+ // SSL, the server and client need separate container in order to operate handshake.
+ protected IManagedContainer separateContainer;
+
+ private IAcceptor acceptor;
+
+ private IConnector connector;
+
+ protected AbstractTransportTest()
+ {
+ }
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+ // create container for JVM or TCP only.
+ container = createContainer();
+ LifecycleUtil.activate(container);
+
+ if (!useJVMTransport() && useSSLTransport())
+ {
+ // the SSL need separate container between client and server
+ separateContainer = createContainer();
+ LifecycleUtil.activate(separateContainer);
+ }
+ }
+
+ @Override
+ protected void doTearDown() throws Exception
+ {
+ try
+ {
+ sleep(20);
+ LifecycleUtil.deactivate(container);
+ }
+ finally
+ {
+ connector = null;
+ acceptor = null;
+ container = null;
+ if (!useJVMTransport() && useSSLTransport())
+ {
+ separateContainer = null;
+ }
+ super.doTearDown();
+ }
+ }
+
+ protected boolean useJVMTransport()
+ {
+ return false;
+ }
+
+ protected boolean useSSLTransport()
+ {
+ return false;
+ }
+
+ protected IManagedContainer createContainer()
+ {
+ IManagedContainer container = ContainerUtil.createContainer();
+ Net4jUtil.prepareContainer(container);
+ if (useJVMTransport())
+ {
+ JVMUtil.prepareContainer(container);
+ }
+ else
+ {
+ if (useSSLTransport())
+ {
+ SSLUtil.prepareContainer(container);
+ }
+ else
+ {
+ TCPUtil.prepareContainer(container);
+ }
+ }
+
+ return container;
+ }
+
+ protected IAcceptor getAcceptor()
+ {
+ if (acceptor == null)
+ {
+ if (useJVMTransport())
+ {
+ acceptor = JVMUtil.getAcceptor(container, "default"); //$NON-NLS-1$
+ }
+ else
+ {
+ if (useSSLTransport())
+ {
+ acceptor = SSLUtil.getAcceptor(container, null);
+ }
+ else
+ {
+ acceptor = TCPUtil.getAcceptor(container, null);
+ }
+ }
+ }
+
+ return acceptor;
+ }
+
+ protected IConnector getConnector()
+ {
+ if (connector == null)
+ {
+ if (useJVMTransport())
+ {
+ connector = JVMUtil.getConnector(container, "default"); //$NON-NLS-1$
+ }
+ else
+ {
+ if (useSSLTransport())
+ {
+ // cannot use same container with the acceptor.
+ connector = SSLUtil.getConnector(separateContainer, HOST);
+ }
+ else
+ {
+ connector = TCPUtil.getConnector(container, HOST);
+ }
+ }
+ }
+
+ return connector;
+ }
+
+ protected void startTransport() throws Exception
+ {
+ if (container != null)
+ {
+ IAcceptor acceptor = getAcceptor();
+ LifecycleUtil.activate(acceptor);
+
+ IConnector connector = getConnector();
+ LifecycleUtil.activate(connector);
+ }
+ }
+
+ protected void stopTransport() throws Exception
+ {
+ connector.close();
+ connector = null;
+
+ acceptor.close();
+ acceptor = null;
+ }
+
+ protected void restartContainer() throws Exception
+ {
+ msg("RESTARTING CONTAINER"); //$NON-NLS-1$
+ stopTransport();
+
+ LifecycleUtil.deactivate(container);
+ container = createContainer();
+ LifecycleUtil.activate(container);
+
+ if (!useJVMTransport() && useSSLTransport())
+ {
+ LifecycleUtil.deactivate(separateContainer);
+ separateContainer = createContainer();
+ LifecycleUtil.activate(separateContainer);
+ }
+ startTransport();
+ msg("RESTARTING CONTAINER - FINISHED"); //$NON-NLS-1$
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllSSLTests.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllSSLTests.java
index d3629b3e8d..043043b2b9 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllSSLTests.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllSSLTests.java
@@ -1,37 +1,37 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Teerawat Chaiyakijpichet (No Magic Asia Ltd.) - initial API and implementation
- */
-package org.eclipse.net4j.tests;
-
-import org.eclipse.net4j.tests.bugzilla.Bugzilla_241463_Test;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Teerawat Chaiyakijpichet (No Magic Asia Ltd.)
- */
-public class AllSSLTests
-{
- public static Test suite()
- {
- TestSuite suite = new TestSuite("Tests for SSL Net4j"); //$NON-NLS-1$
- suite.addTestSuite(ChannelTest.SSL.class);
- suite.addTestSuite(TCPConnectorTest.SSL.class);
- suite.addTestSuite(TransportTest.SSL.class);
- suite.addTestSuite(SignalTest.SSL.class);
- suite.addTestSuite(SignalMonitorTest.SSL.class);
- suite.addTestSuite(ExceptionTest.SSL.class);
- // Bugzillas
- suite.addTestSuite(Bugzilla_241463_Test.SSL.class);
-
- return suite;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Teerawat Chaiyakijpichet (No Magic Asia Ltd.) - initial API and implementation
+ */
+package org.eclipse.net4j.tests;
+
+import org.eclipse.net4j.tests.bugzilla.Bugzilla_241463_Test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Teerawat Chaiyakijpichet (No Magic Asia Ltd.)
+ */
+public class AllSSLTests
+{
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("Tests for SSL Net4j"); //$NON-NLS-1$
+ suite.addTestSuite(ChannelTest.SSL.class);
+ suite.addTestSuite(TCPConnectorTest.SSL.class);
+ suite.addTestSuite(TransportTest.SSL.class);
+ suite.addTestSuite(SignalTest.SSL.class);
+ suite.addTestSuite(SignalMonitorTest.SSL.class);
+ suite.addTestSuite(ExceptionTest.SSL.class);
+ // Bugzillas
+ suite.addTestSuite(Bugzilla_241463_Test.SSL.class);
+
+ return suite;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java
index cde0650580..6543c4dc52 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java
@@ -1,77 +1,77 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.tests.bugzilla.Bugzilla_241463_Test;
-import org.eclipse.net4j.tests.bugzilla.Bugzilla_262875_Test;
-import org.eclipse.net4j.util.tests.ExpectedIOTest;
-import org.eclipse.net4j.util.tests.ExtendedIOTest;
-import org.eclipse.net4j.util.tests.MultiMapTest;
-import org.eclipse.net4j.util.tests.QueueWorkerWorkSerializerTest;
-import org.eclipse.net4j.util.tests.ReferenceValueMapTest;
-import org.eclipse.net4j.util.tests.SecurityTest;
-import org.eclipse.net4j.util.tests.SortedFileMapTest;
-import org.eclipse.net4j.util.tests.StringCompressorTest;
-import org.eclipse.net4j.util.tests.SynchronizingCorrelatorTest;
-import org.eclipse.net4j.util.tests.UUIDGeneratorTest;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author Eike Stepper
- */
-public class AllTests
-{
- public static Test suite()
- {
- TestSuite suite = new TestSuite("Tests for Net4j"); //$NON-NLS-1$
- suite.addTestSuite(UUIDGeneratorTest.class);
- suite.addTestSuite(MultiMapTest.class);
- suite.addTestSuite(SortedFileMapTest.class);
- suite.addTestSuite(SynchronizingCorrelatorTest.class);
- suite.addTestSuite(ReferenceValueMapTest.class);
- suite.addTestSuite(BufferPoolTest.class);
- suite.addTestSuite(ExtendedIOTest.class);
- suite.addTestSuite(StringCompressorTest.class);
- suite.addTestSuite(ChannelTest.JVM.class);
- suite.addTestSuite(ChannelTest.TCP.class);
- // suite.addTestSuite(ChannelTest.SSL.class);
- suite.addTestSuite(TCPConnectorTest.TCP.class);
- // suite.addTestSuite(TCPConnectorTest.SSL.class);
- suite.addTestSuite(TransportTest.JVM.class);
- suite.addTestSuite(TransportTest.TCP.class);
- // suite.addTestSuite(TransportTest.SSL.class);
- suite.addTestSuite(SignalTest.TCP.class);
- // suite.addTestSuite(SignalTest.SSL.class);
- suite.addTestSuite(SignalMonitorTest.TCP.class);
- // suite.addTestSuite(SignalMonitorTest.SSL.class);
- suite.addTestSuite(ExceptionTest.TCP.class);
- // suite.addTestSuite(ExceptionTest.SSL.class);
- suite.addTestSuite(SecurityTest.class);
- suite.addTestSuite(QueueWorkerWorkSerializerTest.class);
- suite.addTestSuite(ExpectedIOTest.class);
-
- // Bugzillas
- suite.addTestSuite(Bugzilla_241463_Test.TCP.class);
- // suite.addTestSuite(Bugzilla_241463_Test.SSL.class);
- suite.addTestSuite(Bugzilla_262875_Test.class);
-
- // Defs
- // suite.addTestSuite(TestDefTest.class);
- // suite.addTestSuite(TCPAcceptorDefImplTest.class);
- // suite.addTestSuite(TCPConnectorDefImplTest.class);
- // suite.addTestSuite(JVMAcceptorDefImplTest.class);
- // suite.addTestSuite(JVMConnectorDefImplTest.class);
-
- return suite;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.tests.bugzilla.Bugzilla_241463_Test;
+import org.eclipse.net4j.tests.bugzilla.Bugzilla_262875_Test;
+import org.eclipse.net4j.util.tests.ExpectedIOTest;
+import org.eclipse.net4j.util.tests.ExtendedIOTest;
+import org.eclipse.net4j.util.tests.MultiMapTest;
+import org.eclipse.net4j.util.tests.QueueWorkerWorkSerializerTest;
+import org.eclipse.net4j.util.tests.ReferenceValueMapTest;
+import org.eclipse.net4j.util.tests.SecurityTest;
+import org.eclipse.net4j.util.tests.SortedFileMapTest;
+import org.eclipse.net4j.util.tests.StringCompressorTest;
+import org.eclipse.net4j.util.tests.SynchronizingCorrelatorTest;
+import org.eclipse.net4j.util.tests.UUIDGeneratorTest;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Eike Stepper
+ */
+public class AllTests
+{
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("Tests for Net4j"); //$NON-NLS-1$
+ suite.addTestSuite(UUIDGeneratorTest.class);
+ suite.addTestSuite(MultiMapTest.class);
+ suite.addTestSuite(SortedFileMapTest.class);
+ suite.addTestSuite(SynchronizingCorrelatorTest.class);
+ suite.addTestSuite(ReferenceValueMapTest.class);
+ suite.addTestSuite(BufferPoolTest.class);
+ suite.addTestSuite(ExtendedIOTest.class);
+ suite.addTestSuite(StringCompressorTest.class);
+ suite.addTestSuite(ChannelTest.JVM.class);
+ suite.addTestSuite(ChannelTest.TCP.class);
+ // suite.addTestSuite(ChannelTest.SSL.class);
+ suite.addTestSuite(TCPConnectorTest.TCP.class);
+ // suite.addTestSuite(TCPConnectorTest.SSL.class);
+ suite.addTestSuite(TransportTest.JVM.class);
+ suite.addTestSuite(TransportTest.TCP.class);
+ // suite.addTestSuite(TransportTest.SSL.class);
+ suite.addTestSuite(SignalTest.TCP.class);
+ // suite.addTestSuite(SignalTest.SSL.class);
+ suite.addTestSuite(SignalMonitorTest.TCP.class);
+ // suite.addTestSuite(SignalMonitorTest.SSL.class);
+ suite.addTestSuite(ExceptionTest.TCP.class);
+ // suite.addTestSuite(ExceptionTest.SSL.class);
+ suite.addTestSuite(SecurityTest.class);
+ suite.addTestSuite(QueueWorkerWorkSerializerTest.class);
+ suite.addTestSuite(ExpectedIOTest.class);
+
+ // Bugzillas
+ suite.addTestSuite(Bugzilla_241463_Test.TCP.class);
+ // suite.addTestSuite(Bugzilla_241463_Test.SSL.class);
+ suite.addTestSuite(Bugzilla_262875_Test.class);
+
+ // Defs
+ // suite.addTestSuite(TestDefTest.class);
+ // suite.addTestSuite(TCPAcceptorDefImplTest.class);
+ // suite.addTestSuite(TCPConnectorDefImplTest.class);
+ // suite.addTestSuite(JVMAcceptorDefImplTest.class);
+ // suite.addTestSuite(JVMConnectorDefImplTest.class);
+
+ return suite;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ChannelTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ChannelTest.java
index 29f6ed8f14..4fef07cff9 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ChannelTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ChannelTest.java
@@ -1,371 +1,371 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Teerawat Chaiyakijpichet (No Magic Asia Ltd.) - SSL
- */
-package org.eclipse.net4j.tests;
-
-import org.eclipse.net4j.channel.IChannel;
-import org.eclipse.net4j.tests.data.TinyData;
-import org.eclipse.net4j.tests.signal.ArrayRequest;
-import org.eclipse.net4j.tests.signal.TestSignalProtocol;
-import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
-import org.eclipse.net4j.util.concurrent.MonitoredThread;
-import org.eclipse.net4j.util.concurrent.MonitoredThread.MultiThreadMonitor;
-import org.eclipse.net4j.util.io.IOUtil;
-import org.eclipse.net4j.util.lifecycle.ILifecycle;
-import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
-
-import org.eclipse.spi.net4j.InternalConnector;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public abstract class ChannelTest extends AbstractProtocolTest
-{
- private static final long TIMEOUT = 20000;
-
- private static final int THREADS = 40;
-
- private List<TestSignalProtocol> protocols;
-
- public ChannelTest()
- {
- }
-
- public void testSingleThreadNoData() throws Exception
- {
- final LatchTimeOuter timeOuter = new LatchTimeOuter(4);
- final DeactivationListener deactivationListener = new DeactivationListener()
- {
- @Override
- protected void onDeactivated(ILifecycle lifecycle)
- {
- super.onDeactivated(lifecycle);
- timeOuter.countDown();
- }
- };
-
- TestSignalProtocol protocol = openTestSignalProtocol();
- protocol.addListener(deactivationListener);
- assertActive(protocol);
-
- IChannel channel = protocol.getChannel();
- channel.addListener(deactivationListener);
- assertActive(channel);
-
- InternalConnector serverConnector = (InternalConnector)getAcceptor().getAcceptedConnectors()[0];
- Collection<IChannel> serverChannels = serverConnector.getChannels();
- assertEquals(1, serverChannels.size());
-
- IChannel serverChannel = serverChannels.iterator().next();
- serverChannel.addListener(deactivationListener);
- assertActive(serverChannel);
-
- TestSignalProtocol serverProtocol = (TestSignalProtocol)serverChannel.getReceiveHandler();
- serverProtocol.addListener(deactivationListener);
- assertActive(serverProtocol);
-
- protocol.close();
- assertInactive(protocol);
- assertInactive(channel);
-
- assertInactive(serverChannel);
- assertInactive(serverProtocol);
- assertEquals(0, serverConnector.getChannels().size());
-
- timeOuter.assertNoTimeOut();
- Set<ILifecycle> deactivatedSet = deactivationListener.getDeactivatedSet();
- assertEquals(true, deactivatedSet.contains(channel));
- assertEquals(true, deactivatedSet.contains(protocol));
- assertEquals(true, deactivatedSet.contains(serverChannel));
- assertEquals(true, deactivatedSet.contains(serverProtocol));
-
- synchronized (protocols)
- {
- assertEquals(0, protocols.size());
- }
- }
-
- public void testSingleThreadNoData100() throws Exception
- {
- disableConsole();
- for (int i = 0; i < 100; i++)
- {
- IOUtil.OUT().println(Thread.currentThread().getName() + ": " + i); //$NON-NLS-1$
- testSingleThreadNoData();
- }
- }
-
- public void testSingleThreadTinyData() throws Exception
- {
- TestSignalProtocol protocol = openTestSignalProtocol();
- assertActive(protocol);
-
- byte[] data = TinyData.getBytes();
- byte[] result = new ArrayRequest(protocol, data).send();
- assertEquals(true, Arrays.equals(data, result));
-
- protocol.close();
- assertInactive(protocol);
- }
-
- public void testSingleThreadTinyData100() throws Exception
- {
- disableConsole();
- for (int i = 0; i < 100; i++)
- {
- IOUtil.OUT().println(Thread.currentThread().getName() + ": " + i); //$NON-NLS-1$
- testSingleThreadTinyData();
- }
- }
-
- public void testMultiThreadNoData() throws Exception
- {
- MultiThreadMonitor threadMonitor = new MultiThreadMonitor(TIMEOUT);
- for (int i = 0; i < THREADS; i++)
- {
- threadMonitor.addThread(new MonitoredThread("TEST-THREAD-" + i, threadMonitor) //$NON-NLS-1$
- {
- @Override
- protected void doRun() throws Exception
- {
- for (int i = 0; i < 100; i++)
- {
- IOUtil.OUT().println(Thread.currentThread().getName() + ": " + i); //$NON-NLS-1$
- TestSignalProtocol protocol = openTestSignalProtocol();
- assertActive(protocol);
-
- protocol.close();
- assertInactive(protocol);
- heartBeat();
- }
- }
- });
- }
-
- disableConsole();
- threadMonitor.run();
- enableConsole();
- }
-
- public void testMultiThreadTinyData() throws Exception
- {
- MultiThreadMonitor threadMonitor = new MultiThreadMonitor(TIMEOUT);
-
- for (int i = 0; i < THREADS; i++)
- {
- threadMonitor.addThread(new MonitoredThread("TEST-THREAD-" + i, threadMonitor) //$NON-NLS-1$
- {
- @Override
- protected void doRun() throws Exception
- {
- for (int i = 0; i < 100; i++)
- {
- IOUtil.OUT().println(Thread.currentThread().getName() + ": " + i); //$NON-NLS-1$
- TestSignalProtocol protocol = openTestSignalProtocol();
- assertActive(protocol);
- heartBeat();
-
- byte[] data = TinyData.getBytes();
- byte[] result = new ArrayRequest(protocol, data).send();
- assertEquals(true, Arrays.equals(data, result));
- heartBeat();
-
- protocol.close();
- assertInactive(protocol);
- heartBeat();
- }
- }
- });
- }
-
- disableConsole();
- threadMonitor.run();
- enableConsole();
- }
-
- public void testMultiThreadDataLoop() throws Exception
- {
- MultiThreadMonitor threadMonitor = new MultiThreadMonitor(TIMEOUT, 10L);
- for (int i = 0; i < THREADS; i++)
- {
- threadMonitor.addThread(new MonitoredThread("TEST-THREAD-" + i, threadMonitor) //$NON-NLS-1$
- {
- @Override
- protected void doRun() throws Exception
- {
- for (int i = 0; i < 10; i++)
- {
- long start = System.currentTimeMillis();
- TestSignalProtocol protocol = openTestSignalProtocol();
- assertActive(protocol);
-
- for (int j = 0; j < 50; j++)
- {
- byte[] data = TinyData.getBytes();
- byte[] result = new ArrayRequest(protocol, data).send();
- assertEquals(true, Arrays.equals(data, result));
-
- heartBeat();
- ConcurrencyUtil.sleep(10L);
- }
-
- protocol.close();
- assertInactive(protocol);
- long stop = System.currentTimeMillis();
- IOUtil.OUT().println(Thread.currentThread().getName() + ": " + i + " (" + (stop - start) + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- }
- });
- }
-
- disableConsole();
- threadMonitor.run();
- enableConsole();
- }
-
- @Override
- protected abstract boolean useJVMTransport();
-
- @Override
- protected void doSetUp() throws Exception
- {
- super.doSetUp();
- startTransport();
- getConnector().setOpenChannelTimeout(TIMEOUT);
- protocols = new ArrayList<TestSignalProtocol>();
- }
-
- @Override
- protected void doTearDown() throws Exception
- {
- for (TestSignalProtocol protocol : protocols)
- {
- protocol.close();
- }
-
- protocols = null;
-
- getConnector().close();
- super.doTearDown();
- }
-
- private TestSignalProtocol openTestSignalProtocol()
- {
- final TestSignalProtocol protocol = new TestSignalProtocol(getConnector());
- synchronized (protocols)
- {
- protocols.add(protocol);
- protocol.getChannel().addListener(new LifecycleEventAdapter()
- {
- @Override
- protected void onDeactivated(ILifecycle lifecycle)
- {
- synchronized (protocols)
- {
- protocol.getChannel().removeListener(this);
- boolean removed = protocols.remove(protocol);
- assertEquals(true, removed);
- }
- }
- });
- }
-
- return protocol;
- }
-
- /**
- * @author Eike Stepper
- */
- private static class DeactivationListener extends LifecycleEventAdapter
- {
- private Set<ILifecycle> deactivatedSet = new HashSet<ILifecycle>();
-
- public DeactivationListener()
- {
- }
-
- public Set<ILifecycle> getDeactivatedSet()
- {
- return deactivatedSet;
- }
-
- @Override
- protected void onDeactivated(ILifecycle lifecycle)
- {
- synchronized (deactivatedSet)
- {
- deactivatedSet.add(lifecycle);
- deactivatedSet.notifyAll();
- }
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static final class TCP extends ChannelTest
- {
- @Override
- protected boolean useJVMTransport()
- {
- return false;
- }
-
- @Override
- protected boolean useSSLTransport()
- {
- return false;
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static final class JVM extends ChannelTest
- {
- @Override
- protected boolean useJVMTransport()
- {
- return true;
- }
-
- @Override
- protected boolean useSSLTransport()
- {
- return false;
- }
- }
-
- /**
- * @author Teerawat Chaiyakijpichet (No Magic Asia Ltd.)
- */
- public static final class SSL extends ChannelTest
- {
- @Override
- protected boolean useJVMTransport()
- {
- return false;
- }
-
- @Override
- protected boolean useSSLTransport()
- {
- return true;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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
+ * Teerawat Chaiyakijpichet (No Magic Asia Ltd.) - SSL
+ */
+package org.eclipse.net4j.tests;
+
+import org.eclipse.net4j.channel.IChannel;
+import org.eclipse.net4j.tests.data.TinyData;
+import org.eclipse.net4j.tests.signal.ArrayRequest;
+import org.eclipse.net4j.tests.signal.TestSignalProtocol;
+import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
+import org.eclipse.net4j.util.concurrent.MonitoredThread;
+import org.eclipse.net4j.util.concurrent.MonitoredThread.MultiThreadMonitor;
+import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.net4j.util.lifecycle.ILifecycle;
+import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
+
+import org.eclipse.spi.net4j.InternalConnector;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class ChannelTest extends AbstractProtocolTest
+{
+ private static final long TIMEOUT = 20000;
+
+ private static final int THREADS = 40;
+
+ private List<TestSignalProtocol> protocols;
+
+ public ChannelTest()
+ {
+ }
+
+ public void testSingleThreadNoData() throws Exception
+ {
+ final LatchTimeOuter timeOuter = new LatchTimeOuter(4);
+ final DeactivationListener deactivationListener = new DeactivationListener()
+ {
+ @Override
+ protected void onDeactivated(ILifecycle lifecycle)
+ {
+ super.onDeactivated(lifecycle);
+ timeOuter.countDown();
+ }
+ };
+
+ TestSignalProtocol protocol = openTestSignalProtocol();
+ protocol.addListener(deactivationListener);
+ assertActive(protocol);
+
+ IChannel channel = protocol.getChannel();
+ channel.addListener(deactivationListener);
+ assertActive(channel);
+
+ InternalConnector serverConnector = (InternalConnector)getAcceptor().getAcceptedConnectors()[0];
+ Collection<IChannel> serverChannels = serverConnector.getChannels();
+ assertEquals(1, serverChannels.size());
+
+ IChannel serverChannel = serverChannels.iterator().next();
+ serverChannel.addListener(deactivationListener);
+ assertActive(serverChannel);
+
+ TestSignalProtocol serverProtocol = (TestSignalProtocol)serverChannel.getReceiveHandler();
+ serverProtocol.addListener(deactivationListener);
+ assertActive(serverProtocol);
+
+ protocol.close();
+ assertInactive(protocol);
+ assertInactive(channel);
+
+ assertInactive(serverChannel);
+ assertInactive(serverProtocol);
+ assertEquals(0, serverConnector.getChannels().size());
+
+ timeOuter.assertNoTimeOut();
+ Set<ILifecycle> deactivatedSet = deactivationListener.getDeactivatedSet();
+ assertEquals(true, deactivatedSet.contains(channel));
+ assertEquals(true, deactivatedSet.contains(protocol));
+ assertEquals(true, deactivatedSet.contains(serverChannel));
+ assertEquals(true, deactivatedSet.contains(serverProtocol));
+
+ synchronized (protocols)
+ {
+ assertEquals(0, protocols.size());
+ }
+ }
+
+ public void testSingleThreadNoData100() throws Exception
+ {
+ disableConsole();
+ for (int i = 0; i < 100; i++)
+ {
+ IOUtil.OUT().println(Thread.currentThread().getName() + ": " + i); //$NON-NLS-1$
+ testSingleThreadNoData();
+ }
+ }
+
+ public void testSingleThreadTinyData() throws Exception
+ {
+ TestSignalProtocol protocol = openTestSignalProtocol();
+ assertActive(protocol);
+
+ byte[] data = TinyData.getBytes();
+ byte[] result = new ArrayRequest(protocol, data).send();
+ assertEquals(true, Arrays.equals(data, result));
+
+ protocol.close();
+ assertInactive(protocol);
+ }
+
+ public void testSingleThreadTinyData100() throws Exception
+ {
+ disableConsole();
+ for (int i = 0; i < 100; i++)
+ {
+ IOUtil.OUT().println(Thread.currentThread().getName() + ": " + i); //$NON-NLS-1$
+ testSingleThreadTinyData();
+ }
+ }
+
+ public void testMultiThreadNoData() throws Exception
+ {
+ MultiThreadMonitor threadMonitor = new MultiThreadMonitor(TIMEOUT);
+ for (int i = 0; i < THREADS; i++)
+ {
+ threadMonitor.addThread(new MonitoredThread("TEST-THREAD-" + i, threadMonitor) //$NON-NLS-1$
+ {
+ @Override
+ protected void doRun() throws Exception
+ {
+ for (int i = 0; i < 100; i++)
+ {
+ IOUtil.OUT().println(Thread.currentThread().getName() + ": " + i); //$NON-NLS-1$
+ TestSignalProtocol protocol = openTestSignalProtocol();
+ assertActive(protocol);
+
+ protocol.close();
+ assertInactive(protocol);
+ heartBeat();
+ }
+ }
+ });
+ }
+
+ disableConsole();
+ threadMonitor.run();
+ enableConsole();
+ }
+
+ public void testMultiThreadTinyData() throws Exception
+ {
+ MultiThreadMonitor threadMonitor = new MultiThreadMonitor(TIMEOUT);
+
+ for (int i = 0; i < THREADS; i++)
+ {
+ threadMonitor.addThread(new MonitoredThread("TEST-THREAD-" + i, threadMonitor) //$NON-NLS-1$
+ {
+ @Override
+ protected void doRun() throws Exception
+ {
+ for (int i = 0; i < 100; i++)
+ {
+ IOUtil.OUT().println(Thread.currentThread().getName() + ": " + i); //$NON-NLS-1$
+ TestSignalProtocol protocol = openTestSignalProtocol();
+ assertActive(protocol);
+ heartBeat();
+
+ byte[] data = TinyData.getBytes();
+ byte[] result = new ArrayRequest(protocol, data).send();
+ assertEquals(true, Arrays.equals(data, result));
+ heartBeat();
+
+ protocol.close();
+ assertInactive(protocol);
+ heartBeat();
+ }
+ }
+ });
+ }
+
+ disableConsole();
+ threadMonitor.run();
+ enableConsole();
+ }
+
+ public void testMultiThreadDataLoop() throws Exception
+ {
+ MultiThreadMonitor threadMonitor = new MultiThreadMonitor(TIMEOUT, 10L);
+ for (int i = 0; i < THREADS; i++)
+ {
+ threadMonitor.addThread(new MonitoredThread("TEST-THREAD-" + i, threadMonitor) //$NON-NLS-1$
+ {
+ @Override
+ protected void doRun() throws Exception
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ long start = System.currentTimeMillis();
+ TestSignalProtocol protocol = openTestSignalProtocol();
+ assertActive(protocol);
+
+ for (int j = 0; j < 50; j++)
+ {
+ byte[] data = TinyData.getBytes();
+ byte[] result = new ArrayRequest(protocol, data).send();
+ assertEquals(true, Arrays.equals(data, result));
+
+ heartBeat();
+ ConcurrencyUtil.sleep(10L);
+ }
+
+ protocol.close();
+ assertInactive(protocol);
+ long stop = System.currentTimeMillis();
+ IOUtil.OUT().println(Thread.currentThread().getName() + ": " + i + " (" + (stop - start) + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
+ });
+ }
+
+ disableConsole();
+ threadMonitor.run();
+ enableConsole();
+ }
+
+ @Override
+ protected abstract boolean useJVMTransport();
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+ startTransport();
+ getConnector().setOpenChannelTimeout(TIMEOUT);
+ protocols = new ArrayList<TestSignalProtocol>();
+ }
+
+ @Override
+ protected void doTearDown() throws Exception
+ {
+ for (TestSignalProtocol protocol : protocols)
+ {
+ protocol.close();
+ }
+
+ protocols = null;
+
+ getConnector().close();
+ super.doTearDown();
+ }
+
+ private TestSignalProtocol openTestSignalProtocol()
+ {
+ final TestSignalProtocol protocol = new TestSignalProtocol(getConnector());
+ synchronized (protocols)
+ {
+ protocols.add(protocol);
+ protocol.getChannel().addListener(new LifecycleEventAdapter()
+ {
+ @Override
+ protected void onDeactivated(ILifecycle lifecycle)
+ {
+ synchronized (protocols)
+ {
+ protocol.getChannel().removeListener(this);
+ boolean removed = protocols.remove(protocol);
+ assertEquals(true, removed);
+ }
+ }
+ });
+ }
+
+ return protocol;
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static class DeactivationListener extends LifecycleEventAdapter
+ {
+ private Set<ILifecycle> deactivatedSet = new HashSet<ILifecycle>();
+
+ public DeactivationListener()
+ {
+ }
+
+ public Set<ILifecycle> getDeactivatedSet()
+ {
+ return deactivatedSet;
+ }
+
+ @Override
+ protected void onDeactivated(ILifecycle lifecycle)
+ {
+ synchronized (deactivatedSet)
+ {
+ deactivatedSet.add(lifecycle);
+ deactivatedSet.notifyAll();
+ }
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class TCP extends ChannelTest
+ {
+ @Override
+ protected boolean useJVMTransport()
+ {
+ return false;
+ }
+
+ @Override
+ protected boolean useSSLTransport()
+ {
+ return false;
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class JVM extends ChannelTest
+ {
+ @Override
+ protected boolean useJVMTransport()
+ {
+ return true;
+ }
+
+ @Override
+ protected boolean useSSLTransport()
+ {
+ return false;
+ }
+ }
+
+ /**
+ * @author Teerawat Chaiyakijpichet (No Magic Asia Ltd.)
+ */
+ public static final class SSL extends ChannelTest
+ {
+ @Override
+ protected boolean useJVMTransport()
+ {
+ return false;
+ }
+
+ @Override
+ protected boolean useSSLTransport()
+ {
+ return true;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ExceptionTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ExceptionTest.java
index 11f64315a5..82d18b63d2 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ExceptionTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/ExceptionTest.java
@@ -1,167 +1,167 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Teerawat Chaiyakijpichet (No Magic Asia Ltd.) - SSL
- */
-package org.eclipse.net4j.tests;
-
-import org.eclipse.net4j.signal.RemoteException;
-import org.eclipse.net4j.tests.signal.ExceptionRequest;
-import org.eclipse.net4j.tests.signal.TestSignalProtocol;
-import org.eclipse.net4j.util.io.IOUtil;
-
-import java.io.IOException;
-import java.rmi.AlreadyBoundException;
-
-/**
- * @author Eike Stepper
- */
-public class ExceptionTest extends AbstractProtocolTest
-{
- public ExceptionTest()
- {
- }
-
- public void testExceptionInIRequesting() throws Exception
- {
- exceptionInPhase(1, false);
- }
-
- public void testExceptionInIndicating() throws Exception
- {
- exceptionInPhase(2, false);
- }
-
- public void testExceptionInResponding() throws Exception
- {
- exceptionInPhase(3, false);
- }
-
- public void testExceptionInConfirming() throws Exception
- {
- exceptionInPhase(4, false);
- }
-
- public void testIOExceptionInIRequesting() throws Exception
- {
- exceptionInPhase(1, true);
- }
-
- public void testIOExceptionInIndicating() throws Exception
- {
- exceptionInPhase(2, true);
- }
-
- public void testIOExceptionInResponding() throws Exception
- {
- exceptionInPhase(3, true);
- }
-
- public void testIOExceptionInConfirming() throws Exception
- {
- exceptionInPhase(4, true);
- }
-
- private void exceptionInPhase(int phase, boolean ioProblem) throws Exception
- {
- startTransport();
- TestSignalProtocol protocol = new TestSignalProtocol(getConnector());
-
- try
- {
- new ExceptionRequest(protocol, phase, ioProblem).send();
- fail("Exception expected"); //$NON-NLS-1$
- }
- catch (Exception ex)
- {
- IOUtil.print(ex);
- if (ioProblem)
- {
- IOException ioe = null;
- if (phase == 2 || phase == 3)
- {
- if (ex instanceof RemoteException)
- {
- assertEquals(((RemoteException)ex).whileResponding(), phase == 3);
- ioe = (IOException)ex.getCause();
- }
- else
- {
- fail("RemoteException expected"); //$NON-NLS-1$
- }
- }
- else
- {
- ioe = (IOException)ex;
- }
-
- assertEquals(TestSignalProtocol.SIMULATED_EXCEPTION, ioe.getMessage());
- }
- else
- {
- ClassNotFoundException cnfe = null;
- if (phase == 2 || phase == 3)
- {
- if (ex instanceof RemoteException)
- {
- assertEquals(((RemoteException)ex).whileResponding(), phase == 3);
- cnfe = (ClassNotFoundException)ex.getCause();
- }
- else
- {
- fail("RemoteException expected"); //$NON-NLS-1$
- }
- }
- else
- {
- cnfe = (ClassNotFoundException)ex;
- }
-
- AlreadyBoundException abe = (AlreadyBoundException)cnfe.getCause();
- assertEquals(TestSignalProtocol.SIMULATED_EXCEPTION, abe.getMessage());
- }
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static final class TCP extends ExceptionTest
- {
- @Override
- protected boolean useJVMTransport()
- {
- return false;
- }
-
- @Override
- protected boolean useSSLTransport()
- {
- return false;
- }
- }
-
- /**
- * @author Teerawat Chaiyakijpichet (No Magic Asia Ltd.)
- */
- public static final class SSL extends ExceptionTest
- {
- @Override
- protected boolean useJVMTransport()
- {
- return false;
- }
-
- @Override
- protected boolean useSSLTransport()
- {
- return true;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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
+ * Teerawat Chaiyakijpichet (No Magic Asia Ltd.) - SSL
+ */
+package org.eclipse.net4j.tests;
+
+import org.eclipse.net4j.signal.RemoteException;
+import org.eclipse.net4j.tests.signal.ExceptionRequest;
+import org.eclipse.net4j.tests.signal.TestSignalProtocol;
+import org.eclipse.net4j.util.io.IOUtil;
+
+import java.io.IOException;
+import java.rmi.AlreadyBoundException;
+
+/**
+ * @author Eike Stepper
+ */
+public class ExceptionTest extends AbstractProtocolTest
+{
+ public ExceptionTest()
+ {
+ }
+
+ public void testExceptionInIRequesting() throws Exception
+ {
+ exceptionInPhase(1, false);
+ }
+
+ public void testExceptionInIndicating() throws Exception
+ {
+ exceptionInPhase(2, false);
+ }
+
+ public void testExceptionInResponding() throws Exception
+ {
+ exceptionInPhase(3, false);
+ }
+
+ public void testExceptionInConfirming() throws Exception
+ {
+ exceptionInPhase(4, false);
+ }
+
+ public void testIOExceptionInIRequesting() throws Exception
+ {
+ exceptionInPhase(1, true);
+ }
+
+ public void testIOExceptionInIndicating() throws Exception
+ {
+ exceptionInPhase(2, true);
+ }
+
+ public void testIOExceptionInResponding() throws Exception
+ {
+ exceptionInPhase(3, true);
+ }
+
+ public void testIOExceptionInConfirming() throws Exception
+ {
+ exceptionInPhase(4, true);
+ }
+
+ private void exceptionInPhase(int phase, boolean ioProblem) throws Exception
+ {
+ startTransport();
+ TestSignalProtocol protocol = new TestSignalProtocol(getConnector());
+
+ try
+ {
+ new ExceptionRequest(protocol, phase, ioProblem).send();
+ fail("Exception expected"); //$NON-NLS-1$
+ }
+ catch (Exception ex)
+ {
+ IOUtil.print(ex);
+ if (ioProblem)
+ {
+ IOException ioe = null;
+ if (phase == 2 || phase == 3)
+ {
+ if (ex instanceof RemoteException)
+ {
+ assertEquals(((RemoteException)ex).whileResponding(), phase == 3);
+ ioe = (IOException)ex.getCause();
+ }
+ else
+ {
+ fail("RemoteException expected"); //$NON-NLS-1$
+ }
+ }
+ else
+ {
+ ioe = (IOException)ex;
+ }
+
+ assertEquals(TestSignalProtocol.SIMULATED_EXCEPTION, ioe.getMessage());
+ }
+ else
+ {
+ ClassNotFoundException cnfe = null;
+ if (phase == 2 || phase == 3)
+ {
+ if (ex instanceof RemoteException)
+ {
+ assertEquals(((RemoteException)ex).whileResponding(), phase == 3);
+ cnfe = (ClassNotFoundException)ex.getCause();
+ }
+ else
+ {
+ fail("RemoteException expected"); //$NON-NLS-1$
+ }
+ }
+ else
+ {
+ cnfe = (ClassNotFoundException)ex;
+ }
+
+ AlreadyBoundException abe = (AlreadyBoundException)cnfe.getCause();
+ assertEquals(TestSignalProtocol.SIMULATED_EXCEPTION, abe.getMessage());
+ }
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class TCP extends ExceptionTest
+ {
+ @Override
+ protected boolean useJVMTransport()
+ {
+ return false;
+ }
+
+ @Override
+ protected boolean useSSLTransport()
+ {
+ return false;
+ }
+ }
+
+ /**
+ * @author Teerawat Chaiyakijpichet (No Magic Asia Ltd.)
+ */
+ public static final class SSL extends ExceptionTest
+ {
+ @Override
+ protected boolean useJVMTransport()
+ {
+ return false;
+ }
+
+ @Override
+ protected boolean useSSLTransport()
+ {
+ return true;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SelectorTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SelectorTest.java
index bed8237abb..866236ba6a 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SelectorTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SelectorTest.java
@@ -1,37 +1,37 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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 java.nio.channels.Selector;
-import java.nio.channels.spi.SelectorProvider;
-
-import junit.framework.TestCase;
-
-/**
- * @author Eike Stepper
- */
-public class SelectorTest extends TestCase
-{
- public void testOpen() throws Exception
- {
- SelectorProvider provider = SelectorProvider.provider();
- System.out.println(provider.getClass().getName());
- for (int i = 0; i < 5; i++)
- {
- long start = System.currentTimeMillis();
- Selector selector = provider.openSelector();
- long duration = System.currentTimeMillis() - start;
-
- System.out.println(duration);
- selector.close();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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 java.nio.channels.Selector;
+import java.nio.channels.spi.SelectorProvider;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Eike Stepper
+ */
+public class SelectorTest extends TestCase
+{
+ public void testOpen() throws Exception
+ {
+ SelectorProvider provider = SelectorProvider.provider();
+ System.out.println(provider.getClass().getName());
+ for (int i = 0; i < 5; i++)
+ {
+ long start = System.currentTimeMillis();
+ Selector selector = provider.openSelector();
+ long duration = System.currentTimeMillis() - start;
+
+ System.out.println(duration);
+ selector.close();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalMonitorTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalMonitorTest.java
index 5d5440b096..7ccceb9805 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalMonitorTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalMonitorTest.java
@@ -1,218 +1,218 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Teerawat Chaiyakijpichet (No Magic Asia Ltd.) - SSL
- */
-package org.eclipse.net4j.tests;
-
-import org.eclipse.net4j.signal.IndicationWithMonitoring;
-import org.eclipse.net4j.signal.RequestWithMonitoring;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.signal.SignalReactor;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.factory.ProductCreationException;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import org.eclipse.net4j.util.om.monitor.Monitor;
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-import org.eclipse.spi.net4j.ServerProtocolFactory;
-
-/**
- * @author Eike Stepper
- */
-public class SignalMonitorTest extends AbstractTransportTest
-{
- public static final String PROTOCOL_TYPE = "protocol"; //$NON-NLS-1$
-
- public static final short SIGNAL_ID = 1;
-
- @Override
- protected IManagedContainer createContainer()
- {
- IManagedContainer container = super.createContainer();
- container.registerFactory(new ServerProtocolFactory(PROTOCOL_TYPE)
- {
- public Object create(String description) throws ProductCreationException
- {
- return new SignalProtocol<Object>(PROTOCOL_TYPE)
- {
- @Override
- protected SignalReactor createSignalReactor(short signalID)
- {
- switch (signalID)
- {
- case SIGNAL_ID:
- return new IndicationWithMonitoring(this, SIGNAL_ID)
- {
- @Override
- protected void indicating(ExtendedDataInputStream in, OMMonitor monitor) throws Exception
- {
- monitor.begin(1 + 100);
-
- try
- {
- in.readBoolean();
- monitor.worked();
-
- for (int i = 0; i < 100; i++)
- {
- sleep(100);
- monitor.worked();
- }
- }
- finally
- {
- monitor.done();
- }
- }
-
- @Override
- protected void responding(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception
- {
- monitor.begin();
-
- try
- {
- out.writeBoolean(true);
- monitor.worked();
- }
- finally
- {
- monitor.done();
- }
- }
- };
-
- default:
- return super.createSignalReactor(signalID);
- }
- }
- };
- }
- });
-
- return container;
- }
-
- public void testMonitorProgress() throws Exception
- {
- startTransport();
- SignalProtocol<Object> protocol = new ClientProtocol();
- protocol.open(getConnector());
-
- RequestWithMonitoring<Boolean> request = new RequestWithMonitoring<Boolean>(protocol, SIGNAL_ID)
- {
- @Override
- protected void requesting(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception
- {
- monitor.begin();
-
- try
- {
- out.writeBoolean(true);
- monitor.worked();
- }
- finally
- {
- monitor.done();
- }
- }
-
- @Override
- protected Boolean confirming(ExtendedDataInputStream in, OMMonitor monitor) throws Exception
- {
- monitor.begin();
-
- try
- {
- boolean result = in.readBoolean();
- monitor.worked();
- return result;
- }
- finally
- {
- monitor.done();
- }
- }
- };
-
- request.send(4000L, new TestMonitor());
- sleep(200);
- protocol.close();
- }
-
- /**
- * @author Eike Stepper
- */
- public static final class ClientProtocol extends SignalProtocol<Object>
- {
- public ClientProtocol()
- {
- super(PROTOCOL_TYPE);
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class TestMonitor extends Monitor
- {
- @Override
- public OMMonitor begin(double totalWork)
- {
- super.begin(totalWork);
- System.out.println("totalWork: " + getTotalWork()); //$NON-NLS-1$
- return this;
- }
-
- @Override
- public void worked(double work)
- {
- super.worked(work);
- System.out.println("work: " + getWork()); //$NON-NLS-1$
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static final class TCP extends SignalMonitorTest
- {
- @Override
- protected boolean useJVMTransport()
- {
- return false;
- }
-
- @Override
- protected boolean useSSLTransport()
- {
- return false;
- }
- }
-
- /**
- * @author Teerawat Chaiyakijpichet (No Magic Asia Ltd.)
- */
- public static final class SSL extends SignalMonitorTest
- {
- @Override
- protected boolean useJVMTransport()
- {
- return false;
- }
-
- @Override
- protected boolean useSSLTransport()
- {
- return true;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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
+ * Teerawat Chaiyakijpichet (No Magic Asia Ltd.) - SSL
+ */
+package org.eclipse.net4j.tests;
+
+import org.eclipse.net4j.signal.IndicationWithMonitoring;
+import org.eclipse.net4j.signal.RequestWithMonitoring;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.signal.SignalReactor;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.factory.ProductCreationException;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.net4j.util.om.monitor.Monitor;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+
+import org.eclipse.spi.net4j.ServerProtocolFactory;
+
+/**
+ * @author Eike Stepper
+ */
+public class SignalMonitorTest extends AbstractTransportTest
+{
+ public static final String PROTOCOL_TYPE = "protocol"; //$NON-NLS-1$
+
+ public static final short SIGNAL_ID = 1;
+
+ @Override
+ protected IManagedContainer createContainer()
+ {
+ IManagedContainer container = super.createContainer();
+ container.registerFactory(new ServerProtocolFactory(PROTOCOL_TYPE)
+ {
+ public Object create(String description) throws ProductCreationException
+ {
+ return new SignalProtocol<Object>(PROTOCOL_TYPE)
+ {
+ @Override
+ protected SignalReactor createSignalReactor(short signalID)
+ {
+ switch (signalID)
+ {
+ case SIGNAL_ID:
+ return new IndicationWithMonitoring(this, SIGNAL_ID)
+ {
+ @Override
+ protected void indicating(ExtendedDataInputStream in, OMMonitor monitor) throws Exception
+ {
+ monitor.begin(1 + 100);
+
+ try
+ {
+ in.readBoolean();
+ monitor.worked();
+
+ for (int i = 0; i < 100; i++)
+ {
+ sleep(100);
+ monitor.worked();
+ }
+ }
+ finally
+ {
+ monitor.done();
+ }
+ }
+
+ @Override
+ protected void responding(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception
+ {
+ monitor.begin();
+
+ try
+ {
+ out.writeBoolean(true);
+ monitor.worked();
+ }
+ finally
+ {
+ monitor.done();
+ }
+ }
+ };
+
+ default:
+ return super.createSignalReactor(signalID);
+ }
+ }
+ };
+ }
+ });
+
+ return container;
+ }
+
+ public void testMonitorProgress() throws Exception
+ {
+ startTransport();
+ SignalProtocol<Object> protocol = new ClientProtocol();
+ protocol.open(getConnector());
+
+ RequestWithMonitoring<Boolean> request = new RequestWithMonitoring<Boolean>(protocol, SIGNAL_ID)
+ {
+ @Override
+ protected void requesting(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception
+ {
+ monitor.begin();
+
+ try
+ {
+ out.writeBoolean(true);
+ monitor.worked();
+ }
+ finally
+ {
+ monitor.done();
+ }
+ }
+
+ @Override
+ protected Boolean confirming(ExtendedDataInputStream in, OMMonitor monitor) throws Exception
+ {
+ monitor.begin();
+
+ try
+ {
+ boolean result = in.readBoolean();
+ monitor.worked();
+ return result;
+ }
+ finally
+ {
+ monitor.done();
+ }
+ }
+ };
+
+ request.send(4000L, new TestMonitor());
+ sleep(200);
+ protocol.close();
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class ClientProtocol extends SignalProtocol<Object>
+ {
+ public ClientProtocol()
+ {
+ super(PROTOCOL_TYPE);
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class TestMonitor extends Monitor
+ {
+ @Override
+ public OMMonitor begin(double totalWork)
+ {
+ super.begin(totalWork);
+ System.out.println("totalWork: " + getTotalWork()); //$NON-NLS-1$
+ return this;
+ }
+
+ @Override
+ public void worked(double work)
+ {
+ super.worked(work);
+ System.out.println("work: " + getWork()); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class TCP extends SignalMonitorTest
+ {
+ @Override
+ protected boolean useJVMTransport()
+ {
+ return false;
+ }
+
+ @Override
+ protected boolean useSSLTransport()
+ {
+ return false;
+ }
+ }
+
+ /**
+ * @author Teerawat Chaiyakijpichet (No Magic Asia Ltd.)
+ */
+ public static final class SSL extends SignalMonitorTest
+ {
+ @Override
+ protected boolean useJVMTransport()
+ {
+ return false;
+ }
+
+ @Override
+ protected boolean useSSLTransport()
+ {
+ return true;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalStreamWrappingTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalStreamWrappingTest.java
index 90a7788f58..b83b9b6203 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalStreamWrappingTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalStreamWrappingTest.java
@@ -1,88 +1,88 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.signal.wrapping.XORStreamWrapperInjector;
-import org.eclipse.net4j.tests.data.HugeData;
-import org.eclipse.net4j.tests.data.TinyData;
-import org.eclipse.net4j.tests.signal.ArrayRequest;
-import org.eclipse.net4j.tests.signal.TestSignalProtocol;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.io.XORStreamWrapper;
-
-import java.util.Arrays;
-
-/**
- * @author Eike Stepper
- */
-public class SignalStreamWrappingTest extends AbstractProtocolTest
-{
- private static final int[] KEY = { 1, 2, 3, 4, 5 };
-
- @Override
- protected IManagedContainer createContainer()
- {
- IManagedContainer container = super.createContainer();
- container.addPostProcessor(new XORStreamWrapperInjector(TestSignalProtocol.PROTOCOL_NAME, KEY));
- return container;
- }
-
- public void testXORStreamWrapping() throws Exception
- {
- TestSignalProtocol protocol = null;
-
- try
- {
- startTransport();
- protocol = new TestSignalProtocol(getConnector());
- protocol.setStreamWrapper(new XORStreamWrapper(KEY));
- protocol.setTimeout(1000000L);
-
- byte[] data = HugeData.getBytes();
- byte[] result = new ArrayRequest(protocol, data).send();
- assertEquals(true, Arrays.equals(data, result));
- }
- finally
- {
- if (protocol != null)
- {
- protocol.close();
- }
- }
- }
-
- public void testXORStreamWrappingWithMultipleSignals() throws Exception
- {
- TestSignalProtocol protocol = null;
-
- try
- {
- startTransport();
- protocol = new TestSignalProtocol(getConnector());
- protocol.setStreamWrapper(new XORStreamWrapper(KEY));
- protocol.setTimeout(1000000L);
-
- for (int i = 0; i < 20; i++)
- {
- byte[] data = TinyData.getBytes();
- byte[] result = new ArrayRequest(protocol, data).send();
- assertEquals(true, Arrays.equals(data, result));
- }
- }
- finally
- {
- if (protocol != null)
- {
- protocol.close();
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.signal.wrapping.XORStreamWrapperInjector;
+import org.eclipse.net4j.tests.data.HugeData;
+import org.eclipse.net4j.tests.data.TinyData;
+import org.eclipse.net4j.tests.signal.ArrayRequest;
+import org.eclipse.net4j.tests.signal.TestSignalProtocol;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.io.XORStreamWrapper;
+
+import java.util.Arrays;
+
+/**
+ * @author Eike Stepper
+ */
+public class SignalStreamWrappingTest extends AbstractProtocolTest
+{
+ private static final int[] KEY = { 1, 2, 3, 4, 5 };
+
+ @Override
+ protected IManagedContainer createContainer()
+ {
+ IManagedContainer container = super.createContainer();
+ container.addPostProcessor(new XORStreamWrapperInjector(TestSignalProtocol.PROTOCOL_NAME, KEY));
+ return container;
+ }
+
+ public void testXORStreamWrapping() throws Exception
+ {
+ TestSignalProtocol protocol = null;
+
+ try
+ {
+ startTransport();
+ protocol = new TestSignalProtocol(getConnector());
+ protocol.setStreamWrapper(new XORStreamWrapper(KEY));
+ protocol.setTimeout(1000000L);
+
+ byte[] data = HugeData.getBytes();
+ byte[] result = new ArrayRequest(protocol, data).send();
+ assertEquals(true, Arrays.equals(data, result));
+ }
+ finally
+ {
+ if (protocol != null)
+ {
+ protocol.close();
+ }
+ }
+ }
+
+ public void testXORStreamWrappingWithMultipleSignals() throws Exception
+ {
+ TestSignalProtocol protocol = null;
+
+ try
+ {
+ startTransport();
+ protocol = new TestSignalProtocol(getConnector());
+ protocol.setStreamWrapper(new XORStreamWrapper(KEY));
+ protocol.setTimeout(1000000L);
+
+ for (int i = 0; i < 20; i++)
+ {
+ byte[] data = TinyData.getBytes();
+ byte[] result = new ArrayRequest(protocol, data).send();
+ assertEquals(true, Arrays.equals(data, result));
+ }
+ }
+ finally
+ {
+ if (protocol != null)
+ {
+ protocol.close();
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java
index 263c619df7..a7969b6c4c 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java
@@ -1,175 +1,175 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Teerawat Chaiyakijpichet (No Magic Asia Ltd.) - SSL
- */
-package org.eclipse.net4j.tests;
-
-import org.eclipse.net4j.internal.tcp.TCPConnector;
-import org.eclipse.net4j.tests.data.TinyData;
-import org.eclipse.net4j.tests.signal.ArrayRequest;
-import org.eclipse.net4j.tests.signal.AsyncRequest;
-import org.eclipse.net4j.tests.signal.IntRequest;
-import org.eclipse.net4j.tests.signal.StringRequest;
-import org.eclipse.net4j.tests.signal.TestSignalProtocol;
-import org.eclipse.net4j.util.ReflectUtil;
-import org.eclipse.net4j.util.lifecycle.ILifecycle;
-import org.eclipse.net4j.util.om.OMPlatform;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.nio.channels.SocketChannel;
-import java.util.Arrays;
-
-/**
- * @author Eike Stepper
- */
-public class SignalTest extends AbstractProtocolTest
-{
- public void testInteger() throws Exception
- {
- TestSignalProtocol protocol = null;
-
- try
- {
- startTransport();
- protocol = new TestSignalProtocol(getConnector());
- int data = 0x0a;
- int result = new IntRequest(protocol, data).send();
- assertEquals(data, result);
- }
- finally
- {
- if (protocol != null)
- {
- protocol.close();
- }
- }
- }
-
- public void testArray() throws Exception
- {
- TestSignalProtocol protocol = null;
-
- try
- {
- startTransport();
- protocol = new TestSignalProtocol(getConnector());
- byte[] data = TinyData.getBytes();
- byte[] result = new ArrayRequest(protocol, data).send();
- assertEquals(true, Arrays.equals(data, result));
- }
- finally
- {
- if (protocol != null)
- {
- protocol.close();
- }
- }
- }
-
- public void testAsync() throws Exception
- {
- TestSignalProtocol protocol = null;
-
- try
- {
- startTransport();
- OMPlatform.INSTANCE.setDebugging(false);
- protocol = new TestSignalProtocol(getConnector());
- String data = TinyData.getText();
- for (int i = 0; i < 1000; i++)
- {
- msg("Loop " + i); //$NON-NLS-1$
- new AsyncRequest(protocol, data).sendAsync();
- String result = new StringRequest(protocol, data).send();
- assertEquals(data, result);
- }
- }
- finally
- {
- if (protocol != null)
- {
- protocol.close();
- }
- }
- }
-
- public void testCloseSocketChannel() throws Exception
- {
- TestSignalProtocol protocol = null;
-
- try
- {
- startTransport();
- protocol = new TestSignalProtocol(getConnector());
- final ILifecycle lifecycle = protocol;
-
- closeSocketChannel((TCPConnector)getAcceptor().getAcceptedConnectors()[0]);
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return !lifecycle.isActive();
- }
- }.assertNoTimeOut();
- }
- finally
- {
- if (protocol != null)
- {
- protocol.close();
- }
- }
- }
-
- private static void closeSocketChannel(TCPConnector connector) throws IOException
- {
- Field field = ReflectUtil.getField(TCPConnector.class, "socketChannel");
- SocketChannel socketChannel = (SocketChannel)ReflectUtil.getValue(field, connector);
- socketChannel.close();
- }
-
- /**
- * @author Eike Stepper
- */
- public static final class TCP extends SignalTest
- {
- @Override
- protected boolean useJVMTransport()
- {
- return false;
- }
-
- @Override
- protected boolean useSSLTransport()
- {
- return false;
- }
- }
-
- /**
- * @author Teerawat Chaiyakijpichet (No Magic Asia Ltd.)
- */
- public static final class SSL extends SignalTest
- {
- @Override
- protected boolean useJVMTransport()
- {
- return false;
- }
-
- @Override
- protected boolean useSSLTransport()
- {
- return true;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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
+ * Teerawat Chaiyakijpichet (No Magic Asia Ltd.) - SSL
+ */
+package org.eclipse.net4j.tests;
+
+import org.eclipse.net4j.internal.tcp.TCPConnector;
+import org.eclipse.net4j.tests.data.TinyData;
+import org.eclipse.net4j.tests.signal.ArrayRequest;
+import org.eclipse.net4j.tests.signal.AsyncRequest;
+import org.eclipse.net4j.tests.signal.IntRequest;
+import org.eclipse.net4j.tests.signal.StringRequest;
+import org.eclipse.net4j.tests.signal.TestSignalProtocol;
+import org.eclipse.net4j.util.ReflectUtil;
+import org.eclipse.net4j.util.lifecycle.ILifecycle;
+import org.eclipse.net4j.util.om.OMPlatform;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.nio.channels.SocketChannel;
+import java.util.Arrays;
+
+/**
+ * @author Eike Stepper
+ */
+public class SignalTest extends AbstractProtocolTest
+{
+ public void testInteger() throws Exception
+ {
+ TestSignalProtocol protocol = null;
+
+ try
+ {
+ startTransport();
+ protocol = new TestSignalProtocol(getConnector());
+ int data = 0x0a;
+ int result = new IntRequest(protocol, data).send();
+ assertEquals(data, result);
+ }
+ finally
+ {
+ if (protocol != null)
+ {
+ protocol.close();
+ }
+ }
+ }
+
+ public void testArray() throws Exception
+ {
+ TestSignalProtocol protocol = null;
+
+ try
+ {
+ startTransport();
+ protocol = new TestSignalProtocol(getConnector());
+ byte[] data = TinyData.getBytes();
+ byte[] result = new ArrayRequest(protocol, data).send();
+ assertEquals(true, Arrays.equals(data, result));
+ }
+ finally
+ {
+ if (protocol != null)
+ {
+ protocol.close();
+ }
+ }
+ }
+
+ public void testAsync() throws Exception
+ {
+ TestSignalProtocol protocol = null;
+
+ try
+ {
+ startTransport();
+ OMPlatform.INSTANCE.setDebugging(false);
+ protocol = new TestSignalProtocol(getConnector());
+ String data = TinyData.getText();
+ for (int i = 0; i < 1000; i++)
+ {
+ msg("Loop " + i); //$NON-NLS-1$
+ new AsyncRequest(protocol, data).sendAsync();
+ String result = new StringRequest(protocol, data).send();
+ assertEquals(data, result);
+ }
+ }
+ finally
+ {
+ if (protocol != null)
+ {
+ protocol.close();
+ }
+ }
+ }
+
+ public void testCloseSocketChannel() throws Exception
+ {
+ TestSignalProtocol protocol = null;
+
+ try
+ {
+ startTransport();
+ protocol = new TestSignalProtocol(getConnector());
+ final ILifecycle lifecycle = protocol;
+
+ closeSocketChannel((TCPConnector)getAcceptor().getAcceptedConnectors()[0]);
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return !lifecycle.isActive();
+ }
+ }.assertNoTimeOut();
+ }
+ finally
+ {
+ if (protocol != null)
+ {
+ protocol.close();
+ }
+ }
+ }
+
+ private static void closeSocketChannel(TCPConnector connector) throws IOException
+ {
+ Field field = ReflectUtil.getField(TCPConnector.class, "socketChannel");
+ SocketChannel socketChannel = (SocketChannel)ReflectUtil.getValue(field, connector);
+ socketChannel.close();
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class TCP extends SignalTest
+ {
+ @Override
+ protected boolean useJVMTransport()
+ {
+ return false;
+ }
+
+ @Override
+ protected boolean useSSLTransport()
+ {
+ return false;
+ }
+ }
+
+ /**
+ * @author Teerawat Chaiyakijpichet (No Magic Asia Ltd.)
+ */
+ public static final class SSL extends SignalTest
+ {
+ @Override
+ protected boolean useJVMTransport()
+ {
+ return false;
+ }
+
+ @Override
+ protected boolean useSSLTransport()
+ {
+ return true;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPUnitTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPUnitTest.java
index 3e13bad105..1bcc0d4f02 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPUnitTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPUnitTest.java
@@ -1,27 +1,27 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.util.tests.AbstractOMTest;
-
-/**
- * @author Eike Stepper
- */
-public class TCPUnitTest extends AbstractOMTest
-{
- public TCPUnitTest()
- {
- }
-
- public void test()
- {
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.util.tests.AbstractOMTest;
+
+/**
+ * @author Eike Stepper
+ */
+public class TCPUnitTest extends AbstractOMTest
+{
+ public TCPUnitTest()
+ {
+ }
+
+ public void test()
+ {
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/apps/Performance.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/apps/Performance.java
index ef2fe360d1..5585e7f782 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/apps/Performance.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/apps/Performance.java
@@ -1,144 +1,144 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.apps;
-
-import org.eclipse.net4j.util.io.IOUtil;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.Proxy;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.SocketAddress;
-import java.nio.channels.Selector;
-import java.nio.channels.spi.SelectorProvider;
-import java.util.concurrent.CountDownLatch;
-
-/**
- * @author Eike Stepper
- */
-public class Performance
-{
- public static void main(String[] args) throws Exception
- {
- testInetAddress();
- testServerSocket();
- // testRouter();
- testSocket();
- testSelector();
- }
-
- public static void testInetAddress() throws Exception
- {
- System.out.println(InetAddress.class.getName());
- for (int i = 0; i < 2; i++)
- {
- long start = System.currentTimeMillis();
- InetAddress inet = InetAddress.getByName("localhost"); //$NON-NLS-1$
- inet.getHostAddress();
- long duration = System.currentTimeMillis() - start;
-
- System.out.println(duration);
- }
- }
-
- public static void testServerSocket() throws IOException
- {
- System.out.println(ServerSocket.class.getName());
- for (int i = 0; i < 2; i++)
- {
- long start = System.currentTimeMillis();
- ServerSocket serverSocket = new ServerSocket(2036);
- long duration = System.currentTimeMillis() - start;
-
- System.out.println(duration);
- serverSocket.close();
- }
- }
-
- public static void testRouter() throws Exception
- {
- System.out.println(Socket.class.getName() + " (ROUTER)"); //$NON-NLS-1$
- for (int i = 0; i < 2; i++)
- {
- final SocketAddress endpoint = new InetSocketAddress(InetAddress.getByName("192.168.1.1"), 80); //$NON-NLS-1$
- Socket socket = new Socket(Proxy.NO_PROXY);
-
- long start = System.currentTimeMillis();
- socket.connect(endpoint);
- long duration = System.currentTimeMillis() - start;
-
- System.out.println(duration);
- socket.close();
- Thread.sleep(500);
- }
- }
-
- public static void testSocket() throws Exception
- {
- System.out.println(Socket.class.getName() + " (LOOPBACK)"); //$NON-NLS-1$
- for (int i = 0; i < 2; i++)
- {
- final SocketAddress endpoint = new InetSocketAddress(InetAddress.getByName("127.0.0.1"), 2036); //$NON-NLS-1$
- final CountDownLatch latch = new CountDownLatch(1);
- new Thread()
- {
- @Override
- public void run()
- {
- try
- {
- ServerSocket serverSocket = new ServerSocket();
- serverSocket.bind(endpoint);
- latch.countDown();
-
- Socket socket = serverSocket.accept();
- socket.close();
- serverSocket.close();
- }
- catch (IOException ex)
- {
- IOUtil.print(ex);
- latch.countDown();
- }
- }
- }.start();
-
- latch.await();
- Thread.sleep(500);
- Socket socket = new Socket(Proxy.NO_PROXY);
-
- long start = System.currentTimeMillis();
- socket.connect(endpoint);
- long duration = System.currentTimeMillis() - start;
-
- System.out.println(duration);
- socket.close();
- Thread.sleep(500);
- }
- }
-
- public static void testSelector() throws IOException
- {
- SelectorProvider provider = SelectorProvider.provider();
- System.out.println(provider.getClass().getName());
- for (int i = 0; i < 2; i++)
- {
- long start = System.currentTimeMillis();
- Selector selector = provider.openSelector();
- long duration = System.currentTimeMillis() - start;
-
- System.out.println(duration);
- selector.close();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.apps;
+
+import org.eclipse.net4j.util.io.IOUtil;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.nio.channels.Selector;
+import java.nio.channels.spi.SelectorProvider;
+import java.util.concurrent.CountDownLatch;
+
+/**
+ * @author Eike Stepper
+ */
+public class Performance
+{
+ public static void main(String[] args) throws Exception
+ {
+ testInetAddress();
+ testServerSocket();
+ // testRouter();
+ testSocket();
+ testSelector();
+ }
+
+ public static void testInetAddress() throws Exception
+ {
+ System.out.println(InetAddress.class.getName());
+ for (int i = 0; i < 2; i++)
+ {
+ long start = System.currentTimeMillis();
+ InetAddress inet = InetAddress.getByName("localhost"); //$NON-NLS-1$
+ inet.getHostAddress();
+ long duration = System.currentTimeMillis() - start;
+
+ System.out.println(duration);
+ }
+ }
+
+ public static void testServerSocket() throws IOException
+ {
+ System.out.println(ServerSocket.class.getName());
+ for (int i = 0; i < 2; i++)
+ {
+ long start = System.currentTimeMillis();
+ ServerSocket serverSocket = new ServerSocket(2036);
+ long duration = System.currentTimeMillis() - start;
+
+ System.out.println(duration);
+ serverSocket.close();
+ }
+ }
+
+ public static void testRouter() throws Exception
+ {
+ System.out.println(Socket.class.getName() + " (ROUTER)"); //$NON-NLS-1$
+ for (int i = 0; i < 2; i++)
+ {
+ final SocketAddress endpoint = new InetSocketAddress(InetAddress.getByName("192.168.1.1"), 80); //$NON-NLS-1$
+ Socket socket = new Socket(Proxy.NO_PROXY);
+
+ long start = System.currentTimeMillis();
+ socket.connect(endpoint);
+ long duration = System.currentTimeMillis() - start;
+
+ System.out.println(duration);
+ socket.close();
+ Thread.sleep(500);
+ }
+ }
+
+ public static void testSocket() throws Exception
+ {
+ System.out.println(Socket.class.getName() + " (LOOPBACK)"); //$NON-NLS-1$
+ for (int i = 0; i < 2; i++)
+ {
+ final SocketAddress endpoint = new InetSocketAddress(InetAddress.getByName("127.0.0.1"), 2036); //$NON-NLS-1$
+ final CountDownLatch latch = new CountDownLatch(1);
+ new Thread()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ ServerSocket serverSocket = new ServerSocket();
+ serverSocket.bind(endpoint);
+ latch.countDown();
+
+ Socket socket = serverSocket.accept();
+ socket.close();
+ serverSocket.close();
+ }
+ catch (IOException ex)
+ {
+ IOUtil.print(ex);
+ latch.countDown();
+ }
+ }
+ }.start();
+
+ latch.await();
+ Thread.sleep(500);
+ Socket socket = new Socket(Proxy.NO_PROXY);
+
+ long start = System.currentTimeMillis();
+ socket.connect(endpoint);
+ long duration = System.currentTimeMillis() - start;
+
+ System.out.println(duration);
+ socket.close();
+ Thread.sleep(500);
+ }
+ }
+
+ public static void testSelector() throws IOException
+ {
+ SelectorProvider provider = SelectorProvider.provider();
+ System.out.println(provider.getClass().getName());
+ for (int i = 0; i < 2; i++)
+ {
+ long start = System.currentTimeMillis();
+ Selector selector = provider.openSelector();
+ long duration = System.currentTimeMillis() - start;
+
+ System.out.println(duration);
+ selector.close();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/apps/TCPConnectivityLoss.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/apps/TCPConnectivityLoss.java
index 3ce96388e8..ccabea4776 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/apps/TCPConnectivityLoss.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/apps/TCPConnectivityLoss.java
@@ -1,102 +1,102 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.apps;
-
-import org.eclipse.net4j.Net4jUtil;
-import org.eclipse.net4j.tcp.ITCPConnector;
-import org.eclipse.net4j.tcp.TCPUtil;
-import org.eclipse.net4j.util.container.ManagedContainer;
-import org.eclipse.net4j.util.lifecycle.ILifecycle;
-import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.log.PrintLogHandler;
-import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
-
-import java.util.Date;
-
-/**
- * @author Eike Stepper
- */
-public class TCPConnectivityLoss
-{
- private static boolean stop;
-
- public static ManagedContainer createContainer()
- {
- OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
- OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
- OMPlatform.INSTANCE.setDebugging(true);
-
- ManagedContainer container = new ManagedContainer();
- Net4jUtil.prepareContainer(container);
- TCPUtil.prepareContainer(container);
- container.activate();
- return container;
- }
-
- public static void sleep() throws Exception
- {
- System.out.println("Started: " + new Date()); //$NON-NLS-1$
- stop = false;
- int count = 0;
- while (System.in.available() == 0)
- {
- Thread.sleep(1000L);
- System.out.print("."); //$NON-NLS-1$
- if (++count % 80 == 0)
- {
- System.out.println();
- }
-
- if (stop)
- {
- System.out.println("Loss of connectivity: " + new Date()); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static class Server
- {
- public static void main(String[] args) throws Exception
- {
- ManagedContainer container = createContainer();
- TCPUtil.getAcceptor(container, null);
- sleep();
- container.deactivate();
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static class Client
- {
- public static void main(String[] args) throws Exception
- {
- ManagedContainer container = createContainer();
- ITCPConnector connector = TCPUtil.getConnector(container, "192.168.1.35"); //$NON-NLS-1$
- connector.addListener(new LifecycleEventAdapter()
- {
- @Override
- protected void onDeactivated(ILifecycle lifecycle)
- {
- stop = true;
- }
- });
-
- sleep();
- container.deactivate();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.apps;
+
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.tcp.ITCPConnector;
+import org.eclipse.net4j.tcp.TCPUtil;
+import org.eclipse.net4j.util.container.ManagedContainer;
+import org.eclipse.net4j.util.lifecycle.ILifecycle;
+import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.log.PrintLogHandler;
+import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
+
+import java.util.Date;
+
+/**
+ * @author Eike Stepper
+ */
+public class TCPConnectivityLoss
+{
+ private static boolean stop;
+
+ public static ManagedContainer createContainer()
+ {
+ OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
+ OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
+ OMPlatform.INSTANCE.setDebugging(true);
+
+ ManagedContainer container = new ManagedContainer();
+ Net4jUtil.prepareContainer(container);
+ TCPUtil.prepareContainer(container);
+ container.activate();
+ return container;
+ }
+
+ public static void sleep() throws Exception
+ {
+ System.out.println("Started: " + new Date()); //$NON-NLS-1$
+ stop = false;
+ int count = 0;
+ while (System.in.available() == 0)
+ {
+ Thread.sleep(1000L);
+ System.out.print("."); //$NON-NLS-1$
+ if (++count % 80 == 0)
+ {
+ System.out.println();
+ }
+
+ if (stop)
+ {
+ System.out.println("Loss of connectivity: " + new Date()); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class Server
+ {
+ public static void main(String[] args) throws Exception
+ {
+ ManagedContainer container = createContainer();
+ TCPUtil.getAcceptor(container, null);
+ sleep();
+ container.deactivate();
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class Client
+ {
+ public static void main(String[] args) throws Exception
+ {
+ ManagedContainer container = createContainer();
+ ITCPConnector connector = TCPUtil.getConnector(container, "192.168.1.35"); //$NON-NLS-1$
+ connector.addListener(new LifecycleEventAdapter()
+ {
+ @Override
+ protected void onDeactivated(ILifecycle lifecycle)
+ {
+ stop = true;
+ }
+ });
+
+ sleep();
+ container.deactivate();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla_241463_Test.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla_241463_Test.java
index d44fc80fab..95d46d8b6e 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla_241463_Test.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla_241463_Test.java
@@ -1,212 +1,212 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Teerawat Chaiyakijpichet (No Magic Asia Ltd.) - maintenance (SSL)
- */
-package org.eclipse.net4j.tests.bugzilla;
-
-import org.eclipse.net4j.TransportInjector;
-import org.eclipse.net4j.internal.tcp.TCPAcceptor;
-import org.eclipse.net4j.internal.tcp.TCPAcceptorFactory;
-import org.eclipse.net4j.internal.tcp.TCPConnectorFactory;
-import org.eclipse.net4j.internal.tcp.TCPSelectorFactory;
-import org.eclipse.net4j.internal.tcp.TCPSelectorInjector;
-import org.eclipse.net4j.internal.tcp.TCPServerConnector;
-import org.eclipse.net4j.internal.tcp.ssl.SSLAcceptor;
-import org.eclipse.net4j.internal.tcp.ssl.SSLAcceptorFactory;
-import org.eclipse.net4j.internal.tcp.ssl.SSLConnectorFactory;
-import org.eclipse.net4j.internal.tcp.ssl.SSLServerConnector;
-import org.eclipse.net4j.tcp.ITCPAcceptor;
-import org.eclipse.net4j.tcp.ITCPSelector;
-import org.eclipse.net4j.tests.AbstractTransportTest;
-import org.eclipse.net4j.tests.ChannelTest;
-import org.eclipse.net4j.tests.signal.TestSignalProtocol;
-import org.eclipse.net4j.util.concurrent.ExecutorServiceFactory;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.container.ManagedContainer;
-import org.eclipse.net4j.util.security.RandomizerFactory;
-
-import org.eclipse.internal.net4j.buffer.BufferProviderFactory;
-
-import org.eclipse.spi.net4j.InternalChannel;
-
-import java.nio.channels.ClosedChannelException;
-import java.nio.channels.ServerSocketChannel;
-import java.nio.channels.SocketChannel;
-
-/**
- * @author Eike Stepper
- */
-public class Bugzilla_241463_Test extends AbstractTransportTest
-{
- @Override
- protected IManagedContainer createContainer()
- {
- IManagedContainer container = new ManagedContainer();
-
- // Net4j
- container.registerFactory(new ExecutorServiceFactory());
- container.registerFactory(new BufferProviderFactory());
- container.registerFactory(new RandomizerFactory());
- container.addPostProcessor(new TransportInjector());
-
- container.registerFactory(new TCPSelectorFactory());
- container.addPostProcessor(new TCPSelectorInjector());
-
- if (useSSLTransport())
- {
- // SSL
- container.registerFactory(new FakeSSLAcceptorFactory());
- container.registerFactory(new SSLConnectorFactory());
- }
- else
- {
- // TCP
- container.registerFactory(new FakeAcceptorFactory());
- container.registerFactory(new TCPConnectorFactory());
- }
-
- // Test
- container.registerFactory(new TestSignalProtocol.Factory());
- return container;
- }
-
- public void testBugzilla241463() throws Exception
- {
- startTransport();
- getConnector().setOpenChannelTimeout(2000L);
-
- try
- {
- new TestSignalProtocol(getConnector());
- fail("Exception expected"); //$NON-NLS-1$
- }
- catch (Exception expected)
- {
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class FakeAcceptorFactory extends TCPAcceptorFactory
- {
- @Override
- public TCPAcceptor create(String description)
- {
- TCPAcceptor acceptor = new TCPAcceptor()
- {
- @Override
- protected TCPServerConnector createConnector()
- {
- return new TCPServerConnector(this)
- {
- @Override
- public InternalChannel inverseOpenChannel(short channelIndex, String protocolID)
- {
- throw new RuntimeException("Simulated problem"); //$NON-NLS-1$
- }
- };
- }
- };
-
- acceptor.setAddress(ITCPAcceptor.DEFAULT_ADDRESS);
- acceptor.setPort(ITCPAcceptor.DEFAULT_PORT);
- return acceptor;
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class FakeSSLAcceptorFactory extends SSLAcceptorFactory
- {
- @Override
- public SSLAcceptor create(String description)
- {
- SSLAcceptor acceptor = new SSLAcceptor()
- {
-
- @Override
- public void handleAccept(ITCPSelector selector, ServerSocketChannel serverSocketChannel)
- {
- try
- {
- SocketChannel socketChannel = serverSocketChannel.accept();
- if (socketChannel != null)
- {
- socketChannel.configureBlocking(false);
-
- SSLServerConnector connector = new SSLServerConnector(this)
- {
- @Override
- public InternalChannel inverseOpenChannel(short channelID, String protocolID)
- {
- throw new RuntimeException("Simulated problem"); //$NON-NLS-1$
- }
- };
- prepareConnector(connector);
- connector.setSocketChannel(socketChannel);
- connector.setSelector(selector);
- connector.activate();
- }
- }
- catch (ClosedChannelException ex)
- {
- deactivateAsync();
- }
- catch (Exception ex)
- {
- deactivateAsync();
- }
- }
- };
-
- acceptor.setAddress(ITCPAcceptor.DEFAULT_ADDRESS);
- acceptor.setPort(ITCPAcceptor.DEFAULT_PORT);
- return acceptor;
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static final class TCP extends ChannelTest
- {
- @Override
- protected boolean useJVMTransport()
- {
- return false;
- }
-
- @Override
- protected boolean useSSLTransport()
- {
- return false;
- }
- }
-
- /**
- * @author Teerawat Chaiyakijpichet (No Magic Asia Ltd.)
- */
- public static final class SSL extends ChannelTest
- {
- @Override
- protected boolean useJVMTransport()
- {
- return false;
- }
-
- @Override
- protected boolean useSSLTransport()
- {
- return true;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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
+ * Teerawat Chaiyakijpichet (No Magic Asia Ltd.) - maintenance (SSL)
+ */
+package org.eclipse.net4j.tests.bugzilla;
+
+import org.eclipse.net4j.TransportInjector;
+import org.eclipse.net4j.internal.tcp.TCPAcceptor;
+import org.eclipse.net4j.internal.tcp.TCPAcceptorFactory;
+import org.eclipse.net4j.internal.tcp.TCPConnectorFactory;
+import org.eclipse.net4j.internal.tcp.TCPSelectorFactory;
+import org.eclipse.net4j.internal.tcp.TCPSelectorInjector;
+import org.eclipse.net4j.internal.tcp.TCPServerConnector;
+import org.eclipse.net4j.internal.tcp.ssl.SSLAcceptor;
+import org.eclipse.net4j.internal.tcp.ssl.SSLAcceptorFactory;
+import org.eclipse.net4j.internal.tcp.ssl.SSLConnectorFactory;
+import org.eclipse.net4j.internal.tcp.ssl.SSLServerConnector;
+import org.eclipse.net4j.tcp.ITCPAcceptor;
+import org.eclipse.net4j.tcp.ITCPSelector;
+import org.eclipse.net4j.tests.AbstractTransportTest;
+import org.eclipse.net4j.tests.ChannelTest;
+import org.eclipse.net4j.tests.signal.TestSignalProtocol;
+import org.eclipse.net4j.util.concurrent.ExecutorServiceFactory;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.container.ManagedContainer;
+import org.eclipse.net4j.util.security.RandomizerFactory;
+
+import org.eclipse.internal.net4j.buffer.BufferProviderFactory;
+
+import org.eclipse.spi.net4j.InternalChannel;
+
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.ServerSocketChannel;
+import java.nio.channels.SocketChannel;
+
+/**
+ * @author Eike Stepper
+ */
+public class Bugzilla_241463_Test extends AbstractTransportTest
+{
+ @Override
+ protected IManagedContainer createContainer()
+ {
+ IManagedContainer container = new ManagedContainer();
+
+ // Net4j
+ container.registerFactory(new ExecutorServiceFactory());
+ container.registerFactory(new BufferProviderFactory());
+ container.registerFactory(new RandomizerFactory());
+ container.addPostProcessor(new TransportInjector());
+
+ container.registerFactory(new TCPSelectorFactory());
+ container.addPostProcessor(new TCPSelectorInjector());
+
+ if (useSSLTransport())
+ {
+ // SSL
+ container.registerFactory(new FakeSSLAcceptorFactory());
+ container.registerFactory(new SSLConnectorFactory());
+ }
+ else
+ {
+ // TCP
+ container.registerFactory(new FakeAcceptorFactory());
+ container.registerFactory(new TCPConnectorFactory());
+ }
+
+ // Test
+ container.registerFactory(new TestSignalProtocol.Factory());
+ return container;
+ }
+
+ public void testBugzilla241463() throws Exception
+ {
+ startTransport();
+ getConnector().setOpenChannelTimeout(2000L);
+
+ try
+ {
+ new TestSignalProtocol(getConnector());
+ fail("Exception expected"); //$NON-NLS-1$
+ }
+ catch (Exception expected)
+ {
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class FakeAcceptorFactory extends TCPAcceptorFactory
+ {
+ @Override
+ public TCPAcceptor create(String description)
+ {
+ TCPAcceptor acceptor = new TCPAcceptor()
+ {
+ @Override
+ protected TCPServerConnector createConnector()
+ {
+ return new TCPServerConnector(this)
+ {
+ @Override
+ public InternalChannel inverseOpenChannel(short channelIndex, String protocolID)
+ {
+ throw new RuntimeException("Simulated problem"); //$NON-NLS-1$
+ }
+ };
+ }
+ };
+
+ acceptor.setAddress(ITCPAcceptor.DEFAULT_ADDRESS);
+ acceptor.setPort(ITCPAcceptor.DEFAULT_PORT);
+ return acceptor;
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class FakeSSLAcceptorFactory extends SSLAcceptorFactory
+ {
+ @Override
+ public SSLAcceptor create(String description)
+ {
+ SSLAcceptor acceptor = new SSLAcceptor()
+ {
+
+ @Override
+ public void handleAccept(ITCPSelector selector, ServerSocketChannel serverSocketChannel)
+ {
+ try
+ {
+ SocketChannel socketChannel = serverSocketChannel.accept();
+ if (socketChannel != null)
+ {
+ socketChannel.configureBlocking(false);
+
+ SSLServerConnector connector = new SSLServerConnector(this)
+ {
+ @Override
+ public InternalChannel inverseOpenChannel(short channelID, String protocolID)
+ {
+ throw new RuntimeException("Simulated problem"); //$NON-NLS-1$
+ }
+ };
+ prepareConnector(connector);
+ connector.setSocketChannel(socketChannel);
+ connector.setSelector(selector);
+ connector.activate();
+ }
+ }
+ catch (ClosedChannelException ex)
+ {
+ deactivateAsync();
+ }
+ catch (Exception ex)
+ {
+ deactivateAsync();
+ }
+ }
+ };
+
+ acceptor.setAddress(ITCPAcceptor.DEFAULT_ADDRESS);
+ acceptor.setPort(ITCPAcceptor.DEFAULT_PORT);
+ return acceptor;
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class TCP extends ChannelTest
+ {
+ @Override
+ protected boolean useJVMTransport()
+ {
+ return false;
+ }
+
+ @Override
+ protected boolean useSSLTransport()
+ {
+ return false;
+ }
+ }
+
+ /**
+ * @author Teerawat Chaiyakijpichet (No Magic Asia Ltd.)
+ */
+ public static final class SSL extends ChannelTest
+ {
+ @Override
+ protected boolean useJVMTransport()
+ {
+ return false;
+ }
+
+ @Override
+ protected boolean useSSLTransport()
+ {
+ return true;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla_262875_Test.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla_262875_Test.java
index 0bc708cf10..611c869a47 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla_262875_Test.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla_262875_Test.java
@@ -1,210 +1,210 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * David Bonneau - initial API and implementation
- * Andre Dietisheim - maintenance
- */
-package org.eclipse.net4j.tests.bugzilla;
-
-import org.eclipse.net4j.Net4jUtil;
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.jvm.JVMUtil;
-import org.eclipse.net4j.signal.IndicationWithResponse;
-import org.eclipse.net4j.signal.RequestWithConfirmation;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.signal.SignalReactor;
-import org.eclipse.net4j.util.IErrorHandler;
-import org.eclipse.net4j.util.concurrent.Worker;
-import org.eclipse.net4j.util.container.ContainerUtil;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.factory.ProductCreationException;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import org.eclipse.net4j.util.tests.AbstractOMTest;
-
-import org.eclipse.spi.net4j.ServerProtocolFactory;
-
-import java.nio.BufferUnderflowException;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-/**
- * @author David Bonneau
- */
-public class Bugzilla_262875_Test extends AbstractOMTest
-{
- /** the length of the metadata sent in a buffer: channelID, correlationID */
- private static final short BUFFER_METADATA_LENTGH = 10;
-
- private IManagedContainer container;
-
- private IConnector connector;
-
- @Override
- protected void doSetUp() throws Exception
- {
- super.doSetUp();
- container = ContainerUtil.createContainer();
- Net4jUtil.prepareContainer(container);
- JVMUtil.prepareContainer(container);
- container.registerFactory(new TestProtocol.Factory());
- container.activate();
-
- JVMUtil.getAcceptor(container, "default");
- connector = JVMUtil.getConnector(container, "default");
- }
-
- @Override
- protected void doTearDown() throws Exception
- {
- connector.close();
- container.deactivate();
- super.doTearDown();
- }
-
- /**
- * Tests if a buffer underflow exception occurs if the data sent in a request exactly matches the capacity of a
- * buffer.
- *
- * @throws Exception
- * the exception
- */
- public void testGivenDataMatchesBufferLengthThenBufferUnderflowException() throws Exception
- {
- final AtomicBoolean failed = new AtomicBoolean(false);
- final CountDownLatch latch = new CountDownLatch(1);
- IErrorHandler oldErrorHandler = Worker.setGlobalErrorHandler(new IErrorHandler()
- {
- public void handleError(Throwable t)
- {
- t.printStackTrace();
- if (t instanceof BufferUnderflowException)
- {
- failed.set(true);
- }
-
- latch.countDown();
- }
- });
-
- try
- {
- TestProtocol protocol = new TestProtocol();
- protocol.open(connector);
-
- short bufferCapacity = protocol.getBufferProvider().getBufferCapacity();
- new TestProtocol.Request(protocol, bufferCapacity - BUFFER_METADATA_LENTGH).send();
-
- latch.await(DEFAULT_TIMEOUT_EXPECTED, TimeUnit.MILLISECONDS);
- assertEquals(false, failed.get());
- }
- finally
- {
- Worker.setGlobalErrorHandler(oldErrorHandler);
- }
- }
-
- /**
- * @author David Bonneau
- */
- private static final class TestProtocol extends SignalProtocol<Object>
- {
- private static final String NAME = "TEST_PROTOCOL";
-
- private static final short SIGNAL_ID = 10;
-
- public TestProtocol()
- {
- super(NAME);
- }
-
- @Override
- protected SignalReactor createSignalReactor(short signalID)
- {
- switch (signalID)
- {
- case SIGNAL_ID:
- return new Indication(this);
- }
-
- return super.createSignalReactor(signalID);
- }
-
- /**
- * @author David Bonneau
- */
- private static final class Request extends RequestWithConfirmation<Boolean>
- {
- private int requestNumOfBytes;
-
- public Request(SignalProtocol<?> protocol, int requestNumOfBytes)
- {
- super(protocol, SIGNAL_ID);
- this.requestNumOfBytes = requestNumOfBytes;
- }
-
- @Override
- protected void requesting(ExtendedDataOutputStream out) throws Exception
- {
- for (int i = 0; i < requestNumOfBytes; ++i)
- {
- out.writeByte(i);
- }
-
- // delay completion
- Thread.sleep(100);
- }
-
- @Override
- protected Boolean confirming(ExtendedDataInputStream in) throws Exception
- {
- return in.readBoolean();
- }
- }
-
- /**
- * @author David Bonneau
- */
- private static final class Indication extends IndicationWithResponse
- {
- public Indication(SignalProtocol<?> protocol)
- {
- super(protocol, SIGNAL_ID);
- }
-
- @Override
- protected void indicating(ExtendedDataInputStream in) throws Exception
- {
- System.out.println("indicating");
- }
-
- @Override
- protected void responding(ExtendedDataOutputStream out) throws Exception
- {
- out.writeBoolean(true);
- }
- }
-
- /**
- * @author David Bonneau
- */
- private static final class Factory extends ServerProtocolFactory
- {
- public Factory()
- {
- super(NAME);
- }
-
- public Object create(String description) throws ProductCreationException
- {
- return new TestProtocol();
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * David Bonneau - initial API and implementation
+ * Andre Dietisheim - maintenance
+ */
+package org.eclipse.net4j.tests.bugzilla;
+
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.connector.IConnector;
+import org.eclipse.net4j.jvm.JVMUtil;
+import org.eclipse.net4j.signal.IndicationWithResponse;
+import org.eclipse.net4j.signal.RequestWithConfirmation;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.signal.SignalReactor;
+import org.eclipse.net4j.util.IErrorHandler;
+import org.eclipse.net4j.util.concurrent.Worker;
+import org.eclipse.net4j.util.container.ContainerUtil;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.factory.ProductCreationException;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.net4j.util.tests.AbstractOMTest;
+
+import org.eclipse.spi.net4j.ServerProtocolFactory;
+
+import java.nio.BufferUnderflowException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * @author David Bonneau
+ */
+public class Bugzilla_262875_Test extends AbstractOMTest
+{
+ /** the length of the metadata sent in a buffer: channelID, correlationID */
+ private static final short BUFFER_METADATA_LENTGH = 10;
+
+ private IManagedContainer container;
+
+ private IConnector connector;
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+ container = ContainerUtil.createContainer();
+ Net4jUtil.prepareContainer(container);
+ JVMUtil.prepareContainer(container);
+ container.registerFactory(new TestProtocol.Factory());
+ container.activate();
+
+ JVMUtil.getAcceptor(container, "default");
+ connector = JVMUtil.getConnector(container, "default");
+ }
+
+ @Override
+ protected void doTearDown() throws Exception
+ {
+ connector.close();
+ container.deactivate();
+ super.doTearDown();
+ }
+
+ /**
+ * Tests if a buffer underflow exception occurs if the data sent in a request exactly matches the capacity of a
+ * buffer.
+ *
+ * @throws Exception
+ * the exception
+ */
+ public void testGivenDataMatchesBufferLengthThenBufferUnderflowException() throws Exception
+ {
+ final AtomicBoolean failed = new AtomicBoolean(false);
+ final CountDownLatch latch = new CountDownLatch(1);
+ IErrorHandler oldErrorHandler = Worker.setGlobalErrorHandler(new IErrorHandler()
+ {
+ public void handleError(Throwable t)
+ {
+ t.printStackTrace();
+ if (t instanceof BufferUnderflowException)
+ {
+ failed.set(true);
+ }
+
+ latch.countDown();
+ }
+ });
+
+ try
+ {
+ TestProtocol protocol = new TestProtocol();
+ protocol.open(connector);
+
+ short bufferCapacity = protocol.getBufferProvider().getBufferCapacity();
+ new TestProtocol.Request(protocol, bufferCapacity - BUFFER_METADATA_LENTGH).send();
+
+ latch.await(DEFAULT_TIMEOUT_EXPECTED, TimeUnit.MILLISECONDS);
+ assertEquals(false, failed.get());
+ }
+ finally
+ {
+ Worker.setGlobalErrorHandler(oldErrorHandler);
+ }
+ }
+
+ /**
+ * @author David Bonneau
+ */
+ private static final class TestProtocol extends SignalProtocol<Object>
+ {
+ private static final String NAME = "TEST_PROTOCOL";
+
+ private static final short SIGNAL_ID = 10;
+
+ public TestProtocol()
+ {
+ super(NAME);
+ }
+
+ @Override
+ protected SignalReactor createSignalReactor(short signalID)
+ {
+ switch (signalID)
+ {
+ case SIGNAL_ID:
+ return new Indication(this);
+ }
+
+ return super.createSignalReactor(signalID);
+ }
+
+ /**
+ * @author David Bonneau
+ */
+ private static final class Request extends RequestWithConfirmation<Boolean>
+ {
+ private int requestNumOfBytes;
+
+ public Request(SignalProtocol<?> protocol, int requestNumOfBytes)
+ {
+ super(protocol, SIGNAL_ID);
+ this.requestNumOfBytes = requestNumOfBytes;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ for (int i = 0; i < requestNumOfBytes; ++i)
+ {
+ out.writeByte(i);
+ }
+
+ // delay completion
+ Thread.sleep(100);
+ }
+
+ @Override
+ protected Boolean confirming(ExtendedDataInputStream in) throws Exception
+ {
+ return in.readBoolean();
+ }
+ }
+
+ /**
+ * @author David Bonneau
+ */
+ private static final class Indication extends IndicationWithResponse
+ {
+ public Indication(SignalProtocol<?> protocol)
+ {
+ super(protocol, SIGNAL_ID);
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws Exception
+ {
+ System.out.println("indicating");
+ }
+
+ @Override
+ protected void responding(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeBoolean(true);
+ }
+ }
+
+ /**
+ * @author David Bonneau
+ */
+ private static final class Factory extends ServerProtocolFactory
+ {
+ public Factory()
+ {
+ super(NAME);
+ }
+
+ public Object create(String description) throws ProductCreationException
+ {
+ return new TestProtocol();
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bundle/OM.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bundle/OM.java
index 49794b3590..4ae5d1a620 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bundle/OM.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bundle/OM.java
@@ -1,44 +1,44 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.bundle;
-
-import org.eclipse.net4j.util.om.OMBundle;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.OSGiActivator;
-import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.trace.OMTracer;
-
-/**
- * The <em>Operations & Maintenance</em> class of this bundle.
- *
- * @author Eike Stepper
- */
-public abstract class OM
-{
- public static final String BUNDLE_ID = "org.eclipse.net4j.tests"; //$NON-NLS-1$
-
- public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
-
- public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
-
- public static final OMLogger LOG = BUNDLE.logger();
-
- /**
- * @author Eike Stepper
- */
- public static final class Activator extends OSGiActivator
- {
- public Activator()
- {
- super(BUNDLE);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.bundle;
+
+import org.eclipse.net4j.util.om.OMBundle;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.OSGiActivator;
+import org.eclipse.net4j.util.om.log.OMLogger;
+import org.eclipse.net4j.util.om.trace.OMTracer;
+
+/**
+ * The <em>Operations & Maintenance</em> class of this bundle.
+ *
+ * @author Eike Stepper
+ */
+public abstract class OM
+{
+ public static final String BUNDLE_ID = "org.eclipse.net4j.tests"; //$NON-NLS-1$
+
+ public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
+
+ public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
+
+ public static final OMLogger LOG = BUNDLE.logger();
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Activator extends OSGiActivator
+ {
+ public Activator()
+ {
+ super(BUNDLE);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/data/HugeData.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/data/HugeData.java
index 4331c19988..8641044c50 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/data/HugeData.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/data/HugeData.java
@@ -1,245 +1,245 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.data;
-
-import java.util.StringTokenizer;
-
-/**
- * @author Eike Stepper
- */
-public final class HugeData
-{
- public static final String NL = System.getProperty("line.separator"); //$NON-NLS-1$
-
- public static StringTokenizer getTokenizer()
- {
- return new StringTokenizer(getText(), NL);
- }
-
- public static String[] getArray()
- {
- return getText().split(NL);
- }
-
- public static byte[] getBytes()
- {
- return getText().getBytes();
- }
-
- public static String getText()
- {
- return "/**" + NL //$NON-NLS-1$
- + " * COPYRIGHT (C) 2004 - 2008 EIKE STEPPER, GERMANY." + NL //$NON-NLS-1$
- + " * ALL RIGHTS RESERVED. THIS PROGRAM AND THE ACCOMPANYING MATERIALS" + NL //$NON-NLS-1$
- + " * ARE MADE AVAILABLE UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE V1.0" + NL //$NON-NLS-1$
- + " * WHICH ACCOMPANIES THIS DISTRIBUTION, AND IS AVAILABLE AT" + NL //$NON-NLS-1$
- + " * HTTP://WWW.ECLIPSE.ORG/LEGAL/EPL-V10.HTML" + NL + " * " + NL + " * CONTRIBUTORS:" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " * EIKE STEPPER - INITIAL API AND IMPLEMENTATION" + NL //$NON-NLS-1$
- + " */" + NL //$NON-NLS-1$
- + "PACKAGE ORG.ECLIPSE.INTERNAL.NET4J.TRANSPORT.CONNECTOR;" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + "IMPORT ORG.ECLIPSE.NET4J.TRANSPORT.BUFFER.BUFFERPROVIDER;" + NL //$NON-NLS-1$
- + "IMPORT ORG.ECLIPSE.NET4J.TRANSPORT.CHANNEL.CHANNEL;" + NL //$NON-NLS-1$
- + "IMPORT ORG.ECLIPSE.NET4J.TRANSPORT.CHANNEL.MULTIPLEXER;" + NL //$NON-NLS-1$
- + "IMPORT ORG.ECLIPSE.NET4J.TRANSPORT.CONNECTOR.CONNECTOR;" + NL //$NON-NLS-1$
- + "IMPORT ORG.ECLIPSE.NET4J.TRANSPORT.CONNECTOR.CONNECTOREXCEPTION;" + NL //$NON-NLS-1$
- + "IMPORT ORG.ECLIPSE.NET4J.TRANSPORT.CONNECTOR.CREDENTIALS;" + NL //$NON-NLS-1$
- + "IMPORT ORG.ECLIPSE.NET4J.TRANSPORT.CONNECTOR.PROTOCOL;" + NL //$NON-NLS-1$
- + "IMPORT ORG.ECLIPSE.NET4J.TRANSPORT.CONNECTOR.PROTOCOLFACTORY;" + NL //$NON-NLS-1$
- + "IMPORT ORG.ECLIPSE.NET4J.UTIL.LIFECYCLE.LIFECYCLELISTENER;" + NL //$NON-NLS-1$
- + "IMPORT ORG.ECLIPSE.NET4J.UTIL.LIFECYCLE.LIFECYCLENOTIFIER;" + NL //$NON-NLS-1$
- + "IMPORT ORG.ECLIPSE.NET4J.UTIL.REGISTRY.IREGISTRY;" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + "IMPORT ORG.ECLIPSE.INTERNAL.NET4J.TRANSPORT.CHANNEL.CHANNELIMPL;" + NL //$NON-NLS-1$
- + "IMPORT ORG.ECLIPSE.INTERNAL.NET4J.UTIL.STREAM.BUFFERQUEUE;" + NL //$NON-NLS-1$
- + "IMPORT ORG.ECLIPSE.INTERNAL.NET4J.UTIL.LIFECYCLE.ABSTRACTCOMPONENT;" + NL //$NON-NLS-1$
- + "IMPORT ORG.ECLIPSE.INTERNAL.NET4J.UTIL.LIFECYCLE.LIFECYCLEUTIL;" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + "IMPORT JAVA.UTIL.ARRAYLIST;" + NL + "IMPORT JAVA.UTIL.LIST;" + NL + "IMPORT JAVA.UTIL.QUEUE;" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + "IMPORT JAVA.UTIL.CONCURRENT.CONCURRENTLINKEDQUEUE;" + NL + "IMPORT JAVA.UTIL.CONCURRENT.COUNTDOWNLATCH;" //$NON-NLS-1$ //$NON-NLS-2$
- + NL + "IMPORT JAVA.UTIL.CONCURRENT.EXECUTORSERVICE;" + NL + "IMPORT JAVA.UTIL.CONCURRENT.TIMEUNIT;" + NL + "" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + NL + "/**" + NL + " * @AUTHOR EIKE STEPPER" + NL + " */" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + "PUBLIC ABSTRACT CLASS ABSTRACTCONNECTOR EXTENDS ABSTRACTLIFECYCLE IMPLEMENTS CONNECTOR, CHANNELMULTIPLEXER" //$NON-NLS-1$
- + NL + "{" + NL + " PRIVATE STATIC FINAL CHANNELIMPL NULL_CHANNEL = NEW CHANNELIMPL(NULL);" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " PRIVATE CONNECTORCREDENTIALS CREDENTIALS;" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " PRIVATE IREGISTRY<STRING, PROTOCOLFACTORY> PROTOCOLFACTORYREGISTRY;" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " PRIVATE BUFFERPROVIDER BUFFERPROVIDER;" + NL + "" + NL + " /**" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " * AN OPTIONAL EXECUTOR TO BE USED BY THE {@LINK CHANNEL}S TO PROCESS THEIR" + NL //$NON-NLS-1$
- + " * {@LINK CHANNELIMPL#RECEIVEQUEUE} INSTEAD OF THE CURRENT THREAD. IF NOT" + NL //$NON-NLS-1$
- + " * <CODE>NULL</CODE> THE SENDER AND THE RECEIVER PEERS BECOME DECOUPLED." + NL + " * <P>" + NL + " */" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + NL + " PRIVATE EXECUTORSERVICE RECEIVEEXECUTOR;" + NL + "" + NL + " /**" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " * TODO SYNCHRONIZE ON CHANNELS?" + NL + " */" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " PRIVATE LIST<CHANNELIMPL> CHANNELS = NEW ARRAYLIST();" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " PRIVATE STATE STATE = STATE.DISCONNECTED;" + NL + "" + NL + " /**" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " * DON\'T INITIALIZE LAZILY TO CIRCUMVENT SYNCHRONIZATION!" + NL + " */" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " PRIVATE QUEUE<STATELISTENER> STATELISTENERS = NEW CONCURRENTLINKEDQUEUE();" + NL + "" + NL + " /**" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " * DON\'T INITIALIZE LAZILY TO CIRCUMVENT SYNCHRONIZATION!" + NL + " */" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " PRIVATE QUEUE<CHANNELLISTENER> CHANNELLISTENERS = NEW CONCURRENTLINKEDQUEUE();" + NL + "" + NL + " /**" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + NL + " * IS REGISTERED WITH EACH {@LINK CHANNEL} OF THIS {@LINK CONNECTOR}." + NL + " * <P>" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " */" + NL + " PRIVATE LIFECYCLELISTENER CHANNELLIFECYCLELISTENER = NEW CHANNELLIFECYCLELISTENER();" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + "" + NL + " PRIVATE COUNTDOWNLATCH FINISHEDCONNECTING;" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " PRIVATE COUNTDOWNLATCH FINISHEDNEGOTIATING;" + NL + "" + NL + " PUBLIC ABSTRACTCONNECTOR()" + NL + " {" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + NL + " }" + NL + "" + NL + " PUBLIC EXECUTORSERVICE GETRECEIVEEXECUTOR()" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " RETURN RECEIVEEXECUTOR;" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " PUBLIC VOID SETRECEIVEEXECUTOR(EXECUTORSERVICE RECEIVEEXECUTOR)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " THIS.RECEIVEEXECUTOR = RECEIVEEXECUTOR;" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " PUBLIC IREGISTRY<STRING, PROTOCOLFACTORY> GETPROTOCOLFACTORYREGISTRY()" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " RETURN PROTOCOLFACTORYREGISTRY;" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " PUBLIC VOID SETPROTOCOLFACTORYREGISTRY(IREGISTRY<STRING, PROTOCOLFACTORY> PROTOCOLFACTORYREGISTRY)" + NL //$NON-NLS-1$
- + " {" + NL + " THIS.PROTOCOLFACTORYREGISTRY = PROTOCOLFACTORYREGISTRY;" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " PUBLIC VOID ADDSTATELISTENER(STATELISTENER LISTENER)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " STATELISTENERS.ADD(LISTENER);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " PUBLIC VOID REMOVESTATELISTENER(STATELISTENER LISTENER)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " STATELISTENERS.REMOVE(LISTENER);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " PUBLIC VOID ADDCHANNELLISTENER(CHANNELLISTENER LISTENER)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " CHANNELLISTENERS.ADD(LISTENER);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " PUBLIC VOID REMOVECHANNELLISTENER(CHANNELLISTENER LISTENER)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " CHANNELLISTENERS.REMOVE(LISTENER);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " PUBLIC BUFFERPROVIDER GETBUFFERPROVIDER()" + NL + " {" + NL + " RETURN BUFFERPROVIDER;" + NL + " }" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + NL + "" + NL + " PUBLIC VOID SETBUFFERPROVIDER(BUFFERPROVIDER BUFFERPROVIDER)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " THIS.BUFFERPROVIDER = BUFFERPROVIDER;" + NL + " }" + NL + "" + NL + " PUBLIC BOOLEAN ISCLIENT()" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " {" + NL + " RETURN GETTYPE() == TYPE.CLIENT;" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " PUBLIC BOOLEAN ISSERVER()" + NL + " {" + NL + " RETURN GETTYPE() == TYPE.SERVER;" + NL + " }" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + "" + NL + " PUBLIC CONNECTORCREDENTIALS GETCREDENTIALS()" + NL + " {" + NL + " RETURN CREDENTIALS;" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " }" + NL + "" + NL + " PUBLIC VOID SETCREDENTIALS(CONNECTORCREDENTIALS CREDENTIALS)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " THIS.CREDENTIALS = CREDENTIALS;" + NL + " }" + NL + "" + NL + " PUBLIC STATE GETSTATE()" + NL + " {" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- + NL + " RETURN STATE;" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " PUBLIC VOID SETSTATE(STATE NEWSTATE) THROWS CONNECTOREXCEPTION" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " STATE OLDSTATE = GETSTATE();" + NL + " IF (NEWSTATE != OLDSTATE)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " IOUTIL.OUT().PRINTLN(TOSTRING() + \": SETTING STATE \" + NEWSTATE + \" (WAS \"" + NL //$NON-NLS-1$
- + " + OLDSTATE.TOSTRING().TOLOWERCASE() + \")\");" + NL + " STATE = NEWSTATE;" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " FIRESTATECHANGED(NEWSTATE, OLDSTATE);" + NL + "" + NL + " SWITCH (NEWSTATE)" + NL + " {" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + NL + " CASE DISCONNECTED:" + NL + " IF (FINISHEDCONNECTING != NULL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " FINISHEDCONNECTING.COUNTDOWN();" + NL + " FINISHEDCONNECTING = NULL;" + NL + " }" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + NL + "" + NL + " IF (FINISHEDNEGOTIATING != NULL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " FINISHEDNEGOTIATING.COUNTDOWN();" + NL + " FINISHEDNEGOTIATING = NULL;" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " }" + NL + " BREAK;" + NL + "" + NL + " CASE CONNECTING:" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " FINISHEDCONNECTING = NEW COUNTDOWNLATCH(1);" + NL //$NON-NLS-1$
- + " FINISHEDNEGOTIATING = NEW COUNTDOWNLATCH(1);" + NL + " IF (GETTYPE() == TYPE.SERVER)" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " {" + NL + " SETSTATE(STATE.NEGOTIATING);" + NL + " }" + NL + " BREAK;" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + "" + NL + " CASE NEGOTIATING:" + NL + " FINISHEDCONNECTING.COUNTDOWN();" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " SETSTATE(STATE.CONNECTED); // TODO IMPLEMENT NEGOTIATION" + NL + " BREAK;" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " CASE CONNECTED:" + NL + " FINISHEDCONNECTING.COUNTDOWN(); // JUST IN CASE OF SUSPICION" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " FINISHEDNEGOTIATING.COUNTDOWN();" + NL + " BREAK;" + NL + "" + NL + " }" + NL + " }" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- + NL + " }" + NL + "" + NL + " PUBLIC BOOLEAN ISCONNECTED()" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " RETURN GETSTATE() == STATE.CONNECTED;" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " PUBLIC VOID CONNECTASYNC() THROWS CONNECTOREXCEPTION" + NL + " {" + NL + " TRY" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " ACTIVATE();" + NL + " }" + NL + " CATCH (CONNECTOREXCEPTION EX)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " THROW EX;" + NL + " }" + NL + " CATCH (EXCEPTION EX)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " THROW NEW CONNECTOREXCEPTION(EX);" + NL + " }" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " PUBLIC BOOLEAN WAITFORCONNECTION(LONG TIMEOUT) THROWS CONNECTOREXCEPTION" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " STATE STATE = GETSTATE();" + NL + " IF (STATE == STATE.DISCONNECTED)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " RETURN FALSE;" + NL + " }" + NL + "" + NL + " TRY" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- + " IOUTIL.OUT().PRINTLN(TOSTRING() + \": WAITING FOR CONNECTION...\");" + NL //$NON-NLS-1$
- + " RETURN FINISHEDNEGOTIATING.AWAIT(TIMEOUT, TIMEUNIT.MILLISECONDS);" + NL + " }" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " CATCH (INTERRUPTEDEXCEPTION EX)" + NL + " {" + NL + " RETURN FALSE;" + NL + " }" + NL + " }" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- + NL + "" + NL + " PUBLIC BOOLEAN CONNECT(LONG TIMEOUT) THROWS CONNECTOREXCEPTION" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " CONNECTASYNC();" + NL + " RETURN WAITFORCONNECTION(TIMEOUT);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " PUBLIC CONNECTOREXCEPTION DISCONNECT()" + NL + " {" + NL + " EXCEPTION EX = DEACTIVATE();" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " IF (EX == NULL)" + NL + " {" + NL + " RETURN NULL;" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- + " IF (EX INSTANCEOF CONNECTOREXCEPTION)" + NL + " {" + NL + " RETURN (CONNECTOREXCEPTION)EX;" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " }" + NL + "" + NL + " RETURN NEW CONNECTOREXCEPTION(EX);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- + " PUBLIC CHANNEL[] GETCHANNELS()" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " FINAL LIST<CHANNEL> RESULT = NEW ARRAYLIST<CHANNEL>();" + NL + " SYNCHRONIZED (CHANNELS)" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " {" + NL + " FOR (FINAL CHANNELIMPL CHANNEL : CHANNELS)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " IF (CHANNEL != NULL_CHANNEL)" + NL + " {" + NL + " RESULT.ADD(CHANNEL);" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " }" + NL + " }" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " RETURN RESULT.TOARRAY(NEW CHANNEL[RESULT.SIZE()]);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " PUBLIC CHANNEL OPENCHANNEL() THROWS CONNECTOREXCEPTION" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " RETURN OPENCHANNEL(NULL);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " PUBLIC CHANNEL OPENCHANNEL(STRING PROTOCOLID) THROWS CONNECTOREXCEPTION" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " SHORT CHANNELINDEX = FINDFREECHANNELINDEX();" + NL //$NON-NLS-1$
- + " CHANNELIMPL CHANNEL = CREATECHANNEL(CHANNELINDEX, PROTOCOLID);" + NL //$NON-NLS-1$
- + " REGISTERCHANNELWITHPEER(CHANNELINDEX, PROTOCOLID);" + NL + "" + NL + " TRY" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " CHANNEL.ACTIVATE();" + NL + " }" + NL + " CATCH (CONNECTOREXCEPTION EX)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " THROW EX;" + NL + " }" + NL + " CATCH (EXCEPTION EX)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " THROW NEW CONNECTOREXCEPTION(EX);" + NL + " }" + NL + "" + NL + " RETURN CHANNEL;" + NL + " }" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- + NL + "" + NL + " PUBLIC CHANNELIMPL CREATECHANNEL(SHORT CHANNELINDEX, STRING PROTOCOLID)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " PROTOCOL PROTOCOL = CREATEPROTOCOL(PROTOCOLID);" + NL + " IF (PROTOCOL == NULL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " IOUTIL.OUT().PRINTLN(TOSTRING() + \": OPENING CHANNEL WITHOUT PROTOCOL\");" + NL + " }" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " ELSE" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " IOUTIL.OUT().PRINTLN(TOSTRING() + \": OPENING CHANNEL WITH PROTOCOL \" + PROTOCOLID);" + NL + " }" //$NON-NLS-1$ //$NON-NLS-2$
- + NL + "" + NL + " CHANNELIMPL CHANNEL = NEW CHANNELIMPL(RECEIVEEXECUTOR);" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " CHANNEL.SETCHANNELINDEX(CHANNELINDEX);" + NL + " CHANNEL.SETMULTIPLEXER(THIS);" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " CHANNEL.SETRECEIVEHANDLER(PROTOCOL);" + NL //$NON-NLS-1$
- + " CHANNEL.ADDLIFECYCLELISTENER(CHANNELLIFECYCLELISTENER);" + NL + " ADDCHANNEL(CHANNEL);" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " RETURN CHANNEL;" + NL + " }" + NL + "" + NL + " PUBLIC CHANNELIMPL GETCHANNEL(SHORT CHANNELINDEX)" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + NL + " {" + NL + " TRY" + NL + " {" + NL + " CHANNELIMPL CHANNEL = CHANNELS.GET(CHANNELINDEX);" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + NL + " IF (CHANNEL == NULL || CHANNEL == NULL_CHANNEL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " THROW NEW NULLPOINTEREXCEPTION();" + NL + " }" + NL + "" + NL + " RETURN CHANNEL;" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " }" + NL + " CATCH (INDEXOUTOFBOUNDSEXCEPTION EX)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " IOUTIL.OUT().PRINTLN(TOSTRING() + \": INVALID CHANNELINDEX \" + CHANNELINDEX);" + NL //$NON-NLS-1$
- + " RETURN NULL;" + NL + " }" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " PROTECTED LIST<BUFFERQUEUE> GETCHANNELBUFFERQUEUES()" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " FINAL LIST<BUFFERQUEUE> RESULT = NEW ARRAYLIST<BUFFERQUEUE>();" + NL + " SYNCHRONIZED (CHANNELS)" //$NON-NLS-1$ //$NON-NLS-2$
- + NL + " {" + NL + " FOR (FINAL CHANNELIMPL CHANNEL : CHANNELS)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " IF (CHANNEL != NULL_CHANNEL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " BUFFERQUEUE BUFFERQUEUE = CHANNEL.GETSENDQUEUE();" + NL + " RESULT.ADD(BUFFERQUEUE);" //$NON-NLS-1$ //$NON-NLS-2$
- + NL + " }" + NL + " }" + NL + " }" + NL + "" + NL + " RETURN RESULT;" + NL + " }" + NL + "" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- + NL + " PROTECTED SHORT FINDFREECHANNELINDEX()" + NL + " {" + NL + " SYNCHRONIZED (CHANNELS)" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " {" + NL + " INT SIZE = CHANNELS.SIZE();" + NL + " FOR (SHORT I = 0; I < SIZE; I++)" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " {" + NL + " IF (CHANNELS.GET(I) == NULL_CHANNEL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " RETURN I;" + NL + " }" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " CHANNELS.ADD(NULL_CHANNEL);" + NL + " RETURN (SHORT)SIZE;" + NL + " }" + NL + " }" + NL + "" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- + NL + " PROTECTED VOID ADDCHANNEL(CHANNELIMPL CHANNEL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " SHORT CHANNELINDEX = CHANNEL.GETCHANNELINDEX();" + NL + " WHILE (CHANNELINDEX >= CHANNELS.SIZE())" //$NON-NLS-1$ //$NON-NLS-2$
- + NL + " {" + NL + " CHANNELS.ADD(NULL_CHANNEL);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " CHANNELS.SET(CHANNELINDEX, CHANNEL);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " PROTECTED VOID REMOVECHANNEL(CHANNELIMPL CHANNEL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " CHANNEL.REMOVELIFECYCLELISTENER(CHANNELLIFECYCLELISTENER);" + NL //$NON-NLS-1$
- + " INT CHANNELINDEX = CHANNEL.GETCHANNELINDEX();" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " IOUTIL.OUT().PRINTLN(TOSTRING() + \": REMOVING CHANNEL \" + CHANNELINDEX);" + NL //$NON-NLS-1$
- + " CHANNELS.SET(CHANNELINDEX, NULL_CHANNEL);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " PROTECTED PROTOCOL CREATEPROTOCOL(STRING PROTOCOLID)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " IF (PROTOCOLID == NULL || PROTOCOLID.LENGTH() == 0)" + NL + " {" + NL + " RETURN NULL;" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " }" + NL + "" + NL + " IREGISTRY<STRING, PROTOCOLFACTORY> REGISTRY = GETPROTOCOLFACTORYREGISTRY();" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + NL + " IF (REGISTRY == NULL)" + NL + " {" + NL + " RETURN NULL;" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- + " PROTOCOLFACTORY FACTORY = REGISTRY.LOOKUP(PROTOCOLID);" + NL + " IF (FACTORY == NULL)" + NL + " {" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + NL + " RETURN NULL;" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " IOUTIL.OUT().PRINTLN(TOSTRING() + \": CREATING PROTOCOL \" + PROTOCOLID);" + NL //$NON-NLS-1$
- + " RETURN FACTORY.CREATEPROTOCOL();" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " PROTECTED VOID FIRECHANNELOPENED(CHANNEL CHANNEL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " FOR (CHANNELLISTENER LISTENER : CHANNELLISTENERS)" + NL + " {" + NL + " TRY" + NL + " {" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + NL + " LISTENER.NOTIFYCHANNELOPENED(CHANNEL);" + NL + " }" + NL + " CATCH (EXCEPTION EX)" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + NL + " {" + NL + " EX.PRINTSTACKTRACE();" + NL + " }" + NL + " }" + NL + " }" + NL + "" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- + NL + " PROTECTED VOID FIRECHANNELCLOSING(CHANNEL CHANNEL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " FOR (CHANNELLISTENER LISTENER : CHANNELLISTENERS)" + NL + " {" + NL + " TRY" + NL + " {" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + NL + " LISTENER.NOTIFYCHANNELCLOSING(CHANNEL);" + NL + " }" + NL + " CATCH (EXCEPTION EX)" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + NL + " {" + NL + " EX.PRINTSTACKTRACE();" + NL + " }" + NL + " }" + NL + " }" + NL + "" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- + NL + " PROTECTED VOID FIRESTATECHANGED(STATE NEWSTATE, STATE OLDSTATE)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " FOR (STATELISTENER LISTENER : STATELISTENERS)" + NL + " {" + NL + " TRY" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " LISTENER.NOTIFYSTATECHANGED(THIS, NEWSTATE, OLDSTATE);" + NL + " }" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " CATCH (EXCEPTION EX)" + NL + " {" + NL + " EX.PRINTSTACKTRACE();" + NL + " }" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " }" + NL + " }" + NL + "" + NL + " @OVERRIDE" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " PROTECTED VOID ONACCESSBEFOREACTIVATE() THROWS EXCEPTION" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " SUPER.ONACCESSBEFOREACTIVATE();" + NL + " IF (BUFFERPROVIDER == NULL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " THROW NEW ILLEGALSTATEEXCEPTION(\"BUFFERPROVIDER == NULL\");" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " IF (PROTOCOLFACTORYREGISTRY == NULL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " IOUTIL.OUT().PRINTLN(TOSTRING() + \": (INFO) PROTOCOLFACTORYREGISTRY == NULL\");" + NL + " }" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + "" + NL + " IF (RECEIVEEXECUTOR == NULL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " IOUTIL.OUT().PRINTLN(TOSTRING() + \": (INFO) RECEIVEEXECUTOR == NULL\");" + NL + " }" + NL + " }" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + NL + "" + NL + " @OVERRIDE" + NL + " PROTECTED VOID ONACTIVATE() THROWS EXCEPTION" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " SUPER.ONACTIVATE();" + NL + " SETSTATE(STATE.CONNECTING);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " @OVERRIDE" + NL + " PROTECTED VOID ONDEACTIVATE() THROWS EXCEPTION" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " SETSTATE(STATE.DISCONNECTED);" + NL + " FOR (SHORT I = 0; I < CHANNELS.SIZE(); I++)" + NL + " {" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + NL + " CHANNELIMPL CHANNEL = CHANNELS.GET(I);" + NL + " IF (CHANNEL != NULL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " LIFECYCLEUTIL.DEACTIVATE(CHANNEL);" + NL + " }" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " CHANNELS.CLEAR();" + NL + " SUPER.ONDEACTIVATE();" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + " PROTECTED ABSTRACT VOID REGISTERCHANNELWITHPEER(SHORT CHANNELINDEX, STRING PROTOCOLID)" + NL //$NON-NLS-1$
- + " THROWS CONNECTOREXCEPTION;" + NL + "" + NL + " /**" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " * IS REGISTERED WITH EACH {@LINK CHANNEL} OF THIS {@LINK CONNECTOR}." + NL + " * <P>" + NL + " * " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + NL + " * @AUTHOR EIKE STEPPER" + NL + " */" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " PRIVATE FINAL CLASS CHANNELLIFECYCLELISTENER IMPLEMENTS LIFECYCLELISTENER" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " PUBLIC VOID NOTIFYLIFECYCLEACTIVATED(LIFECYCLENOTIFIER NOTIFIER)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " CHANNELIMPL CHANNEL = (CHANNELIMPL)NOTIFIER;" + NL + " FIRECHANNELOPENED(CHANNEL);" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " }" + NL + "" + NL + " PUBLIC VOID NOTIFYLIFECYCLEDEACTIVATING(LIFECYCLENOTIFIER NOTIFIER)" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " {" + NL + " CHANNELIMPL CHANNEL = (CHANNELIMPL)NOTIFIER;" + NL //$NON-NLS-1$ //$NON-NLS-2$
- + " FIRECHANNELCLOSING(CHANNEL);" + NL + " REMOVECHANNEL(CHANNEL);" + NL + " }" + NL + " }" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- + "}" + NL; //$NON-NLS-1$
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.data;
+
+import java.util.StringTokenizer;
+
+/**
+ * @author Eike Stepper
+ */
+public final class HugeData
+{
+ public static final String NL = System.getProperty("line.separator"); //$NON-NLS-1$
+
+ public static StringTokenizer getTokenizer()
+ {
+ return new StringTokenizer(getText(), NL);
+ }
+
+ public static String[] getArray()
+ {
+ return getText().split(NL);
+ }
+
+ public static byte[] getBytes()
+ {
+ return getText().getBytes();
+ }
+
+ public static String getText()
+ {
+ return "/**" + NL //$NON-NLS-1$
+ + " * COPYRIGHT (C) 2004 - 2008 EIKE STEPPER, GERMANY." + NL //$NON-NLS-1$
+ + " * ALL RIGHTS RESERVED. THIS PROGRAM AND THE ACCOMPANYING MATERIALS" + NL //$NON-NLS-1$
+ + " * ARE MADE AVAILABLE UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE V1.0" + NL //$NON-NLS-1$
+ + " * WHICH ACCOMPANIES THIS DISTRIBUTION, AND IS AVAILABLE AT" + NL //$NON-NLS-1$
+ + " * HTTP://WWW.ECLIPSE.ORG/LEGAL/EPL-V10.HTML" + NL + " * " + NL + " * CONTRIBUTORS:" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " * EIKE STEPPER - INITIAL API AND IMPLEMENTATION" + NL //$NON-NLS-1$
+ + " */" + NL //$NON-NLS-1$
+ + "PACKAGE ORG.ECLIPSE.INTERNAL.NET4J.TRANSPORT.CONNECTOR;" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + "IMPORT ORG.ECLIPSE.NET4J.TRANSPORT.BUFFER.BUFFERPROVIDER;" + NL //$NON-NLS-1$
+ + "IMPORT ORG.ECLIPSE.NET4J.TRANSPORT.CHANNEL.CHANNEL;" + NL //$NON-NLS-1$
+ + "IMPORT ORG.ECLIPSE.NET4J.TRANSPORT.CHANNEL.MULTIPLEXER;" + NL //$NON-NLS-1$
+ + "IMPORT ORG.ECLIPSE.NET4J.TRANSPORT.CONNECTOR.CONNECTOR;" + NL //$NON-NLS-1$
+ + "IMPORT ORG.ECLIPSE.NET4J.TRANSPORT.CONNECTOR.CONNECTOREXCEPTION;" + NL //$NON-NLS-1$
+ + "IMPORT ORG.ECLIPSE.NET4J.TRANSPORT.CONNECTOR.CREDENTIALS;" + NL //$NON-NLS-1$
+ + "IMPORT ORG.ECLIPSE.NET4J.TRANSPORT.CONNECTOR.PROTOCOL;" + NL //$NON-NLS-1$
+ + "IMPORT ORG.ECLIPSE.NET4J.TRANSPORT.CONNECTOR.PROTOCOLFACTORY;" + NL //$NON-NLS-1$
+ + "IMPORT ORG.ECLIPSE.NET4J.UTIL.LIFECYCLE.LIFECYCLELISTENER;" + NL //$NON-NLS-1$
+ + "IMPORT ORG.ECLIPSE.NET4J.UTIL.LIFECYCLE.LIFECYCLENOTIFIER;" + NL //$NON-NLS-1$
+ + "IMPORT ORG.ECLIPSE.NET4J.UTIL.REGISTRY.IREGISTRY;" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + "IMPORT ORG.ECLIPSE.INTERNAL.NET4J.TRANSPORT.CHANNEL.CHANNELIMPL;" + NL //$NON-NLS-1$
+ + "IMPORT ORG.ECLIPSE.INTERNAL.NET4J.UTIL.STREAM.BUFFERQUEUE;" + NL //$NON-NLS-1$
+ + "IMPORT ORG.ECLIPSE.INTERNAL.NET4J.UTIL.LIFECYCLE.ABSTRACTCOMPONENT;" + NL //$NON-NLS-1$
+ + "IMPORT ORG.ECLIPSE.INTERNAL.NET4J.UTIL.LIFECYCLE.LIFECYCLEUTIL;" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + "IMPORT JAVA.UTIL.ARRAYLIST;" + NL + "IMPORT JAVA.UTIL.LIST;" + NL + "IMPORT JAVA.UTIL.QUEUE;" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + "IMPORT JAVA.UTIL.CONCURRENT.CONCURRENTLINKEDQUEUE;" + NL + "IMPORT JAVA.UTIL.CONCURRENT.COUNTDOWNLATCH;" //$NON-NLS-1$ //$NON-NLS-2$
+ + NL + "IMPORT JAVA.UTIL.CONCURRENT.EXECUTORSERVICE;" + NL + "IMPORT JAVA.UTIL.CONCURRENT.TIMEUNIT;" + NL + "" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + NL + "/**" + NL + " * @AUTHOR EIKE STEPPER" + NL + " */" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + "PUBLIC ABSTRACT CLASS ABSTRACTCONNECTOR EXTENDS ABSTRACTLIFECYCLE IMPLEMENTS CONNECTOR, CHANNELMULTIPLEXER" //$NON-NLS-1$
+ + NL + "{" + NL + " PRIVATE STATIC FINAL CHANNELIMPL NULL_CHANNEL = NEW CHANNELIMPL(NULL);" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " PRIVATE CONNECTORCREDENTIALS CREDENTIALS;" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " PRIVATE IREGISTRY<STRING, PROTOCOLFACTORY> PROTOCOLFACTORYREGISTRY;" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " PRIVATE BUFFERPROVIDER BUFFERPROVIDER;" + NL + "" + NL + " /**" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " * AN OPTIONAL EXECUTOR TO BE USED BY THE {@LINK CHANNEL}S TO PROCESS THEIR" + NL //$NON-NLS-1$
+ + " * {@LINK CHANNELIMPL#RECEIVEQUEUE} INSTEAD OF THE CURRENT THREAD. IF NOT" + NL //$NON-NLS-1$
+ + " * <CODE>NULL</CODE> THE SENDER AND THE RECEIVER PEERS BECOME DECOUPLED." + NL + " * <P>" + NL + " */" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + NL + " PRIVATE EXECUTORSERVICE RECEIVEEXECUTOR;" + NL + "" + NL + " /**" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " * TODO SYNCHRONIZE ON CHANNELS?" + NL + " */" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " PRIVATE LIST<CHANNELIMPL> CHANNELS = NEW ARRAYLIST();" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " PRIVATE STATE STATE = STATE.DISCONNECTED;" + NL + "" + NL + " /**" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " * DON\'T INITIALIZE LAZILY TO CIRCUMVENT SYNCHRONIZATION!" + NL + " */" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " PRIVATE QUEUE<STATELISTENER> STATELISTENERS = NEW CONCURRENTLINKEDQUEUE();" + NL + "" + NL + " /**" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " * DON\'T INITIALIZE LAZILY TO CIRCUMVENT SYNCHRONIZATION!" + NL + " */" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " PRIVATE QUEUE<CHANNELLISTENER> CHANNELLISTENERS = NEW CONCURRENTLINKEDQUEUE();" + NL + "" + NL + " /**" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + NL + " * IS REGISTERED WITH EACH {@LINK CHANNEL} OF THIS {@LINK CONNECTOR}." + NL + " * <P>" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " */" + NL + " PRIVATE LIFECYCLELISTENER CHANNELLIFECYCLELISTENER = NEW CHANNELLIFECYCLELISTENER();" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + "" + NL + " PRIVATE COUNTDOWNLATCH FINISHEDCONNECTING;" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " PRIVATE COUNTDOWNLATCH FINISHEDNEGOTIATING;" + NL + "" + NL + " PUBLIC ABSTRACTCONNECTOR()" + NL + " {" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + NL + " }" + NL + "" + NL + " PUBLIC EXECUTORSERVICE GETRECEIVEEXECUTOR()" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " RETURN RECEIVEEXECUTOR;" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " PUBLIC VOID SETRECEIVEEXECUTOR(EXECUTORSERVICE RECEIVEEXECUTOR)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " THIS.RECEIVEEXECUTOR = RECEIVEEXECUTOR;" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " PUBLIC IREGISTRY<STRING, PROTOCOLFACTORY> GETPROTOCOLFACTORYREGISTRY()" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " RETURN PROTOCOLFACTORYREGISTRY;" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " PUBLIC VOID SETPROTOCOLFACTORYREGISTRY(IREGISTRY<STRING, PROTOCOLFACTORY> PROTOCOLFACTORYREGISTRY)" + NL //$NON-NLS-1$
+ + " {" + NL + " THIS.PROTOCOLFACTORYREGISTRY = PROTOCOLFACTORYREGISTRY;" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " PUBLIC VOID ADDSTATELISTENER(STATELISTENER LISTENER)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " STATELISTENERS.ADD(LISTENER);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " PUBLIC VOID REMOVESTATELISTENER(STATELISTENER LISTENER)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " STATELISTENERS.REMOVE(LISTENER);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " PUBLIC VOID ADDCHANNELLISTENER(CHANNELLISTENER LISTENER)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " CHANNELLISTENERS.ADD(LISTENER);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " PUBLIC VOID REMOVECHANNELLISTENER(CHANNELLISTENER LISTENER)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " CHANNELLISTENERS.REMOVE(LISTENER);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " PUBLIC BUFFERPROVIDER GETBUFFERPROVIDER()" + NL + " {" + NL + " RETURN BUFFERPROVIDER;" + NL + " }" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + NL + "" + NL + " PUBLIC VOID SETBUFFERPROVIDER(BUFFERPROVIDER BUFFERPROVIDER)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " THIS.BUFFERPROVIDER = BUFFERPROVIDER;" + NL + " }" + NL + "" + NL + " PUBLIC BOOLEAN ISCLIENT()" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " {" + NL + " RETURN GETTYPE() == TYPE.CLIENT;" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " PUBLIC BOOLEAN ISSERVER()" + NL + " {" + NL + " RETURN GETTYPE() == TYPE.SERVER;" + NL + " }" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + "" + NL + " PUBLIC CONNECTORCREDENTIALS GETCREDENTIALS()" + NL + " {" + NL + " RETURN CREDENTIALS;" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " }" + NL + "" + NL + " PUBLIC VOID SETCREDENTIALS(CONNECTORCREDENTIALS CREDENTIALS)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " THIS.CREDENTIALS = CREDENTIALS;" + NL + " }" + NL + "" + NL + " PUBLIC STATE GETSTATE()" + NL + " {" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ + NL + " RETURN STATE;" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " PUBLIC VOID SETSTATE(STATE NEWSTATE) THROWS CONNECTOREXCEPTION" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " STATE OLDSTATE = GETSTATE();" + NL + " IF (NEWSTATE != OLDSTATE)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " IOUTIL.OUT().PRINTLN(TOSTRING() + \": SETTING STATE \" + NEWSTATE + \" (WAS \"" + NL //$NON-NLS-1$
+ + " + OLDSTATE.TOSTRING().TOLOWERCASE() + \")\");" + NL + " STATE = NEWSTATE;" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " FIRESTATECHANGED(NEWSTATE, OLDSTATE);" + NL + "" + NL + " SWITCH (NEWSTATE)" + NL + " {" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + NL + " CASE DISCONNECTED:" + NL + " IF (FINISHEDCONNECTING != NULL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " FINISHEDCONNECTING.COUNTDOWN();" + NL + " FINISHEDCONNECTING = NULL;" + NL + " }" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + NL + "" + NL + " IF (FINISHEDNEGOTIATING != NULL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " FINISHEDNEGOTIATING.COUNTDOWN();" + NL + " FINISHEDNEGOTIATING = NULL;" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " }" + NL + " BREAK;" + NL + "" + NL + " CASE CONNECTING:" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " FINISHEDCONNECTING = NEW COUNTDOWNLATCH(1);" + NL //$NON-NLS-1$
+ + " FINISHEDNEGOTIATING = NEW COUNTDOWNLATCH(1);" + NL + " IF (GETTYPE() == TYPE.SERVER)" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " {" + NL + " SETSTATE(STATE.NEGOTIATING);" + NL + " }" + NL + " BREAK;" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + "" + NL + " CASE NEGOTIATING:" + NL + " FINISHEDCONNECTING.COUNTDOWN();" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " SETSTATE(STATE.CONNECTED); // TODO IMPLEMENT NEGOTIATION" + NL + " BREAK;" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " CASE CONNECTED:" + NL + " FINISHEDCONNECTING.COUNTDOWN(); // JUST IN CASE OF SUSPICION" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " FINISHEDNEGOTIATING.COUNTDOWN();" + NL + " BREAK;" + NL + "" + NL + " }" + NL + " }" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ + NL + " }" + NL + "" + NL + " PUBLIC BOOLEAN ISCONNECTED()" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " RETURN GETSTATE() == STATE.CONNECTED;" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " PUBLIC VOID CONNECTASYNC() THROWS CONNECTOREXCEPTION" + NL + " {" + NL + " TRY" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " ACTIVATE();" + NL + " }" + NL + " CATCH (CONNECTOREXCEPTION EX)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " THROW EX;" + NL + " }" + NL + " CATCH (EXCEPTION EX)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " THROW NEW CONNECTOREXCEPTION(EX);" + NL + " }" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " PUBLIC BOOLEAN WAITFORCONNECTION(LONG TIMEOUT) THROWS CONNECTOREXCEPTION" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " STATE STATE = GETSTATE();" + NL + " IF (STATE == STATE.DISCONNECTED)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " RETURN FALSE;" + NL + " }" + NL + "" + NL + " TRY" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ + " IOUTIL.OUT().PRINTLN(TOSTRING() + \": WAITING FOR CONNECTION...\");" + NL //$NON-NLS-1$
+ + " RETURN FINISHEDNEGOTIATING.AWAIT(TIMEOUT, TIMEUNIT.MILLISECONDS);" + NL + " }" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " CATCH (INTERRUPTEDEXCEPTION EX)" + NL + " {" + NL + " RETURN FALSE;" + NL + " }" + NL + " }" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ + NL + "" + NL + " PUBLIC BOOLEAN CONNECT(LONG TIMEOUT) THROWS CONNECTOREXCEPTION" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " CONNECTASYNC();" + NL + " RETURN WAITFORCONNECTION(TIMEOUT);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " PUBLIC CONNECTOREXCEPTION DISCONNECT()" + NL + " {" + NL + " EXCEPTION EX = DEACTIVATE();" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " IF (EX == NULL)" + NL + " {" + NL + " RETURN NULL;" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ + " IF (EX INSTANCEOF CONNECTOREXCEPTION)" + NL + " {" + NL + " RETURN (CONNECTOREXCEPTION)EX;" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " }" + NL + "" + NL + " RETURN NEW CONNECTOREXCEPTION(EX);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ + " PUBLIC CHANNEL[] GETCHANNELS()" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " FINAL LIST<CHANNEL> RESULT = NEW ARRAYLIST<CHANNEL>();" + NL + " SYNCHRONIZED (CHANNELS)" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " {" + NL + " FOR (FINAL CHANNELIMPL CHANNEL : CHANNELS)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " IF (CHANNEL != NULL_CHANNEL)" + NL + " {" + NL + " RESULT.ADD(CHANNEL);" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " }" + NL + " }" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " RETURN RESULT.TOARRAY(NEW CHANNEL[RESULT.SIZE()]);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " PUBLIC CHANNEL OPENCHANNEL() THROWS CONNECTOREXCEPTION" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " RETURN OPENCHANNEL(NULL);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " PUBLIC CHANNEL OPENCHANNEL(STRING PROTOCOLID) THROWS CONNECTOREXCEPTION" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " SHORT CHANNELINDEX = FINDFREECHANNELINDEX();" + NL //$NON-NLS-1$
+ + " CHANNELIMPL CHANNEL = CREATECHANNEL(CHANNELINDEX, PROTOCOLID);" + NL //$NON-NLS-1$
+ + " REGISTERCHANNELWITHPEER(CHANNELINDEX, PROTOCOLID);" + NL + "" + NL + " TRY" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " CHANNEL.ACTIVATE();" + NL + " }" + NL + " CATCH (CONNECTOREXCEPTION EX)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " THROW EX;" + NL + " }" + NL + " CATCH (EXCEPTION EX)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " THROW NEW CONNECTOREXCEPTION(EX);" + NL + " }" + NL + "" + NL + " RETURN CHANNEL;" + NL + " }" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ + NL + "" + NL + " PUBLIC CHANNELIMPL CREATECHANNEL(SHORT CHANNELINDEX, STRING PROTOCOLID)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " PROTOCOL PROTOCOL = CREATEPROTOCOL(PROTOCOLID);" + NL + " IF (PROTOCOL == NULL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " IOUTIL.OUT().PRINTLN(TOSTRING() + \": OPENING CHANNEL WITHOUT PROTOCOL\");" + NL + " }" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " ELSE" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " IOUTIL.OUT().PRINTLN(TOSTRING() + \": OPENING CHANNEL WITH PROTOCOL \" + PROTOCOLID);" + NL + " }" //$NON-NLS-1$ //$NON-NLS-2$
+ + NL + "" + NL + " CHANNELIMPL CHANNEL = NEW CHANNELIMPL(RECEIVEEXECUTOR);" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " CHANNEL.SETCHANNELINDEX(CHANNELINDEX);" + NL + " CHANNEL.SETMULTIPLEXER(THIS);" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " CHANNEL.SETRECEIVEHANDLER(PROTOCOL);" + NL //$NON-NLS-1$
+ + " CHANNEL.ADDLIFECYCLELISTENER(CHANNELLIFECYCLELISTENER);" + NL + " ADDCHANNEL(CHANNEL);" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " RETURN CHANNEL;" + NL + " }" + NL + "" + NL + " PUBLIC CHANNELIMPL GETCHANNEL(SHORT CHANNELINDEX)" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + NL + " {" + NL + " TRY" + NL + " {" + NL + " CHANNELIMPL CHANNEL = CHANNELS.GET(CHANNELINDEX);" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + NL + " IF (CHANNEL == NULL || CHANNEL == NULL_CHANNEL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " THROW NEW NULLPOINTEREXCEPTION();" + NL + " }" + NL + "" + NL + " RETURN CHANNEL;" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " }" + NL + " CATCH (INDEXOUTOFBOUNDSEXCEPTION EX)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " IOUTIL.OUT().PRINTLN(TOSTRING() + \": INVALID CHANNELINDEX \" + CHANNELINDEX);" + NL //$NON-NLS-1$
+ + " RETURN NULL;" + NL + " }" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " PROTECTED LIST<BUFFERQUEUE> GETCHANNELBUFFERQUEUES()" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " FINAL LIST<BUFFERQUEUE> RESULT = NEW ARRAYLIST<BUFFERQUEUE>();" + NL + " SYNCHRONIZED (CHANNELS)" //$NON-NLS-1$ //$NON-NLS-2$
+ + NL + " {" + NL + " FOR (FINAL CHANNELIMPL CHANNEL : CHANNELS)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " IF (CHANNEL != NULL_CHANNEL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " BUFFERQUEUE BUFFERQUEUE = CHANNEL.GETSENDQUEUE();" + NL + " RESULT.ADD(BUFFERQUEUE);" //$NON-NLS-1$ //$NON-NLS-2$
+ + NL + " }" + NL + " }" + NL + " }" + NL + "" + NL + " RETURN RESULT;" + NL + " }" + NL + "" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
+ + NL + " PROTECTED SHORT FINDFREECHANNELINDEX()" + NL + " {" + NL + " SYNCHRONIZED (CHANNELS)" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " {" + NL + " INT SIZE = CHANNELS.SIZE();" + NL + " FOR (SHORT I = 0; I < SIZE; I++)" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " {" + NL + " IF (CHANNELS.GET(I) == NULL_CHANNEL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " RETURN I;" + NL + " }" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " CHANNELS.ADD(NULL_CHANNEL);" + NL + " RETURN (SHORT)SIZE;" + NL + " }" + NL + " }" + NL + "" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ + NL + " PROTECTED VOID ADDCHANNEL(CHANNELIMPL CHANNEL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " SHORT CHANNELINDEX = CHANNEL.GETCHANNELINDEX();" + NL + " WHILE (CHANNELINDEX >= CHANNELS.SIZE())" //$NON-NLS-1$ //$NON-NLS-2$
+ + NL + " {" + NL + " CHANNELS.ADD(NULL_CHANNEL);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " CHANNELS.SET(CHANNELINDEX, CHANNEL);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " PROTECTED VOID REMOVECHANNEL(CHANNELIMPL CHANNEL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " CHANNEL.REMOVELIFECYCLELISTENER(CHANNELLIFECYCLELISTENER);" + NL //$NON-NLS-1$
+ + " INT CHANNELINDEX = CHANNEL.GETCHANNELINDEX();" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " IOUTIL.OUT().PRINTLN(TOSTRING() + \": REMOVING CHANNEL \" + CHANNELINDEX);" + NL //$NON-NLS-1$
+ + " CHANNELS.SET(CHANNELINDEX, NULL_CHANNEL);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " PROTECTED PROTOCOL CREATEPROTOCOL(STRING PROTOCOLID)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " IF (PROTOCOLID == NULL || PROTOCOLID.LENGTH() == 0)" + NL + " {" + NL + " RETURN NULL;" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " }" + NL + "" + NL + " IREGISTRY<STRING, PROTOCOLFACTORY> REGISTRY = GETPROTOCOLFACTORYREGISTRY();" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + NL + " IF (REGISTRY == NULL)" + NL + " {" + NL + " RETURN NULL;" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ + " PROTOCOLFACTORY FACTORY = REGISTRY.LOOKUP(PROTOCOLID);" + NL + " IF (FACTORY == NULL)" + NL + " {" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + NL + " RETURN NULL;" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " IOUTIL.OUT().PRINTLN(TOSTRING() + \": CREATING PROTOCOL \" + PROTOCOLID);" + NL //$NON-NLS-1$
+ + " RETURN FACTORY.CREATEPROTOCOL();" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " PROTECTED VOID FIRECHANNELOPENED(CHANNEL CHANNEL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " FOR (CHANNELLISTENER LISTENER : CHANNELLISTENERS)" + NL + " {" + NL + " TRY" + NL + " {" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + NL + " LISTENER.NOTIFYCHANNELOPENED(CHANNEL);" + NL + " }" + NL + " CATCH (EXCEPTION EX)" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + NL + " {" + NL + " EX.PRINTSTACKTRACE();" + NL + " }" + NL + " }" + NL + " }" + NL + "" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ + NL + " PROTECTED VOID FIRECHANNELCLOSING(CHANNEL CHANNEL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " FOR (CHANNELLISTENER LISTENER : CHANNELLISTENERS)" + NL + " {" + NL + " TRY" + NL + " {" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + NL + " LISTENER.NOTIFYCHANNELCLOSING(CHANNEL);" + NL + " }" + NL + " CATCH (EXCEPTION EX)" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + NL + " {" + NL + " EX.PRINTSTACKTRACE();" + NL + " }" + NL + " }" + NL + " }" + NL + "" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ + NL + " PROTECTED VOID FIRESTATECHANGED(STATE NEWSTATE, STATE OLDSTATE)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " FOR (STATELISTENER LISTENER : STATELISTENERS)" + NL + " {" + NL + " TRY" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " LISTENER.NOTIFYSTATECHANGED(THIS, NEWSTATE, OLDSTATE);" + NL + " }" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " CATCH (EXCEPTION EX)" + NL + " {" + NL + " EX.PRINTSTACKTRACE();" + NL + " }" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " }" + NL + " }" + NL + "" + NL + " @OVERRIDE" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " PROTECTED VOID ONACCESSBEFOREACTIVATE() THROWS EXCEPTION" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " SUPER.ONACCESSBEFOREACTIVATE();" + NL + " IF (BUFFERPROVIDER == NULL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " THROW NEW ILLEGALSTATEEXCEPTION(\"BUFFERPROVIDER == NULL\");" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " IF (PROTOCOLFACTORYREGISTRY == NULL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " IOUTIL.OUT().PRINTLN(TOSTRING() + \": (INFO) PROTOCOLFACTORYREGISTRY == NULL\");" + NL + " }" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + "" + NL + " IF (RECEIVEEXECUTOR == NULL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " IOUTIL.OUT().PRINTLN(TOSTRING() + \": (INFO) RECEIVEEXECUTOR == NULL\");" + NL + " }" + NL + " }" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + NL + "" + NL + " @OVERRIDE" + NL + " PROTECTED VOID ONACTIVATE() THROWS EXCEPTION" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " SUPER.ONACTIVATE();" + NL + " SETSTATE(STATE.CONNECTING);" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " @OVERRIDE" + NL + " PROTECTED VOID ONDEACTIVATE() THROWS EXCEPTION" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " SETSTATE(STATE.DISCONNECTED);" + NL + " FOR (SHORT I = 0; I < CHANNELS.SIZE(); I++)" + NL + " {" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + NL + " CHANNELIMPL CHANNEL = CHANNELS.GET(I);" + NL + " IF (CHANNEL != NULL)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " LIFECYCLEUTIL.DEACTIVATE(CHANNEL);" + NL + " }" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " CHANNELS.CLEAR();" + NL + " SUPER.ONDEACTIVATE();" + NL + " }" + NL + "" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + " PROTECTED ABSTRACT VOID REGISTERCHANNELWITHPEER(SHORT CHANNELINDEX, STRING PROTOCOLID)" + NL //$NON-NLS-1$
+ + " THROWS CONNECTOREXCEPTION;" + NL + "" + NL + " /**" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " * IS REGISTERED WITH EACH {@LINK CHANNEL} OF THIS {@LINK CONNECTOR}." + NL + " * <P>" + NL + " * " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + NL + " * @AUTHOR EIKE STEPPER" + NL + " */" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " PRIVATE FINAL CLASS CHANNELLIFECYCLELISTENER IMPLEMENTS LIFECYCLELISTENER" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " PUBLIC VOID NOTIFYLIFECYCLEACTIVATED(LIFECYCLENOTIFIER NOTIFIER)" + NL + " {" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " CHANNELIMPL CHANNEL = (CHANNELIMPL)NOTIFIER;" + NL + " FIRECHANNELOPENED(CHANNEL);" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " }" + NL + "" + NL + " PUBLIC VOID NOTIFYLIFECYCLEDEACTIVATING(LIFECYCLENOTIFIER NOTIFIER)" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " {" + NL + " CHANNELIMPL CHANNEL = (CHANNELIMPL)NOTIFIER;" + NL //$NON-NLS-1$ //$NON-NLS-2$
+ + " FIRECHANNELCLOSING(CHANNEL);" + NL + " REMOVECHANNEL(CHANNEL);" + NL + " }" + NL + " }" + NL //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ + "}" + NL; //$NON-NLS-1$
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/data/TinyData.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/data/TinyData.java
index cc6d06a7f0..fa19a1bd37 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/data/TinyData.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/data/TinyData.java
@@ -1,41 +1,41 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.data;
-
-import java.util.StringTokenizer;
-
-/**
- * @author Eike Stepper
- */
-public final class TinyData
-{
- public static final String NL = System.getProperty("line.separator"); //$NON-NLS-1$
-
- public static StringTokenizer getTokenizer()
- {
- return new StringTokenizer(getText(), NL);
- }
-
- public static String[] getArray()
- {
- return getText().split(NL);
- }
-
- public static byte[] getBytes()
- {
- return getText().getBytes();
- }
-
- public static String getText()
- {
- return "COPYRIGHT (C) 2004 - 2008 EIKE STEPPER, GERMANY. ALL RIGHTS RESERVED."; //$NON-NLS-1$
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.data;
+
+import java.util.StringTokenizer;
+
+/**
+ * @author Eike Stepper
+ */
+public final class TinyData
+{
+ public static final String NL = System.getProperty("line.separator"); //$NON-NLS-1$
+
+ public static StringTokenizer getTokenizer()
+ {
+ return new StringTokenizer(getText(), NL);
+ }
+
+ public static String[] getArray()
+ {
+ return getText().split(NL);
+ }
+
+ public static byte[] getBytes()
+ {
+ return getText().getBytes();
+ }
+
+ public static String getText()
+ {
+ return "COPYRIGHT (C) 2004 - 2008 EIKE STEPPER, GERMANY. ALL RIGHTS RESERVED."; //$NON-NLS-1$
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/defs/JVMAcceptorDefImplTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/defs/JVMAcceptorDefImplTest.java
index 5afbfb5b67..9691e05d0b 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/defs/JVMAcceptorDefImplTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/defs/JVMAcceptorDefImplTest.java
@@ -1,95 +1,95 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.net4j.tests.defs;
-
-import org.eclipse.net4j.Net4jUtil;
-import org.eclipse.net4j.buffer.IBufferPool;
-import org.eclipse.net4j.defs.JVMAcceptorDef;
-import org.eclipse.net4j.defs.Net4jDefsFactory;
-import org.eclipse.net4j.internal.jvm.JVMClientConnector;
-import org.eclipse.net4j.jvm.IJVMAcceptor;
-import org.eclipse.net4j.jvm.IJVMConnector;
-import org.eclipse.net4j.util.defs.Net4jUtilDefsFactory;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.tests.AbstractOMTest;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-/**
- * @author Andre Dietisheim
- */
-public class JVMAcceptorDefImplTest extends AbstractOMTest
-{
- private static final String NAME = "JVMConnector1"; //$NON-NLS-1$
-
- private static final long TIMEOUT = 10000l;
-
- private static final long DELAY = 500l;
-
- private IJVMConnector jvmConnector;
-
- @Override
- protected void doSetUp() throws Exception
- {
- jvmConnector = createJVMClientConnector();
- }
-
- @Override
- protected void doTearDown() throws Exception
- {
- LifecycleUtil.deactivate(jvmConnector);
- }
-
- public void testAcceptorDefOpensConnection()
- {
- JVMAcceptorDef jvmAcceptorDef = Net4jDefsFactory.eINSTANCE.createJVMAcceptorDef();
- jvmAcceptorDef.setBufferProvider(Net4jDefsFactory.eINSTANCE.createBufferPoolDef());
- jvmAcceptorDef.setExecutorService(Net4jUtilDefsFactory.eINSTANCE.createThreadPoolDef());
- jvmAcceptorDef.setName(NAME);
-
- IJVMAcceptor jvmAcceptor = (IJVMAcceptor)jvmAcceptorDef.getInstance();
-
- assertEquals(true, LifecycleUtil.isActive(jvmAcceptor));
-
- LifecycleUtil.activate(jvmConnector);
- jvmConnector.waitForConnection(DELAY + TIMEOUT);
-
- assertEquals(true, LifecycleUtil.isActive(jvmConnector));
-
- LifecycleUtil.deactivate(jvmAcceptor);
- }
-
- protected IJVMConnector createJVMClientConnector()
- {
- JVMClientConnector jvmClientConnector = new JVMClientConnector();
- jvmClientConnector.getConfig().setBufferProvider(createBufferPool());
- jvmClientConnector.getConfig().setReceiveExecutor(createThreadPool());
- jvmClientConnector.setName(NAME);
-
- return jvmClientConnector;
- }
-
- private IBufferPool createBufferPool()
- {
- IBufferPool bufferPool = Net4jUtil.createBufferPool();
- LifecycleUtil.activate(bufferPool);
- return bufferPool;
- }
-
- private ExecutorService createThreadPool()
- {
- ExecutorService threadPool = Executors.newCachedThreadPool();
- LifecycleUtil.activate(threadPool);
- return threadPool;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.net4j.tests.defs;
+
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.buffer.IBufferPool;
+import org.eclipse.net4j.defs.JVMAcceptorDef;
+import org.eclipse.net4j.defs.Net4jDefsFactory;
+import org.eclipse.net4j.internal.jvm.JVMClientConnector;
+import org.eclipse.net4j.jvm.IJVMAcceptor;
+import org.eclipse.net4j.jvm.IJVMConnector;
+import org.eclipse.net4j.util.defs.Net4jUtilDefsFactory;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.tests.AbstractOMTest;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class JVMAcceptorDefImplTest extends AbstractOMTest
+{
+ private static final String NAME = "JVMConnector1"; //$NON-NLS-1$
+
+ private static final long TIMEOUT = 10000l;
+
+ private static final long DELAY = 500l;
+
+ private IJVMConnector jvmConnector;
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ jvmConnector = createJVMClientConnector();
+ }
+
+ @Override
+ protected void doTearDown() throws Exception
+ {
+ LifecycleUtil.deactivate(jvmConnector);
+ }
+
+ public void testAcceptorDefOpensConnection()
+ {
+ JVMAcceptorDef jvmAcceptorDef = Net4jDefsFactory.eINSTANCE.createJVMAcceptorDef();
+ jvmAcceptorDef.setBufferProvider(Net4jDefsFactory.eINSTANCE.createBufferPoolDef());
+ jvmAcceptorDef.setExecutorService(Net4jUtilDefsFactory.eINSTANCE.createThreadPoolDef());
+ jvmAcceptorDef.setName(NAME);
+
+ IJVMAcceptor jvmAcceptor = (IJVMAcceptor)jvmAcceptorDef.getInstance();
+
+ assertEquals(true, LifecycleUtil.isActive(jvmAcceptor));
+
+ LifecycleUtil.activate(jvmConnector);
+ jvmConnector.waitForConnection(DELAY + TIMEOUT);
+
+ assertEquals(true, LifecycleUtil.isActive(jvmConnector));
+
+ LifecycleUtil.deactivate(jvmAcceptor);
+ }
+
+ protected IJVMConnector createJVMClientConnector()
+ {
+ JVMClientConnector jvmClientConnector = new JVMClientConnector();
+ jvmClientConnector.getConfig().setBufferProvider(createBufferPool());
+ jvmClientConnector.getConfig().setReceiveExecutor(createThreadPool());
+ jvmClientConnector.setName(NAME);
+
+ return jvmClientConnector;
+ }
+
+ private IBufferPool createBufferPool()
+ {
+ IBufferPool bufferPool = Net4jUtil.createBufferPool();
+ LifecycleUtil.activate(bufferPool);
+ return bufferPool;
+ }
+
+ private ExecutorService createThreadPool()
+ {
+ ExecutorService threadPool = Executors.newCachedThreadPool();
+ LifecycleUtil.activate(threadPool);
+ return threadPool;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/defs/JVMConnectorDefImplTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/defs/JVMConnectorDefImplTest.java
index a8173c3498..782fd5f13b 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/defs/JVMConnectorDefImplTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/defs/JVMConnectorDefImplTest.java
@@ -1,80 +1,80 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.net4j.tests.defs;
-
-import org.eclipse.net4j.Net4jUtil;
-import org.eclipse.net4j.buffer.IBufferPool;
-import org.eclipse.net4j.defs.JVMConnectorDef;
-import org.eclipse.net4j.defs.Net4jDefsFactory;
-import org.eclipse.net4j.internal.jvm.JVMAcceptor;
-import org.eclipse.net4j.jvm.IJVMAcceptor;
-import org.eclipse.net4j.jvm.IJVMConnector;
-import org.eclipse.net4j.util.defs.Net4jUtilDefsFactory;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.tests.AbstractOMTest;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-/**
- * @author Andre Dietisheim
- */
-public class JVMConnectorDefImplTest extends AbstractOMTest
-{
- private static final String NAME = "test1"; //$NON-NLS-1$
-
- public void testIncompleteInitializationThrowsIllegalArgumentException()
- {
- try
- {
- Net4jDefsFactory.eINSTANCE.createJVMConnectorDef().getInstance();
- fail("IllegalStateException expected!"); //$NON-NLS-1$
- }
- catch (IllegalStateException e)
- {
- }
- }
-
- public void testConnectorLaunchableOpensConnection()
- {
- IJVMAcceptor jvmAcceptor = createJVMAcceptor();
-
- JVMConnectorDef jvmConnectorDef = Net4jDefsFactory.eINSTANCE.createJVMConnectorDef();
-
- jvmConnectorDef.setBufferProvider(Net4jDefsFactory.eINSTANCE.createBufferPoolDef());
- jvmConnectorDef.setExecutorService(Net4jUtilDefsFactory.eINSTANCE.createThreadPoolDef());
- jvmConnectorDef.setName(NAME);
- IJVMConnector jvmConnector = (IJVMConnector)jvmConnectorDef.getInstance();
- jvmConnector.connect(500L);
- assertEquals(true, jvmConnector.isConnected());
-
- LifecycleUtil.deactivate(jvmConnector);
- LifecycleUtil.deactivate(jvmAcceptor);
- }
-
- private IJVMAcceptor createJVMAcceptor()
- {
- ExecutorService threadPool = Executors.newCachedThreadPool();
- LifecycleUtil.activate(threadPool);
-
- IBufferPool bufferPool = Net4jUtil.createBufferPool();
- LifecycleUtil.activate(bufferPool);
-
- JVMAcceptor jvmAcceptor = new JVMAcceptor();
- jvmAcceptor.setName(NAME);
- jvmAcceptor.getConfig().setBufferProvider(bufferPool);
- jvmAcceptor.getConfig().setReceiveExecutor(threadPool);
- LifecycleUtil.activate(jvmAcceptor);
-
- return jvmAcceptor;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.net4j.tests.defs;
+
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.buffer.IBufferPool;
+import org.eclipse.net4j.defs.JVMConnectorDef;
+import org.eclipse.net4j.defs.Net4jDefsFactory;
+import org.eclipse.net4j.internal.jvm.JVMAcceptor;
+import org.eclipse.net4j.jvm.IJVMAcceptor;
+import org.eclipse.net4j.jvm.IJVMConnector;
+import org.eclipse.net4j.util.defs.Net4jUtilDefsFactory;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.tests.AbstractOMTest;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class JVMConnectorDefImplTest extends AbstractOMTest
+{
+ private static final String NAME = "test1"; //$NON-NLS-1$
+
+ public void testIncompleteInitializationThrowsIllegalArgumentException()
+ {
+ try
+ {
+ Net4jDefsFactory.eINSTANCE.createJVMConnectorDef().getInstance();
+ fail("IllegalStateException expected!"); //$NON-NLS-1$
+ }
+ catch (IllegalStateException e)
+ {
+ }
+ }
+
+ public void testConnectorLaunchableOpensConnection()
+ {
+ IJVMAcceptor jvmAcceptor = createJVMAcceptor();
+
+ JVMConnectorDef jvmConnectorDef = Net4jDefsFactory.eINSTANCE.createJVMConnectorDef();
+
+ jvmConnectorDef.setBufferProvider(Net4jDefsFactory.eINSTANCE.createBufferPoolDef());
+ jvmConnectorDef.setExecutorService(Net4jUtilDefsFactory.eINSTANCE.createThreadPoolDef());
+ jvmConnectorDef.setName(NAME);
+ IJVMConnector jvmConnector = (IJVMConnector)jvmConnectorDef.getInstance();
+ jvmConnector.connect(500L);
+ assertEquals(true, jvmConnector.isConnected());
+
+ LifecycleUtil.deactivate(jvmConnector);
+ LifecycleUtil.deactivate(jvmAcceptor);
+ }
+
+ private IJVMAcceptor createJVMAcceptor()
+ {
+ ExecutorService threadPool = Executors.newCachedThreadPool();
+ LifecycleUtil.activate(threadPool);
+
+ IBufferPool bufferPool = Net4jUtil.createBufferPool();
+ LifecycleUtil.activate(bufferPool);
+
+ JVMAcceptor jvmAcceptor = new JVMAcceptor();
+ jvmAcceptor.setName(NAME);
+ jvmAcceptor.getConfig().setBufferProvider(bufferPool);
+ jvmAcceptor.getConfig().setReceiveExecutor(threadPool);
+ LifecycleUtil.activate(jvmAcceptor);
+
+ return jvmAcceptor;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/defs/Util.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/defs/Util.java
index 3c7a87bc6b..c24a553027 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/defs/Util.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/defs/Util.java
@@ -1,138 +1,138 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.defs;
-
-import org.eclipse.net4j.Net4jUtil;
-import org.eclipse.net4j.buffer.IBufferPool;
-import org.eclipse.net4j.internal.tcp.TCPAcceptor;
-import org.eclipse.net4j.internal.tcp.TCPClientConnector;
-import org.eclipse.net4j.internal.tcp.TCPConnector;
-import org.eclipse.net4j.internal.tcp.TCPSelector;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.security.ChallengeNegotiator;
-import org.eclipse.net4j.util.security.INegotiator;
-import org.eclipse.net4j.util.security.IRandomizer;
-import org.eclipse.net4j.util.security.PasswordCredentials;
-import org.eclipse.net4j.util.security.PasswordCredentialsProvider;
-import org.eclipse.net4j.util.security.Randomizer;
-import org.eclipse.net4j.util.security.ResponseNegotiator;
-import org.eclipse.net4j.util.security.UserManager;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-/**
- * @author Eike Stepper
- */
-class Util
-{
- public static TCPAcceptor createTCPAcceptor(String host, int port, long timeout)
- {
- TCPAcceptor acceptor = new TCPAcceptor();
- acceptor.setStartSynchronously(true);
- acceptor.setSynchronousStartTimeout(timeout);
- acceptor.getConfig().setBufferProvider(createBufferPool());
- acceptor.getConfig().setReceiveExecutor(createThreadPool());
- acceptor.setSelector(createTCPSelector());
- acceptor.setAddress(host);
- acceptor.setPort(port);
-
- LifecycleUtil.activate(acceptor);
-
- return acceptor;
- }
-
- private static IRandomizer createRandomizer()
- {
- Randomizer randomizer = new Randomizer();
- LifecycleUtil.activate(randomizer);
-
- return randomizer;
- }
-
- public static void addNegotiator(String userId, String password, TCPAcceptor tcpAcceptor)
- {
- UserManager userManager = new UserManager();
- LifecycleUtil.activate(userManager);
- userManager.addUser(userId, password.toCharArray());
-
- ChallengeNegotiator challengeNegotiator = new ChallengeNegotiator();
- challengeNegotiator.setRandomizer(createRandomizer());
- challengeNegotiator.setUserManager(userManager);
- LifecycleUtil.activate(challengeNegotiator);
-
- tcpAcceptor.getConfig().setNegotiator(challengeNegotiator);
- }
-
- public static void removeNegotiator(TCPAcceptor tcpAcceptor)
- {
- INegotiator negotiator = tcpAcceptor.getConfig().getNegotiator();
- tcpAcceptor.getConfig().setNegotiator(null);
- LifecycleUtil.deactivate(negotiator);
- }
-
- public static TCPConnector createTCPClientConnector(String host, int port, TCPSelector tcpSelector)
- {
- TCPClientConnector tcpConnector = new TCPClientConnector();
- tcpConnector.getConfig().setBufferProvider(createBufferPool());
- tcpConnector.getConfig().setReceiveExecutor(createThreadPool());
- tcpConnector.setSelector(tcpSelector);
- tcpConnector.setHost(host);
- tcpConnector.setPort(port);
-
- return tcpConnector;
- }
-
- public static void addNegotiator(String userId, String password, TCPConnector tcpConnector)
- {
- PasswordCredentials passwordCredentials = new PasswordCredentials(userId, password.toCharArray());
- PasswordCredentialsProvider credentialsProvider = new PasswordCredentialsProvider(passwordCredentials);
- LifecycleUtil.activate(credentialsProvider);
-
- tcpConnector.getConfig().setNegotiator(createResponseNegotiator(credentialsProvider));
- }
-
- public static ResponseNegotiator createResponseNegotiator(PasswordCredentialsProvider credentialsProvider)
- {
- ResponseNegotiator responseNegotiator = new ResponseNegotiator();
- responseNegotiator.setCredentialsProvider(credentialsProvider);
- LifecycleUtil.activate(responseNegotiator);
- return responseNegotiator;
- }
-
- public static void removeNegotiator(TCPConnector tcpConnector)
- {
- INegotiator negotiator = tcpConnector.getConfig().getNegotiator();
- tcpConnector.setNegotiator(null);
- LifecycleUtil.deactivate(negotiator);
- }
-
- public static TCPSelector createTCPSelector()
- {
- TCPSelector selector = new TCPSelector();
- LifecycleUtil.activate(selector);
- return selector;
- }
-
- public static IBufferPool createBufferPool()
- {
- IBufferPool bufferPool = Net4jUtil.createBufferPool();
- LifecycleUtil.activate(bufferPool);
- return bufferPool;
- }
-
- public static ExecutorService createThreadPool()
- {
- ExecutorService threadPool = Executors.newCachedThreadPool();
- LifecycleUtil.activate(threadPool);
- return threadPool;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.defs;
+
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.buffer.IBufferPool;
+import org.eclipse.net4j.internal.tcp.TCPAcceptor;
+import org.eclipse.net4j.internal.tcp.TCPClientConnector;
+import org.eclipse.net4j.internal.tcp.TCPConnector;
+import org.eclipse.net4j.internal.tcp.TCPSelector;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.security.ChallengeNegotiator;
+import org.eclipse.net4j.util.security.INegotiator;
+import org.eclipse.net4j.util.security.IRandomizer;
+import org.eclipse.net4j.util.security.PasswordCredentials;
+import org.eclipse.net4j.util.security.PasswordCredentialsProvider;
+import org.eclipse.net4j.util.security.Randomizer;
+import org.eclipse.net4j.util.security.ResponseNegotiator;
+import org.eclipse.net4j.util.security.UserManager;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * @author Eike Stepper
+ */
+class Util
+{
+ public static TCPAcceptor createTCPAcceptor(String host, int port, long timeout)
+ {
+ TCPAcceptor acceptor = new TCPAcceptor();
+ acceptor.setStartSynchronously(true);
+ acceptor.setSynchronousStartTimeout(timeout);
+ acceptor.getConfig().setBufferProvider(createBufferPool());
+ acceptor.getConfig().setReceiveExecutor(createThreadPool());
+ acceptor.setSelector(createTCPSelector());
+ acceptor.setAddress(host);
+ acceptor.setPort(port);
+
+ LifecycleUtil.activate(acceptor);
+
+ return acceptor;
+ }
+
+ private static IRandomizer createRandomizer()
+ {
+ Randomizer randomizer = new Randomizer();
+ LifecycleUtil.activate(randomizer);
+
+ return randomizer;
+ }
+
+ public static void addNegotiator(String userId, String password, TCPAcceptor tcpAcceptor)
+ {
+ UserManager userManager = new UserManager();
+ LifecycleUtil.activate(userManager);
+ userManager.addUser(userId, password.toCharArray());
+
+ ChallengeNegotiator challengeNegotiator = new ChallengeNegotiator();
+ challengeNegotiator.setRandomizer(createRandomizer());
+ challengeNegotiator.setUserManager(userManager);
+ LifecycleUtil.activate(challengeNegotiator);
+
+ tcpAcceptor.getConfig().setNegotiator(challengeNegotiator);
+ }
+
+ public static void removeNegotiator(TCPAcceptor tcpAcceptor)
+ {
+ INegotiator negotiator = tcpAcceptor.getConfig().getNegotiator();
+ tcpAcceptor.getConfig().setNegotiator(null);
+ LifecycleUtil.deactivate(negotiator);
+ }
+
+ public static TCPConnector createTCPClientConnector(String host, int port, TCPSelector tcpSelector)
+ {
+ TCPClientConnector tcpConnector = new TCPClientConnector();
+ tcpConnector.getConfig().setBufferProvider(createBufferPool());
+ tcpConnector.getConfig().setReceiveExecutor(createThreadPool());
+ tcpConnector.setSelector(tcpSelector);
+ tcpConnector.setHost(host);
+ tcpConnector.setPort(port);
+
+ return tcpConnector;
+ }
+
+ public static void addNegotiator(String userId, String password, TCPConnector tcpConnector)
+ {
+ PasswordCredentials passwordCredentials = new PasswordCredentials(userId, password.toCharArray());
+ PasswordCredentialsProvider credentialsProvider = new PasswordCredentialsProvider(passwordCredentials);
+ LifecycleUtil.activate(credentialsProvider);
+
+ tcpConnector.getConfig().setNegotiator(createResponseNegotiator(credentialsProvider));
+ }
+
+ public static ResponseNegotiator createResponseNegotiator(PasswordCredentialsProvider credentialsProvider)
+ {
+ ResponseNegotiator responseNegotiator = new ResponseNegotiator();
+ responseNegotiator.setCredentialsProvider(credentialsProvider);
+ LifecycleUtil.activate(responseNegotiator);
+ return responseNegotiator;
+ }
+
+ public static void removeNegotiator(TCPConnector tcpConnector)
+ {
+ INegotiator negotiator = tcpConnector.getConfig().getNegotiator();
+ tcpConnector.setNegotiator(null);
+ LifecycleUtil.deactivate(negotiator);
+ }
+
+ public static TCPSelector createTCPSelector()
+ {
+ TCPSelector selector = new TCPSelector();
+ LifecycleUtil.activate(selector);
+ return selector;
+ }
+
+ public static IBufferPool createBufferPool()
+ {
+ IBufferPool bufferPool = Net4jUtil.createBufferPool();
+ LifecycleUtil.activate(bufferPool);
+ return bufferPool;
+ }
+
+ public static ExecutorService createThreadPool()
+ {
+ ExecutorService threadPool = Executors.newCachedThreadPool();
+ LifecycleUtil.activate(threadPool);
+ return threadPool;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ArrayIndication.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ArrayIndication.java
index 443060356f..1fc58b191b 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ArrayIndication.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ArrayIndication.java
@@ -1,40 +1,40 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.signal;
-
-import org.eclipse.net4j.signal.IndicationWithResponse;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public class ArrayIndication extends IndicationWithResponse
-{
- private byte[] data;
-
- public ArrayIndication(TestSignalProtocol protocol)
- {
- super(protocol, TestSignalProtocol.SIGNAL_ARRAY);
- }
-
- @Override
- protected void indicating(ExtendedDataInputStream in) throws Exception
- {
- data = in.readByteArray();
- }
-
- @Override
- protected void responding(ExtendedDataOutputStream out) throws Exception
- {
- out.writeByteArray(data);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.signal;
+
+import org.eclipse.net4j.signal.IndicationWithResponse;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class ArrayIndication extends IndicationWithResponse
+{
+ private byte[] data;
+
+ public ArrayIndication(TestSignalProtocol protocol)
+ {
+ super(protocol, TestSignalProtocol.SIGNAL_ARRAY);
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws Exception
+ {
+ data = in.readByteArray();
+ }
+
+ @Override
+ protected void responding(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeByteArray(data);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ArrayRequest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ArrayRequest.java
index 240c5e2e90..f3e42ce389 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ArrayRequest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ArrayRequest.java
@@ -1,42 +1,42 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.signal;
-
-import org.eclipse.net4j.signal.RequestWithConfirmation;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public class ArrayRequest extends RequestWithConfirmation<byte[]>
-{
- private byte[] data;
-
- public ArrayRequest(SignalProtocol<?> protocol, byte[] data)
- {
- super(protocol, TestSignalProtocol.SIGNAL_ARRAY);
- this.data = data;
- }
-
- @Override
- protected void requesting(ExtendedDataOutputStream out) throws Exception
- {
- out.writeByteArray(data);
- }
-
- @Override
- protected byte[] confirming(ExtendedDataInputStream in) throws Exception
- {
- return in.readByteArray();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.signal;
+
+import org.eclipse.net4j.signal.RequestWithConfirmation;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class ArrayRequest extends RequestWithConfirmation<byte[]>
+{
+ private byte[] data;
+
+ public ArrayRequest(SignalProtocol<?> protocol, byte[] data)
+ {
+ super(protocol, TestSignalProtocol.SIGNAL_ARRAY);
+ this.data = data;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeByteArray(data);
+ }
+
+ @Override
+ protected byte[] confirming(ExtendedDataInputStream in) throws Exception
+ {
+ return in.readByteArray();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/AsyncIndication.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/AsyncIndication.java
index 4e42fe7ae0..a529f2811e 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/AsyncIndication.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/AsyncIndication.java
@@ -1,39 +1,39 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.signal;
-
-import org.eclipse.net4j.signal.Indication;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-
-/**
- * @author Eike Stepper
- */
-public class AsyncIndication extends Indication
-{
- private String data;
-
- public AsyncIndication(SignalProtocol<?> protocol)
- {
- super(protocol, TestSignalProtocol.SIGNAL_ASYNC);
- }
-
- public String getData()
- {
- return data;
- }
-
- @Override
- protected void indicating(ExtendedDataInputStream in) throws Exception
- {
- data = in.readString();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.signal;
+
+import org.eclipse.net4j.signal.Indication;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class AsyncIndication extends Indication
+{
+ private String data;
+
+ public AsyncIndication(SignalProtocol<?> protocol)
+ {
+ super(protocol, TestSignalProtocol.SIGNAL_ASYNC);
+ }
+
+ public String getData()
+ {
+ return data;
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws Exception
+ {
+ data = in.readString();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/AsyncRequest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/AsyncRequest.java
index 0f950f50be..7f3aee6bb3 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/AsyncRequest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/AsyncRequest.java
@@ -1,35 +1,35 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.signal;
-
-import org.eclipse.net4j.signal.Request;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public class AsyncRequest extends Request
-{
- private String data;
-
- public AsyncRequest(SignalProtocol<?> protocol, String data)
- {
- super(protocol, TestSignalProtocol.SIGNAL_ASYNC);
- this.data = data;
- }
-
- @Override
- protected void requesting(ExtendedDataOutputStream out) throws Exception
- {
- out.writeString(data);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.signal;
+
+import org.eclipse.net4j.signal.Request;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class AsyncRequest extends Request
+{
+ private String data;
+
+ public AsyncRequest(SignalProtocol<?> protocol, String data)
+ {
+ super(protocol, TestSignalProtocol.SIGNAL_ASYNC);
+ this.data = data;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeString(data);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ExceptionIndication.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ExceptionIndication.java
index debe1026c1..feda3840bc 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ExceptionIndication.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ExceptionIndication.java
@@ -1,57 +1,57 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.signal;
-
-import org.eclipse.net4j.signal.IndicationWithResponse;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public class ExceptionIndication extends IndicationWithResponse
-{
- private int phase;
-
- private boolean ioProblem;
-
- public ExceptionIndication(TestSignalProtocol protocol)
- {
- super(protocol, TestSignalProtocol.SIGNAL_EXCEPTION);
- }
-
- public int getPhase()
- {
- return phase;
- }
-
- @Override
- protected void indicating(ExtendedDataInputStream in) throws Exception
- {
- phase = in.readInt();
- ioProblem = in.readBoolean();
- if (phase == 2)
- {
- ((TestSignalProtocol)getProtocol()).throwException(ioProblem);
- }
- }
-
- @Override
- protected void responding(ExtendedDataOutputStream out) throws Exception
- {
- if (phase == 3)
- {
- ((TestSignalProtocol)getProtocol()).throwException(ioProblem);
- }
-
- out.writeBoolean(true);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.signal;
+
+import org.eclipse.net4j.signal.IndicationWithResponse;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class ExceptionIndication extends IndicationWithResponse
+{
+ private int phase;
+
+ private boolean ioProblem;
+
+ public ExceptionIndication(TestSignalProtocol protocol)
+ {
+ super(protocol, TestSignalProtocol.SIGNAL_EXCEPTION);
+ }
+
+ public int getPhase()
+ {
+ return phase;
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws Exception
+ {
+ phase = in.readInt();
+ ioProblem = in.readBoolean();
+ if (phase == 2)
+ {
+ ((TestSignalProtocol)getProtocol()).throwException(ioProblem);
+ }
+ }
+
+ @Override
+ protected void responding(ExtendedDataOutputStream out) throws Exception
+ {
+ if (phase == 3)
+ {
+ ((TestSignalProtocol)getProtocol()).throwException(ioProblem);
+ }
+
+ out.writeBoolean(true);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ExceptionRequest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ExceptionRequest.java
index ef4a5031fe..8e8be2e296 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ExceptionRequest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/ExceptionRequest.java
@@ -1,54 +1,54 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.signal;
-
-import org.eclipse.net4j.signal.RequestWithConfirmation;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public class ExceptionRequest extends RequestWithConfirmation<Boolean>
-{
- private int phase;
-
- private boolean ioProblem;
-
- public ExceptionRequest(TestSignalProtocol protocol, int phase, boolean ioProblem)
- {
- super(protocol, TestSignalProtocol.SIGNAL_EXCEPTION);
- this.phase = phase;
- this.ioProblem = ioProblem;
- }
-
- @Override
- protected void requesting(ExtendedDataOutputStream out) throws Exception
- {
- out.writeInt(phase);
- out.writeBoolean(ioProblem);
- if (phase == 1)
- {
- ((TestSignalProtocol)getProtocol()).throwException(ioProblem);
- }
- }
-
- @Override
- protected Boolean confirming(ExtendedDataInputStream in) throws Exception
- {
- if (phase == 4)
- {
- ((TestSignalProtocol)getProtocol()).throwException(ioProblem);
- }
-
- return in.readBoolean();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.signal;
+
+import org.eclipse.net4j.signal.RequestWithConfirmation;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class ExceptionRequest extends RequestWithConfirmation<Boolean>
+{
+ private int phase;
+
+ private boolean ioProblem;
+
+ public ExceptionRequest(TestSignalProtocol protocol, int phase, boolean ioProblem)
+ {
+ super(protocol, TestSignalProtocol.SIGNAL_EXCEPTION);
+ this.phase = phase;
+ this.ioProblem = ioProblem;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeInt(phase);
+ out.writeBoolean(ioProblem);
+ if (phase == 1)
+ {
+ ((TestSignalProtocol)getProtocol()).throwException(ioProblem);
+ }
+ }
+
+ @Override
+ protected Boolean confirming(ExtendedDataInputStream in) throws Exception
+ {
+ if (phase == 4)
+ {
+ ((TestSignalProtocol)getProtocol()).throwException(ioProblem);
+ }
+
+ return in.readBoolean();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntFailIndication.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntFailIndication.java
index 04f668168a..84b6c1ddfc 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntFailIndication.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntFailIndication.java
@@ -1,45 +1,45 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.signal;
-
-import org.eclipse.net4j.signal.IndicationWithResponse;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public class IntFailIndication extends IndicationWithResponse
-{
- private int data;
-
- public IntFailIndication(TestSignalProtocol protocol)
- {
- super(protocol, TestSignalProtocol.SIGNAL_INT_FAIL);
- }
-
- public int getData()
- {
- return data;
- }
-
- @Override
- protected void indicating(ExtendedDataInputStream in) throws Exception
- {
- data = in.readInt();
- }
-
- @Override
- protected void responding(ExtendedDataOutputStream out) throws Exception
- {
- getProtocol().deactivate();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.signal;
+
+import org.eclipse.net4j.signal.IndicationWithResponse;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class IntFailIndication extends IndicationWithResponse
+{
+ private int data;
+
+ public IntFailIndication(TestSignalProtocol protocol)
+ {
+ super(protocol, TestSignalProtocol.SIGNAL_INT_FAIL);
+ }
+
+ public int getData()
+ {
+ return data;
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws Exception
+ {
+ data = in.readInt();
+ }
+
+ @Override
+ protected void responding(ExtendedDataOutputStream out) throws Exception
+ {
+ getProtocol().deactivate();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntFailRequest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntFailRequest.java
index 4b34154254..0d5a682146 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntFailRequest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntFailRequest.java
@@ -1,41 +1,41 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.signal;
-
-import org.eclipse.net4j.signal.RequestWithConfirmation;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public class IntFailRequest extends RequestWithConfirmation<Integer>
-{
- private int data;
-
- public IntFailRequest(TestSignalProtocol protocol, int data)
- {
- super(protocol, TestSignalProtocol.SIGNAL_INT_FAIL);
- this.data = data;
- }
-
- @Override
- protected void requesting(ExtendedDataOutputStream out) throws Exception
- {
- out.writeInt(data);
- }
-
- @Override
- protected Integer confirming(ExtendedDataInputStream in) throws Exception
- {
- return in.readInt();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.signal;
+
+import org.eclipse.net4j.signal.RequestWithConfirmation;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class IntFailRequest extends RequestWithConfirmation<Integer>
+{
+ private int data;
+
+ public IntFailRequest(TestSignalProtocol protocol, int data)
+ {
+ super(protocol, TestSignalProtocol.SIGNAL_INT_FAIL);
+ this.data = data;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeInt(data);
+ }
+
+ @Override
+ protected Integer confirming(ExtendedDataInputStream in) throws Exception
+ {
+ return in.readInt();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntIndication.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntIndication.java
index 67e2f7ec94..f2fa702d97 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntIndication.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntIndication.java
@@ -1,40 +1,40 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.signal;
-
-import org.eclipse.net4j.signal.IndicationWithResponse;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public class IntIndication extends IndicationWithResponse
-{
- private int data;
-
- public IntIndication(TestSignalProtocol protocol)
- {
- super(protocol, TestSignalProtocol.SIGNAL_INT);
- }
-
- @Override
- protected void indicating(ExtendedDataInputStream in) throws Exception
- {
- data = in.readInt();
- }
-
- @Override
- protected void responding(ExtendedDataOutputStream out) throws Exception
- {
- out.writeInt(data);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.signal;
+
+import org.eclipse.net4j.signal.IndicationWithResponse;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class IntIndication extends IndicationWithResponse
+{
+ private int data;
+
+ public IntIndication(TestSignalProtocol protocol)
+ {
+ super(protocol, TestSignalProtocol.SIGNAL_INT);
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws Exception
+ {
+ data = in.readInt();
+ }
+
+ @Override
+ protected void responding(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeInt(data);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntRequest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntRequest.java
index 70bcff63ea..0efdfdc162 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntRequest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/IntRequest.java
@@ -1,41 +1,41 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.signal;
-
-import org.eclipse.net4j.signal.RequestWithConfirmation;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public class IntRequest extends RequestWithConfirmation<Integer>
-{
- private int data;
-
- public IntRequest(TestSignalProtocol protocol, int data)
- {
- super(protocol, TestSignalProtocol.SIGNAL_INT);
- this.data = data;
- }
-
- @Override
- protected void requesting(ExtendedDataOutputStream out) throws Exception
- {
- out.writeInt(data);
- }
-
- @Override
- protected Integer confirming(ExtendedDataInputStream in) throws Exception
- {
- return in.readInt();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.signal;
+
+import org.eclipse.net4j.signal.RequestWithConfirmation;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class IntRequest extends RequestWithConfirmation<Integer>
+{
+ private int data;
+
+ public IntRequest(TestSignalProtocol protocol, int data)
+ {
+ super(protocol, TestSignalProtocol.SIGNAL_INT);
+ this.data = data;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeInt(data);
+ }
+
+ @Override
+ protected Integer confirming(ExtendedDataInputStream in) throws Exception
+ {
+ return in.readInt();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/StringIndication.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/StringIndication.java
index 47846a43fb..cf8db7dfde 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/StringIndication.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/StringIndication.java
@@ -1,40 +1,40 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.signal;
-
-import org.eclipse.net4j.signal.IndicationWithResponse;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public class StringIndication extends IndicationWithResponse
-{
- private String data;
-
- public StringIndication(TestSignalProtocol protocol)
- {
- super(protocol, TestSignalProtocol.SIGNAL_STRING);
- }
-
- @Override
- protected void indicating(ExtendedDataInputStream in) throws Exception
- {
- data = in.readString();
- }
-
- @Override
- protected void responding(ExtendedDataOutputStream out) throws Exception
- {
- out.writeString(data);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.signal;
+
+import org.eclipse.net4j.signal.IndicationWithResponse;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class StringIndication extends IndicationWithResponse
+{
+ private String data;
+
+ public StringIndication(TestSignalProtocol protocol)
+ {
+ super(protocol, TestSignalProtocol.SIGNAL_STRING);
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws Exception
+ {
+ data = in.readString();
+ }
+
+ @Override
+ protected void responding(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeString(data);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/StringRequest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/StringRequest.java
index 0a4a95031b..36a96f8dc1 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/StringRequest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/StringRequest.java
@@ -1,42 +1,42 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.signal;
-
-import org.eclipse.net4j.signal.RequestWithConfirmation;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public class StringRequest extends RequestWithConfirmation<String>
-{
- private String data;
-
- public StringRequest(SignalProtocol<?> protocol, String data)
- {
- super(protocol, TestSignalProtocol.SIGNAL_STRING);
- this.data = data;
- }
-
- @Override
- protected void requesting(ExtendedDataOutputStream out) throws Exception
- {
- out.writeString(data);
- }
-
- @Override
- protected String confirming(ExtendedDataInputStream in) throws Exception
- {
- return in.readString();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.signal;
+
+import org.eclipse.net4j.signal.RequestWithConfirmation;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class StringRequest extends RequestWithConfirmation<String>
+{
+ private String data;
+
+ public StringRequest(SignalProtocol<?> protocol, String data)
+ {
+ super(protocol, TestSignalProtocol.SIGNAL_STRING);
+ this.data = data;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeString(data);
+ }
+
+ @Override
+ protected String confirming(ExtendedDataInputStream in) throws Exception
+ {
+ return in.readString();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalProtocol.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalProtocol.java
index 6b01d7c611..88f2a1265d 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalProtocol.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/signal/TestSignalProtocol.java
@@ -1,120 +1,120 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.signal;
-
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.signal.SignalReactor;
-import org.eclipse.net4j.util.factory.ProductCreationException;
-
-import org.eclipse.spi.net4j.ServerProtocolFactory;
-
-import java.io.IOException;
-import java.rmi.AlreadyBoundException;
-
-/**
- * @author Eike Stepper
- */
-public class TestSignalProtocol extends SignalProtocol<Object>
-{
- public static final String PROTOCOL_NAME = "signal.protocol"; //$NON-NLS-1$
-
- public static final short SIGNAL_INT = 1;
-
- public static final short SIGNAL_INT_FAIL = 2;
-
- public static final short SIGNAL_ARRAY = 3;
-
- public static final short SIGNAL_STRING = 4;
-
- public static final short SIGNAL_ASYNC = 5;
-
- public static final short SIGNAL_EXCEPTION = 6;
-
- public static final String SIMULATED_EXCEPTION = "Simulated exception"; //$NON-NLS-1$
-
- public TestSignalProtocol(IConnector connector)
- {
- this();
- open(connector);
- }
-
- public TestSignalProtocol()
- {
- super(PROTOCOL_NAME);
- }
-
- @Override
- protected SignalReactor createSignalReactor(short signalID)
- {
- switch (signalID)
- {
- case SIGNAL_INT:
- return new IntIndication(this);
-
- case SIGNAL_INT_FAIL:
- return new IntFailIndication(this);
-
- case SIGNAL_ARRAY:
- return new ArrayIndication(this);
-
- case SIGNAL_STRING:
- return new StringIndication(this);
-
- case SIGNAL_ASYNC:
- return new AsyncIndication(this);
-
- case SIGNAL_EXCEPTION:
- return new ExceptionIndication(this);
-
- default:
- return super.createSignalReactor(signalID);
- }
- }
-
- public void throwException(boolean ioProblem) throws Exception
- {
- if (ioProblem)
- {
- throw new IOException(SIMULATED_EXCEPTION);
- }
-
- try
- {
- throwNestedException();
- }
- catch (Exception ex)
- {
- throw new ClassNotFoundException(SIMULATED_EXCEPTION, ex);
- }
- }
-
- public void throwNestedException() throws Exception
- {
- throw new AlreadyBoundException(SIMULATED_EXCEPTION);
- }
-
- /**
- * @author Eike Stepper
- */
- public static class Factory extends ServerProtocolFactory
- {
- public Factory()
- {
- super(PROTOCOL_NAME);
- }
-
- public TestSignalProtocol create(String description) throws ProductCreationException
- {
- return new TestSignalProtocol();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.signal;
+
+import org.eclipse.net4j.connector.IConnector;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.signal.SignalReactor;
+import org.eclipse.net4j.util.factory.ProductCreationException;
+
+import org.eclipse.spi.net4j.ServerProtocolFactory;
+
+import java.io.IOException;
+import java.rmi.AlreadyBoundException;
+
+/**
+ * @author Eike Stepper
+ */
+public class TestSignalProtocol extends SignalProtocol<Object>
+{
+ public static final String PROTOCOL_NAME = "signal.protocol"; //$NON-NLS-1$
+
+ public static final short SIGNAL_INT = 1;
+
+ public static final short SIGNAL_INT_FAIL = 2;
+
+ public static final short SIGNAL_ARRAY = 3;
+
+ public static final short SIGNAL_STRING = 4;
+
+ public static final short SIGNAL_ASYNC = 5;
+
+ public static final short SIGNAL_EXCEPTION = 6;
+
+ public static final String SIMULATED_EXCEPTION = "Simulated exception"; //$NON-NLS-1$
+
+ public TestSignalProtocol(IConnector connector)
+ {
+ this();
+ open(connector);
+ }
+
+ public TestSignalProtocol()
+ {
+ super(PROTOCOL_NAME);
+ }
+
+ @Override
+ protected SignalReactor createSignalReactor(short signalID)
+ {
+ switch (signalID)
+ {
+ case SIGNAL_INT:
+ return new IntIndication(this);
+
+ case SIGNAL_INT_FAIL:
+ return new IntFailIndication(this);
+
+ case SIGNAL_ARRAY:
+ return new ArrayIndication(this);
+
+ case SIGNAL_STRING:
+ return new StringIndication(this);
+
+ case SIGNAL_ASYNC:
+ return new AsyncIndication(this);
+
+ case SIGNAL_EXCEPTION:
+ return new ExceptionIndication(this);
+
+ default:
+ return super.createSignalReactor(signalID);
+ }
+ }
+
+ public void throwException(boolean ioProblem) throws Exception
+ {
+ if (ioProblem)
+ {
+ throw new IOException(SIMULATED_EXCEPTION);
+ }
+
+ try
+ {
+ throwNestedException();
+ }
+ catch (Exception ex)
+ {
+ throw new ClassNotFoundException(SIMULATED_EXCEPTION, ex);
+ }
+ }
+
+ public void throwNestedException() throws Exception
+ {
+ throw new AlreadyBoundException(SIMULATED_EXCEPTION);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class Factory extends ServerProtocolFactory
+ {
+ public Factory()
+ {
+ super(PROTOCOL_NAME);
+ }
+
+ public TestSignalProtocol create(String description) throws ProductCreationException
+ {
+ return new TestSignalProtocol();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java
index 295793e7d0..6caa2d943a 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java
@@ -1,772 +1,772 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.util.tests;
-
-import org.eclipse.net4j.tests.bundle.OM;
-import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
-import org.eclipse.net4j.util.event.EventUtil;
-import org.eclipse.net4j.util.event.IListener;
-import org.eclipse.net4j.util.io.IORuntimeException;
-import org.eclipse.net4j.util.io.IOUtil;
-import org.eclipse.net4j.util.io.TMPUtil;
-import org.eclipse.net4j.util.lifecycle.ILifecycle;
-import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.log.FileLogHandler;
-import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.log.OMLogger.Level;
-import org.eclipse.net4j.util.om.log.PrintLogHandler;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
-
-import java.io.File;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.Lock;
-
-import junit.framework.Assert;
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
-import junit.framework.TestResult;
-
-/**
- * @author Eike Stepper
- */
-public abstract class AbstractOMTest extends TestCase
-{
- public static final long DEFAULT_TIMEOUT = 15 * 1000;
-
- public static final long DEFAULT_TIMEOUT_EXPECTED = 3 * 1000;
-
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, AbstractOMTest.class);
-
- public static boolean EXTERNAL_LOG;
-
- public static boolean SUPPRESS_OUTPUT;
-
- private static boolean consoleEnabled;
-
- private static String testName;
-
- private transient List<File> filesToDelete = new ArrayList<File>();
-
- private transient String codeLink;
-
- static
- {
- try
- {
- if (EXTERNAL_LOG)
- {
- SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
- String prefix = AbstractOMTest.class.getName() + "-" + formatter.format(new Date()) + "-";
- File logFile = TMPUtil.createTempFile(prefix, ".log");
-
- OMPlatform.INSTANCE.addLogHandler(new FileLogHandler(logFile, OMLogger.Level.WARN)
- {
- @Override
- protected void writeLog(OMLogger logger, Level level, String msg, Throwable t) throws Throwable
- {
- super.writeLog(logger, level, "--> " + testName + "\n" + msg, t);
- }
- });
-
- IOUtil.ERR().println("Logging errors and warnings to " + logFile);
- IOUtil.ERR().println();
- }
- }
- catch (Throwable ex)
- {
- IOUtil.print(ex);
- }
- }
-
- protected AbstractOMTest()
- {
- }
-
- public String getCodeLink()
- {
- return codeLink;
- }
-
- public void determineCodeLink()
- {
- if (codeLink == null)
- {
- codeLink = determineCodeLink(getName());
- if (codeLink == null)
- {
- codeLink = determineCodeLink("doSetUp");
- if (codeLink == null)
- {
- codeLink = getClass().getName() + "." + getName() + "(" + getClass().getSimpleName() + ".java:1)";
- }
- }
- }
- }
-
- protected String determineCodeLink(String methodName)
- {
- String className = getClass().getName();
- StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
- for (StackTraceElement frame : stackTrace)
- {
- if (frame.getClassName().equals(className) && frame.getMethodName().equals(methodName))
- {
- return frame.toString();
- }
- }
-
- return null;
- }
-
- @Override
- public void setUp() throws Exception
- {
- testName = getClass().getName() + "." + getName() + "()";
- codeLink = null;
-
- PrintTraceHandler.CONSOLE.setShortContext(true);
- OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
- OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
- enableConsole();
-
- if (!SUPPRESS_OUTPUT)
- {
- IOUtil.OUT().println("*******************************************************"); //$NON-NLS-1$
- Thread.yield();
- Thread.sleep(2L);
- IOUtil.ERR().println(this);
- Thread.yield();
- Thread.sleep(2L);
- IOUtil.OUT().println("*******************************************************"); //$NON-NLS-1$
- }
-
- super.setUp();
- doSetUp();
-
- if (!SUPPRESS_OUTPUT)
- {
- IOUtil.OUT().println();
- IOUtil.OUT().println("------------------------ START ------------------------"); //$NON-NLS-1$
- }
- }
-
- @Override
- public void tearDown() throws Exception
- {
- enableConsole();
- if (!SUPPRESS_OUTPUT)
- {
- IOUtil.OUT().println("------------------------- END -------------------------"); //$NON-NLS-1$
- IOUtil.OUT().println();
- }
-
- try
- {
- doTearDown();
- }
- catch (Exception ex)
- {
- IOUtil.print(ex);
- }
-
- try
- {
- super.tearDown();
- }
- catch (Exception ex)
- {
- IOUtil.print(ex);
- }
-
- if (!SUPPRESS_OUTPUT)
- {
- IOUtil.OUT().println();
- IOUtil.OUT().println();
- }
- }
-
- @Override
- public void runBare() throws Throwable
- {
- try
- {
- // Don't call super.runBare() because it does not clean up after exceptions from setUp()
- Throwable exception = null;
-
- try
- {
- setUp();
- runTest();
- }
- catch (Throwable running)
- {
- exception = running;
- }
- finally
- {
- try
- {
- tearDown();
- }
- catch (Throwable tearingDown)
- {
- if (exception == null)
- {
- exception = tearingDown;
- }
- }
- }
-
- if (exception != null)
- {
- throw exception;
- }
- }
- catch (SkipTestException ex)
- {
- OM.LOG.info("Skipped " + this); //$NON-NLS-1$
- }
- catch (Throwable t)
- {
- if (!SUPPRESS_OUTPUT)
- {
- t.printStackTrace(IOUtil.OUT());
- }
-
- throw t;
- }
- }
-
- @Override
- public void run(TestResult result)
- {
- try
- {
- super.run(result);
- }
- catch (SkipTestException ex)
- {
- OM.LOG.info("Skipped " + this); //$NON-NLS-1$
- }
- catch (RuntimeException ex)
- {
- if (!SUPPRESS_OUTPUT)
- {
- ex.printStackTrace(IOUtil.OUT());
- }
-
- throw ex;
- }
- catch (Error err)
- {
- if (!SUPPRESS_OUTPUT)
- {
- err.printStackTrace(IOUtil.OUT());
- }
-
- throw err;
- }
- }
-
- protected void enableConsole()
- {
- if (!SUPPRESS_OUTPUT)
- {
- OMPlatform.INSTANCE.setDebugging(true);
- consoleEnabled = true;
- }
- }
-
- protected void disableConsole()
- {
- if (!SUPPRESS_OUTPUT)
- {
- 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
- {
- deleteFiles();
- }
-
- public void deleteFiles()
- {
- for (File file : filesToDelete)
- {
- IOUtil.delete(file);
- }
-
- filesToDelete.clear();
- }
-
- public void addFileToDelete(File file)
- {
- filesToDelete.add(file);
- }
-
- public File createTempFolder() throws IORuntimeException
- {
- File folder = TMPUtil.createTempFolder();
- addFileToDelete(folder);
- return folder;
- }
-
- public File createTempFolder(String prefix) throws IORuntimeException
- {
- File folder = TMPUtil.createTempFolder(prefix);
- addFileToDelete(folder);
- return folder;
- }
-
- public File createTempFolder(String prefix, String suffix) throws IORuntimeException
- {
- File folder = TMPUtil.createTempFolder(prefix, suffix);
- addFileToDelete(folder);
- return folder;
- }
-
- public File createTempFolder(String prefix, String suffix, File directory) throws IORuntimeException
- {
- File folder = TMPUtil.createTempFile(prefix, suffix, directory);
- addFileToDelete(folder);
- return folder;
- }
-
- public File createTempFile() throws IORuntimeException
- {
- File file = TMPUtil.createTempFile();
- addFileToDelete(file);
- return file;
- }
-
- public File createTempFile(String prefix) throws IORuntimeException
- {
- File file = TMPUtil.createTempFile(prefix);
- addFileToDelete(file);
- return file;
- }
-
- public File createTempFile(String prefix, String suffix) throws IORuntimeException
- {
- File file = TMPUtil.createTempFile(prefix, suffix);
- addFileToDelete(file);
- return file;
- }
-
- public File createTempFile(String prefix, String suffix, File directory) throws IORuntimeException
- {
- File file = TMPUtil.createTempFile(prefix, suffix, directory);
- addFileToDelete(file);
- return file;
- }
-
- /**
- * @deprecated Use assertEquals(message, true, ...)
- */
- @Deprecated
- public static void assertTrue(String message, boolean condition)
- {
- throw new UnsupportedOperationException("Use assertEquals(message, true, ...)");
- }
-
- /**
- * @deprecated Use assertEquals(true, ...)
- */
- @Deprecated
- public static void assertTrue(boolean condition)
- {
- throw new UnsupportedOperationException("Use assertEquals(true, ...)");
- }
-
- /**
- * @deprecated Use assertEquals(message, false, ...)
- */
- @Deprecated
- public static void assertFalse(String message, boolean condition)
- {
- throw new UnsupportedOperationException("Use assertEquals(message, false, ...)");
- }
-
- /**
- * @deprecated Use assertEquals(false, ...)
- */
- @Deprecated
- public static void assertFalse(boolean condition)
- {
- throw new UnsupportedOperationException("Use assertEquals(false, ...)");
- }
-
- public static void assertEquals(Object[] expected, Object[] actual)
- {
- if (!Arrays.deepEquals(expected, actual))
- {
- throw new AssertionFailedError("expected:" + Arrays.deepToString(expected) + " but was:"
- + Arrays.deepToString(actual));
- }
- }
-
- public static void assertEquals(Object expected, Object actual)
- {
- // IMPORTANT: Give possible CDOLegacyWrapper a chance for actual, too
- if (actual != null && actual.equals(expected))
- {
- return;
- }
-
- Assert.assertEquals(expected, actual);
- }
-
- public static void assertEquals(String message, Object expected, Object actual)
- {
- if (expected == null && actual == null)
- {
- return;
- }
-
- if (expected != null && expected.equals(actual))
- {
- return;
- }
-
- // IMPORTANT: Give possible CDOLegacyWrapper a chance for actual, too
- if (actual != null && actual.equals(expected))
- {
- return;
- }
-
- failNotEquals(message, expected, actual);
- }
-
- public static void sleep(long millis)
- {
- msg("Sleeping " + millis);
- ConcurrencyUtil.sleep(millis);
- }
-
- public static void assertInstanceOf(Class<?> expected, Object object)
- {
- assertEquals("Not an instance of " + expected + ": " + object.getClass().getName(), true,
- expected.isInstance(object));
- }
-
- public static void assertActive(Object object) throws InterruptedException
- {
- final LatchTimeOuter timeOuter = new LatchTimeOuter();
- IListener listener = new LifecycleEventAdapter()
- {
- @Override
- protected void onActivated(ILifecycle lifecycle)
- {
- timeOuter.countDown();
- }
- };
-
- EventUtil.addListener(object, listener);
-
- try
- {
- if (LifecycleUtil.isActive(object))
- {
- timeOuter.countDown();
- }
-
- timeOuter.assertNoTimeOut();
- }
- finally
- {
- EventUtil.removeListener(object, listener);
- }
- }
-
- public static void assertInactive(Object object) throws InterruptedException
- {
- final LatchTimeOuter timeOuter = new LatchTimeOuter();
- IListener listener = new LifecycleEventAdapter()
- {
- @Override
- protected void onDeactivated(ILifecycle lifecycle)
- {
- timeOuter.countDown();
- }
- };
-
- EventUtil.addListener(object, listener);
-
- try
- {
- if (!LifecycleUtil.isActive(object))
- {
- timeOuter.countDown();
- }
-
- timeOuter.assertNoTimeOut();
- }
- finally
- {
- EventUtil.removeListener(object, listener);
- }
- }
-
- public static void assertSimilar(double expected, double actual, int precision)
- {
- final double factor = 10 * precision;
- if (Math.round(expected * factor) != Math.round(actual * factor))
- {
- assertEquals(expected, actual);
- }
- }
-
- public static void assertSimilar(float expected, float actual, int precision)
- {
- final float factor = 10 * precision;
- if (Math.round(expected * factor) != Math.round(actual * factor))
- {
- assertEquals(expected, actual);
- }
- }
-
- protected static void msg(Object m)
- {
- if (!SUPPRESS_OUTPUT)
- {
- if (consoleEnabled && TRACER.isEnabled())
- {
- TRACER.trace("--> " + m); //$NON-NLS-1$
- }
- }
- }
-
- protected static void skipTest(boolean skip)
- {
- if (skip)
- {
- throw new SkipTestException();
- }
- }
-
- protected static void skipTest()
- {
- skipTest(true);
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class SkipTestException extends RuntimeException
- {
- private static final long serialVersionUID = 1L;
- }
-
- /**
- * @author Eike Stepper
- */
- public static class AsyncResult<T>
- {
- private volatile T value;
-
- private CountDownLatch latch = new CountDownLatch(1);
-
- public AsyncResult()
- {
- }
-
- public void setValue(T value)
- {
- this.value = value;
- latch.countDown();
- }
-
- public T getValue(long timeout) throws Exception
- {
- if (!latch.await(timeout, TimeUnit.MILLISECONDS))
- {
- throw new TimeoutException("Result value not available after " + timeout + " milli seconds");
- }
-
- return value;
- }
-
- public T getValue() throws Exception
- {
- return getValue(DEFAULT_TIMEOUT);
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static interface ITimeOuter
- {
- public boolean timedOut(long timeoutMillis) throws InterruptedException;
- }
-
- /**
- * @author Eike Stepper
- */
- public static abstract class TimeOuter implements ITimeOuter
- {
- public boolean timedOut() throws InterruptedException
- {
- return timedOut(DEFAULT_TIMEOUT);
- }
-
- public void assertTimeOut(long timeoutMillis) throws InterruptedException
- {
- assertEquals("Timeout expected", true, timedOut(timeoutMillis));
- }
-
- public void assertTimeOut() throws InterruptedException
- {
- assertTimeOut(DEFAULT_TIMEOUT_EXPECTED);
- }
-
- public void assertNoTimeOut(long timeoutMillis) throws InterruptedException
- {
- assertEquals("Timeout after " + timeoutMillis + " millis", false, timedOut(timeoutMillis));
- }
-
- public void assertNoTimeOut() throws InterruptedException
- {
- assertNoTimeOut(DEFAULT_TIMEOUT);
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static abstract class PollingTimeOuter extends TimeOuter
- {
- public static final long DEFAULT_SLEEP_MILLIS = 1;
-
- private long sleepMillis = DEFAULT_SLEEP_MILLIS;
-
- public PollingTimeOuter(long sleepMillis)
- {
- this.sleepMillis = sleepMillis;
- }
-
- public PollingTimeOuter()
- {
- }
-
- public boolean timedOut(long timeoutMillis) throws InterruptedException
- {
- int retries = (int)Math.round(timeoutMillis / sleepMillis + .5d);
- for (int i = 0; i < retries; i++)
- {
- if (successful())
- {
- return false;
- }
-
- sleep(sleepMillis);
- }
-
- return true;
- }
-
- protected abstract boolean successful();
- }
-
- /**
- * @author Eike Stepper
- */
- public static class LockTimeOuter extends TimeOuter
- {
- private Lock lock;
-
- public LockTimeOuter(Lock lock)
- {
- this.lock = lock;
- }
-
- public Lock getLock()
- {
- return lock;
- }
-
- public boolean timedOut(long timeoutMillis) throws InterruptedException
- {
- Condition condition = lock.newCondition();
- return !condition.await(timeoutMillis, TimeUnit.MILLISECONDS);
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static class LatchTimeOuter extends TimeOuter
- {
- private CountDownLatch latch;
-
- public LatchTimeOuter(CountDownLatch latch)
- {
- this.latch = latch;
- }
-
- public LatchTimeOuter(int count)
- {
- this(new CountDownLatch(count));
- }
-
- public LatchTimeOuter()
- {
- this(1);
- }
-
- public CountDownLatch getLatch()
- {
- return latch;
- }
-
- public long getCount()
- {
- return latch.getCount();
- }
-
- public void countDown()
- {
- latch.countDown();
- }
-
- public void countDown(int n)
- {
- for (int i = 0; i < n; i++)
- {
- countDown();
- }
- }
-
- public boolean timedOut(long timeoutMillis) throws InterruptedException
- {
- return !latch.await(timeoutMillis, TimeUnit.MILLISECONDS);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.util.tests;
+
+import org.eclipse.net4j.tests.bundle.OM;
+import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
+import org.eclipse.net4j.util.event.EventUtil;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.io.IORuntimeException;
+import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.net4j.util.io.TMPUtil;
+import org.eclipse.net4j.util.lifecycle.ILifecycle;
+import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.log.FileLogHandler;
+import org.eclipse.net4j.util.om.log.OMLogger;
+import org.eclipse.net4j.util.om.log.OMLogger.Level;
+import org.eclipse.net4j.util.om.log.PrintLogHandler;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
+
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+
+import junit.framework.Assert;
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+import junit.framework.TestResult;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class AbstractOMTest extends TestCase
+{
+ public static final long DEFAULT_TIMEOUT = 15 * 1000;
+
+ public static final long DEFAULT_TIMEOUT_EXPECTED = 3 * 1000;
+
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, AbstractOMTest.class);
+
+ public static boolean EXTERNAL_LOG;
+
+ public static boolean SUPPRESS_OUTPUT;
+
+ private static boolean consoleEnabled;
+
+ private static String testName;
+
+ private transient List<File> filesToDelete = new ArrayList<File>();
+
+ private transient String codeLink;
+
+ static
+ {
+ try
+ {
+ if (EXTERNAL_LOG)
+ {
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
+ String prefix = AbstractOMTest.class.getName() + "-" + formatter.format(new Date()) + "-";
+ File logFile = TMPUtil.createTempFile(prefix, ".log");
+
+ OMPlatform.INSTANCE.addLogHandler(new FileLogHandler(logFile, OMLogger.Level.WARN)
+ {
+ @Override
+ protected void writeLog(OMLogger logger, Level level, String msg, Throwable t) throws Throwable
+ {
+ super.writeLog(logger, level, "--> " + testName + "\n" + msg, t);
+ }
+ });
+
+ IOUtil.ERR().println("Logging errors and warnings to " + logFile);
+ IOUtil.ERR().println();
+ }
+ }
+ catch (Throwable ex)
+ {
+ IOUtil.print(ex);
+ }
+ }
+
+ protected AbstractOMTest()
+ {
+ }
+
+ public String getCodeLink()
+ {
+ return codeLink;
+ }
+
+ public void determineCodeLink()
+ {
+ if (codeLink == null)
+ {
+ codeLink = determineCodeLink(getName());
+ if (codeLink == null)
+ {
+ codeLink = determineCodeLink("doSetUp");
+ if (codeLink == null)
+ {
+ codeLink = getClass().getName() + "." + getName() + "(" + getClass().getSimpleName() + ".java:1)";
+ }
+ }
+ }
+ }
+
+ protected String determineCodeLink(String methodName)
+ {
+ String className = getClass().getName();
+ StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
+ for (StackTraceElement frame : stackTrace)
+ {
+ if (frame.getClassName().equals(className) && frame.getMethodName().equals(methodName))
+ {
+ return frame.toString();
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public void setUp() throws Exception
+ {
+ testName = getClass().getName() + "." + getName() + "()";
+ codeLink = null;
+
+ PrintTraceHandler.CONSOLE.setShortContext(true);
+ OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
+ OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
+ enableConsole();
+
+ if (!SUPPRESS_OUTPUT)
+ {
+ IOUtil.OUT().println("*******************************************************"); //$NON-NLS-1$
+ Thread.yield();
+ Thread.sleep(2L);
+ IOUtil.ERR().println(this);
+ Thread.yield();
+ Thread.sleep(2L);
+ IOUtil.OUT().println("*******************************************************"); //$NON-NLS-1$
+ }
+
+ super.setUp();
+ doSetUp();
+
+ if (!SUPPRESS_OUTPUT)
+ {
+ IOUtil.OUT().println();
+ IOUtil.OUT().println("------------------------ START ------------------------"); //$NON-NLS-1$
+ }
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ enableConsole();
+ if (!SUPPRESS_OUTPUT)
+ {
+ IOUtil.OUT().println("------------------------- END -------------------------"); //$NON-NLS-1$
+ IOUtil.OUT().println();
+ }
+
+ try
+ {
+ doTearDown();
+ }
+ catch (Exception ex)
+ {
+ IOUtil.print(ex);
+ }
+
+ try
+ {
+ super.tearDown();
+ }
+ catch (Exception ex)
+ {
+ IOUtil.print(ex);
+ }
+
+ if (!SUPPRESS_OUTPUT)
+ {
+ IOUtil.OUT().println();
+ IOUtil.OUT().println();
+ }
+ }
+
+ @Override
+ public void runBare() throws Throwable
+ {
+ try
+ {
+ // Don't call super.runBare() because it does not clean up after exceptions from setUp()
+ Throwable exception = null;
+
+ try
+ {
+ setUp();
+ runTest();
+ }
+ catch (Throwable running)
+ {
+ exception = running;
+ }
+ finally
+ {
+ try
+ {
+ tearDown();
+ }
+ catch (Throwable tearingDown)
+ {
+ if (exception == null)
+ {
+ exception = tearingDown;
+ }
+ }
+ }
+
+ if (exception != null)
+ {
+ throw exception;
+ }
+ }
+ catch (SkipTestException ex)
+ {
+ OM.LOG.info("Skipped " + this); //$NON-NLS-1$
+ }
+ catch (Throwable t)
+ {
+ if (!SUPPRESS_OUTPUT)
+ {
+ t.printStackTrace(IOUtil.OUT());
+ }
+
+ throw t;
+ }
+ }
+
+ @Override
+ public void run(TestResult result)
+ {
+ try
+ {
+ super.run(result);
+ }
+ catch (SkipTestException ex)
+ {
+ OM.LOG.info("Skipped " + this); //$NON-NLS-1$
+ }
+ catch (RuntimeException ex)
+ {
+ if (!SUPPRESS_OUTPUT)
+ {
+ ex.printStackTrace(IOUtil.OUT());
+ }
+
+ throw ex;
+ }
+ catch (Error err)
+ {
+ if (!SUPPRESS_OUTPUT)
+ {
+ err.printStackTrace(IOUtil.OUT());
+ }
+
+ throw err;
+ }
+ }
+
+ protected void enableConsole()
+ {
+ if (!SUPPRESS_OUTPUT)
+ {
+ OMPlatform.INSTANCE.setDebugging(true);
+ consoleEnabled = true;
+ }
+ }
+
+ protected void disableConsole()
+ {
+ if (!SUPPRESS_OUTPUT)
+ {
+ 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
+ {
+ deleteFiles();
+ }
+
+ public void deleteFiles()
+ {
+ for (File file : filesToDelete)
+ {
+ IOUtil.delete(file);
+ }
+
+ filesToDelete.clear();
+ }
+
+ public void addFileToDelete(File file)
+ {
+ filesToDelete.add(file);
+ }
+
+ public File createTempFolder() throws IORuntimeException
+ {
+ File folder = TMPUtil.createTempFolder();
+ addFileToDelete(folder);
+ return folder;
+ }
+
+ public File createTempFolder(String prefix) throws IORuntimeException
+ {
+ File folder = TMPUtil.createTempFolder(prefix);
+ addFileToDelete(folder);
+ return folder;
+ }
+
+ public File createTempFolder(String prefix, String suffix) throws IORuntimeException
+ {
+ File folder = TMPUtil.createTempFolder(prefix, suffix);
+ addFileToDelete(folder);
+ return folder;
+ }
+
+ public File createTempFolder(String prefix, String suffix, File directory) throws IORuntimeException
+ {
+ File folder = TMPUtil.createTempFile(prefix, suffix, directory);
+ addFileToDelete(folder);
+ return folder;
+ }
+
+ public File createTempFile() throws IORuntimeException
+ {
+ File file = TMPUtil.createTempFile();
+ addFileToDelete(file);
+ return file;
+ }
+
+ public File createTempFile(String prefix) throws IORuntimeException
+ {
+ File file = TMPUtil.createTempFile(prefix);
+ addFileToDelete(file);
+ return file;
+ }
+
+ public File createTempFile(String prefix, String suffix) throws IORuntimeException
+ {
+ File file = TMPUtil.createTempFile(prefix, suffix);
+ addFileToDelete(file);
+ return file;
+ }
+
+ public File createTempFile(String prefix, String suffix, File directory) throws IORuntimeException
+ {
+ File file = TMPUtil.createTempFile(prefix, suffix, directory);
+ addFileToDelete(file);
+ return file;
+ }
+
+ /**
+ * @deprecated Use assertEquals(message, true, ...)
+ */
+ @Deprecated
+ public static void assertTrue(String message, boolean condition)
+ {
+ throw new UnsupportedOperationException("Use assertEquals(message, true, ...)");
+ }
+
+ /**
+ * @deprecated Use assertEquals(true, ...)
+ */
+ @Deprecated
+ public static void assertTrue(boolean condition)
+ {
+ throw new UnsupportedOperationException("Use assertEquals(true, ...)");
+ }
+
+ /**
+ * @deprecated Use assertEquals(message, false, ...)
+ */
+ @Deprecated
+ public static void assertFalse(String message, boolean condition)
+ {
+ throw new UnsupportedOperationException("Use assertEquals(message, false, ...)");
+ }
+
+ /**
+ * @deprecated Use assertEquals(false, ...)
+ */
+ @Deprecated
+ public static void assertFalse(boolean condition)
+ {
+ throw new UnsupportedOperationException("Use assertEquals(false, ...)");
+ }
+
+ public static void assertEquals(Object[] expected, Object[] actual)
+ {
+ if (!Arrays.deepEquals(expected, actual))
+ {
+ throw new AssertionFailedError("expected:" + Arrays.deepToString(expected) + " but was:"
+ + Arrays.deepToString(actual));
+ }
+ }
+
+ public static void assertEquals(Object expected, Object actual)
+ {
+ // IMPORTANT: Give possible CDOLegacyWrapper a chance for actual, too
+ if (actual != null && actual.equals(expected))
+ {
+ return;
+ }
+
+ Assert.assertEquals(expected, actual);
+ }
+
+ public static void assertEquals(String message, Object expected, Object actual)
+ {
+ if (expected == null && actual == null)
+ {
+ return;
+ }
+
+ if (expected != null && expected.equals(actual))
+ {
+ return;
+ }
+
+ // IMPORTANT: Give possible CDOLegacyWrapper a chance for actual, too
+ if (actual != null && actual.equals(expected))
+ {
+ return;
+ }
+
+ failNotEquals(message, expected, actual);
+ }
+
+ public static void sleep(long millis)
+ {
+ msg("Sleeping " + millis);
+ ConcurrencyUtil.sleep(millis);
+ }
+
+ public static void assertInstanceOf(Class<?> expected, Object object)
+ {
+ assertEquals("Not an instance of " + expected + ": " + object.getClass().getName(), true,
+ expected.isInstance(object));
+ }
+
+ public static void assertActive(Object object) throws InterruptedException
+ {
+ final LatchTimeOuter timeOuter = new LatchTimeOuter();
+ IListener listener = new LifecycleEventAdapter()
+ {
+ @Override
+ protected void onActivated(ILifecycle lifecycle)
+ {
+ timeOuter.countDown();
+ }
+ };
+
+ EventUtil.addListener(object, listener);
+
+ try
+ {
+ if (LifecycleUtil.isActive(object))
+ {
+ timeOuter.countDown();
+ }
+
+ timeOuter.assertNoTimeOut();
+ }
+ finally
+ {
+ EventUtil.removeListener(object, listener);
+ }
+ }
+
+ public static void assertInactive(Object object) throws InterruptedException
+ {
+ final LatchTimeOuter timeOuter = new LatchTimeOuter();
+ IListener listener = new LifecycleEventAdapter()
+ {
+ @Override
+ protected void onDeactivated(ILifecycle lifecycle)
+ {
+ timeOuter.countDown();
+ }
+ };
+
+ EventUtil.addListener(object, listener);
+
+ try
+ {
+ if (!LifecycleUtil.isActive(object))
+ {
+ timeOuter.countDown();
+ }
+
+ timeOuter.assertNoTimeOut();
+ }
+ finally
+ {
+ EventUtil.removeListener(object, listener);
+ }
+ }
+
+ public static void assertSimilar(double expected, double actual, int precision)
+ {
+ final double factor = 10 * precision;
+ if (Math.round(expected * factor) != Math.round(actual * factor))
+ {
+ assertEquals(expected, actual);
+ }
+ }
+
+ public static void assertSimilar(float expected, float actual, int precision)
+ {
+ final float factor = 10 * precision;
+ if (Math.round(expected * factor) != Math.round(actual * factor))
+ {
+ assertEquals(expected, actual);
+ }
+ }
+
+ protected static void msg(Object m)
+ {
+ if (!SUPPRESS_OUTPUT)
+ {
+ if (consoleEnabled && TRACER.isEnabled())
+ {
+ TRACER.trace("--> " + m); //$NON-NLS-1$
+ }
+ }
+ }
+
+ protected static void skipTest(boolean skip)
+ {
+ if (skip)
+ {
+ throw new SkipTestException();
+ }
+ }
+
+ protected static void skipTest()
+ {
+ skipTest(true);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class SkipTestException extends RuntimeException
+ {
+ private static final long serialVersionUID = 1L;
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class AsyncResult<T>
+ {
+ private volatile T value;
+
+ private CountDownLatch latch = new CountDownLatch(1);
+
+ public AsyncResult()
+ {
+ }
+
+ public void setValue(T value)
+ {
+ this.value = value;
+ latch.countDown();
+ }
+
+ public T getValue(long timeout) throws Exception
+ {
+ if (!latch.await(timeout, TimeUnit.MILLISECONDS))
+ {
+ throw new TimeoutException("Result value not available after " + timeout + " milli seconds");
+ }
+
+ return value;
+ }
+
+ public T getValue() throws Exception
+ {
+ return getValue(DEFAULT_TIMEOUT);
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static interface ITimeOuter
+ {
+ public boolean timedOut(long timeoutMillis) throws InterruptedException;
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static abstract class TimeOuter implements ITimeOuter
+ {
+ public boolean timedOut() throws InterruptedException
+ {
+ return timedOut(DEFAULT_TIMEOUT);
+ }
+
+ public void assertTimeOut(long timeoutMillis) throws InterruptedException
+ {
+ assertEquals("Timeout expected", true, timedOut(timeoutMillis));
+ }
+
+ public void assertTimeOut() throws InterruptedException
+ {
+ assertTimeOut(DEFAULT_TIMEOUT_EXPECTED);
+ }
+
+ public void assertNoTimeOut(long timeoutMillis) throws InterruptedException
+ {
+ assertEquals("Timeout after " + timeoutMillis + " millis", false, timedOut(timeoutMillis));
+ }
+
+ public void assertNoTimeOut() throws InterruptedException
+ {
+ assertNoTimeOut(DEFAULT_TIMEOUT);
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static abstract class PollingTimeOuter extends TimeOuter
+ {
+ public static final long DEFAULT_SLEEP_MILLIS = 1;
+
+ private long sleepMillis = DEFAULT_SLEEP_MILLIS;
+
+ public PollingTimeOuter(long sleepMillis)
+ {
+ this.sleepMillis = sleepMillis;
+ }
+
+ public PollingTimeOuter()
+ {
+ }
+
+ public boolean timedOut(long timeoutMillis) throws InterruptedException
+ {
+ int retries = (int)Math.round(timeoutMillis / sleepMillis + .5d);
+ for (int i = 0; i < retries; i++)
+ {
+ if (successful())
+ {
+ return false;
+ }
+
+ sleep(sleepMillis);
+ }
+
+ return true;
+ }
+
+ protected abstract boolean successful();
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class LockTimeOuter extends TimeOuter
+ {
+ private Lock lock;
+
+ public LockTimeOuter(Lock lock)
+ {
+ this.lock = lock;
+ }
+
+ public Lock getLock()
+ {
+ return lock;
+ }
+
+ public boolean timedOut(long timeoutMillis) throws InterruptedException
+ {
+ Condition condition = lock.newCondition();
+ return !condition.await(timeoutMillis, TimeUnit.MILLISECONDS);
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class LatchTimeOuter extends TimeOuter
+ {
+ private CountDownLatch latch;
+
+ public LatchTimeOuter(CountDownLatch latch)
+ {
+ this.latch = latch;
+ }
+
+ public LatchTimeOuter(int count)
+ {
+ this(new CountDownLatch(count));
+ }
+
+ public LatchTimeOuter()
+ {
+ this(1);
+ }
+
+ public CountDownLatch getLatch()
+ {
+ return latch;
+ }
+
+ public long getCount()
+ {
+ return latch.getCount();
+ }
+
+ public void countDown()
+ {
+ latch.countDown();
+ }
+
+ public void countDown(int n)
+ {
+ for (int i = 0; i < n; i++)
+ {
+ countDown();
+ }
+ }
+
+ public boolean timedOut(long timeoutMillis) throws InterruptedException
+ {
+ return !latch.await(timeoutMillis, TimeUnit.MILLISECONDS);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/ConcurrentRunner.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/ConcurrentRunner.java
index fcb7de36c5..8ddd3b1fb6 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/ConcurrentRunner.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/ConcurrentRunner.java
@@ -1,140 +1,140 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.net4j.util.tests;
-
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-
-/**
- * A class that implements a concurrent execution environment for runnables. It waits until all runnables submitted for
- * execution are terminated and returns the first throwable that occurs
- *
- * @author Andre Dietisheim
- */
-public class ConcurrentRunner
-{
- /**
- * Executes Runnables in concurrent manner. The first Throwable thrown by those runnables is thrown back to the
- * caller.
- *
- * @param runnables
- * the runnables to execute
- * @param maxThreads
- * the maximum number of threads to use
- * @param numOfExecution
- * the number of executions per runnable
- * @throws Throwable
- * the throwable
- */
- public static void run(Runnable[] runnables, int maxThreads, int numOfExecution) throws Throwable
- {
- ExecutorService threadPool = Executors.newFixedThreadPool(maxThreads);
- Future<Throwable>[] futures = execute(numOfExecution, threadPool, runnables);
- throwOnFailure(futures, threadPool);
- }
-
- /**
- * Executes the runnables. The runnables are wrapped in Callables when they're submitted to the thread pool.
- *
- * @param loops
- * the loops
- * @param threadPool
- * the thread pool
- * @param runnables
- * the runnables
- * @return the future<throwable>[] that allow to wait for the runnables result
- */
- @SuppressWarnings("unchecked")
- private static Future<Throwable>[] execute(int loops, ExecutorService threadPool, Runnable[] runnables)
- {
- Future<Throwable>[] futures = new Future[loops * runnables.length];
- for (int j = 0; j < loops; j++)
- {
- for (int i = 0; i < runnables.length; i++)
- {
- futures[j * runnables.length + i] = threadPool.submit(new ThrowableCatchingWrapper(runnables[i]));
- }
- }
-
- return futures;
- }
-
- /**
- * Throw a throwable if it occured while executing the runnables
- *
- * @param futures
- * the futures
- * @param threadPool
- * @throws InterruptedException
- * the interrupted exception
- * @throws ExecutionException
- * the execution exception
- * @throws Throwable
- * the throwable
- */
- private static void throwOnFailure(Future<Throwable>[] futures, ExecutorService threadPool)
- throws InterruptedException, ExecutionException, Throwable
- {
- for (Future<Throwable> future : futures)
- {
- Throwable e = future.get();
- if (e != null)
- {
- threadPool.shutdownNow();
- throw e;
- }
- }
- }
-
- /**
- * A Wrapper for runnables that catches a Throwable that occur when running the runnable
- */
- private static class ThrowableCatchingWrapper implements Callable<Throwable>
- {
- /** The runnable. */
- private Runnable runnable;
-
- /**
- * Instantiates a new concurrent test case.
- *
- * @param runnable
- * the runnable
- */
- private ThrowableCatchingWrapper(Runnable runnable)
- {
- this.runnable = runnable;
- }
-
- /**
- * Call.
- *
- * @return the throwable
- * @throws Exception
- * the exception
- */
- public Throwable call() throws Exception
- {
- try
- {
- runnable.run();
- return null;
- }
- catch (Throwable t)
- {
- return t;
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.net4j.util.tests;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+/**
+ * A class that implements a concurrent execution environment for runnables. It waits until all runnables submitted for
+ * execution are terminated and returns the first throwable that occurs
+ *
+ * @author Andre Dietisheim
+ */
+public class ConcurrentRunner
+{
+ /**
+ * Executes Runnables in concurrent manner. The first Throwable thrown by those runnables is thrown back to the
+ * caller.
+ *
+ * @param runnables
+ * the runnables to execute
+ * @param maxThreads
+ * the maximum number of threads to use
+ * @param numOfExecution
+ * the number of executions per runnable
+ * @throws Throwable
+ * the throwable
+ */
+ public static void run(Runnable[] runnables, int maxThreads, int numOfExecution) throws Throwable
+ {
+ ExecutorService threadPool = Executors.newFixedThreadPool(maxThreads);
+ Future<Throwable>[] futures = execute(numOfExecution, threadPool, runnables);
+ throwOnFailure(futures, threadPool);
+ }
+
+ /**
+ * Executes the runnables. The runnables are wrapped in Callables when they're submitted to the thread pool.
+ *
+ * @param loops
+ * the loops
+ * @param threadPool
+ * the thread pool
+ * @param runnables
+ * the runnables
+ * @return the future<throwable>[] that allow to wait for the runnables result
+ */
+ @SuppressWarnings("unchecked")
+ private static Future<Throwable>[] execute(int loops, ExecutorService threadPool, Runnable[] runnables)
+ {
+ Future<Throwable>[] futures = new Future[loops * runnables.length];
+ for (int j = 0; j < loops; j++)
+ {
+ for (int i = 0; i < runnables.length; i++)
+ {
+ futures[j * runnables.length + i] = threadPool.submit(new ThrowableCatchingWrapper(runnables[i]));
+ }
+ }
+
+ return futures;
+ }
+
+ /**
+ * Throw a throwable if it occured while executing the runnables
+ *
+ * @param futures
+ * the futures
+ * @param threadPool
+ * @throws InterruptedException
+ * the interrupted exception
+ * @throws ExecutionException
+ * the execution exception
+ * @throws Throwable
+ * the throwable
+ */
+ private static void throwOnFailure(Future<Throwable>[] futures, ExecutorService threadPool)
+ throws InterruptedException, ExecutionException, Throwable
+ {
+ for (Future<Throwable> future : futures)
+ {
+ Throwable e = future.get();
+ if (e != null)
+ {
+ threadPool.shutdownNow();
+ throw e;
+ }
+ }
+ }
+
+ /**
+ * A Wrapper for runnables that catches a Throwable that occur when running the runnable
+ */
+ private static class ThrowableCatchingWrapper implements Callable<Throwable>
+ {
+ /** The runnable. */
+ private Runnable runnable;
+
+ /**
+ * Instantiates a new concurrent test case.
+ *
+ * @param runnable
+ * the runnable
+ */
+ private ThrowableCatchingWrapper(Runnable runnable)
+ {
+ this.runnable = runnable;
+ }
+
+ /**
+ * Call.
+ *
+ * @return the throwable
+ * @throws Exception
+ * the exception
+ */
+ public Throwable call() throws Exception
+ {
+ try
+ {
+ runnable.run();
+ return null;
+ }
+ catch (Throwable t)
+ {
+ return t;
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/ExtendedIOTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/ExtendedIOTest.java
index 854e9521ad..23ec1c3018 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/ExtendedIOTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/ExtendedIOTest.java
@@ -1,157 +1,157 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.util.tests;
-
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.HashMap;
-
-/**
- * @author Eike Stepper
- */
-public class ExtendedIOTest extends AbstractOMTest
-{
- @SuppressWarnings("unchecked")
- public void testObject() throws Exception
- {
- final HashMap<String, String> map = createMap();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ExtendedDataOutputStream edos = new ExtendedDataOutputStream(baos);
- edos.writeObject(map);
- edos.close();
-
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- ExtendedDataInputStream edis = new ExtendedDataInputStream(bais);
- HashMap<String, String> result = (HashMap<String, String>)edis.readObject();
- assertEquals(map, result);
- }
-
- public void testObject1() throws Exception
- {
- final byte[] byteArray = createByteArray1();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ExtendedDataOutputStream edos = new ExtendedDataOutputStream(baos);
- edos.writeObject(byteArray);
- edos.close();
-
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- ExtendedDataInputStream edis = new ExtendedDataInputStream(bais);
- byte[] result = (byte[])edis.readObject();
- assertEquals(true, Arrays.equals(byteArray, result));
- }
-
- public void testObject2() throws Exception
- {
- final byte[] byteArray = createByteArray2();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ExtendedDataOutputStream edos = new ExtendedDataOutputStream(baos);
- edos.writeObject(byteArray);
- edos.close();
-
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- ExtendedDataInputStream edis = new ExtendedDataInputStream(bais);
- byte[] result = (byte[])edis.readObject();
- assertEquals(true, Arrays.equals(byteArray, result));
- }
-
- public void testByteArray1() throws Exception
- {
- final byte[] byteArray = createByteArray1();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ExtendedDataOutputStream edos = new ExtendedDataOutputStream(baos);
- edos.writeByteArray(byteArray);
- edos.close();
-
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- ExtendedDataInputStream edis = new ExtendedDataInputStream(bais);
- byte[] result = edis.readByteArray();
- assertEquals(true, Arrays.equals(byteArray, result));
- }
-
- public void testByteArray2() throws Exception
- {
- final byte[] byteArray = createByteArray2();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ExtendedDataOutputStream edos = new ExtendedDataOutputStream(baos);
- edos.writeByteArray(byteArray);
- edos.close();
-
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- ExtendedDataInputStream edis = new ExtendedDataInputStream(bais);
- byte[] result = edis.readByteArray();
- assertEquals(true, Arrays.equals(byteArray, result));
- }
-
- private byte[] createByteArray1() throws IOException
- {
- HashMap<String, String> map = createMap();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ExtendedDataOutputStream edos = new ExtendedDataOutputStream(baos);
- edos.writeObject(map);
- edos.close();
- return baos.toByteArray();
- }
-
- private byte[] createByteArray2()
- {
- byte[] byteArray = new byte[256];
- byte v = Byte.MIN_VALUE;
- for (int i = 0; i < byteArray.length; i++)
- {
- byteArray[i] = v++;
- }
-
- return byteArray;
- }
-
- private HashMap<String, String> createMap()
- {
- HashMap<String, String> map = new HashMap<String, String>();
- putMap(map, "org.eclipse.net4j.util.io.CachedFileMap.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.CloseableIterator.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.DataInputExtender.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.DataOutputExtender.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.DelegatingInputStream.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.DelegatingOutputStream.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.DelegatingStreamWrapper.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.ExtendedDataInput.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.ExtendedDataInputStream.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.ExtendedDataOutput.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.ExtendedDataOutputStream.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.ExtendedIOUtil.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.GZIPStreamWrapper.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.IOFilter.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.IORunnable.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.IORuntimeException.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.IOUtil.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.IOVisitor.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.IStreamWrapper.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.NIOUtil.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.SortedFileMap.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.StreamWrapperChain.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.TMPUtil.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.XORInputStream.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.XOROutputStream.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.XORStreamWrapper.java"); //$NON-NLS-1$
- putMap(map, "org.eclipse.net4j.util.io.ZIPUtil.java"); //$NON-NLS-1$
- return map;
- }
-
- private void putMap(HashMap<String, String> map, String string)
- {
- map.put(string, string);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.util.tests;
+
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashMap;
+
+/**
+ * @author Eike Stepper
+ */
+public class ExtendedIOTest extends AbstractOMTest
+{
+ @SuppressWarnings("unchecked")
+ public void testObject() throws Exception
+ {
+ final HashMap<String, String> map = createMap();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ExtendedDataOutputStream edos = new ExtendedDataOutputStream(baos);
+ edos.writeObject(map);
+ edos.close();
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ ExtendedDataInputStream edis = new ExtendedDataInputStream(bais);
+ HashMap<String, String> result = (HashMap<String, String>)edis.readObject();
+ assertEquals(map, result);
+ }
+
+ public void testObject1() throws Exception
+ {
+ final byte[] byteArray = createByteArray1();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ExtendedDataOutputStream edos = new ExtendedDataOutputStream(baos);
+ edos.writeObject(byteArray);
+ edos.close();
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ ExtendedDataInputStream edis = new ExtendedDataInputStream(bais);
+ byte[] result = (byte[])edis.readObject();
+ assertEquals(true, Arrays.equals(byteArray, result));
+ }
+
+ public void testObject2() throws Exception
+ {
+ final byte[] byteArray = createByteArray2();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ExtendedDataOutputStream edos = new ExtendedDataOutputStream(baos);
+ edos.writeObject(byteArray);
+ edos.close();
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ ExtendedDataInputStream edis = new ExtendedDataInputStream(bais);
+ byte[] result = (byte[])edis.readObject();
+ assertEquals(true, Arrays.equals(byteArray, result));
+ }
+
+ public void testByteArray1() throws Exception
+ {
+ final byte[] byteArray = createByteArray1();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ExtendedDataOutputStream edos = new ExtendedDataOutputStream(baos);
+ edos.writeByteArray(byteArray);
+ edos.close();
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ ExtendedDataInputStream edis = new ExtendedDataInputStream(bais);
+ byte[] result = edis.readByteArray();
+ assertEquals(true, Arrays.equals(byteArray, result));
+ }
+
+ public void testByteArray2() throws Exception
+ {
+ final byte[] byteArray = createByteArray2();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ExtendedDataOutputStream edos = new ExtendedDataOutputStream(baos);
+ edos.writeByteArray(byteArray);
+ edos.close();
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ ExtendedDataInputStream edis = new ExtendedDataInputStream(bais);
+ byte[] result = edis.readByteArray();
+ assertEquals(true, Arrays.equals(byteArray, result));
+ }
+
+ private byte[] createByteArray1() throws IOException
+ {
+ HashMap<String, String> map = createMap();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ExtendedDataOutputStream edos = new ExtendedDataOutputStream(baos);
+ edos.writeObject(map);
+ edos.close();
+ return baos.toByteArray();
+ }
+
+ private byte[] createByteArray2()
+ {
+ byte[] byteArray = new byte[256];
+ byte v = Byte.MIN_VALUE;
+ for (int i = 0; i < byteArray.length; i++)
+ {
+ byteArray[i] = v++;
+ }
+
+ return byteArray;
+ }
+
+ private HashMap<String, String> createMap()
+ {
+ HashMap<String, String> map = new HashMap<String, String>();
+ putMap(map, "org.eclipse.net4j.util.io.CachedFileMap.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.CloseableIterator.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.DataInputExtender.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.DataOutputExtender.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.DelegatingInputStream.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.DelegatingOutputStream.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.DelegatingStreamWrapper.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.ExtendedDataInput.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.ExtendedDataInputStream.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.ExtendedDataOutput.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.ExtendedDataOutputStream.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.ExtendedIOUtil.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.GZIPStreamWrapper.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.IOFilter.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.IORunnable.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.IORuntimeException.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.IOUtil.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.IOVisitor.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.IStreamWrapper.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.NIOUtil.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.SortedFileMap.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.StreamWrapperChain.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.TMPUtil.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.XORInputStream.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.XOROutputStream.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.XORStreamWrapper.java"); //$NON-NLS-1$
+ putMap(map, "org.eclipse.net4j.util.io.ZIPUtil.java"); //$NON-NLS-1$
+ return map;
+ }
+
+ private void putMap(HashMap<String, String> map, String string)
+ {
+ map.put(string, string);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/FastListTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/FastListTest.java
index 495f927042..c483bda9c3 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/FastListTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/FastListTest.java
@@ -1,294 +1,294 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Caspar De Groot - maintenance
- */
-package org.eclipse.net4j.util.tests;
-
-import org.eclipse.net4j.util.collection.ConcurrentArray;
-
-/**
- * @author Eike Stepper
- * @since 3.1
- */
-public class FastListTest extends AbstractOMTest
-{
- public static void testAddFirst() throws Exception
- {
- TestList list = new TestList();
- list.add(5);
-
- Integer[] result = list.get();
- assertEquals(true, result != null);
- assertEquals(true, result.length == 1);
- assertEquals(true, list.getElements().length == 1);
- assertEquals(true, !list.isEmpty());
- assertEquals(true, list.added == 1);
- assertEquals(true, list.removed == 0);
- }
-
- public static void testAddSecond() throws Exception
- {
- TestList list = new TestList();
- list.add(5);
- list.add(7);
-
- Integer[] result = list.get();
- assertEquals(true, result != null);
- assertEquals(true, result.length == 2);
- assertEquals(true, list.getElements().length == 2);
- assertEquals(true, !list.isEmpty());
- assertEquals(true, list.added == 1);
- assertEquals(true, list.removed == 0);
- }
-
- public static void testRemoveHead() throws Exception
- {
- TestList list = new TestList();
- list.add(5);
- list.add(7);
- list.add(2);
- list.add(9);
- list.add(1);
- list.add(4);
- list.add(8);
-
- Integer[] old = list.reset();
- boolean removed = list.remove(5);
-
- Integer[] result = list.get();
- assertEquals(true, removed);
- assertEquals(true, result != null);
- assertEquals(true, result != old);
- assertEquals(true, result.length == 6);
- assertEquals(true, list.getElements().length == 6);
- assertEquals(true, !list.isEmpty());
- assertEquals(true, list.added == 0);
- assertEquals(true, list.removed == 0);
- assertEquals(true, result[0] == 7);
- assertEquals(true, result[1] == 2);
- assertEquals(true, result[2] == 9);
- assertEquals(true, result[3] == 1);
- assertEquals(true, result[4] == 4);
- assertEquals(true, result[5] == 8);
- }
-
- public static void testRemoveMiddle() throws Exception
- {
- TestList list = new TestList();
- list.add(5);
- list.add(7);
- list.add(2);
- list.add(9);
- list.add(1);
- list.add(4);
- list.add(8);
-
- Integer[] old = list.reset();
- boolean removed = list.remove(9);
-
- Integer[] result = list.get();
- assertEquals(true, removed);
- assertEquals(true, result != null);
- assertEquals(true, result != old);
- assertEquals(true, result.length == 6);
- assertEquals(true, list.getElements().length == 6);
- assertEquals(true, !list.isEmpty());
- assertEquals(true, list.added == 0);
- assertEquals(true, list.removed == 0);
- assertEquals(true, result[0] == 5);
- assertEquals(true, result[1] == 7);
- assertEquals(true, result[2] == 2);
- assertEquals(true, result[3] == 1);
- assertEquals(true, result[4] == 4);
- assertEquals(true, result[5] == 8);
- }
-
- public void testRemoveMiddleOfThree()
- {
- TestList list = new TestList();
- Integer one = new Integer(1);
- Integer two = new Integer(2);
- Integer three = new Integer(3);
-
- list.add(one);
- list.add(two);
- list.add(three);
-
- list.remove(two);
-
- Integer[] elements = list.get();
- assertSame(one, elements[0]);
- assertSame(three, elements[1]);
- }
-
- public static void testRemoveTail() throws Exception
- {
- TestList list = new TestList();
- list.add(5);
- list.add(7);
- list.add(2);
- list.add(9);
- list.add(1);
- list.add(4);
- list.add(8);
-
- Integer[] old = list.reset();
- boolean removed = list.remove(8);
-
- Integer[] result = list.get();
- assertEquals(true, removed);
- assertEquals(true, result != old);
- assertEquals(true, result != null);
- assertEquals(true, result.length == 6);
- assertEquals(true, list.getElements().length == 6);
- assertEquals(true, !list.isEmpty());
- assertEquals(true, list.added == 0);
- assertEquals(true, list.removed == 0);
- assertEquals(true, result[0] == 5);
- assertEquals(true, result[1] == 7);
- assertEquals(true, result[2] == 2);
- assertEquals(true, result[3] == 9);
- assertEquals(true, result[4] == 1);
- assertEquals(true, result[5] == 4);
- }
-
- public static void testRemoveLast() throws Exception
- {
- TestList list = new TestList();
- list.add(5);
- list.add(7);
-
- Integer[] old = list.reset();
- boolean removed1 = list.remove(7);
- boolean removed2 = list.remove(5);
-
- Integer[] result = list.get();
- assertEquals(true, removed1);
- assertEquals(true, removed2);
- assertEquals(true, result != old);
- assertEquals(true, result == null);
- assertEquals(true, list.getElements() == null);
- assertEquals(true, list.isEmpty());
- assertEquals(true, list.added == 0);
- assertEquals(true, list.removed == 1);
- }
-
- public static void testNotFoundInMany() throws Exception
- {
- TestList list = new TestList();
- list.add(5);
- list.add(7);
- list.add(2);
- list.add(9);
- list.add(1);
- list.add(4);
- list.add(8);
-
- Integer[] old = list.reset();
- boolean removed = list.remove(10);
-
- Integer[] result = list.get();
- assertEquals(true, !removed);
- assertEquals(true, result != null);
- assertEquals(true, result == old);
- assertEquals(true, result.length == 7);
- assertEquals(true, list.getElements().length == 7);
- assertEquals(true, !list.isEmpty());
- assertEquals(true, list.added == 0);
- assertEquals(true, list.removed == 0);
- assertEquals(true, result[0] == 5);
- assertEquals(true, result[1] == 7);
- assertEquals(true, result[2] == 2);
- assertEquals(true, result[3] == 9);
- assertEquals(true, result[4] == 1);
- assertEquals(true, result[5] == 4);
- assertEquals(true, result[6] == 8);
- }
-
- public static void testNotFoundInOne() throws Exception
- {
- TestList list = new TestList();
- list.add(5);
-
- Integer[] old = list.reset();
- boolean removed = list.remove(10);
-
- Integer[] result = list.get();
- assertEquals(true, !removed);
- assertEquals(true, result != null);
- assertEquals(true, result == old);
- assertEquals(true, result.length == 1);
- assertEquals(true, list.getElements().length == 1);
- assertEquals(true, !list.isEmpty());
- assertEquals(true, list.added == 0);
- assertEquals(true, list.removed == 0);
- assertEquals(true, result[0] == 5);
- }
-
- public static void testNotFoundInEmpty() throws Exception
- {
- TestList list = new TestList();
-
- Integer[] old = list.reset();
- boolean removed = list.remove(10);
-
- Integer[] result = list.get();
- assertEquals(true, !removed);
- assertEquals(true, result == null);
- assertEquals(true, result == old);
- assertEquals(true, list.isEmpty());
- assertEquals(true, list.added == 0);
- assertEquals(true, list.removed == 0);
- }
-
- /**
- * @author Eike Stepper
- */
- public static class TestList extends ConcurrentArray<Integer>
- {
- public int added;
-
- public int removed;
-
- public TestList()
- {
- }
-
- public Integer[] getElements()
- {
- return elements;
- }
-
- public Integer[] reset()
- {
- added = 0;
- removed = 0;
- return elements;
- }
-
- @Override
- protected Integer[] newArray(int length)
- {
- return new Integer[length];
- }
-
- @Override
- protected void firstElementAdded()
- {
- ++added;
- }
-
- @Override
- protected void lastElementRemoved()
- {
- ++removed;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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
+ * Caspar De Groot - maintenance
+ */
+package org.eclipse.net4j.util.tests;
+
+import org.eclipse.net4j.util.collection.ConcurrentArray;
+
+/**
+ * @author Eike Stepper
+ * @since 3.1
+ */
+public class FastListTest extends AbstractOMTest
+{
+ public static void testAddFirst() throws Exception
+ {
+ TestList list = new TestList();
+ list.add(5);
+
+ Integer[] result = list.get();
+ assertEquals(true, result != null);
+ assertEquals(true, result.length == 1);
+ assertEquals(true, list.getElements().length == 1);
+ assertEquals(true, !list.isEmpty());
+ assertEquals(true, list.added == 1);
+ assertEquals(true, list.removed == 0);
+ }
+
+ public static void testAddSecond() throws Exception
+ {
+ TestList list = new TestList();
+ list.add(5);
+ list.add(7);
+
+ Integer[] result = list.get();
+ assertEquals(true, result != null);
+ assertEquals(true, result.length == 2);
+ assertEquals(true, list.getElements().length == 2);
+ assertEquals(true, !list.isEmpty());
+ assertEquals(true, list.added == 1);
+ assertEquals(true, list.removed == 0);
+ }
+
+ public static void testRemoveHead() throws Exception
+ {
+ TestList list = new TestList();
+ list.add(5);
+ list.add(7);
+ list.add(2);
+ list.add(9);
+ list.add(1);
+ list.add(4);
+ list.add(8);
+
+ Integer[] old = list.reset();
+ boolean removed = list.remove(5);
+
+ Integer[] result = list.get();
+ assertEquals(true, removed);
+ assertEquals(true, result != null);
+ assertEquals(true, result != old);
+ assertEquals(true, result.length == 6);
+ assertEquals(true, list.getElements().length == 6);
+ assertEquals(true, !list.isEmpty());
+ assertEquals(true, list.added == 0);
+ assertEquals(true, list.removed == 0);
+ assertEquals(true, result[0] == 7);
+ assertEquals(true, result[1] == 2);
+ assertEquals(true, result[2] == 9);
+ assertEquals(true, result[3] == 1);
+ assertEquals(true, result[4] == 4);
+ assertEquals(true, result[5] == 8);
+ }
+
+ public static void testRemoveMiddle() throws Exception
+ {
+ TestList list = new TestList();
+ list.add(5);
+ list.add(7);
+ list.add(2);
+ list.add(9);
+ list.add(1);
+ list.add(4);
+ list.add(8);
+
+ Integer[] old = list.reset();
+ boolean removed = list.remove(9);
+
+ Integer[] result = list.get();
+ assertEquals(true, removed);
+ assertEquals(true, result != null);
+ assertEquals(true, result != old);
+ assertEquals(true, result.length == 6);
+ assertEquals(true, list.getElements().length == 6);
+ assertEquals(true, !list.isEmpty());
+ assertEquals(true, list.added == 0);
+ assertEquals(true, list.removed == 0);
+ assertEquals(true, result[0] == 5);
+ assertEquals(true, result[1] == 7);
+ assertEquals(true, result[2] == 2);
+ assertEquals(true, result[3] == 1);
+ assertEquals(true, result[4] == 4);
+ assertEquals(true, result[5] == 8);
+ }
+
+ public void testRemoveMiddleOfThree()
+ {
+ TestList list = new TestList();
+ Integer one = new Integer(1);
+ Integer two = new Integer(2);
+ Integer three = new Integer(3);
+
+ list.add(one);
+ list.add(two);
+ list.add(three);
+
+ list.remove(two);
+
+ Integer[] elements = list.get();
+ assertSame(one, elements[0]);
+ assertSame(three, elements[1]);
+ }
+
+ public static void testRemoveTail() throws Exception
+ {
+ TestList list = new TestList();
+ list.add(5);
+ list.add(7);
+ list.add(2);
+ list.add(9);
+ list.add(1);
+ list.add(4);
+ list.add(8);
+
+ Integer[] old = list.reset();
+ boolean removed = list.remove(8);
+
+ Integer[] result = list.get();
+ assertEquals(true, removed);
+ assertEquals(true, result != old);
+ assertEquals(true, result != null);
+ assertEquals(true, result.length == 6);
+ assertEquals(true, list.getElements().length == 6);
+ assertEquals(true, !list.isEmpty());
+ assertEquals(true, list.added == 0);
+ assertEquals(true, list.removed == 0);
+ assertEquals(true, result[0] == 5);
+ assertEquals(true, result[1] == 7);
+ assertEquals(true, result[2] == 2);
+ assertEquals(true, result[3] == 9);
+ assertEquals(true, result[4] == 1);
+ assertEquals(true, result[5] == 4);
+ }
+
+ public static void testRemoveLast() throws Exception
+ {
+ TestList list = new TestList();
+ list.add(5);
+ list.add(7);
+
+ Integer[] old = list.reset();
+ boolean removed1 = list.remove(7);
+ boolean removed2 = list.remove(5);
+
+ Integer[] result = list.get();
+ assertEquals(true, removed1);
+ assertEquals(true, removed2);
+ assertEquals(true, result != old);
+ assertEquals(true, result == null);
+ assertEquals(true, list.getElements() == null);
+ assertEquals(true, list.isEmpty());
+ assertEquals(true, list.added == 0);
+ assertEquals(true, list.removed == 1);
+ }
+
+ public static void testNotFoundInMany() throws Exception
+ {
+ TestList list = new TestList();
+ list.add(5);
+ list.add(7);
+ list.add(2);
+ list.add(9);
+ list.add(1);
+ list.add(4);
+ list.add(8);
+
+ Integer[] old = list.reset();
+ boolean removed = list.remove(10);
+
+ Integer[] result = list.get();
+ assertEquals(true, !removed);
+ assertEquals(true, result != null);
+ assertEquals(true, result == old);
+ assertEquals(true, result.length == 7);
+ assertEquals(true, list.getElements().length == 7);
+ assertEquals(true, !list.isEmpty());
+ assertEquals(true, list.added == 0);
+ assertEquals(true, list.removed == 0);
+ assertEquals(true, result[0] == 5);
+ assertEquals(true, result[1] == 7);
+ assertEquals(true, result[2] == 2);
+ assertEquals(true, result[3] == 9);
+ assertEquals(true, result[4] == 1);
+ assertEquals(true, result[5] == 4);
+ assertEquals(true, result[6] == 8);
+ }
+
+ public static void testNotFoundInOne() throws Exception
+ {
+ TestList list = new TestList();
+ list.add(5);
+
+ Integer[] old = list.reset();
+ boolean removed = list.remove(10);
+
+ Integer[] result = list.get();
+ assertEquals(true, !removed);
+ assertEquals(true, result != null);
+ assertEquals(true, result == old);
+ assertEquals(true, result.length == 1);
+ assertEquals(true, list.getElements().length == 1);
+ assertEquals(true, !list.isEmpty());
+ assertEquals(true, list.added == 0);
+ assertEquals(true, list.removed == 0);
+ assertEquals(true, result[0] == 5);
+ }
+
+ public static void testNotFoundInEmpty() throws Exception
+ {
+ TestList list = new TestList();
+
+ Integer[] old = list.reset();
+ boolean removed = list.remove(10);
+
+ Integer[] result = list.get();
+ assertEquals(true, !removed);
+ assertEquals(true, result == null);
+ assertEquals(true, result == old);
+ assertEquals(true, list.isEmpty());
+ assertEquals(true, list.added == 0);
+ assertEquals(true, list.removed == 0);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class TestList extends ConcurrentArray<Integer>
+ {
+ public int added;
+
+ public int removed;
+
+ public TestList()
+ {
+ }
+
+ public Integer[] getElements()
+ {
+ return elements;
+ }
+
+ public Integer[] reset()
+ {
+ added = 0;
+ removed = 0;
+ return elements;
+ }
+
+ @Override
+ protected Integer[] newArray(int length)
+ {
+ return new Integer[length];
+ }
+
+ @Override
+ protected void firstElementAdded()
+ {
+ ++added;
+ }
+
+ @Override
+ protected void lastElementRemoved()
+ {
+ ++removed;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/MonitorTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/MonitorTest.java
index 6ed7971120..51238103bb 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/MonitorTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/MonitorTest.java
@@ -1,302 +1,302 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.util.tests;
-
-import org.eclipse.net4j.util.om.monitor.Monitor;
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-import org.eclipse.net4j.util.om.monitor.OMMonitor.Async;
-
-/**
- * @author Eike Stepper
- */
-public class MonitorTest extends AbstractOMTest
-{
- public void testBeginNotCalledOnMonitor() throws Exception
- {
- try
- {
- OMMonitor monitor = new Monitor();
- monitor.worked();
- fail("IllegalStateException expected"); //$NON-NLS-1$
- }
- catch (IllegalStateException ex)
- {
- // Success
- }
-
- try
- {
- OMMonitor monitor = new Monitor();
- monitor.fork();
- fail("IllegalStateException expected"); //$NON-NLS-1$
- }
- catch (IllegalStateException ex)
- {
- // Success
- }
-
- Async async = null;
- try
- {
- OMMonitor monitor = new Monitor();
- async = monitor.forkAsync();
- fail("IllegalStateException expected"); //$NON-NLS-1$
- }
- catch (IllegalStateException ex)
- {
- // Success
- }
- finally
- {
- if (async != null)
- {
- async.stop();
- }
- }
- }
-
- public void testBeginNotCalledOnNestedMonitor() throws Exception
- {
- try
- {
- OMMonitor monitor = new Monitor().begin().fork();
- monitor.worked();
- fail("IllegalStateException expected"); //$NON-NLS-1$
- }
- catch (IllegalStateException ex)
- {
- // Success
- }
-
- try
- {
- OMMonitor monitor = new Monitor().begin().fork();
- monitor.fork();
- fail("IllegalStateException expected"); //$NON-NLS-1$
- }
- catch (IllegalStateException ex)
- {
- // Success
- }
-
- Async async = null;
- try
- {
- OMMonitor monitor = new Monitor().begin().fork();
- async = monitor.forkAsync();
- fail("IllegalStateException expected"); //$NON-NLS-1$
- }
- catch (IllegalStateException ex)
- {
- // Success
- }
- finally
- {
- if (async != null)
- {
- async.stop();
- }
- }
- }
-
- public void testBeginCalledOnMonitor() throws Exception
- {
- {
- OMMonitor monitor = new Monitor().begin();
- monitor.worked();
- }
-
- {
- OMMonitor monitor = new Monitor().begin();
- monitor.fork();
- }
-
- Async async = null;
- try
- {
- OMMonitor monitor = new Monitor().begin();
- async = monitor.forkAsync();
- }
- finally
- {
- if (async != null)
- {
- async.stop();
- }
- }
- }
-
- public void testBeginCalledOnNestedMonitor() throws Exception
- {
- {
- OMMonitor monitor = new Monitor().begin().fork().begin();
- monitor.worked();
- }
-
- {
- OMMonitor monitor = new Monitor().begin().fork().begin();
- monitor.fork();
- }
-
- Async async = null;
- try
- {
- OMMonitor monitor = new Monitor().begin().fork().begin();
- async = monitor.forkAsync();
- }
- finally
- {
- if (async != null)
- {
- async.stop();
- }
- }
- }
-
- public void testProgress() throws Exception
- {
- // Worked completely
- {
- OMMonitor monitor = new Monitor();
- assertNotSame(OMMonitor.ZERO, monitor.getTotalWork());
- assertEquals(OMMonitor.ZERO, monitor.getWork());
-
- monitor.begin(OMMonitor.TEN);
- assertEquals(OMMonitor.TEN, monitor.getTotalWork());
- assertEquals(OMMonitor.ZERO, monitor.getWork());
-
- for (int i = 0; i < 10; i++)
- {
- monitor.worked();
- assertEquals(OMMonitor.TEN, monitor.getTotalWork());
- assertEquals((double)i + 1, monitor.getWork());
- }
-
- monitor.done();
- assertEquals(OMMonitor.TEN, monitor.getTotalWork());
- assertEquals(monitor.getTotalWork(), monitor.getWork());
- }
-
- // Worked incompletely
- {
- OMMonitor monitor = new Monitor();
- assertNotSame(OMMonitor.ZERO, monitor.getTotalWork());
- assertEquals(OMMonitor.ZERO, monitor.getWork());
-
- monitor.begin(OMMonitor.TEN);
- assertEquals(OMMonitor.TEN, monitor.getTotalWork());
- assertEquals(OMMonitor.ZERO, monitor.getWork());
-
- for (int i = 0; i < 5; i++)
- {
- monitor.worked();
- assertEquals(OMMonitor.TEN, monitor.getTotalWork());
- assertEquals((double)i + 1, monitor.getWork());
- }
-
- monitor.done();
- assertEquals(OMMonitor.TEN, monitor.getTotalWork());
- assertEquals(monitor.getTotalWork(), monitor.getWork());
- }
- }
-
- public void testNestedProgress() throws Exception
- {
- // Worked completely
- {
- OMMonitor main = new Monitor().begin();
- assertEquals(OMMonitor.ONE, main.getTotalWork());
-
- OMMonitor monitor = main.fork();
- assertNotSame(OMMonitor.ZERO, monitor.getTotalWork());
- assertEquals(OMMonitor.ZERO, monitor.getWork());
-
- monitor.begin(OMMonitor.TEN);
- assertEquals(OMMonitor.TEN, monitor.getTotalWork());
- assertEquals(OMMonitor.ZERO, monitor.getWork());
-
- for (int i = 0; i < 10; i++)
- {
- monitor.worked();
- assertEquals(OMMonitor.TEN, monitor.getTotalWork());
- assertEquals((double)i + 1, monitor.getWork());
- assertSimilar(OMMonitor.ONE / OMMonitor.TEN * (i + 1), main.getWork(), 1000);
- }
-
- monitor.done();
- assertEquals(OMMonitor.TEN, monitor.getTotalWork());
- assertEquals(monitor.getTotalWork(), monitor.getWork());
- assertSimilar(OMMonitor.ONE, main.getWork(), 1000);
- }
-
- // Worked incompletely
- {
- OMMonitor main = new Monitor().begin();
- assertEquals(OMMonitor.ONE, main.getTotalWork());
-
- OMMonitor monitor = main.fork();
- assertNotSame(OMMonitor.ZERO, monitor.getTotalWork());
- assertEquals(OMMonitor.ZERO, monitor.getWork());
-
- monitor.begin(OMMonitor.TEN);
- assertEquals(OMMonitor.TEN, monitor.getTotalWork());
- assertEquals(OMMonitor.ZERO, monitor.getWork());
-
- for (int i = 0; i < 5; i++)
- {
- monitor.worked();
- assertEquals(OMMonitor.TEN, monitor.getTotalWork());
- assertEquals((double)i + 1, monitor.getWork());
- assertSimilar(OMMonitor.ONE / OMMonitor.TEN * (i + 1), main.getWork(), 1000);
- }
-
- monitor.done();
- assertEquals(OMMonitor.TEN, monitor.getTotalWork());
- assertEquals(monitor.getTotalWork(), monitor.getWork());
- assertSimilar(OMMonitor.ONE, main.getWork(), 1000);
- }
- }
-
- public void testAsyncProgress() throws Exception
- {
- final long PERIOD = 50;
- OMMonitor main = new Monitor()
- {
- @Override
- protected long getAsyncSchedulePeriod()
- {
- return PERIOD;
- }
- }.begin(3);
-
- main.worked();
- double work = main.getWork();
- assertEquals(OMMonitor.ONE, work);
-
- Async async = main.forkAsync();
- for (int i = 0; i < 20; i++)
- {
- sleep(2 * PERIOD);
- double newWork = main.getWork();
- System.out.println(newWork);
-
- // assertEquals(true, "Worked not enough: " + work, newWork > work);
- // assertEquals(true, "Worked too much: " + newWork, newWork < OMMonitor.ONE + OMMonitor.ONE);
- work = newWork;
- }
-
- async.stop();
- assertSimilar(OMMonitor.ONE + OMMonitor.ONE, main.getWork(), 1000);
-
- main.worked();
- assertSimilar(OMMonitor.ONE + OMMonitor.ONE + OMMonitor.ONE, main.getWork(), 1000);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.util.tests;
+
+import org.eclipse.net4j.util.om.monitor.Monitor;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+import org.eclipse.net4j.util.om.monitor.OMMonitor.Async;
+
+/**
+ * @author Eike Stepper
+ */
+public class MonitorTest extends AbstractOMTest
+{
+ public void testBeginNotCalledOnMonitor() throws Exception
+ {
+ try
+ {
+ OMMonitor monitor = new Monitor();
+ monitor.worked();
+ fail("IllegalStateException expected"); //$NON-NLS-1$
+ }
+ catch (IllegalStateException ex)
+ {
+ // Success
+ }
+
+ try
+ {
+ OMMonitor monitor = new Monitor();
+ monitor.fork();
+ fail("IllegalStateException expected"); //$NON-NLS-1$
+ }
+ catch (IllegalStateException ex)
+ {
+ // Success
+ }
+
+ Async async = null;
+ try
+ {
+ OMMonitor monitor = new Monitor();
+ async = monitor.forkAsync();
+ fail("IllegalStateException expected"); //$NON-NLS-1$
+ }
+ catch (IllegalStateException ex)
+ {
+ // Success
+ }
+ finally
+ {
+ if (async != null)
+ {
+ async.stop();
+ }
+ }
+ }
+
+ public void testBeginNotCalledOnNestedMonitor() throws Exception
+ {
+ try
+ {
+ OMMonitor monitor = new Monitor().begin().fork();
+ monitor.worked();
+ fail("IllegalStateException expected"); //$NON-NLS-1$
+ }
+ catch (IllegalStateException ex)
+ {
+ // Success
+ }
+
+ try
+ {
+ OMMonitor monitor = new Monitor().begin().fork();
+ monitor.fork();
+ fail("IllegalStateException expected"); //$NON-NLS-1$
+ }
+ catch (IllegalStateException ex)
+ {
+ // Success
+ }
+
+ Async async = null;
+ try
+ {
+ OMMonitor monitor = new Monitor().begin().fork();
+ async = monitor.forkAsync();
+ fail("IllegalStateException expected"); //$NON-NLS-1$
+ }
+ catch (IllegalStateException ex)
+ {
+ // Success
+ }
+ finally
+ {
+ if (async != null)
+ {
+ async.stop();
+ }
+ }
+ }
+
+ public void testBeginCalledOnMonitor() throws Exception
+ {
+ {
+ OMMonitor monitor = new Monitor().begin();
+ monitor.worked();
+ }
+
+ {
+ OMMonitor monitor = new Monitor().begin();
+ monitor.fork();
+ }
+
+ Async async = null;
+ try
+ {
+ OMMonitor monitor = new Monitor().begin();
+ async = monitor.forkAsync();
+ }
+ finally
+ {
+ if (async != null)
+ {
+ async.stop();
+ }
+ }
+ }
+
+ public void testBeginCalledOnNestedMonitor() throws Exception
+ {
+ {
+ OMMonitor monitor = new Monitor().begin().fork().begin();
+ monitor.worked();
+ }
+
+ {
+ OMMonitor monitor = new Monitor().begin().fork().begin();
+ monitor.fork();
+ }
+
+ Async async = null;
+ try
+ {
+ OMMonitor monitor = new Monitor().begin().fork().begin();
+ async = monitor.forkAsync();
+ }
+ finally
+ {
+ if (async != null)
+ {
+ async.stop();
+ }
+ }
+ }
+
+ public void testProgress() throws Exception
+ {
+ // Worked completely
+ {
+ OMMonitor monitor = new Monitor();
+ assertNotSame(OMMonitor.ZERO, monitor.getTotalWork());
+ assertEquals(OMMonitor.ZERO, monitor.getWork());
+
+ monitor.begin(OMMonitor.TEN);
+ assertEquals(OMMonitor.TEN, monitor.getTotalWork());
+ assertEquals(OMMonitor.ZERO, monitor.getWork());
+
+ for (int i = 0; i < 10; i++)
+ {
+ monitor.worked();
+ assertEquals(OMMonitor.TEN, monitor.getTotalWork());
+ assertEquals((double)i + 1, monitor.getWork());
+ }
+
+ monitor.done();
+ assertEquals(OMMonitor.TEN, monitor.getTotalWork());
+ assertEquals(monitor.getTotalWork(), monitor.getWork());
+ }
+
+ // Worked incompletely
+ {
+ OMMonitor monitor = new Monitor();
+ assertNotSame(OMMonitor.ZERO, monitor.getTotalWork());
+ assertEquals(OMMonitor.ZERO, monitor.getWork());
+
+ monitor.begin(OMMonitor.TEN);
+ assertEquals(OMMonitor.TEN, monitor.getTotalWork());
+ assertEquals(OMMonitor.ZERO, monitor.getWork());
+
+ for (int i = 0; i < 5; i++)
+ {
+ monitor.worked();
+ assertEquals(OMMonitor.TEN, monitor.getTotalWork());
+ assertEquals((double)i + 1, monitor.getWork());
+ }
+
+ monitor.done();
+ assertEquals(OMMonitor.TEN, monitor.getTotalWork());
+ assertEquals(monitor.getTotalWork(), monitor.getWork());
+ }
+ }
+
+ public void testNestedProgress() throws Exception
+ {
+ // Worked completely
+ {
+ OMMonitor main = new Monitor().begin();
+ assertEquals(OMMonitor.ONE, main.getTotalWork());
+
+ OMMonitor monitor = main.fork();
+ assertNotSame(OMMonitor.ZERO, monitor.getTotalWork());
+ assertEquals(OMMonitor.ZERO, monitor.getWork());
+
+ monitor.begin(OMMonitor.TEN);
+ assertEquals(OMMonitor.TEN, monitor.getTotalWork());
+ assertEquals(OMMonitor.ZERO, monitor.getWork());
+
+ for (int i = 0; i < 10; i++)
+ {
+ monitor.worked();
+ assertEquals(OMMonitor.TEN, monitor.getTotalWork());
+ assertEquals((double)i + 1, monitor.getWork());
+ assertSimilar(OMMonitor.ONE / OMMonitor.TEN * (i + 1), main.getWork(), 1000);
+ }
+
+ monitor.done();
+ assertEquals(OMMonitor.TEN, monitor.getTotalWork());
+ assertEquals(monitor.getTotalWork(), monitor.getWork());
+ assertSimilar(OMMonitor.ONE, main.getWork(), 1000);
+ }
+
+ // Worked incompletely
+ {
+ OMMonitor main = new Monitor().begin();
+ assertEquals(OMMonitor.ONE, main.getTotalWork());
+
+ OMMonitor monitor = main.fork();
+ assertNotSame(OMMonitor.ZERO, monitor.getTotalWork());
+ assertEquals(OMMonitor.ZERO, monitor.getWork());
+
+ monitor.begin(OMMonitor.TEN);
+ assertEquals(OMMonitor.TEN, monitor.getTotalWork());
+ assertEquals(OMMonitor.ZERO, monitor.getWork());
+
+ for (int i = 0; i < 5; i++)
+ {
+ monitor.worked();
+ assertEquals(OMMonitor.TEN, monitor.getTotalWork());
+ assertEquals((double)i + 1, monitor.getWork());
+ assertSimilar(OMMonitor.ONE / OMMonitor.TEN * (i + 1), main.getWork(), 1000);
+ }
+
+ monitor.done();
+ assertEquals(OMMonitor.TEN, monitor.getTotalWork());
+ assertEquals(monitor.getTotalWork(), monitor.getWork());
+ assertSimilar(OMMonitor.ONE, main.getWork(), 1000);
+ }
+ }
+
+ public void testAsyncProgress() throws Exception
+ {
+ final long PERIOD = 50;
+ OMMonitor main = new Monitor()
+ {
+ @Override
+ protected long getAsyncSchedulePeriod()
+ {
+ return PERIOD;
+ }
+ }.begin(3);
+
+ main.worked();
+ double work = main.getWork();
+ assertEquals(OMMonitor.ONE, work);
+
+ Async async = main.forkAsync();
+ for (int i = 0; i < 20; i++)
+ {
+ sleep(2 * PERIOD);
+ double newWork = main.getWork();
+ System.out.println(newWork);
+
+ // assertEquals(true, "Worked not enough: " + work, newWork > work);
+ // assertEquals(true, "Worked too much: " + newWork, newWork < OMMonitor.ONE + OMMonitor.ONE);
+ work = newWork;
+ }
+
+ async.stop();
+ assertSimilar(OMMonitor.ONE + OMMonitor.ONE, main.getWork(), 1000);
+
+ main.worked();
+ assertSimilar(OMMonitor.ONE + OMMonitor.ONE + OMMonitor.ONE, main.getWork(), 1000);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/MultiMapTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/MultiMapTest.java
index 8eddb83df0..a38013ae32 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/MultiMapTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/MultiMapTest.java
@@ -1,291 +1,291 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.util.tests;
-
-import org.eclipse.net4j.util.collection.MapEntry;
-import org.eclipse.net4j.util.collection.MultiMap.ListBased;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class MultiMapTest extends AbstractOMTest
-{
- public void testListBased() throws Exception
- {
- ListBased<Integer, String> multiMap = new ListBased<Integer, String>();
- assertEquals(true, multiMap.isEmpty());
- assertEquals(0, multiMap.size());
- assertEquals(false, multiMap.containsKey(1));
- assertEquals(false, multiMap.containsValue("value" + 1)); //$NON-NLS-1$
- assertEquals(null, multiMap.get(1));
-
- addDelegate(multiMap, 0, 0);
- assertEquals(true, multiMap.isEmpty());
- assertEquals(0, multiMap.size());
- assertEquals(false, multiMap.containsKey(1));
- assertEquals(false, multiMap.containsValue("value" + 1)); //$NON-NLS-1$
- assertEquals(null, multiMap.get(1));
-
- addDelegate(multiMap, 1, 10);
- addDelegate(multiMap, 11, 10);
- addDelegate(multiMap, 21, 10);
- assertEquals(false, multiMap.isEmpty());
- assertEquals(30, multiMap.size());
- assertEquals(true, multiMap.containsKey(1));
- assertEquals(true, multiMap.containsValue("value" + 1)); //$NON-NLS-1$
- assertEquals("value" + 1, multiMap.get(1)); //$NON-NLS-1$
- assertEquals("value" + 6, multiMap.get(6)); //$NON-NLS-1$
-
- addDelegate(multiMap, 6, 10);
- assertEquals(false, multiMap.isEmpty());
- assertEquals(30, multiMap.size());
- assertEquals(true, multiMap.containsKey(1));
- assertEquals(true, multiMap.containsValue("value" + 1)); //$NON-NLS-1$
- assertEquals("value" + 1, multiMap.get(1)); //$NON-NLS-1$
- assertEquals("value" + 6, multiMap.get(6)); //$NON-NLS-1$
- assertEquals(null, multiMap.get(35));
-
- addDelegate(multiMap, 26, 10);
- assertEquals(false, multiMap.isEmpty());
- assertEquals(35, multiMap.size());
- assertEquals(true, multiMap.containsKey(1));
- assertEquals(true, multiMap.containsValue("value" + 1)); //$NON-NLS-1$
- assertEquals("value" + 1, multiMap.get(1)); //$NON-NLS-1$
- assertEquals("value" + 6, multiMap.get(6)); //$NON-NLS-1$
- assertEquals("value" + 35, multiMap.get(35)); //$NON-NLS-1$
- }
-
- public void testEntrySet() throws Exception
- {
- ListBased<Integer, String> multiMap = new ListBased<Integer, String>();
- assertEquals(true, multiMap.entrySet().isEmpty());
- assertEquals(0, multiMap.entrySet().size());
- assertEquals(false, multiMap.entrySet().contains(new MapEntry<Integer, String>(1, "value1"))); //$NON-NLS-1$
-
- addDelegate(multiMap, 0, 0);
- assertEquals(true, multiMap.entrySet().isEmpty());
- assertEquals(0, multiMap.entrySet().size());
- assertEquals(false, multiMap.entrySet().contains(new MapEntry<Integer, String>(1, "value1"))); //$NON-NLS-1$
-
- addDelegate(multiMap, 1, 10);
- addDelegate(multiMap, 11, 10);
- addDelegate(multiMap, 21, 10);
- assertEquals(false, multiMap.entrySet().isEmpty());
- assertEquals(30, multiMap.entrySet().size());
- assertEquals(true, multiMap.entrySet().contains(new MapEntry<Integer, String>(1, "value1"))); //$NON-NLS-1$
-
- addDelegate(multiMap, 6, 10);
- assertEquals(false, multiMap.entrySet().isEmpty());
- assertEquals(30, multiMap.entrySet().size());
- assertEquals(true, multiMap.entrySet().contains(new MapEntry<Integer, String>(1, "value1"))); //$NON-NLS-1$
- assertEquals(false, multiMap.entrySet().contains(new MapEntry<Integer, String>(35, "value35"))); //$NON-NLS-1$
-
- addDelegate(multiMap, 26, 10);
- assertEquals(false, multiMap.entrySet().isEmpty());
- assertEquals(35, multiMap.entrySet().size());
- assertEquals(true, multiMap.entrySet().contains(new MapEntry<Integer, String>(1, "value1"))); //$NON-NLS-1$
- assertEquals(true, multiMap.entrySet().contains(new MapEntry<Integer, String>(35, "value35"))); //$NON-NLS-1$
- }
-
- public void testKeySet() throws Exception
- {
- ListBased<Integer, String> multiMap = new ListBased<Integer, String>();
- assertEquals(true, multiMap.keySet().isEmpty());
- assertEquals(0, multiMap.keySet().size());
- assertEquals(false, multiMap.keySet().contains(1));
-
- addDelegate(multiMap, 0, 0);
- assertEquals(true, multiMap.keySet().isEmpty());
- assertEquals(0, multiMap.keySet().size());
- assertEquals(false, multiMap.keySet().contains(1));
-
- addDelegate(multiMap, 1, 10);
- addDelegate(multiMap, 11, 10);
- addDelegate(multiMap, 21, 10);
- assertEquals(false, multiMap.keySet().isEmpty());
- assertEquals(30, multiMap.keySet().size());
- assertEquals(true, multiMap.keySet().contains(1));
-
- addDelegate(multiMap, 6, 10);
- assertEquals(false, multiMap.keySet().isEmpty());
- assertEquals(30, multiMap.keySet().size());
- assertEquals(true, multiMap.keySet().contains(1));
- assertEquals(false, multiMap.keySet().contains(35));
-
- addDelegate(multiMap, 26, 10);
- assertEquals(false, multiMap.keySet().isEmpty());
- assertEquals(35, multiMap.keySet().size());
- assertEquals(true, multiMap.keySet().contains(1));
- assertEquals(true, multiMap.keySet().contains(35));
- }
-
- public void testValues() throws Exception
- {
- ListBased<Integer, String> multiMap = new ListBased<Integer, String>();
- assertEquals(true, multiMap.values().isEmpty());
- assertEquals(0, multiMap.values().size());
- assertEquals(false, multiMap.values().contains("value1")); //$NON-NLS-1$
-
- addDelegate(multiMap, 0, 0);
- assertEquals(true, multiMap.values().isEmpty());
- assertEquals(0, multiMap.values().size());
- assertEquals(false, multiMap.values().contains("value1")); //$NON-NLS-1$
-
- addDelegate(multiMap, 1, 10);
- addDelegate(multiMap, 11, 10);
- addDelegate(multiMap, 21, 10);
- assertEquals(false, multiMap.values().isEmpty());
- assertEquals(30, multiMap.values().size());
- assertEquals(true, multiMap.values().contains("value1")); //$NON-NLS-1$
-
- addDelegate(multiMap, 6, 10);
- assertEquals(false, multiMap.values().isEmpty());
- assertEquals(30, multiMap.values().size());
- assertEquals(true, multiMap.values().contains("value1")); //$NON-NLS-1$
- assertEquals(false, multiMap.values().contains("value35")); //$NON-NLS-1$
-
- addDelegate(multiMap, 26, 10);
- assertEquals(false, multiMap.values().isEmpty());
- assertEquals(35, multiMap.values().size());
- assertEquals(true, multiMap.values().contains("value1")); //$NON-NLS-1$
- assertEquals(true, multiMap.values().contains("value35")); //$NON-NLS-1$
- }
-
- public void testEntrySetIterator() throws Exception
- {
- ListBased<Integer, String> multiMap = new ListBased<Integer, String>();
- assertIterator(new HashSet<Object>(), multiMap.entrySet());
-
- addDelegate(multiMap, 0, 0);
- assertIterator(new HashSet<Object>(), multiMap.entrySet());
-
- addDelegate(multiMap, 1, 10);
- addDelegate(multiMap, 11, 10);
- addDelegate(multiMap, 21, 10);
- assertIterator(createMapEntries(1, 30), multiMap.entrySet());
-
- addDelegate(multiMap, 6, 10);
- assertIterator(createMapEntries(1, 30), multiMap.entrySet());
-
- addDelegate(multiMap, 26, 10);
- assertIterator(createMapEntries(1, 35), multiMap.entrySet());
- }
-
- public void testKeySetIterator() throws Exception
- {
- ListBased<Integer, String> multiMap = new ListBased<Integer, String>();
- assertIterator(new HashSet<Object>(), multiMap.keySet());
-
- addDelegate(multiMap, 0, 0);
- assertIterator(new HashSet<Object>(), multiMap.keySet());
-
- addDelegate(multiMap, 1, 10);
- addDelegate(multiMap, 11, 10);
- addDelegate(multiMap, 21, 10);
- assertIterator(createKeys(1, 30), multiMap.keySet());
-
- addDelegate(multiMap, 6, 10);
- assertIterator(createKeys(1, 30), multiMap.keySet());
-
- addDelegate(multiMap, 26, 10);
- assertIterator(createKeys(1, 35), multiMap.keySet());
- }
-
- public void testValuesIterator() throws Exception
- {
- ListBased<Integer, String> multiMap = new ListBased<Integer, String>();
- assertIterator(new HashSet<Object>(), multiMap.values());
-
- addDelegate(multiMap, 0, 0);
- assertIterator(new HashSet<Object>(), multiMap.values());
-
- addDelegate(multiMap, 1, 10);
- addDelegate(multiMap, 11, 10);
- addDelegate(multiMap, 21, 10);
- assertIterator(createValues(1, 30), multiMap.values());
-
- addDelegate(multiMap, 6, 10);
- assertIterator(createValues(1, 30), multiMap.values());
-
- addDelegate(multiMap, 26, 10);
- assertIterator(createValues(1, 35), multiMap.values());
- }
-
- private void addDelegate(ListBased<Integer, String> multiMap, int start, int count)
- {
- Map<Integer, String> map = new HashMap<Integer, String>();
- for (int i = 0; i < count; i++)
- {
- int key = start + i;
- map.put(key, "value" + key); //$NON-NLS-1$
- }
-
- multiMap.getDelegates().add(map);
- }
-
- private void assertIterator(Set<?> expectedObjects, Collection<?> actualObjects)
- {
- for (Object actualObject : actualObjects)
- {
- if (!expectedObjects.remove(actualObject))
- {
- fail("Unexpected object: " + actualObject); //$NON-NLS-1$
- }
- }
-
- if (!expectedObjects.isEmpty())
- {
- fail("Missing objects: " + expectedObjects); //$NON-NLS-1$
- }
- }
-
- private Set<Object> createMapEntries(int start, int count)
- {
- Set<Object> result = new HashSet<Object>();
- for (int i = 0; i < count; i++)
- {
- int key = start + i;
- result.add(new MapEntry<Integer, String>(key, "value" + key)); //$NON-NLS-1$
- }
-
- return result;
- }
-
- private Set<Object> createKeys(int start, int count)
- {
- Set<Object> result = new HashSet<Object>();
- for (int i = 0; i < count; i++)
- {
- int key = start + i;
- result.add(key);
- }
-
- return result;
- }
-
- private Set<Object> createValues(int start, int count)
- {
- Set<Object> result = new HashSet<Object>();
- for (int i = 0; i < count; i++)
- {
- int key = start + i;
- result.add("value" + key); //$NON-NLS-1$
- }
-
- return result;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.util.tests;
+
+import org.eclipse.net4j.util.collection.MapEntry;
+import org.eclipse.net4j.util.collection.MultiMap.ListBased;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class MultiMapTest extends AbstractOMTest
+{
+ public void testListBased() throws Exception
+ {
+ ListBased<Integer, String> multiMap = new ListBased<Integer, String>();
+ assertEquals(true, multiMap.isEmpty());
+ assertEquals(0, multiMap.size());
+ assertEquals(false, multiMap.containsKey(1));
+ assertEquals(false, multiMap.containsValue("value" + 1)); //$NON-NLS-1$
+ assertEquals(null, multiMap.get(1));
+
+ addDelegate(multiMap, 0, 0);
+ assertEquals(true, multiMap.isEmpty());
+ assertEquals(0, multiMap.size());
+ assertEquals(false, multiMap.containsKey(1));
+ assertEquals(false, multiMap.containsValue("value" + 1)); //$NON-NLS-1$
+ assertEquals(null, multiMap.get(1));
+
+ addDelegate(multiMap, 1, 10);
+ addDelegate(multiMap, 11, 10);
+ addDelegate(multiMap, 21, 10);
+ assertEquals(false, multiMap.isEmpty());
+ assertEquals(30, multiMap.size());
+ assertEquals(true, multiMap.containsKey(1));
+ assertEquals(true, multiMap.containsValue("value" + 1)); //$NON-NLS-1$
+ assertEquals("value" + 1, multiMap.get(1)); //$NON-NLS-1$
+ assertEquals("value" + 6, multiMap.get(6)); //$NON-NLS-1$
+
+ addDelegate(multiMap, 6, 10);
+ assertEquals(false, multiMap.isEmpty());
+ assertEquals(30, multiMap.size());
+ assertEquals(true, multiMap.containsKey(1));
+ assertEquals(true, multiMap.containsValue("value" + 1)); //$NON-NLS-1$
+ assertEquals("value" + 1, multiMap.get(1)); //$NON-NLS-1$
+ assertEquals("value" + 6, multiMap.get(6)); //$NON-NLS-1$
+ assertEquals(null, multiMap.get(35));
+
+ addDelegate(multiMap, 26, 10);
+ assertEquals(false, multiMap.isEmpty());
+ assertEquals(35, multiMap.size());
+ assertEquals(true, multiMap.containsKey(1));
+ assertEquals(true, multiMap.containsValue("value" + 1)); //$NON-NLS-1$
+ assertEquals("value" + 1, multiMap.get(1)); //$NON-NLS-1$
+ assertEquals("value" + 6, multiMap.get(6)); //$NON-NLS-1$
+ assertEquals("value" + 35, multiMap.get(35)); //$NON-NLS-1$
+ }
+
+ public void testEntrySet() throws Exception
+ {
+ ListBased<Integer, String> multiMap = new ListBased<Integer, String>();
+ assertEquals(true, multiMap.entrySet().isEmpty());
+ assertEquals(0, multiMap.entrySet().size());
+ assertEquals(false, multiMap.entrySet().contains(new MapEntry<Integer, String>(1, "value1"))); //$NON-NLS-1$
+
+ addDelegate(multiMap, 0, 0);
+ assertEquals(true, multiMap.entrySet().isEmpty());
+ assertEquals(0, multiMap.entrySet().size());
+ assertEquals(false, multiMap.entrySet().contains(new MapEntry<Integer, String>(1, "value1"))); //$NON-NLS-1$
+
+ addDelegate(multiMap, 1, 10);
+ addDelegate(multiMap, 11, 10);
+ addDelegate(multiMap, 21, 10);
+ assertEquals(false, multiMap.entrySet().isEmpty());
+ assertEquals(30, multiMap.entrySet().size());
+ assertEquals(true, multiMap.entrySet().contains(new MapEntry<Integer, String>(1, "value1"))); //$NON-NLS-1$
+
+ addDelegate(multiMap, 6, 10);
+ assertEquals(false, multiMap.entrySet().isEmpty());
+ assertEquals(30, multiMap.entrySet().size());
+ assertEquals(true, multiMap.entrySet().contains(new MapEntry<Integer, String>(1, "value1"))); //$NON-NLS-1$
+ assertEquals(false, multiMap.entrySet().contains(new MapEntry<Integer, String>(35, "value35"))); //$NON-NLS-1$
+
+ addDelegate(multiMap, 26, 10);
+ assertEquals(false, multiMap.entrySet().isEmpty());
+ assertEquals(35, multiMap.entrySet().size());
+ assertEquals(true, multiMap.entrySet().contains(new MapEntry<Integer, String>(1, "value1"))); //$NON-NLS-1$
+ assertEquals(true, multiMap.entrySet().contains(new MapEntry<Integer, String>(35, "value35"))); //$NON-NLS-1$
+ }
+
+ public void testKeySet() throws Exception
+ {
+ ListBased<Integer, String> multiMap = new ListBased<Integer, String>();
+ assertEquals(true, multiMap.keySet().isEmpty());
+ assertEquals(0, multiMap.keySet().size());
+ assertEquals(false, multiMap.keySet().contains(1));
+
+ addDelegate(multiMap, 0, 0);
+ assertEquals(true, multiMap.keySet().isEmpty());
+ assertEquals(0, multiMap.keySet().size());
+ assertEquals(false, multiMap.keySet().contains(1));
+
+ addDelegate(multiMap, 1, 10);
+ addDelegate(multiMap, 11, 10);
+ addDelegate(multiMap, 21, 10);
+ assertEquals(false, multiMap.keySet().isEmpty());
+ assertEquals(30, multiMap.keySet().size());
+ assertEquals(true, multiMap.keySet().contains(1));
+
+ addDelegate(multiMap, 6, 10);
+ assertEquals(false, multiMap.keySet().isEmpty());
+ assertEquals(30, multiMap.keySet().size());
+ assertEquals(true, multiMap.keySet().contains(1));
+ assertEquals(false, multiMap.keySet().contains(35));
+
+ addDelegate(multiMap, 26, 10);
+ assertEquals(false, multiMap.keySet().isEmpty());
+ assertEquals(35, multiMap.keySet().size());
+ assertEquals(true, multiMap.keySet().contains(1));
+ assertEquals(true, multiMap.keySet().contains(35));
+ }
+
+ public void testValues() throws Exception
+ {
+ ListBased<Integer, String> multiMap = new ListBased<Integer, String>();
+ assertEquals(true, multiMap.values().isEmpty());
+ assertEquals(0, multiMap.values().size());
+ assertEquals(false, multiMap.values().contains("value1")); //$NON-NLS-1$
+
+ addDelegate(multiMap, 0, 0);
+ assertEquals(true, multiMap.values().isEmpty());
+ assertEquals(0, multiMap.values().size());
+ assertEquals(false, multiMap.values().contains("value1")); //$NON-NLS-1$
+
+ addDelegate(multiMap, 1, 10);
+ addDelegate(multiMap, 11, 10);
+ addDelegate(multiMap, 21, 10);
+ assertEquals(false, multiMap.values().isEmpty());
+ assertEquals(30, multiMap.values().size());
+ assertEquals(true, multiMap.values().contains("value1")); //$NON-NLS-1$
+
+ addDelegate(multiMap, 6, 10);
+ assertEquals(false, multiMap.values().isEmpty());
+ assertEquals(30, multiMap.values().size());
+ assertEquals(true, multiMap.values().contains("value1")); //$NON-NLS-1$
+ assertEquals(false, multiMap.values().contains("value35")); //$NON-NLS-1$
+
+ addDelegate(multiMap, 26, 10);
+ assertEquals(false, multiMap.values().isEmpty());
+ assertEquals(35, multiMap.values().size());
+ assertEquals(true, multiMap.values().contains("value1")); //$NON-NLS-1$
+ assertEquals(true, multiMap.values().contains("value35")); //$NON-NLS-1$
+ }
+
+ public void testEntrySetIterator() throws Exception
+ {
+ ListBased<Integer, String> multiMap = new ListBased<Integer, String>();
+ assertIterator(new HashSet<Object>(), multiMap.entrySet());
+
+ addDelegate(multiMap, 0, 0);
+ assertIterator(new HashSet<Object>(), multiMap.entrySet());
+
+ addDelegate(multiMap, 1, 10);
+ addDelegate(multiMap, 11, 10);
+ addDelegate(multiMap, 21, 10);
+ assertIterator(createMapEntries(1, 30), multiMap.entrySet());
+
+ addDelegate(multiMap, 6, 10);
+ assertIterator(createMapEntries(1, 30), multiMap.entrySet());
+
+ addDelegate(multiMap, 26, 10);
+ assertIterator(createMapEntries(1, 35), multiMap.entrySet());
+ }
+
+ public void testKeySetIterator() throws Exception
+ {
+ ListBased<Integer, String> multiMap = new ListBased<Integer, String>();
+ assertIterator(new HashSet<Object>(), multiMap.keySet());
+
+ addDelegate(multiMap, 0, 0);
+ assertIterator(new HashSet<Object>(), multiMap.keySet());
+
+ addDelegate(multiMap, 1, 10);
+ addDelegate(multiMap, 11, 10);
+ addDelegate(multiMap, 21, 10);
+ assertIterator(createKeys(1, 30), multiMap.keySet());
+
+ addDelegate(multiMap, 6, 10);
+ assertIterator(createKeys(1, 30), multiMap.keySet());
+
+ addDelegate(multiMap, 26, 10);
+ assertIterator(createKeys(1, 35), multiMap.keySet());
+ }
+
+ public void testValuesIterator() throws Exception
+ {
+ ListBased<Integer, String> multiMap = new ListBased<Integer, String>();
+ assertIterator(new HashSet<Object>(), multiMap.values());
+
+ addDelegate(multiMap, 0, 0);
+ assertIterator(new HashSet<Object>(), multiMap.values());
+
+ addDelegate(multiMap, 1, 10);
+ addDelegate(multiMap, 11, 10);
+ addDelegate(multiMap, 21, 10);
+ assertIterator(createValues(1, 30), multiMap.values());
+
+ addDelegate(multiMap, 6, 10);
+ assertIterator(createValues(1, 30), multiMap.values());
+
+ addDelegate(multiMap, 26, 10);
+ assertIterator(createValues(1, 35), multiMap.values());
+ }
+
+ private void addDelegate(ListBased<Integer, String> multiMap, int start, int count)
+ {
+ Map<Integer, String> map = new HashMap<Integer, String>();
+ for (int i = 0; i < count; i++)
+ {
+ int key = start + i;
+ map.put(key, "value" + key); //$NON-NLS-1$
+ }
+
+ multiMap.getDelegates().add(map);
+ }
+
+ private void assertIterator(Set<?> expectedObjects, Collection<?> actualObjects)
+ {
+ for (Object actualObject : actualObjects)
+ {
+ if (!expectedObjects.remove(actualObject))
+ {
+ fail("Unexpected object: " + actualObject); //$NON-NLS-1$
+ }
+ }
+
+ if (!expectedObjects.isEmpty())
+ {
+ fail("Missing objects: " + expectedObjects); //$NON-NLS-1$
+ }
+ }
+
+ private Set<Object> createMapEntries(int start, int count)
+ {
+ Set<Object> result = new HashSet<Object>();
+ for (int i = 0; i < count; i++)
+ {
+ int key = start + i;
+ result.add(new MapEntry<Integer, String>(key, "value" + key)); //$NON-NLS-1$
+ }
+
+ return result;
+ }
+
+ private Set<Object> createKeys(int start, int count)
+ {
+ Set<Object> result = new HashSet<Object>();
+ for (int i = 0; i < count; i++)
+ {
+ int key = start + i;
+ result.add(key);
+ }
+
+ return result;
+ }
+
+ private Set<Object> createValues(int start, int count)
+ {
+ Set<Object> result = new HashSet<Object>();
+ for (int i = 0; i < count; i++)
+ {
+ int key = start + i;
+ result.add("value" + key); //$NON-NLS-1$
+ }
+
+ return result;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/OMTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/OMTest.java
index 03659e4bb6..263cb1af30 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/OMTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/OMTest.java
@@ -1,47 +1,47 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.util.tests;
-
-import org.eclipse.net4j.util.io.IOUtil;
-import org.eclipse.net4j.util.om.OMBundle;
-
-import java.io.InputStream;
-import java.net.URL;
-
-/**
- * @author Eike Stepper
- */
-public class OMTest
-{
- /**
- * Requires this class to be exported to a jar file in this project's plugins/ folder!<br>
- * Also requires an export of the net4j.util bundle in the same folder!
- */
- public static void main(String[] args) throws Exception
- {
- OMBundle bundle = org.eclipse.net4j.internal.util.bundle.OM.BUNDLE;
-
- URL baseUrl = bundle.getBaseURL();
- IOUtil.OUT().println(baseUrl);
- IOUtil.OUT().println();
-
- InputStream stream = bundle.getInputStream("/plugin.xml"); //$NON-NLS-1$
-
- try
- {
- IOUtil.copy(stream, IOUtil.OUT());
- }
- finally
- {
- IOUtil.close(stream);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.util.tests;
+
+import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.net4j.util.om.OMBundle;
+
+import java.io.InputStream;
+import java.net.URL;
+
+/**
+ * @author Eike Stepper
+ */
+public class OMTest
+{
+ /**
+ * Requires this class to be exported to a jar file in this project's plugins/ folder!<br>
+ * Also requires an export of the net4j.util bundle in the same folder!
+ */
+ public static void main(String[] args) throws Exception
+ {
+ OMBundle bundle = org.eclipse.net4j.internal.util.bundle.OM.BUNDLE;
+
+ URL baseUrl = bundle.getBaseURL();
+ IOUtil.OUT().println(baseUrl);
+ IOUtil.OUT().println();
+
+ InputStream stream = bundle.getInputStream("/plugin.xml"); //$NON-NLS-1$
+
+ try
+ {
+ IOUtil.copy(stream, IOUtil.OUT());
+ }
+ finally
+ {
+ IOUtil.close(stream);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/ReferenceValueMapTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/ReferenceValueMapTest.java
index 2e3776c049..678f6b00b6 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/ReferenceValueMapTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/ReferenceValueMapTest.java
@@ -1,43 +1,43 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.util.tests;
-
-import org.eclipse.net4j.util.ref.ReferenceValueMap;
-
-/**
- * @author Eike Stepper
- */
-public class ReferenceValueMapTest extends AbstractOMTest
-{
- public void testSameKey() throws Exception
- {
- ReferenceValueMap<String, Object> map = new ReferenceValueMap.Weak<String, Object>();
- for (int i = 0; i < 10; i++)
- {
- map.put("SIMON", new Object()); //$NON-NLS-1$
- System.gc();
- map.put("SIMON", new Object()); //$NON-NLS-1$
- assertEquals(true, map.size() >= 0);
- }
- }
-
- public void testDifferentKey() throws Exception
- {
- ReferenceValueMap<String, Object> map = new ReferenceValueMap.Weak<String, Object>();
- for (int i = 0; i < 10; i++)
- {
- map.put("SIMON", new Object()); //$NON-NLS-1$
- System.gc();
- map.put("SIMON2", new Object()); //$NON-NLS-1$
- assertEquals(true, map.size() >= 1);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.util.tests;
+
+import org.eclipse.net4j.util.ref.ReferenceValueMap;
+
+/**
+ * @author Eike Stepper
+ */
+public class ReferenceValueMapTest extends AbstractOMTest
+{
+ public void testSameKey() throws Exception
+ {
+ ReferenceValueMap<String, Object> map = new ReferenceValueMap.Weak<String, Object>();
+ for (int i = 0; i < 10; i++)
+ {
+ map.put("SIMON", new Object()); //$NON-NLS-1$
+ System.gc();
+ map.put("SIMON", new Object()); //$NON-NLS-1$
+ assertEquals(true, map.size() >= 0);
+ }
+ }
+
+ public void testDifferentKey() throws Exception
+ {
+ ReferenceValueMap<String, Object> map = new ReferenceValueMap.Weak<String, Object>();
+ for (int i = 0; i < 10; i++)
+ {
+ map.put("SIMON", new Object()); //$NON-NLS-1$
+ System.gc();
+ map.put("SIMON2", new Object()); //$NON-NLS-1$
+ assertEquals(true, map.size() >= 1);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/SecurityTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/SecurityTest.java
index 77e9fc34ad..e3df67621f 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/SecurityTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/SecurityTest.java
@@ -1,241 +1,241 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.util.tests;
-
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.security.ChallengeNegotiator;
-import org.eclipse.net4j.util.security.IChallengeResponse;
-import org.eclipse.net4j.util.security.IPasswordCredentialsProvider;
-import org.eclipse.net4j.util.security.NegotiationContext;
-import org.eclipse.net4j.util.security.PasswordCredentials;
-import org.eclipse.net4j.util.security.PasswordCredentialsProvider;
-import org.eclipse.net4j.util.security.Randomizer;
-import org.eclipse.net4j.util.security.ResponseNegotiator;
-import org.eclipse.net4j.util.security.UserManager;
-
-import java.nio.ByteBuffer;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @author Eike Stepper
- */
-public class SecurityTest extends AbstractOMTest
-{
- private static final int TIMEOUT = 1000;
-
- private static final String USER_ID = "stepper"; //$NON-NLS-1$
-
- private static final char[] PASSWORD1 = "eike2007".toCharArray(); //$NON-NLS-1$
-
- private static final char[] PASSWORD2 = "invalid".toCharArray(); //$NON-NLS-1$
-
- private static final PasswordCredentials CREDENTIALS = new PasswordCredentials(USER_ID, PASSWORD1);
-
- private IPasswordCredentialsProvider credentialsProvider = new PasswordCredentialsProvider(CREDENTIALS);
-
- public void testRandomizerAcceptsSeedsBeforeActivation()
- {
- Randomizer randomizer = new Randomizer();
- randomizer.setSeed(2l);
- }
-
- public void testSuccess() throws Exception
- {
- // Prepare randomizer
- Randomizer randomizer = new Randomizer();
- randomizer.activate();
-
- // Prepare user manager
- UserManager userManager = new UserManager();
- userManager.activate();
- userManager.addUser(USER_ID, PASSWORD1);
-
- // Create negotiation contexts
- PeerNegotiationContext challengeContext = new PeerNegotiationContext();
- PeerNegotiationContext responseContext = new PeerNegotiationContext();
-
- // Prepare challenge context
- challengeContext.setPeer(responseContext);
- Thread challengeThread = new Thread(challengeContext, "challengeThread"); //$NON-NLS-1$
- challengeThread.start();
-
- // Prepare response context
- responseContext.setPeer(challengeContext);
- Thread responseThread = new Thread(responseContext, "responseThread"); //$NON-NLS-1$
- responseThread.start();
-
- // Prepare response negotiator
- ResponseNegotiator responseNegotiator = new ResponseNegotiator();
- responseNegotiator.setCredentialsProvider(credentialsProvider);
- responseNegotiator.activate();
- responseNegotiator.negotiate(responseContext);
-
- // Prepare challenge negotiator
- ChallengeNegotiator challengeNegotiator = new ChallengeNegotiator();
- challengeNegotiator.setRandomizer(randomizer);
- challengeNegotiator.setUserManager(userManager);
- challengeNegotiator.activate();
- challengeNegotiator.negotiate(challengeContext);
-
- Enum<?> responseState = responseContext.waitUntilFinished(TIMEOUT);
- assertEquals(IChallengeResponse.State.SUCCESS, responseState);
-
- Enum<?> challengeState = challengeContext.waitUntilFinished(TIMEOUT);
- assertEquals(IChallengeResponse.State.SUCCESS, challengeState);
-
- challengeContext.deactivate();
- responseContext.deactivate();
- challengeNegotiator.deactivate();
- responseNegotiator.deactivate();
- userManager.deactivate();
- randomizer.deactivate();
- }
-
- public void testFailure() throws Exception
- {
- // Prepare randomizer
- Randomizer randomizer = new Randomizer();
- randomizer.activate();
-
- // Prepare user manager
- UserManager userManager = new UserManager();
- userManager.activate();
- userManager.addUser(USER_ID, PASSWORD2);
-
- // Create negotiation contexts
- PeerNegotiationContext challengeContext = new PeerNegotiationContext();
- PeerNegotiationContext responseContext = new PeerNegotiationContext();
-
- // Prepare challenge context
- challengeContext.setPeer(responseContext);
- Thread challengeThread = new Thread(challengeContext, "challengeThread"); //$NON-NLS-1$
- challengeThread.start();
-
- // Prepare response context
- responseContext.setPeer(challengeContext);
- Thread responseThread = new Thread(responseContext, "responseThread"); //$NON-NLS-1$
- responseThread.start();
-
- // Prepare response negotiator
- ResponseNegotiator responseNegotiator = new ResponseNegotiator();
- responseNegotiator.setCredentialsProvider(credentialsProvider);
- responseNegotiator.activate();
- responseNegotiator.negotiate(responseContext);
-
- // Prepare challenge negotiator
- ChallengeNegotiator challengeNegotiator = new ChallengeNegotiator();
- challengeNegotiator.setRandomizer(randomizer);
- challengeNegotiator.setUserManager(userManager);
- challengeNegotiator.activate();
- challengeNegotiator.negotiate(challengeContext);
-
- Enum<?> responseState = responseContext.waitUntilFinished(TIMEOUT);
- assertEquals(IChallengeResponse.State.FAILURE, responseState);
-
- Enum<?> challengeState = challengeContext.waitUntilFinished(TIMEOUT);
- assertEquals(IChallengeResponse.State.FAILURE, challengeState);
-
- challengeContext.deactivate();
- responseContext.deactivate();
- challengeNegotiator.deactivate();
- responseNegotiator.deactivate();
- userManager.deactivate();
- randomizer.deactivate();
- }
-
- /**
- * @author Eike Stepper
- */
- private final class PeerNegotiationContext extends NegotiationContext implements Runnable
- {
- private PeerNegotiationContext peer;
-
- private String userID;
-
- private BlockingQueue<ByteBuffer> queue = new LinkedBlockingQueue<ByteBuffer>();
-
- private boolean running;
-
- public PeerNegotiationContext()
- {
- }
-
- @SuppressWarnings("unused")
- public PeerNegotiationContext getPeer()
- {
- return peer;
- }
-
- public void setPeer(PeerNegotiationContext peer)
- {
- this.peer = peer;
- }
-
- @SuppressWarnings("unused")
- public String getUserID()
- {
- return userID;
- }
-
- public void setUserID(String userID)
- {
- this.userID = userID;
- }
-
- public ByteBuffer getBuffer()
- {
- return ByteBuffer.allocateDirect(4096);
- }
-
- public void transmitBuffer(ByteBuffer buffer)
- {
- buffer.flip();
- queue.add(buffer);
- }
-
- public void deactivate()
- {
- running = false;
- }
-
- public void run()
- {
- running = true;
- while (running)
- {
- if (peer != null)
- {
- Receiver receiver = peer.getReceiver();
- if (receiver != null)
- {
- ByteBuffer buffer = null;
-
- try
- {
- buffer = queue.poll(20, TimeUnit.MILLISECONDS);
- }
- catch (InterruptedException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- if (buffer != null)
- {
- receiver.receiveBuffer(peer, buffer);
- }
- }
- }
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.util.tests;
+
+import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.security.ChallengeNegotiator;
+import org.eclipse.net4j.util.security.IChallengeResponse;
+import org.eclipse.net4j.util.security.IPasswordCredentialsProvider;
+import org.eclipse.net4j.util.security.NegotiationContext;
+import org.eclipse.net4j.util.security.PasswordCredentials;
+import org.eclipse.net4j.util.security.PasswordCredentialsProvider;
+import org.eclipse.net4j.util.security.Randomizer;
+import org.eclipse.net4j.util.security.ResponseNegotiator;
+import org.eclipse.net4j.util.security.UserManager;
+
+import java.nio.ByteBuffer;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author Eike Stepper
+ */
+public class SecurityTest extends AbstractOMTest
+{
+ private static final int TIMEOUT = 1000;
+
+ private static final String USER_ID = "stepper"; //$NON-NLS-1$
+
+ private static final char[] PASSWORD1 = "eike2007".toCharArray(); //$NON-NLS-1$
+
+ private static final char[] PASSWORD2 = "invalid".toCharArray(); //$NON-NLS-1$
+
+ private static final PasswordCredentials CREDENTIALS = new PasswordCredentials(USER_ID, PASSWORD1);
+
+ private IPasswordCredentialsProvider credentialsProvider = new PasswordCredentialsProvider(CREDENTIALS);
+
+ public void testRandomizerAcceptsSeedsBeforeActivation()
+ {
+ Randomizer randomizer = new Randomizer();
+ randomizer.setSeed(2l);
+ }
+
+ public void testSuccess() throws Exception
+ {
+ // Prepare randomizer
+ Randomizer randomizer = new Randomizer();
+ randomizer.activate();
+
+ // Prepare user manager
+ UserManager userManager = new UserManager();
+ userManager.activate();
+ userManager.addUser(USER_ID, PASSWORD1);
+
+ // Create negotiation contexts
+ PeerNegotiationContext challengeContext = new PeerNegotiationContext();
+ PeerNegotiationContext responseContext = new PeerNegotiationContext();
+
+ // Prepare challenge context
+ challengeContext.setPeer(responseContext);
+ Thread challengeThread = new Thread(challengeContext, "challengeThread"); //$NON-NLS-1$
+ challengeThread.start();
+
+ // Prepare response context
+ responseContext.setPeer(challengeContext);
+ Thread responseThread = new Thread(responseContext, "responseThread"); //$NON-NLS-1$
+ responseThread.start();
+
+ // Prepare response negotiator
+ ResponseNegotiator responseNegotiator = new ResponseNegotiator();
+ responseNegotiator.setCredentialsProvider(credentialsProvider);
+ responseNegotiator.activate();
+ responseNegotiator.negotiate(responseContext);
+
+ // Prepare challenge negotiator
+ ChallengeNegotiator challengeNegotiator = new ChallengeNegotiator();
+ challengeNegotiator.setRandomizer(randomizer);
+ challengeNegotiator.setUserManager(userManager);
+ challengeNegotiator.activate();
+ challengeNegotiator.negotiate(challengeContext);
+
+ Enum<?> responseState = responseContext.waitUntilFinished(TIMEOUT);
+ assertEquals(IChallengeResponse.State.SUCCESS, responseState);
+
+ Enum<?> challengeState = challengeContext.waitUntilFinished(TIMEOUT);
+ assertEquals(IChallengeResponse.State.SUCCESS, challengeState);
+
+ challengeContext.deactivate();
+ responseContext.deactivate();
+ challengeNegotiator.deactivate();
+ responseNegotiator.deactivate();
+ userManager.deactivate();
+ randomizer.deactivate();
+ }
+
+ public void testFailure() throws Exception
+ {
+ // Prepare randomizer
+ Randomizer randomizer = new Randomizer();
+ randomizer.activate();
+
+ // Prepare user manager
+ UserManager userManager = new UserManager();
+ userManager.activate();
+ userManager.addUser(USER_ID, PASSWORD2);
+
+ // Create negotiation contexts
+ PeerNegotiationContext challengeContext = new PeerNegotiationContext();
+ PeerNegotiationContext responseContext = new PeerNegotiationContext();
+
+ // Prepare challenge context
+ challengeContext.setPeer(responseContext);
+ Thread challengeThread = new Thread(challengeContext, "challengeThread"); //$NON-NLS-1$
+ challengeThread.start();
+
+ // Prepare response context
+ responseContext.setPeer(challengeContext);
+ Thread responseThread = new Thread(responseContext, "responseThread"); //$NON-NLS-1$
+ responseThread.start();
+
+ // Prepare response negotiator
+ ResponseNegotiator responseNegotiator = new ResponseNegotiator();
+ responseNegotiator.setCredentialsProvider(credentialsProvider);
+ responseNegotiator.activate();
+ responseNegotiator.negotiate(responseContext);
+
+ // Prepare challenge negotiator
+ ChallengeNegotiator challengeNegotiator = new ChallengeNegotiator();
+ challengeNegotiator.setRandomizer(randomizer);
+ challengeNegotiator.setUserManager(userManager);
+ challengeNegotiator.activate();
+ challengeNegotiator.negotiate(challengeContext);
+
+ Enum<?> responseState = responseContext.waitUntilFinished(TIMEOUT);
+ assertEquals(IChallengeResponse.State.FAILURE, responseState);
+
+ Enum<?> challengeState = challengeContext.waitUntilFinished(TIMEOUT);
+ assertEquals(IChallengeResponse.State.FAILURE, challengeState);
+
+ challengeContext.deactivate();
+ responseContext.deactivate();
+ challengeNegotiator.deactivate();
+ responseNegotiator.deactivate();
+ userManager.deactivate();
+ randomizer.deactivate();
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class PeerNegotiationContext extends NegotiationContext implements Runnable
+ {
+ private PeerNegotiationContext peer;
+
+ private String userID;
+
+ private BlockingQueue<ByteBuffer> queue = new LinkedBlockingQueue<ByteBuffer>();
+
+ private boolean running;
+
+ public PeerNegotiationContext()
+ {
+ }
+
+ @SuppressWarnings("unused")
+ public PeerNegotiationContext getPeer()
+ {
+ return peer;
+ }
+
+ public void setPeer(PeerNegotiationContext peer)
+ {
+ this.peer = peer;
+ }
+
+ @SuppressWarnings("unused")
+ public String getUserID()
+ {
+ return userID;
+ }
+
+ public void setUserID(String userID)
+ {
+ this.userID = userID;
+ }
+
+ public ByteBuffer getBuffer()
+ {
+ return ByteBuffer.allocateDirect(4096);
+ }
+
+ public void transmitBuffer(ByteBuffer buffer)
+ {
+ buffer.flip();
+ queue.add(buffer);
+ }
+
+ public void deactivate()
+ {
+ running = false;
+ }
+
+ public void run()
+ {
+ running = true;
+ while (running)
+ {
+ if (peer != null)
+ {
+ Receiver receiver = peer.getReceiver();
+ if (receiver != null)
+ {
+ ByteBuffer buffer = null;
+
+ try
+ {
+ buffer = queue.poll(20, TimeUnit.MILLISECONDS);
+ }
+ catch (InterruptedException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ if (buffer != null)
+ {
+ receiver.receiveBuffer(peer, buffer);
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/StreamWrapperTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/StreamWrapperTest.java
index f3094846ae..ceda4895f9 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/StreamWrapperTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/StreamWrapperTest.java
@@ -1,46 +1,46 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.util.tests;
-
-import org.eclipse.net4j.util.io.XORInputStream;
-import org.eclipse.net4j.util.io.XOROutputStream;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-
-/**
- * @author Eike Stepper
- */
-public class StreamWrapperTest extends AbstractOMTest
-{
- public void testXORStreams() throws Exception
- {
- int[] key = { 1, 2, 3, 4 };
-
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- XOROutputStream xorOutputStream = new XOROutputStream(byteArrayOutputStream, key);
- PrintStream printStream = new PrintStream(xorOutputStream);
- printStream.println("Hello world!");
- printStream.println("Hello world!");
-
- XORInputStream xorInputStream = new XORInputStream(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()),
- key);
-
- InputStreamReader inputStreamReader = new InputStreamReader(xorInputStream);
- BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
-
- assertEquals("Hello world!", bufferedReader.readLine());
- assertEquals("Hello world!", bufferedReader.readLine());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.util.tests;
+
+import org.eclipse.net4j.util.io.XORInputStream;
+import org.eclipse.net4j.util.io.XOROutputStream;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class StreamWrapperTest extends AbstractOMTest
+{
+ public void testXORStreams() throws Exception
+ {
+ int[] key = { 1, 2, 3, 4 };
+
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XOROutputStream xorOutputStream = new XOROutputStream(byteArrayOutputStream, key);
+ PrintStream printStream = new PrintStream(xorOutputStream);
+ printStream.println("Hello world!");
+ printStream.println("Hello world!");
+
+ XORInputStream xorInputStream = new XORInputStream(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()),
+ key);
+
+ InputStreamReader inputStreamReader = new InputStreamReader(xorInputStream);
+ BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
+
+ assertEquals("Hello world!", bufferedReader.readLine());
+ assertEquals("Hello world!", bufferedReader.readLine());
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/SynchronizingCorrelatorTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/SynchronizingCorrelatorTest.java
index 9e8a078a3e..a31f89cc07 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/SynchronizingCorrelatorTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/SynchronizingCorrelatorTest.java
@@ -1,151 +1,151 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.util.tests;
-
-import org.eclipse.net4j.util.concurrent.ISynchronizer;
-import org.eclipse.net4j.util.concurrent.SynchronizingCorrelator;
-
-/**
- * @author Eike Stepper
- */
-public class SynchronizingCorrelatorTest extends AbstractOMTest
-{
- public void testPutConsumerFirst() throws Exception
- {
- final Boolean[] result = { false };
- final SynchronizingCorrelator<String, Boolean> correlator = new SynchronizingCorrelator<String, Boolean>();
- final Thread consumer = new Thread()
- {
- @Override
- public void run()
- {
- ISynchronizer<Boolean> eike = correlator.correlate("eike"); //$NON-NLS-1$
- result[0] = eike.get(5000);
- msg("RESULT: " + result[0]); //$NON-NLS-1$
- }
- };
-
- consumer.start();
- sleep(100);
-
- correlator.put("eike", true, DEFAULT_TIMEOUT); //$NON-NLS-1$
- consumer.join(DEFAULT_TIMEOUT);
- assertEquals(Boolean.TRUE, result[0]);
- }
-
- public void testPutConsumerFirst10() throws Exception
- {
- for (int i = 0; i < 10; i++)
- {
- testPutConsumerFirst();
- }
- }
-
- public void testBlockingPutConsumerFirst() throws Exception
- {
- final Boolean[] result = { false };
- final SynchronizingCorrelator<String, Boolean> correlator = new SynchronizingCorrelator<String, Boolean>();
- final Thread consumer = new Thread()
- {
- @Override
- public void run()
- {
- ISynchronizer<Boolean> eike = correlator.correlate("eike"); //$NON-NLS-1$
- result[0] = eike.get(5000);
- msg("RESULT: " + result[0]); //$NON-NLS-1$
- }
- };
-
- consumer.start();
- Thread.sleep(10);
-
- boolean consumed = correlator.put("eike", true, 1000); //$NON-NLS-1$
- msg("Consumed: " + consumed); //$NON-NLS-1$
- assertEquals(true, consumed);
-
- consumer.join(1000);
- assertEquals(Boolean.TRUE, result[0]);
- }
-
- public void testBlockingPutConsumerFirst10() throws Exception
- {
- for (int i = 0; i < 10; i++)
- {
- testBlockingPutConsumerFirst();
- }
- }
-
- public void _testPutProducerFirst() throws Exception
- {
- final Boolean[] result = { false };
- final SynchronizingCorrelator<String, Boolean> correlator = new SynchronizingCorrelator<String, Boolean>();
- correlator.put("eike", true, DEFAULT_TIMEOUT); //$NON-NLS-1$
-
- final Thread consumer = new Thread()
- {
- @Override
- public void run()
- {
- ISynchronizer<Boolean> eike = correlator.correlate("eike"); //$NON-NLS-1$
- result[0] = eike.get(5000);
- msg("RESULT: " + result[0]); //$NON-NLS-1$
- }
- };
-
- consumer.start();
- Thread.sleep(10);
-
- consumer.join(100);
- assertEquals(Boolean.TRUE, result[0]);
- }
-
- public void _testPutProducerFirst10() throws Exception
- {
- for (int i = 0; i < 10; i++)
- {
- _testPutProducerFirst();
- }
- }
-
- public void testBlockingPutProducerFirst() throws Exception
- {
- final Boolean[] result = { false };
- final SynchronizingCorrelator<String, Boolean> correlator = new SynchronizingCorrelator<String, Boolean>();
- boolean consumed = correlator.put("eike", true, 50); //$NON-NLS-1$
- msg("Consumed: " + consumed); //$NON-NLS-1$
- assertEquals(false, consumed);
-
- final Thread consumer = new Thread()
- {
- @Override
- public void run()
- {
- ISynchronizer<Boolean> eike = correlator.correlate("eike"); //$NON-NLS-1$
- result[0] = eike.get(5000);
- msg("RESULT: " + result[0]); //$NON-NLS-1$
- }
- };
-
- consumer.start();
- Thread.sleep(10);
-
- consumer.join(1000);
- assertEquals(Boolean.TRUE, result[0]);
- }
-
- public void testBlockingPutProducerFirst10() throws Exception
- {
- for (int i = 0; i < 10; i++)
- {
- testBlockingPutProducerFirst();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.util.tests;
+
+import org.eclipse.net4j.util.concurrent.ISynchronizer;
+import org.eclipse.net4j.util.concurrent.SynchronizingCorrelator;
+
+/**
+ * @author Eike Stepper
+ */
+public class SynchronizingCorrelatorTest extends AbstractOMTest
+{
+ public void testPutConsumerFirst() throws Exception
+ {
+ final Boolean[] result = { false };
+ final SynchronizingCorrelator<String, Boolean> correlator = new SynchronizingCorrelator<String, Boolean>();
+ final Thread consumer = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ ISynchronizer<Boolean> eike = correlator.correlate("eike"); //$NON-NLS-1$
+ result[0] = eike.get(5000);
+ msg("RESULT: " + result[0]); //$NON-NLS-1$
+ }
+ };
+
+ consumer.start();
+ sleep(100);
+
+ correlator.put("eike", true, DEFAULT_TIMEOUT); //$NON-NLS-1$
+ consumer.join(DEFAULT_TIMEOUT);
+ assertEquals(Boolean.TRUE, result[0]);
+ }
+
+ public void testPutConsumerFirst10() throws Exception
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ testPutConsumerFirst();
+ }
+ }
+
+ public void testBlockingPutConsumerFirst() throws Exception
+ {
+ final Boolean[] result = { false };
+ final SynchronizingCorrelator<String, Boolean> correlator = new SynchronizingCorrelator<String, Boolean>();
+ final Thread consumer = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ ISynchronizer<Boolean> eike = correlator.correlate("eike"); //$NON-NLS-1$
+ result[0] = eike.get(5000);
+ msg("RESULT: " + result[0]); //$NON-NLS-1$
+ }
+ };
+
+ consumer.start();
+ Thread.sleep(10);
+
+ boolean consumed = correlator.put("eike", true, 1000); //$NON-NLS-1$
+ msg("Consumed: " + consumed); //$NON-NLS-1$
+ assertEquals(true, consumed);
+
+ consumer.join(1000);
+ assertEquals(Boolean.TRUE, result[0]);
+ }
+
+ public void testBlockingPutConsumerFirst10() throws Exception
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ testBlockingPutConsumerFirst();
+ }
+ }
+
+ public void _testPutProducerFirst() throws Exception
+ {
+ final Boolean[] result = { false };
+ final SynchronizingCorrelator<String, Boolean> correlator = new SynchronizingCorrelator<String, Boolean>();
+ correlator.put("eike", true, DEFAULT_TIMEOUT); //$NON-NLS-1$
+
+ final Thread consumer = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ ISynchronizer<Boolean> eike = correlator.correlate("eike"); //$NON-NLS-1$
+ result[0] = eike.get(5000);
+ msg("RESULT: " + result[0]); //$NON-NLS-1$
+ }
+ };
+
+ consumer.start();
+ Thread.sleep(10);
+
+ consumer.join(100);
+ assertEquals(Boolean.TRUE, result[0]);
+ }
+
+ public void _testPutProducerFirst10() throws Exception
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ _testPutProducerFirst();
+ }
+ }
+
+ public void testBlockingPutProducerFirst() throws Exception
+ {
+ final Boolean[] result = { false };
+ final SynchronizingCorrelator<String, Boolean> correlator = new SynchronizingCorrelator<String, Boolean>();
+ boolean consumed = correlator.put("eike", true, 50); //$NON-NLS-1$
+ msg("Consumed: " + consumed); //$NON-NLS-1$
+ assertEquals(false, consumed);
+
+ final Thread consumer = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ ISynchronizer<Boolean> eike = correlator.correlate("eike"); //$NON-NLS-1$
+ result[0] = eike.get(5000);
+ msg("RESULT: " + result[0]); //$NON-NLS-1$
+ }
+ };
+
+ consumer.start();
+ Thread.sleep(10);
+
+ consumer.join(1000);
+ assertEquals(Boolean.TRUE, result[0]);
+ }
+
+ public void testBlockingPutProducerFirst10() throws Exception
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ testBlockingPutProducerFirst();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/UTFTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/UTFTest.java
index 957317d477..027f13b08a 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/UTFTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/UTFTest.java
@@ -1,65 +1,65 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.util.tests;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public class UTFTest extends AbstractOMTest
-{
- private static final int UNSIGNED_SHORT_MAX = (1 << 16) - 1;
-
- public void testUTF8_OneOctet() throws Exception
- {
- final int MAX = UNSIGNED_SHORT_MAX / 10 + 1;
- String part = "0123456789"; //$NON-NLS-1$
- assertEquals(10, part.length());
-
- StringBuilder builder = new StringBuilder();
- for (int i = 0; i < MAX; i++)
- {
- builder.append(part);
- }
-
- String str = builder.toString();
- assertEquals(true, str.length() > UNSIGNED_SHORT_MAX);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- DataOutputStream dos = new DataOutputStream(baos);
- dos.writeUTF(str);
-
- String received = baos.toString("UTF-8"); //$NON-NLS-1$
- assertEquals(str, received);
- }
-
- public void testUTF8_ThreeOctets() throws Exception
- {
- final int MAX = UNSIGNED_SHORT_MAX >> 1;
- StringBuilder builder = new StringBuilder();
- for (int i = 0; i < MAX; i++)
- {
- builder.append("\u6771"); //$NON-NLS-1$
- }
-
- String str = builder.toString();
- assertEquals(MAX, str.length());
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- DataOutputStream dos = new DataOutputStream(baos);
- dos.writeUTF(str);
-
- String received = baos.toString("UTF-8"); //$NON-NLS-1$
- assertEquals(str, received);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.util.tests;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class UTFTest extends AbstractOMTest
+{
+ private static final int UNSIGNED_SHORT_MAX = (1 << 16) - 1;
+
+ public void testUTF8_OneOctet() throws Exception
+ {
+ final int MAX = UNSIGNED_SHORT_MAX / 10 + 1;
+ String part = "0123456789"; //$NON-NLS-1$
+ assertEquals(10, part.length());
+
+ StringBuilder builder = new StringBuilder();
+ for (int i = 0; i < MAX; i++)
+ {
+ builder.append(part);
+ }
+
+ String str = builder.toString();
+ assertEquals(true, str.length() > UNSIGNED_SHORT_MAX);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DataOutputStream dos = new DataOutputStream(baos);
+ dos.writeUTF(str);
+
+ String received = baos.toString("UTF-8"); //$NON-NLS-1$
+ assertEquals(str, received);
+ }
+
+ public void testUTF8_ThreeOctets() throws Exception
+ {
+ final int MAX = UNSIGNED_SHORT_MAX >> 1;
+ StringBuilder builder = new StringBuilder();
+ for (int i = 0; i < MAX; i++)
+ {
+ builder.append("\u6771"); //$NON-NLS-1$
+ }
+
+ String str = builder.toString();
+ assertEquals(MAX, str.length());
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DataOutputStream dos = new DataOutputStream(baos);
+ dos.writeUTF(str);
+
+ String received = baos.toString("UTF-8"); //$NON-NLS-1$
+ assertEquals(str, received);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/ZipTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/ZipTest.java
index 109c0a807f..eb89f1d66c 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/ZipTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/ZipTest.java
@@ -1,34 +1,34 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.util.tests;
-
-import org.eclipse.net4j.util.io.ZIPUtil;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class ZipTest extends AbstractOMTest
-{
- public void testZip() throws Exception
- {
- File zipFile = newFile("src.zip"); //$NON-NLS-1$
- File sourceFolder = newFile("src"); //$NON-NLS-1$
- ZIPUtil.zip(sourceFolder, false, zipFile);
- }
-
- private static File newFile(String path) throws IOException
- {
- return new File(path).getCanonicalFile();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.util.tests;
+
+import org.eclipse.net4j.util.io.ZIPUtil;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * @author Eike Stepper
+ */
+public class ZipTest extends AbstractOMTest
+{
+ public void testZip() throws Exception
+ {
+ File zipFile = newFile("src.zip"); //$NON-NLS-1$
+ File sourceFolder = newFile("src"); //$NON-NLS-1$
+ ZIPUtil.zip(sourceFolder, false, zipFile);
+ }
+
+ private static File newFile(String path) throws IOException
+ {
+ return new File(path).getCanonicalFile();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/cache/CacheTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/cache/CacheTest.java
index b3e30eea8a..23689ee1d3 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/cache/CacheTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/cache/CacheTest.java
@@ -1,54 +1,54 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.util.tests.cache;
-
-import org.eclipse.net4j.util.cache.CacheMonitor;
-import org.eclipse.net4j.util.cache.ICacheMonitor.ConditionPolicy;
-import org.eclipse.net4j.util.cache.ThresholdConditionPolicy;
-import org.eclipse.net4j.util.tests.AbstractOMTest;
-
-/**
- * @author Eike Stepper
- */
-public class CacheTest extends AbstractOMTest
-{
- public void testLifecycle() throws Exception
- {
- ConditionPolicy conditionPolicy = new ThresholdConditionPolicy(1000000L, 10000000L);
-
- CacheMonitor cacheMonitor = new CacheMonitor();
- cacheMonitor.setConditionPolicy(conditionPolicy);
- cacheMonitor.setPauseRED(100L);
- cacheMonitor.setPauseYELLOW(100L);
- cacheMonitor.setPauseGREEN(100L);
- cacheMonitor.setDaemon(true);
- cacheMonitor.activate();
-
- RevisionManager revisionManager = new RevisionManager();
- revisionManager.setCacheMonitor(cacheMonitor);
- revisionManager.activate();
-
- for (int version = 1; version <= 10; version++)
- {
- for (int id = 1; id <= 100; id++)
- {
- revisionManager.getRevision(id, version);
- sleep(200);
- }
-
- System.gc();
- sleep(1000);
- }
-
- revisionManager.deactivate();
- cacheMonitor.deactivate();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.util.tests.cache;
+
+import org.eclipse.net4j.util.cache.CacheMonitor;
+import org.eclipse.net4j.util.cache.ICacheMonitor.ConditionPolicy;
+import org.eclipse.net4j.util.cache.ThresholdConditionPolicy;
+import org.eclipse.net4j.util.tests.AbstractOMTest;
+
+/**
+ * @author Eike Stepper
+ */
+public class CacheTest extends AbstractOMTest
+{
+ public void testLifecycle() throws Exception
+ {
+ ConditionPolicy conditionPolicy = new ThresholdConditionPolicy(1000000L, 10000000L);
+
+ CacheMonitor cacheMonitor = new CacheMonitor();
+ cacheMonitor.setConditionPolicy(conditionPolicy);
+ cacheMonitor.setPauseRED(100L);
+ cacheMonitor.setPauseYELLOW(100L);
+ cacheMonitor.setPauseGREEN(100L);
+ cacheMonitor.setDaemon(true);
+ cacheMonitor.activate();
+
+ RevisionManager revisionManager = new RevisionManager();
+ revisionManager.setCacheMonitor(cacheMonitor);
+ revisionManager.activate();
+
+ for (int version = 1; version <= 10; version++)
+ {
+ for (int id = 1; id <= 100; id++)
+ {
+ revisionManager.getRevision(id, version);
+ sleep(200);
+ }
+
+ System.gc();
+ sleep(1000);
+ }
+
+ revisionManager.deactivate();
+ cacheMonitor.deactivate();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/cache/Revision.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/cache/Revision.java
index 1475882fd3..c73354da0b 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/cache/Revision.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/cache/Revision.java
@@ -1,67 +1,67 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.util.tests.cache;
-
-import org.eclipse.net4j.util.io.IOUtil;
-
-/**
- * @author Eike Stepper
- */
-public class Revision
-{
- private RevisionManager revisionManager;
-
- private int id;
-
- private int version;
-
- private byte[] data = new byte[100000];
-
- public Revision(RevisionManager revisionManager, int id, int version)
- {
- this.revisionManager = revisionManager;
- this.id = id;
- this.version = version;
- }
-
- public RevisionManager getRevisionManager()
- {
- return revisionManager;
- }
-
- public int getID()
- {
- return id;
- }
-
- public int getVersion()
- {
- return version;
- }
-
- public byte[] getData()
- {
- return data;
- }
-
- @Override
- public String toString()
- {
- return "R" + id + "v" + version; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Override
- protected void finalize() throws Throwable
- {
- IOUtil.ERR().println("FINALIZE " + this); //$NON-NLS-1$
- revisionManager.finalizeRevision(this);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.util.tests.cache;
+
+import org.eclipse.net4j.util.io.IOUtil;
+
+/**
+ * @author Eike Stepper
+ */
+public class Revision
+{
+ private RevisionManager revisionManager;
+
+ private int id;
+
+ private int version;
+
+ private byte[] data = new byte[100000];
+
+ public Revision(RevisionManager revisionManager, int id, int version)
+ {
+ this.revisionManager = revisionManager;
+ this.id = id;
+ this.version = version;
+ }
+
+ public RevisionManager getRevisionManager()
+ {
+ return revisionManager;
+ }
+
+ public int getID()
+ {
+ return id;
+ }
+
+ public int getVersion()
+ {
+ return version;
+ }
+
+ public byte[] getData()
+ {
+ return data;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "R" + id + "v" + version; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Override
+ protected void finalize() throws Throwable
+ {
+ IOUtil.ERR().println("FINALIZE " + this); //$NON-NLS-1$
+ revisionManager.finalizeRevision(this);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/cache/RevisionManager.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/cache/RevisionManager.java
index 772f559dd5..e5f2415885 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/cache/RevisionManager.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/cache/RevisionManager.java
@@ -1,147 +1,147 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.util.tests.cache;
-
-import org.eclipse.net4j.util.cache.Cache;
-
-import java.lang.ref.Reference;
-import java.lang.ref.ReferenceQueue;
-import java.lang.ref.SoftReference;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class RevisionManager extends Cache<Revision>
-{
- private Map<Integer, TimeLine> timeLines = new HashMap<Integer, TimeLine>();
-
- public RevisionManager()
- {
- }
-
- public Revision getRevision(int id, int version)
- {
- TimeLine timeLine = getTimeLine(id);
- return timeLine.getRevision(version);
- }
-
- public void evictElements(int elementCount)
- {
- }
-
- protected TimeLine getTimeLine(int id)
- {
- TimeLine timeLine = timeLines.get(id);
- if (timeLine == null)
- {
- timeLine = new TimeLine(id);
- timeLines.put(id, timeLine);
- }
-
- return timeLine;
- }
-
- protected Revision loadRevision(int id, int version)
- {
- Revision revision = new Revision(this, id, version);
- return revision;
- }
-
- protected void finalizeRevision(Revision revision)
- {
- // TimeLine timeLine = getTimeLine(revision.getID());
- // timeLine.addRevision(revision);
- }
-
- @Override
- protected void unreachableElement(Reference<? extends Revision> reference)
- {
- }
-
- /**
- * @author Eike Stepper
- */
- private class TimeLine
- {
- private int id;
-
- private List<Reference<Revision>> revisions = new ArrayList<Reference<Revision>>();
-
- public TimeLine(int id)
- {
- this.id = id;
- }
-
- public Revision getRevision(int version)
- {
- for (Iterator<Reference<Revision>> it = revisions.iterator(); it.hasNext();)
- {
- Reference<Revision> reference = it.next();
- Revision revision = reference.get();
- if (revision != null)
- {
- if (revision.getVersion() == version)
- {
- return revision;
- }
- }
- else
- {
- it.remove();
- break;
- }
- }
-
- long time = System.currentTimeMillis();
- Revision revision = loadRevision(id, version);
- time = System.currentTimeMillis() - time;
-
- addRevision(revision);
- return revision;
- }
-
- public void addRevision(Revision revision)
- {
- revisions.add(new CacheElement(revision, getReferenceQueue()));
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class CacheElement extends SoftReference<Revision>
- {
- private int id;
-
- private int version;
-
- // private Reference<Revision> ref;
-
- public CacheElement(Revision revision, ReferenceQueue<Revision> queue)
- {
- super(revision, queue);
- // ref = new WeakReference<Revision>(revision, queue);
- id = revision.getID();
- version = revision.getVersion();
- }
-
- @Override
- public String toString()
- {
- return "R" + id + "v" + version + (get() == null ? "" : " UNCLEARED"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.util.tests.cache;
+
+import org.eclipse.net4j.util.cache.Cache;
+
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.SoftReference;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class RevisionManager extends Cache<Revision>
+{
+ private Map<Integer, TimeLine> timeLines = new HashMap<Integer, TimeLine>();
+
+ public RevisionManager()
+ {
+ }
+
+ public Revision getRevision(int id, int version)
+ {
+ TimeLine timeLine = getTimeLine(id);
+ return timeLine.getRevision(version);
+ }
+
+ public void evictElements(int elementCount)
+ {
+ }
+
+ protected TimeLine getTimeLine(int id)
+ {
+ TimeLine timeLine = timeLines.get(id);
+ if (timeLine == null)
+ {
+ timeLine = new TimeLine(id);
+ timeLines.put(id, timeLine);
+ }
+
+ return timeLine;
+ }
+
+ protected Revision loadRevision(int id, int version)
+ {
+ Revision revision = new Revision(this, id, version);
+ return revision;
+ }
+
+ protected void finalizeRevision(Revision revision)
+ {
+ // TimeLine timeLine = getTimeLine(revision.getID());
+ // timeLine.addRevision(revision);
+ }
+
+ @Override
+ protected void unreachableElement(Reference<? extends Revision> reference)
+ {
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private class TimeLine
+ {
+ private int id;
+
+ private List<Reference<Revision>> revisions = new ArrayList<Reference<Revision>>();
+
+ public TimeLine(int id)
+ {
+ this.id = id;
+ }
+
+ public Revision getRevision(int version)
+ {
+ for (Iterator<Reference<Revision>> it = revisions.iterator(); it.hasNext();)
+ {
+ Reference<Revision> reference = it.next();
+ Revision revision = reference.get();
+ if (revision != null)
+ {
+ if (revision.getVersion() == version)
+ {
+ return revision;
+ }
+ }
+ else
+ {
+ it.remove();
+ break;
+ }
+ }
+
+ long time = System.currentTimeMillis();
+ Revision revision = loadRevision(id, version);
+ time = System.currentTimeMillis() - time;
+
+ addRevision(revision);
+ return revision;
+ }
+
+ public void addRevision(Revision revision)
+ {
+ revisions.add(new CacheElement(revision, getReferenceQueue()));
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class CacheElement extends SoftReference<Revision>
+ {
+ private int id;
+
+ private int version;
+
+ // private Reference<Revision> ref;
+
+ public CacheElement(Revision revision, ReferenceQueue<Revision> queue)
+ {
+ super(revision, queue);
+ // ref = new WeakReference<Revision>(revision, queue);
+ id = revision.getID();
+ version = revision.getVersion();
+ }
+
+ @Override
+ public String toString()
+ {
+ return "R" + id + "v" + version + (get() == null ? "" : " UNCLEARED"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/cache/SensitiveProtoTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/cache/SensitiveProtoTest.java
index 5a621a8739..c81a59648f 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/cache/SensitiveProtoTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/cache/SensitiveProtoTest.java
@@ -1,84 +1,84 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.util.tests.cache;
-
-import org.eclipse.net4j.util.ref.KeyedWeakReference;
-import org.eclipse.net4j.util.tests.AbstractOMTest;
-
-import java.lang.ref.ReferenceQueue;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * @author Eike Stepper
- */
-public class SensitiveProtoTest extends AbstractOMTest
-{
- @SuppressWarnings("unchecked")
- public void testSensitiveCacheWithEvictionPolicy() throws Exception
- {
- ConcurrentMap<Integer, KeyedAndValuedWeakReference<Integer, String>> map //
- = new ConcurrentHashMap<Integer, KeyedAndValuedWeakReference<Integer, String>>();
-
- ReferenceQueue<String> queue //
- = new ReferenceQueue<String>();
-
- for (int i = 0; i < 20; i++)
- {
- map.put(i, new KeyedAndValuedWeakReference<Integer, String>(i, String.valueOf(i), queue));
- }
-
- for (int gc = 0; gc < 10; gc++)
- {
- System.gc();
- sleep(100);
- }
-
- KeyedAndValuedWeakReference<Integer, String> ref;
- while ((ref = (KeyedAndValuedWeakReference<Integer, String>)queue.poll()) != null)
- {
- int i = ref.getKey();
- System.out.println("Dequeued i=" + i); //$NON-NLS-1$
- if (i < 10)
- {
- map.put(i, new KeyedAndValuedWeakReference<Integer, String>(i, ref.getValue(), queue));
- }
- else
- {
- map.remove(i, ref);
- }
- }
-
- assertEquals(10, map.size());
- }
-
- public static class KeyedAndValuedWeakReference<K, T> extends KeyedWeakReference<K, T>
- {
- private T value;
-
- public KeyedAndValuedWeakReference(K key, T ref, ReferenceQueue<T> queue)
- {
- super(key, ref, queue);
- value = ref;
- }
-
- public KeyedAndValuedWeakReference(K key, T ref)
- {
- super(key, ref);
- value = ref;
- }
-
- public T getValue()
- {
- return value;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.util.tests.cache;
+
+import org.eclipse.net4j.util.ref.KeyedWeakReference;
+import org.eclipse.net4j.util.tests.AbstractOMTest;
+
+import java.lang.ref.ReferenceQueue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * @author Eike Stepper
+ */
+public class SensitiveProtoTest extends AbstractOMTest
+{
+ @SuppressWarnings("unchecked")
+ public void testSensitiveCacheWithEvictionPolicy() throws Exception
+ {
+ ConcurrentMap<Integer, KeyedAndValuedWeakReference<Integer, String>> map //
+ = new ConcurrentHashMap<Integer, KeyedAndValuedWeakReference<Integer, String>>();
+
+ ReferenceQueue<String> queue //
+ = new ReferenceQueue<String>();
+
+ for (int i = 0; i < 20; i++)
+ {
+ map.put(i, new KeyedAndValuedWeakReference<Integer, String>(i, String.valueOf(i), queue));
+ }
+
+ for (int gc = 0; gc < 10; gc++)
+ {
+ System.gc();
+ sleep(100);
+ }
+
+ KeyedAndValuedWeakReference<Integer, String> ref;
+ while ((ref = (KeyedAndValuedWeakReference<Integer, String>)queue.poll()) != null)
+ {
+ int i = ref.getKey();
+ System.out.println("Dequeued i=" + i); //$NON-NLS-1$
+ if (i < 10)
+ {
+ map.put(i, new KeyedAndValuedWeakReference<Integer, String>(i, ref.getValue(), queue));
+ }
+ else
+ {
+ map.remove(i, ref);
+ }
+ }
+
+ assertEquals(10, map.size());
+ }
+
+ public static class KeyedAndValuedWeakReference<K, T> extends KeyedWeakReference<K, T>
+ {
+ private T value;
+
+ public KeyedAndValuedWeakReference(K key, T ref, ReferenceQueue<T> queue)
+ {
+ super(key, ref, queue);
+ value = ref;
+ }
+
+ public KeyedAndValuedWeakReference(K key, T ref)
+ {
+ super(key, ref);
+ value = ref;
+ }
+
+ public T getValue()
+ {
+ return value;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/DefsFactory.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/DefsFactory.java
index 825132da49..a34370d6c8 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/DefsFactory.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/DefsFactory.java
@@ -1,48 +1,48 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.net4j.util.tests.defs;
-
-import org.eclipse.emf.ecore.EFactory;
-
-/**
- * <!-- begin-user-doc --> The <b>Factory</b> for the model. It provides a create method for each non-abstract class of
- * the model. <!-- end-user-doc -->
- *
- * @see org.eclipse.net4j.util.tests.defs.DefsPackage
- * @generated
- */
-public interface DefsFactory extends EFactory
-{
- /**
- * The singleton instance of the factory. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- DefsFactory eINSTANCE = org.eclipse.net4j.util.tests.defs.impl.DefsFactoryImpl.init();
-
- /**
- * Returns a new object of class '<em>Test Def</em>'. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @return a new object of class '<em>Test Def</em>'.
- * @generated
- */
- TestDef createTestDef();
-
- /**
- * Returns the package supported by this factory. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @return the package supported by this factory.
- * @generated
- */
- DefsPackage getDefsPackage();
-
-} // DefsFactory
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.net4j.util.tests.defs;
+
+import org.eclipse.emf.ecore.EFactory;
+
+/**
+ * <!-- begin-user-doc --> The <b>Factory</b> for the model. It provides a create method for each non-abstract class of
+ * the model. <!-- end-user-doc -->
+ *
+ * @see org.eclipse.net4j.util.tests.defs.DefsPackage
+ * @generated
+ */
+public interface DefsFactory extends EFactory
+{
+ /**
+ * The singleton instance of the factory. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ DefsFactory eINSTANCE = org.eclipse.net4j.util.tests.defs.impl.DefsFactoryImpl.init();
+
+ /**
+ * Returns a new object of class '<em>Test Def</em>'. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return a new object of class '<em>Test Def</em>'.
+ * @generated
+ */
+ TestDef createTestDef();
+
+ /**
+ * Returns the package supported by this factory. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the package supported by this factory.
+ * @generated
+ */
+ DefsPackage getDefsPackage();
+
+} // DefsFactory
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/DefsPackage.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/DefsPackage.java
index 927c7572f9..371f383426 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/DefsPackage.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/DefsPackage.java
@@ -1,181 +1,181 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.net4j.util.tests.defs;
-
-import org.eclipse.net4j.util.defs.Net4jUtilDefsPackage;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-
-/**
- * <!-- begin-user-doc --> The <b>Package</b> for the model. It contains accessors for the meta objects to represent
- * <ul>
- * <li>each class,</li>
- * <li>each feature of each class,</li>
- * <li>each enum,</li>
- * <li>and each data type</li>
- * </ul>
- * <!-- end-user-doc -->
- *
- * @see org.eclipse.net4j.util.tests.defs.DefsFactory
- * @model kind="package"
- * @generated
- */
-public interface DefsPackage extends EPackage
-{
- /**
- * The package name. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- String eNAME = "defs"; //$NON-NLS-1$
-
- /**
- * The package namespace URI. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- String eNS_URI = "http://www.eclipse.org/NET4J/defs/tests/1.0.0"; //$NON-NLS-1$
-
- /**
- * The package namespace name. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- String eNS_PREFIX = "net4j.defs.tests"; //$NON-NLS-1$
-
- /**
- * The singleton instance of the package. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- DefsPackage eINSTANCE = org.eclipse.net4j.util.tests.defs.impl.DefsPackageImpl.init();
-
- /**
- * The meta object id for the '{@link org.eclipse.net4j.util.tests.defs.impl.TestDefImpl <em>Test Def</em>}' class.
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @see org.eclipse.net4j.util.tests.defs.impl.TestDefImpl
- * @see org.eclipse.net4j.util.tests.defs.impl.DefsPackageImpl#getTestDef()
- * @generated
- */
- int TEST_DEF = 0;
-
- /**
- * The feature id for the '<em><b>References</b></em>' reference list. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- * @ordered
- */
- int TEST_DEF__REFERENCES = Net4jUtilDefsPackage.DEF_FEATURE_COUNT + 0;
-
- /**
- * The feature id for the '<em><b>Attribute</b></em>' attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- * @ordered
- */
- int TEST_DEF__ATTRIBUTE = Net4jUtilDefsPackage.DEF_FEATURE_COUNT + 1;
-
- /**
- * The number of structural features of the '<em>Test Def</em>' class. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- * @ordered
- */
- int TEST_DEF_FEATURE_COUNT = Net4jUtilDefsPackage.DEF_FEATURE_COUNT + 2;
-
- /**
- * Returns the meta object for class '{@link org.eclipse.net4j.util.tests.defs.TestDef <em>Test Def</em>}'. <!--
- * begin-user-doc --> <!-- end-user-doc -->
- *
- * @return the meta object for class '<em>Test Def</em>'.
- * @see org.eclipse.net4j.util.tests.defs.TestDef
- * @generated
- */
- EClass getTestDef();
-
- /**
- * Returns the meta object for the reference list '{@link org.eclipse.net4j.util.tests.defs.TestDef#getReferences
- * <em>References</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @return the meta object for the reference list '<em>References</em>'.
- * @see org.eclipse.net4j.util.tests.defs.TestDef#getReferences()
- * @see #getTestDef()
- * @generated
- */
- EReference getTestDef_References();
-
- /**
- * Returns the meta object for the attribute '{@link org.eclipse.net4j.util.tests.defs.TestDef#getAttribute
- * <em>Attribute</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @return the meta object for the attribute '<em>Attribute</em>'.
- * @see org.eclipse.net4j.util.tests.defs.TestDef#getAttribute()
- * @see #getTestDef()
- * @generated
- */
- EAttribute getTestDef_Attribute();
-
- /**
- * Returns the factory that creates the instances of the model. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @return the factory that creates the instances of the model.
- * @generated
- */
- DefsFactory getDefsFactory();
-
- /**
- * <!-- begin-user-doc --> Defines literals for the meta objects that represent
- * <ul>
- * <li>each class,</li>
- * <li>each feature of each class,</li>
- * <li>each enum,</li>
- * <li>and each data type</li>
- * </ul>
- * <!-- end-user-doc -->
- *
- * @generated
- */
- interface Literals
- {
- /**
- * The meta object literal for the '{@link org.eclipse.net4j.util.tests.defs.impl.TestDefImpl <em>Test Def</em>}'
- * class. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @see org.eclipse.net4j.util.tests.defs.impl.TestDefImpl
- * @see org.eclipse.net4j.util.tests.defs.impl.DefsPackageImpl#getTestDef()
- * @generated
- */
- EClass TEST_DEF = eINSTANCE.getTestDef();
-
- /**
- * The meta object literal for the '<em><b>References</b></em>' reference list feature. <!-- begin-user-doc --> <!--
- * end-user-doc -->
- *
- * @generated
- */
- EReference TEST_DEF__REFERENCES = eINSTANCE.getTestDef_References();
-
- /**
- * The meta object literal for the '<em><b>Attribute</b></em>' attribute feature. <!-- begin-user-doc --> <!--
- * end-user-doc -->
- *
- * @generated
- */
- EAttribute TEST_DEF__ATTRIBUTE = eINSTANCE.getTestDef_Attribute();
-
- }
-
-} // DefsPackage
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.net4j.util.tests.defs;
+
+import org.eclipse.net4j.util.defs.Net4jUtilDefsPackage;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+
+/**
+ * <!-- begin-user-doc --> The <b>Package</b> for the model. It contains accessors for the meta objects to represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ *
+ * @see org.eclipse.net4j.util.tests.defs.DefsFactory
+ * @model kind="package"
+ * @generated
+ */
+public interface DefsPackage extends EPackage
+{
+ /**
+ * The package name. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ String eNAME = "defs"; //$NON-NLS-1$
+
+ /**
+ * The package namespace URI. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ String eNS_URI = "http://www.eclipse.org/NET4J/defs/tests/1.0.0"; //$NON-NLS-1$
+
+ /**
+ * The package namespace name. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ String eNS_PREFIX = "net4j.defs.tests"; //$NON-NLS-1$
+
+ /**
+ * The singleton instance of the package. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ DefsPackage eINSTANCE = org.eclipse.net4j.util.tests.defs.impl.DefsPackageImpl.init();
+
+ /**
+ * The meta object id for the '{@link org.eclipse.net4j.util.tests.defs.impl.TestDefImpl <em>Test Def</em>}' class.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see org.eclipse.net4j.util.tests.defs.impl.TestDefImpl
+ * @see org.eclipse.net4j.util.tests.defs.impl.DefsPackageImpl#getTestDef()
+ * @generated
+ */
+ int TEST_DEF = 0;
+
+ /**
+ * The feature id for the '<em><b>References</b></em>' reference list. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int TEST_DEF__REFERENCES = Net4jUtilDefsPackage.DEF_FEATURE_COUNT + 0;
+
+ /**
+ * The feature id for the '<em><b>Attribute</b></em>' attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int TEST_DEF__ATTRIBUTE = Net4jUtilDefsPackage.DEF_FEATURE_COUNT + 1;
+
+ /**
+ * The number of structural features of the '<em>Test Def</em>' class. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int TEST_DEF_FEATURE_COUNT = Net4jUtilDefsPackage.DEF_FEATURE_COUNT + 2;
+
+ /**
+ * Returns the meta object for class '{@link org.eclipse.net4j.util.tests.defs.TestDef <em>Test Def</em>}'. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the meta object for class '<em>Test Def</em>'.
+ * @see org.eclipse.net4j.util.tests.defs.TestDef
+ * @generated
+ */
+ EClass getTestDef();
+
+ /**
+ * Returns the meta object for the reference list '{@link org.eclipse.net4j.util.tests.defs.TestDef#getReferences
+ * <em>References</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the meta object for the reference list '<em>References</em>'.
+ * @see org.eclipse.net4j.util.tests.defs.TestDef#getReferences()
+ * @see #getTestDef()
+ * @generated
+ */
+ EReference getTestDef_References();
+
+ /**
+ * Returns the meta object for the attribute '{@link org.eclipse.net4j.util.tests.defs.TestDef#getAttribute
+ * <em>Attribute</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the meta object for the attribute '<em>Attribute</em>'.
+ * @see org.eclipse.net4j.util.tests.defs.TestDef#getAttribute()
+ * @see #getTestDef()
+ * @generated
+ */
+ EAttribute getTestDef_Attribute();
+
+ /**
+ * Returns the factory that creates the instances of the model. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the factory that creates the instances of the model.
+ * @generated
+ */
+ DefsFactory getDefsFactory();
+
+ /**
+ * <!-- begin-user-doc --> Defines literals for the meta objects that represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ interface Literals
+ {
+ /**
+ * The meta object literal for the '{@link org.eclipse.net4j.util.tests.defs.impl.TestDefImpl <em>Test Def</em>}'
+ * class. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see org.eclipse.net4j.util.tests.defs.impl.TestDefImpl
+ * @see org.eclipse.net4j.util.tests.defs.impl.DefsPackageImpl#getTestDef()
+ * @generated
+ */
+ EClass TEST_DEF = eINSTANCE.getTestDef();
+
+ /**
+ * The meta object literal for the '<em><b>References</b></em>' reference list feature. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @generated
+ */
+ EReference TEST_DEF__REFERENCES = eINSTANCE.getTestDef_References();
+
+ /**
+ * The meta object literal for the '<em><b>Attribute</b></em>' attribute feature. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @generated
+ */
+ EAttribute TEST_DEF__ATTRIBUTE = eINSTANCE.getTestDef_Attribute();
+
+ }
+
+} // DefsPackage
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/TestDef.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/TestDef.java
index 2c628310ce..de70a74727 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/TestDef.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/TestDef.java
@@ -1,77 +1,77 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.net4j.util.tests.defs;
-
-import org.eclipse.net4j.util.defs.Def;
-
-import org.eclipse.emf.common.util.EList;
-
-/**
- * <!-- begin-user-doc --> A representation of the model object '<em><b>Test Def</b></em>'. <!-- end-user-doc -->
- * <p>
- * The following features are supported:
- * <ul>
- * <li>{@link org.eclipse.net4j.util.tests.defs.TestDef#getReferences <em>References</em>}</li>
- * <li>{@link org.eclipse.net4j.util.tests.defs.TestDef#getAttribute <em>Attribute</em>}</li>
- * </ul>
- * </p>
- *
- * @see org.eclipse.net4j.util.tests.defs.TestDefsPackage#getTestDef()
- * @model
- * @generated
- */
-public interface TestDef extends Def
-{
- /**
- * Returns the value of the '<em><b>References</b></em>' reference list. The list contents are of type
- * {@link org.eclipse.net4j.util.defs.Def}. <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>References</em>' reference list isn't clear, there really should be more of a
- * description here...
- * </p>
- * <!-- end-user-doc -->
- *
- * @return the value of the '<em>References</em>' reference list.
- * @see org.eclipse.net4j.util.tests.defs.TestDefsPackage#getTestDef_References()
- * @model
- * @generated
- */
- EList<Def> getReferences();
-
- /**
- * Returns the value of the '<em><b>Attribute</b></em>' attribute. <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Attribute</em>' attribute isn't clear, there really should be more of a description
- * here...
- * </p>
- * <!-- end-user-doc -->
- *
- * @return the value of the '<em>Attribute</em>' attribute.
- * @see #setAttribute(String)
- * @see org.eclipse.net4j.util.tests.defs.TestDefsPackage#getTestDef_Attribute()
- * @model
- * @generated
- */
- String getAttribute();
-
- /**
- * Sets the value of the '{@link org.eclipse.net4j.util.tests.defs.TestDef#getAttribute <em>Attribute</em>}'
- * attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @param value
- * the new value of the '<em>Attribute</em>' attribute.
- * @see #getAttribute()
- * @generated
- */
- void setAttribute(String value);
-
-} // TestDef
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.net4j.util.tests.defs;
+
+import org.eclipse.net4j.util.defs.Def;
+
+import org.eclipse.emf.common.util.EList;
+
+/**
+ * <!-- begin-user-doc --> A representation of the model object '<em><b>Test Def</b></em>'. <!-- end-user-doc -->
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.eclipse.net4j.util.tests.defs.TestDef#getReferences <em>References</em>}</li>
+ * <li>{@link org.eclipse.net4j.util.tests.defs.TestDef#getAttribute <em>Attribute</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.net4j.util.tests.defs.TestDefsPackage#getTestDef()
+ * @model
+ * @generated
+ */
+public interface TestDef extends Def
+{
+ /**
+ * Returns the value of the '<em><b>References</b></em>' reference list. The list contents are of type
+ * {@link org.eclipse.net4j.util.defs.Def}. <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>References</em>' reference list isn't clear, there really should be more of a
+ * description here...
+ * </p>
+ * <!-- end-user-doc -->
+ *
+ * @return the value of the '<em>References</em>' reference list.
+ * @see org.eclipse.net4j.util.tests.defs.TestDefsPackage#getTestDef_References()
+ * @model
+ * @generated
+ */
+ EList<Def> getReferences();
+
+ /**
+ * Returns the value of the '<em><b>Attribute</b></em>' attribute. <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Attribute</em>' attribute isn't clear, there really should be more of a description
+ * here...
+ * </p>
+ * <!-- end-user-doc -->
+ *
+ * @return the value of the '<em>Attribute</em>' attribute.
+ * @see #setAttribute(String)
+ * @see org.eclipse.net4j.util.tests.defs.TestDefsPackage#getTestDef_Attribute()
+ * @model
+ * @generated
+ */
+ String getAttribute();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.net4j.util.tests.defs.TestDef#getAttribute <em>Attribute</em>}'
+ * attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @param value
+ * the new value of the '<em>Attribute</em>' attribute.
+ * @see #getAttribute()
+ * @generated
+ */
+ void setAttribute(String value);
+
+} // TestDef
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/TestDefTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/TestDefTest.java
index 63e34b3f97..ee9cc87a1d 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/TestDefTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/TestDefTest.java
@@ -1,261 +1,261 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.net4j.util.tests.defs;
-
-import org.eclipse.net4j.util.defs.Def;
-import org.eclipse.net4j.util.defs.impl.DefImpl;
-import org.eclipse.net4j.util.lifecycle.Lifecycle;
-import org.eclipse.net4j.util.lifecycle.LifecycleException;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.tests.AbstractOMTest;
-
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantLock;
-
-/**
- * @author Andre Dietisheim
- */
-public class TestDefTest extends AbstractOMTest
-{
- private Def def;
-
- public TestDefTest()
- {
- }
-
- @Override
- public void doSetUp()
- {
- def = new BlockingTokenDef();
- }
-
- public void testGetInstanceReturnsSameInstance()
- {
- Object thisInstance = def.getInstance();
- Object thatInstance = def.getInstance();
- assertEquals(true, thisInstance == thatInstance);
- }
-
- public void testInstanceCreatedIsActivated()
- {
- Object instance = def.getInstance();
- assertEquals(true, LifecycleUtil.isActive(instance));
- }
-
- public void testInstanceDeactivatesIfUnset()
- {
- Object instance = def.getInstance();
- def.unsetInstance();
- assertEquals(true, ((DefImpl)def).getInternalInstance() == null);
- assertEquals(true, !LifecycleUtil.isActive(instance));
- }
-
- public void testNewInstanceIsCreatedIfDefWasTouchedAfterwards() throws Exception
- {
- Def def = new DefImpl()
- {
- @Override
- public boolean isTouched()
- {
- return true;
- }
-
- @Override
- protected Object createInstance()
- {
- return new String(""); //$NON-NLS-1$
- }
- };
-
- Object thisInstance = def.getInstance();
- Object thatInstance = def.getInstance();
- assertEquals(true, thatInstance != thisInstance);
- }
-
- public void testSameInstanceIfDefWasntTouched() throws Exception
- {
- Def def = new DefImpl()
- {
- @Override
- public boolean isTouched()
- {
- return false;
- }
-
- @Override
- protected Object createInstance()
- {
- return new String(""); //$NON-NLS-1$
- }
- };
-
- Object thisInstance = def.getInstance();
- Object thatInstance = def.getInstance();
- assertEquals(true, thatInstance == thisInstance);
- }
-
- public void testSetAttributeTouches()
- {
- TestDef def = createTestDef();
- assertEquals(true, !def.isTouched());
- def.setAttribute("aValue"); //$NON-NLS-1$
- assertEquals(true, def.isTouched());
- def.getInstance(); // clears touched
- assertEquals(true, !def.isTouched());
- }
-
- public void testAddReferenceTouches()
- {
- TestDef def = createTestDef();
- assertEquals(true, !def.isTouched());
- def.getReferences().add(createTestDef());
- assertEquals(true, def.isTouched());
- }
-
- public void testSetInReferencedDefTouchesReferenchingDef()
- {
- TestDef def = createTestDef();
- assertEquals(true, !def.isTouched());
-
- TestDef referencedDef = createTestDef();
- def.getReferences().add(referencedDef);
- assertEquals(true, !referencedDef.isTouched());
-
- referencedDef.setAttribute("newValue"); //$NON-NLS-1$
- assertEquals(true, referencedDef.isTouched());
- assertEquals(true, def.isTouched());
- }
-
- public void testNewInstanceIsCreatedIfCurrentIsDeactivated() throws Exception
- {
- BlockingToken thisInstance = (BlockingToken)def.getInstance();
- LifecycleUtil.deactivate(thisInstance);
-
- // Wait until instance gets deactivated
- thisInstance.waitForDeactivation();
- BlockingToken thatInstance = (BlockingToken)def.getInstance();
- assertEquals(true, thatInstance != thisInstance);
- }
-
- public void testNewInstanceIsCreatedIfCurrentIsUnset() throws Exception
- {
- BlockingToken thisInstance = (BlockingToken)def.getInstance();
- def.unsetInstance();
-
- // Wait until instance gets deactivated
- thisInstance.waitForDeactivation();
- BlockingToken thatInstance = (BlockingToken)def.getInstance();
- assertEquals(true, thatInstance != thisInstance);
- }
-
- private TestDef createTestDef()
- {
- return DefsFactory.eINSTANCE.createTestDef();
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class BlockingTokenDef extends DefImpl
- {
- public BlockingTokenDef()
- {
- }
-
- @Override
- protected Object createInstance()
- {
- return new BlockingToken();
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class BlockingToken extends Lifecycle
- {
- private static final long WAIT_TIMEOUT = 1000l;
-
- private volatile boolean isActive = false;
-
- private ReentrantLock reentrantLock = new ReentrantLock();
-
- private Condition lockReleaseCondition = reentrantLock.newCondition();
-
- public BlockingToken()
- {
- }
-
- /**
- * (Blocking) Wait for deactivation. The deactivation is triggered in a separate thread. This method allows you
- * blocking wait for deactivation
- *
- * @throws InterruptedException
- * the interrupted exception
- */
- public void waitForDeactivation() throws InterruptedException
- {
- long startTime = System.currentTimeMillis();
- reentrantLock.lock();
- try
- {
- while (isActive)
- {
- if (isTimeout(startTime))
- {
- throw new IllegalStateException("was not deactivated while waiting for '" + WAIT_TIMEOUT + "'!"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- reentrantLock.wait(WAIT_TIMEOUT);
- }
- }
- finally
- {
- reentrantLock.unlock();
- }
- }
-
- @Override
- protected void doActivate() throws LifecycleException
- {
- try
- {
- reentrantLock.lock();
- isActive = true;
- }
- finally
- {
- reentrantLock.unlock();
- }
- }
-
- @Override
- protected void doDeactivate()
- {
- try
- {
- reentrantLock.lock();
- isActive = false;
- lockReleaseCondition.signal();
- }
- finally
- {
- reentrantLock.unlock();
- }
- }
-
- private boolean isTimeout(long startTime)
- {
- return System.currentTimeMillis() - startTime > WAIT_TIMEOUT;
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.net4j.util.tests.defs;
+
+import org.eclipse.net4j.util.defs.Def;
+import org.eclipse.net4j.util.defs.impl.DefImpl;
+import org.eclipse.net4j.util.lifecycle.Lifecycle;
+import org.eclipse.net4j.util.lifecycle.LifecycleException;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.tests.AbstractOMTest;
+
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class TestDefTest extends AbstractOMTest
+{
+ private Def def;
+
+ public TestDefTest()
+ {
+ }
+
+ @Override
+ public void doSetUp()
+ {
+ def = new BlockingTokenDef();
+ }
+
+ public void testGetInstanceReturnsSameInstance()
+ {
+ Object thisInstance = def.getInstance();
+ Object thatInstance = def.getInstance();
+ assertEquals(true, thisInstance == thatInstance);
+ }
+
+ public void testInstanceCreatedIsActivated()
+ {
+ Object instance = def.getInstance();
+ assertEquals(true, LifecycleUtil.isActive(instance));
+ }
+
+ public void testInstanceDeactivatesIfUnset()
+ {
+ Object instance = def.getInstance();
+ def.unsetInstance();
+ assertEquals(true, ((DefImpl)def).getInternalInstance() == null);
+ assertEquals(true, !LifecycleUtil.isActive(instance));
+ }
+
+ public void testNewInstanceIsCreatedIfDefWasTouchedAfterwards() throws Exception
+ {
+ Def def = new DefImpl()
+ {
+ @Override
+ public boolean isTouched()
+ {
+ return true;
+ }
+
+ @Override
+ protected Object createInstance()
+ {
+ return new String(""); //$NON-NLS-1$
+ }
+ };
+
+ Object thisInstance = def.getInstance();
+ Object thatInstance = def.getInstance();
+ assertEquals(true, thatInstance != thisInstance);
+ }
+
+ public void testSameInstanceIfDefWasntTouched() throws Exception
+ {
+ Def def = new DefImpl()
+ {
+ @Override
+ public boolean isTouched()
+ {
+ return false;
+ }
+
+ @Override
+ protected Object createInstance()
+ {
+ return new String(""); //$NON-NLS-1$
+ }
+ };
+
+ Object thisInstance = def.getInstance();
+ Object thatInstance = def.getInstance();
+ assertEquals(true, thatInstance == thisInstance);
+ }
+
+ public void testSetAttributeTouches()
+ {
+ TestDef def = createTestDef();
+ assertEquals(true, !def.isTouched());
+ def.setAttribute("aValue"); //$NON-NLS-1$
+ assertEquals(true, def.isTouched());
+ def.getInstance(); // clears touched
+ assertEquals(true, !def.isTouched());
+ }
+
+ public void testAddReferenceTouches()
+ {
+ TestDef def = createTestDef();
+ assertEquals(true, !def.isTouched());
+ def.getReferences().add(createTestDef());
+ assertEquals(true, def.isTouched());
+ }
+
+ public void testSetInReferencedDefTouchesReferenchingDef()
+ {
+ TestDef def = createTestDef();
+ assertEquals(true, !def.isTouched());
+
+ TestDef referencedDef = createTestDef();
+ def.getReferences().add(referencedDef);
+ assertEquals(true, !referencedDef.isTouched());
+
+ referencedDef.setAttribute("newValue"); //$NON-NLS-1$
+ assertEquals(true, referencedDef.isTouched());
+ assertEquals(true, def.isTouched());
+ }
+
+ public void testNewInstanceIsCreatedIfCurrentIsDeactivated() throws Exception
+ {
+ BlockingToken thisInstance = (BlockingToken)def.getInstance();
+ LifecycleUtil.deactivate(thisInstance);
+
+ // Wait until instance gets deactivated
+ thisInstance.waitForDeactivation();
+ BlockingToken thatInstance = (BlockingToken)def.getInstance();
+ assertEquals(true, thatInstance != thisInstance);
+ }
+
+ public void testNewInstanceIsCreatedIfCurrentIsUnset() throws Exception
+ {
+ BlockingToken thisInstance = (BlockingToken)def.getInstance();
+ def.unsetInstance();
+
+ // Wait until instance gets deactivated
+ thisInstance.waitForDeactivation();
+ BlockingToken thatInstance = (BlockingToken)def.getInstance();
+ assertEquals(true, thatInstance != thisInstance);
+ }
+
+ private TestDef createTestDef()
+ {
+ return DefsFactory.eINSTANCE.createTestDef();
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class BlockingTokenDef extends DefImpl
+ {
+ public BlockingTokenDef()
+ {
+ }
+
+ @Override
+ protected Object createInstance()
+ {
+ return new BlockingToken();
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class BlockingToken extends Lifecycle
+ {
+ private static final long WAIT_TIMEOUT = 1000l;
+
+ private volatile boolean isActive = false;
+
+ private ReentrantLock reentrantLock = new ReentrantLock();
+
+ private Condition lockReleaseCondition = reentrantLock.newCondition();
+
+ public BlockingToken()
+ {
+ }
+
+ /**
+ * (Blocking) Wait for deactivation. The deactivation is triggered in a separate thread. This method allows you
+ * blocking wait for deactivation
+ *
+ * @throws InterruptedException
+ * the interrupted exception
+ */
+ public void waitForDeactivation() throws InterruptedException
+ {
+ long startTime = System.currentTimeMillis();
+ reentrantLock.lock();
+ try
+ {
+ while (isActive)
+ {
+ if (isTimeout(startTime))
+ {
+ throw new IllegalStateException("was not deactivated while waiting for '" + WAIT_TIMEOUT + "'!"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ reentrantLock.wait(WAIT_TIMEOUT);
+ }
+ }
+ finally
+ {
+ reentrantLock.unlock();
+ }
+ }
+
+ @Override
+ protected void doActivate() throws LifecycleException
+ {
+ try
+ {
+ reentrantLock.lock();
+ isActive = true;
+ }
+ finally
+ {
+ reentrantLock.unlock();
+ }
+ }
+
+ @Override
+ protected void doDeactivate()
+ {
+ try
+ {
+ reentrantLock.lock();
+ isActive = false;
+ lockReleaseCondition.signal();
+ }
+ finally
+ {
+ reentrantLock.unlock();
+ }
+ }
+
+ private boolean isTimeout(long startTime)
+ {
+ return System.currentTimeMillis() - startTime > WAIT_TIMEOUT;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/TestDefsFactory.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/TestDefsFactory.java
index aa62ded89d..d6136ecee4 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/TestDefsFactory.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/TestDefsFactory.java
@@ -1,48 +1,48 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.net4j.util.tests.defs;
-
-import org.eclipse.emf.ecore.EFactory;
-
-/**
- * <!-- begin-user-doc --> The <b>Factory</b> for the model. It provides a create method for each non-abstract class of
- * the model. <!-- end-user-doc -->
- *
- * @see org.eclipse.net4j.util.tests.defs.TestDefsPackage
- * @generated
- */
-public interface TestDefsFactory extends EFactory
-{
- /**
- * The singleton instance of the factory. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- TestDefsFactory eINSTANCE = org.eclipse.net4j.util.tests.defs.impl.TestDefsFactoryImpl.init();
-
- /**
- * Returns a new object of class '<em>Test Def</em>'. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @return a new object of class '<em>Test Def</em>'.
- * @generated
- */
- TestDef createTestDef();
-
- /**
- * Returns the package supported by this factory. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @return the package supported by this factory.
- * @generated
- */
- TestDefsPackage getTestDefsPackage();
-
-} // TestDefsFactory
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.net4j.util.tests.defs;
+
+import org.eclipse.emf.ecore.EFactory;
+
+/**
+ * <!-- begin-user-doc --> The <b>Factory</b> for the model. It provides a create method for each non-abstract class of
+ * the model. <!-- end-user-doc -->
+ *
+ * @see org.eclipse.net4j.util.tests.defs.TestDefsPackage
+ * @generated
+ */
+public interface TestDefsFactory extends EFactory
+{
+ /**
+ * The singleton instance of the factory. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ TestDefsFactory eINSTANCE = org.eclipse.net4j.util.tests.defs.impl.TestDefsFactoryImpl.init();
+
+ /**
+ * Returns a new object of class '<em>Test Def</em>'. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return a new object of class '<em>Test Def</em>'.
+ * @generated
+ */
+ TestDef createTestDef();
+
+ /**
+ * Returns the package supported by this factory. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the package supported by this factory.
+ * @generated
+ */
+ TestDefsPackage getTestDefsPackage();
+
+} // TestDefsFactory
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/TestDefsPackage.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/TestDefsPackage.java
index cd888a0952..009874feb1 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/TestDefsPackage.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/TestDefsPackage.java
@@ -1,181 +1,181 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.net4j.util.tests.defs;
-
-import org.eclipse.net4j.util.defs.Net4jUtilDefsPackage;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-
-/**
- * <!-- begin-user-doc --> The <b>Package</b> for the model. It contains accessors for the meta objects to represent
- * <ul>
- * <li>each class,</li>
- * <li>each feature of each class,</li>
- * <li>each enum,</li>
- * <li>and each data type</li>
- * </ul>
- * <!-- end-user-doc -->
- *
- * @see org.eclipse.net4j.util.tests.defs.TestDefsFactory
- * @model kind="package"
- * @generated
- */
-public interface TestDefsPackage extends EPackage
-{
- /**
- * The package name. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- String eNAME = "defs"; //$NON-NLS-1$
-
- /**
- * The package namespace URI. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- String eNS_URI = "http://www.eclipse.org/NET4J/defs/tests/1.0.0"; //$NON-NLS-1$
-
- /**
- * The package namespace name. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- String eNS_PREFIX = "net4j.defs.tests"; //$NON-NLS-1$
-
- /**
- * The singleton instance of the package. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- TestDefsPackage eINSTANCE = org.eclipse.net4j.util.tests.defs.impl.TestDefsPackageImpl.init();
-
- /**
- * The meta object id for the '{@link org.eclipse.net4j.util.tests.defs.impl.TestDefImpl <em>Test Def</em>}' class.
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @see org.eclipse.net4j.util.tests.defs.impl.TestDefImpl
- * @see org.eclipse.net4j.util.tests.defs.impl.TestDefsPackageImpl#getTestDef()
- * @generated
- */
- int TEST_DEF = 0;
-
- /**
- * The feature id for the '<em><b>References</b></em>' reference list. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- * @ordered
- */
- int TEST_DEF__REFERENCES = Net4jUtilDefsPackage.DEF_FEATURE_COUNT + 0;
-
- /**
- * The feature id for the '<em><b>Attribute</b></em>' attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- * @ordered
- */
- int TEST_DEF__ATTRIBUTE = Net4jUtilDefsPackage.DEF_FEATURE_COUNT + 1;
-
- /**
- * The number of structural features of the '<em>Test Def</em>' class. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- * @ordered
- */
- int TEST_DEF_FEATURE_COUNT = Net4jUtilDefsPackage.DEF_FEATURE_COUNT + 2;
-
- /**
- * Returns the meta object for class '{@link org.eclipse.net4j.util.tests.defs.TestDef <em>Test Def</em>}'. <!--
- * begin-user-doc --> <!-- end-user-doc -->
- *
- * @return the meta object for class '<em>Test Def</em>'.
- * @see org.eclipse.net4j.util.tests.defs.TestDef
- * @generated
- */
- EClass getTestDef();
-
- /**
- * Returns the meta object for the reference list '{@link org.eclipse.net4j.util.tests.defs.TestDef#getReferences
- * <em>References</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @return the meta object for the reference list '<em>References</em>'.
- * @see org.eclipse.net4j.util.tests.defs.TestDef#getReferences()
- * @see #getTestDef()
- * @generated
- */
- EReference getTestDef_References();
-
- /**
- * Returns the meta object for the attribute '{@link org.eclipse.net4j.util.tests.defs.TestDef#getAttribute
- * <em>Attribute</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @return the meta object for the attribute '<em>Attribute</em>'.
- * @see org.eclipse.net4j.util.tests.defs.TestDef#getAttribute()
- * @see #getTestDef()
- * @generated
- */
- EAttribute getTestDef_Attribute();
-
- /**
- * Returns the factory that creates the instances of the model. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @return the factory that creates the instances of the model.
- * @generated
- */
- TestDefsFactory getTestDefsFactory();
-
- /**
- * <!-- begin-user-doc --> Defines literals for the meta objects that represent
- * <ul>
- * <li>each class,</li>
- * <li>each feature of each class,</li>
- * <li>each enum,</li>
- * <li>and each data type</li>
- * </ul>
- * <!-- end-user-doc -->
- *
- * @generated
- */
- interface Literals
- {
- /**
- * The meta object literal for the '{@link org.eclipse.net4j.util.tests.defs.impl.TestDefImpl <em>Test Def</em>}'
- * class. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @see org.eclipse.net4j.util.tests.defs.impl.TestDefImpl
- * @see org.eclipse.net4j.util.tests.defs.impl.TestDefsPackageImpl#getTestDef()
- * @generated
- */
- EClass TEST_DEF = eINSTANCE.getTestDef();
-
- /**
- * The meta object literal for the '<em><b>References</b></em>' reference list feature. <!-- begin-user-doc --> <!--
- * end-user-doc -->
- *
- * @generated
- */
- EReference TEST_DEF__REFERENCES = eINSTANCE.getTestDef_References();
-
- /**
- * The meta object literal for the '<em><b>Attribute</b></em>' attribute feature. <!-- begin-user-doc --> <!--
- * end-user-doc -->
- *
- * @generated
- */
- EAttribute TEST_DEF__ATTRIBUTE = eINSTANCE.getTestDef_Attribute();
-
- }
-
-} // TestDefsPackage
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.net4j.util.tests.defs;
+
+import org.eclipse.net4j.util.defs.Net4jUtilDefsPackage;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+
+/**
+ * <!-- begin-user-doc --> The <b>Package</b> for the model. It contains accessors for the meta objects to represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ *
+ * @see org.eclipse.net4j.util.tests.defs.TestDefsFactory
+ * @model kind="package"
+ * @generated
+ */
+public interface TestDefsPackage extends EPackage
+{
+ /**
+ * The package name. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ String eNAME = "defs"; //$NON-NLS-1$
+
+ /**
+ * The package namespace URI. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ String eNS_URI = "http://www.eclipse.org/NET4J/defs/tests/1.0.0"; //$NON-NLS-1$
+
+ /**
+ * The package namespace name. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ String eNS_PREFIX = "net4j.defs.tests"; //$NON-NLS-1$
+
+ /**
+ * The singleton instance of the package. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ TestDefsPackage eINSTANCE = org.eclipse.net4j.util.tests.defs.impl.TestDefsPackageImpl.init();
+
+ /**
+ * The meta object id for the '{@link org.eclipse.net4j.util.tests.defs.impl.TestDefImpl <em>Test Def</em>}' class.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see org.eclipse.net4j.util.tests.defs.impl.TestDefImpl
+ * @see org.eclipse.net4j.util.tests.defs.impl.TestDefsPackageImpl#getTestDef()
+ * @generated
+ */
+ int TEST_DEF = 0;
+
+ /**
+ * The feature id for the '<em><b>References</b></em>' reference list. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int TEST_DEF__REFERENCES = Net4jUtilDefsPackage.DEF_FEATURE_COUNT + 0;
+
+ /**
+ * The feature id for the '<em><b>Attribute</b></em>' attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int TEST_DEF__ATTRIBUTE = Net4jUtilDefsPackage.DEF_FEATURE_COUNT + 1;
+
+ /**
+ * The number of structural features of the '<em>Test Def</em>' class. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int TEST_DEF_FEATURE_COUNT = Net4jUtilDefsPackage.DEF_FEATURE_COUNT + 2;
+
+ /**
+ * Returns the meta object for class '{@link org.eclipse.net4j.util.tests.defs.TestDef <em>Test Def</em>}'. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the meta object for class '<em>Test Def</em>'.
+ * @see org.eclipse.net4j.util.tests.defs.TestDef
+ * @generated
+ */
+ EClass getTestDef();
+
+ /**
+ * Returns the meta object for the reference list '{@link org.eclipse.net4j.util.tests.defs.TestDef#getReferences
+ * <em>References</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the meta object for the reference list '<em>References</em>'.
+ * @see org.eclipse.net4j.util.tests.defs.TestDef#getReferences()
+ * @see #getTestDef()
+ * @generated
+ */
+ EReference getTestDef_References();
+
+ /**
+ * Returns the meta object for the attribute '{@link org.eclipse.net4j.util.tests.defs.TestDef#getAttribute
+ * <em>Attribute</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the meta object for the attribute '<em>Attribute</em>'.
+ * @see org.eclipse.net4j.util.tests.defs.TestDef#getAttribute()
+ * @see #getTestDef()
+ * @generated
+ */
+ EAttribute getTestDef_Attribute();
+
+ /**
+ * Returns the factory that creates the instances of the model. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the factory that creates the instances of the model.
+ * @generated
+ */
+ TestDefsFactory getTestDefsFactory();
+
+ /**
+ * <!-- begin-user-doc --> Defines literals for the meta objects that represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ interface Literals
+ {
+ /**
+ * The meta object literal for the '{@link org.eclipse.net4j.util.tests.defs.impl.TestDefImpl <em>Test Def</em>}'
+ * class. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see org.eclipse.net4j.util.tests.defs.impl.TestDefImpl
+ * @see org.eclipse.net4j.util.tests.defs.impl.TestDefsPackageImpl#getTestDef()
+ * @generated
+ */
+ EClass TEST_DEF = eINSTANCE.getTestDef();
+
+ /**
+ * The meta object literal for the '<em><b>References</b></em>' reference list feature. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @generated
+ */
+ EReference TEST_DEF__REFERENCES = eINSTANCE.getTestDef_References();
+
+ /**
+ * The meta object literal for the '<em><b>Attribute</b></em>' attribute feature. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @generated
+ */
+ EAttribute TEST_DEF__ATTRIBUTE = eINSTANCE.getTestDef_Attribute();
+
+ }
+
+} // TestDefsPackage
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/DefsFactoryImpl.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/DefsFactoryImpl.java
index 0a8e24e360..95ad441aeb 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/DefsFactoryImpl.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/DefsFactoryImpl.java
@@ -1,114 +1,114 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.net4j.util.tests.defs.impl;
-
-import org.eclipse.net4j.util.tests.defs.DefsFactory;
-import org.eclipse.net4j.util.tests.defs.DefsPackage;
-import org.eclipse.net4j.util.tests.defs.TestDef;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.impl.EFactoryImpl;
-import org.eclipse.emf.ecore.plugin.EcorePlugin;
-
-/**
- * <!-- begin-user-doc --> An implementation of the model <b>Factory</b>. <!-- end-user-doc -->
- *
- * @generated
- */
-public class DefsFactoryImpl extends EFactoryImpl implements DefsFactory
-{
- /**
- * Creates the default factory implementation. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public static DefsFactory init()
- {
- try
- {
- DefsFactory theDefsFactory = (DefsFactory)EPackage.Registry.INSTANCE
- .getEFactory("http://www.eclipse.org/NET4J/defs/tests/1.0.0"); //$NON-NLS-1$
- if (theDefsFactory != null)
- {
- return theDefsFactory;
- }
- }
- catch (Exception exception)
- {
- EcorePlugin.INSTANCE.log(exception);
- }
- return new DefsFactoryImpl();
- }
-
- /**
- * Creates an instance of the factory. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public DefsFactoryImpl()
- {
- super();
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- @Override
- public EObject create(EClass eClass)
- {
- switch (eClass.getClassifierID())
- {
- case DefsPackage.TEST_DEF:
- return createTestDef();
- default:
- throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public TestDef createTestDef()
- {
- TestDefImpl testDef = new TestDefImpl();
- return testDef;
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public DefsPackage getDefsPackage()
- {
- return (DefsPackage)getEPackage();
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @deprecated
- * @generated
- */
- @Deprecated
- public static DefsPackage getPackage()
- {
- return DefsPackage.eINSTANCE;
- }
-
-} // DefsFactoryImpl
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.net4j.util.tests.defs.impl;
+
+import org.eclipse.net4j.util.tests.defs.DefsFactory;
+import org.eclipse.net4j.util.tests.defs.DefsPackage;
+import org.eclipse.net4j.util.tests.defs.TestDef;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.impl.EFactoryImpl;
+import org.eclipse.emf.ecore.plugin.EcorePlugin;
+
+/**
+ * <!-- begin-user-doc --> An implementation of the model <b>Factory</b>. <!-- end-user-doc -->
+ *
+ * @generated
+ */
+public class DefsFactoryImpl extends EFactoryImpl implements DefsFactory
+{
+ /**
+ * Creates the default factory implementation. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public static DefsFactory init()
+ {
+ try
+ {
+ DefsFactory theDefsFactory = (DefsFactory)EPackage.Registry.INSTANCE
+ .getEFactory("http://www.eclipse.org/NET4J/defs/tests/1.0.0"); //$NON-NLS-1$
+ if (theDefsFactory != null)
+ {
+ return theDefsFactory;
+ }
+ }
+ catch (Exception exception)
+ {
+ EcorePlugin.INSTANCE.log(exception);
+ }
+ return new DefsFactoryImpl();
+ }
+
+ /**
+ * Creates an instance of the factory. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public DefsFactoryImpl()
+ {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public EObject create(EClass eClass)
+ {
+ switch (eClass.getClassifierID())
+ {
+ case DefsPackage.TEST_DEF:
+ return createTestDef();
+ default:
+ throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public TestDef createTestDef()
+ {
+ TestDefImpl testDef = new TestDefImpl();
+ return testDef;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public DefsPackage getDefsPackage()
+ {
+ return (DefsPackage)getEPackage();
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @deprecated
+ * @generated
+ */
+ @Deprecated
+ public static DefsPackage getPackage()
+ {
+ return DefsPackage.eINSTANCE;
+ }
+
+} // DefsFactoryImpl
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/DefsPackageImpl.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/DefsPackageImpl.java
index 61e15036bd..54fa52d77e 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/DefsPackageImpl.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/DefsPackageImpl.java
@@ -1,226 +1,226 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.net4j.util.tests.defs.impl;
-
-import org.eclipse.net4j.util.defs.Net4jUtilDefsPackage;
-import org.eclipse.net4j.util.tests.defs.DefsFactory;
-import org.eclipse.net4j.util.tests.defs.DefsPackage;
-import org.eclipse.net4j.util.tests.defs.TestDef;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.impl.EPackageImpl;
-
-/**
- * <!-- begin-user-doc --> An implementation of the model <b>Package</b>. <!-- end-user-doc -->
- *
- * @generated
- */
-public class DefsPackageImpl extends EPackageImpl implements DefsPackage
-{
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- private EClass testDefEClass;
-
- /**
- * Creates an instance of the model <b>Package</b>, registered with {@link org.eclipse.emf.ecore.EPackage.Registry
- * EPackage.Registry} by the package package URI value.
- * <p>
- * Note: the correct way to create the package is via the static factory method {@link #init init()}, which also
- * performs initialization of the package, or returns the registered package, if one already exists. <!--
- * begin-user-doc --> <!-- end-user-doc -->
- *
- * @see org.eclipse.emf.ecore.EPackage.Registry
- * @see org.eclipse.net4j.util.tests.defs.DefsPackage#eNS_URI
- * @see #init()
- * @generated
- */
- private DefsPackageImpl()
- {
- super(eNS_URI, DefsFactory.eINSTANCE);
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- private static boolean isInited = false;
-
- /**
- * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
- * Simple dependencies are satisfied by calling this method on all dependent packages before doing anything else. This
- * method drives initialization for interdependent packages directly, in parallel with this package, itself.
- * <p>
- * Of this package and its interdependencies, all packages which have not yet been registered by their URI values are
- * first created and registered. The packages are then initialized in two steps: meta-model objects for all of the
- * packages are created before any are initialized, since one package's meta-model objects may refer to those of
- * another.
- * <p>
- * Invocation of this method will not affect any packages that have already been initialized. <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
- * @see #eNS_URI
- * @see #createPackageContents()
- * @see #initializePackageContents()
- * @generated
- */
- public static DefsPackage init()
- {
- if (isInited)
- {
- return (DefsPackage)EPackage.Registry.INSTANCE.getEPackage(DefsPackage.eNS_URI);
- }
-
- // Obtain or create and register package
- DefsPackageImpl theDefsPackage = (DefsPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof DefsPackageImpl ? EPackage.Registry.INSTANCE
- .getEPackage(eNS_URI) : new DefsPackageImpl());
-
- isInited = true;
-
- // Initialize simple dependencies
- Net4jUtilDefsPackage.eINSTANCE.eClass();
-
- // Create package meta-data objects
- theDefsPackage.createPackageContents();
-
- // Initialize created meta-data
- theDefsPackage.initializePackageContents();
-
- // Mark meta-data to indicate it can't be changed
- theDefsPackage.freeze();
-
- return theDefsPackage;
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public EClass getTestDef()
- {
- return testDefEClass;
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public EReference getTestDef_References()
- {
- return (EReference)testDefEClass.getEStructuralFeatures().get(0);
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public EAttribute getTestDef_Attribute()
- {
- return (EAttribute)testDefEClass.getEStructuralFeatures().get(1);
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public DefsFactory getDefsFactory()
- {
- return (DefsFactory)getEFactoryInstance();
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- private boolean isCreated = false;
-
- /**
- * Creates the meta-model objects for the package. This method is guarded to have no affect on any invocation but its
- * first. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public void createPackageContents()
- {
- if (isCreated)
- {
- return;
- }
- isCreated = true;
-
- // Create classes and their features
- testDefEClass = createEClass(TEST_DEF);
- createEReference(testDefEClass, TEST_DEF__REFERENCES);
- createEAttribute(testDefEClass, TEST_DEF__ATTRIBUTE);
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- private boolean isInitialized = false;
-
- /**
- * Complete the initialization of the package and its meta-model. This method is guarded to have no affect on any
- * invocation but its first. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public void initializePackageContents()
- {
- if (isInitialized)
- {
- return;
- }
- isInitialized = true;
-
- // Initialize package
- setName(eNAME);
- setNsPrefix(eNS_PREFIX);
- setNsURI(eNS_URI);
-
- // Obtain other dependent packages
- Net4jUtilDefsPackage theNet4jUtilDefsPackage = (Net4jUtilDefsPackage)EPackage.Registry.INSTANCE
- .getEPackage(Net4jUtilDefsPackage.eNS_URI);
-
- // Create type parameters
-
- // Set bounds for type parameters
-
- // Add supertypes to classes
- testDefEClass.getESuperTypes().add(theNet4jUtilDefsPackage.getDef());
-
- // Initialize classes and features; add operations and parameters
- initEClass(testDefEClass, TestDef.class, "TestDef", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
- initEReference(getTestDef_References(), theNet4jUtilDefsPackage.getDef(), null, "references", null, 0, -1, //$NON-NLS-1$
- TestDef.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE,
- IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEAttribute(getTestDef_Attribute(), ecorePackage.getEString(), "attribute", null, 0, 1, TestDef.class, //$NON-NLS-1$
- !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
-
- // Create resource
- createResource(eNS_URI);
- }
-
-} // DefsPackageImpl
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.net4j.util.tests.defs.impl;
+
+import org.eclipse.net4j.util.defs.Net4jUtilDefsPackage;
+import org.eclipse.net4j.util.tests.defs.DefsFactory;
+import org.eclipse.net4j.util.tests.defs.DefsPackage;
+import org.eclipse.net4j.util.tests.defs.TestDef;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.impl.EPackageImpl;
+
+/**
+ * <!-- begin-user-doc --> An implementation of the model <b>Package</b>. <!-- end-user-doc -->
+ *
+ * @generated
+ */
+public class DefsPackageImpl extends EPackageImpl implements DefsPackage
+{
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ private EClass testDefEClass;
+
+ /**
+ * Creates an instance of the model <b>Package</b>, registered with {@link org.eclipse.emf.ecore.EPackage.Registry
+ * EPackage.Registry} by the package package URI value.
+ * <p>
+ * Note: the correct way to create the package is via the static factory method {@link #init init()}, which also
+ * performs initialization of the package, or returns the registered package, if one already exists. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see org.eclipse.emf.ecore.EPackage.Registry
+ * @see org.eclipse.net4j.util.tests.defs.DefsPackage#eNS_URI
+ * @see #init()
+ * @generated
+ */
+ private DefsPackageImpl()
+ {
+ super(eNS_URI, DefsFactory.eINSTANCE);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ private static boolean isInited = false;
+
+ /**
+ * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
+ * Simple dependencies are satisfied by calling this method on all dependent packages before doing anything else. This
+ * method drives initialization for interdependent packages directly, in parallel with this package, itself.
+ * <p>
+ * Of this package and its interdependencies, all packages which have not yet been registered by their URI values are
+ * first created and registered. The packages are then initialized in two steps: meta-model objects for all of the
+ * packages are created before any are initialized, since one package's meta-model objects may refer to those of
+ * another.
+ * <p>
+ * Invocation of this method will not affect any packages that have already been initialized. <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @see #eNS_URI
+ * @see #createPackageContents()
+ * @see #initializePackageContents()
+ * @generated
+ */
+ public static DefsPackage init()
+ {
+ if (isInited)
+ {
+ return (DefsPackage)EPackage.Registry.INSTANCE.getEPackage(DefsPackage.eNS_URI);
+ }
+
+ // Obtain or create and register package
+ DefsPackageImpl theDefsPackage = (DefsPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof DefsPackageImpl ? EPackage.Registry.INSTANCE
+ .getEPackage(eNS_URI) : new DefsPackageImpl());
+
+ isInited = true;
+
+ // Initialize simple dependencies
+ Net4jUtilDefsPackage.eINSTANCE.eClass();
+
+ // Create package meta-data objects
+ theDefsPackage.createPackageContents();
+
+ // Initialize created meta-data
+ theDefsPackage.initializePackageContents();
+
+ // Mark meta-data to indicate it can't be changed
+ theDefsPackage.freeze();
+
+ return theDefsPackage;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EClass getTestDef()
+ {
+ return testDefEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EReference getTestDef_References()
+ {
+ return (EReference)testDefEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EAttribute getTestDef_Attribute()
+ {
+ return (EAttribute)testDefEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public DefsFactory getDefsFactory()
+ {
+ return (DefsFactory)getEFactoryInstance();
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ private boolean isCreated = false;
+
+ /**
+ * Creates the meta-model objects for the package. This method is guarded to have no affect on any invocation but its
+ * first. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void createPackageContents()
+ {
+ if (isCreated)
+ {
+ return;
+ }
+ isCreated = true;
+
+ // Create classes and their features
+ testDefEClass = createEClass(TEST_DEF);
+ createEReference(testDefEClass, TEST_DEF__REFERENCES);
+ createEAttribute(testDefEClass, TEST_DEF__ATTRIBUTE);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ private boolean isInitialized = false;
+
+ /**
+ * Complete the initialization of the package and its meta-model. This method is guarded to have no affect on any
+ * invocation but its first. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void initializePackageContents()
+ {
+ if (isInitialized)
+ {
+ return;
+ }
+ isInitialized = true;
+
+ // Initialize package
+ setName(eNAME);
+ setNsPrefix(eNS_PREFIX);
+ setNsURI(eNS_URI);
+
+ // Obtain other dependent packages
+ Net4jUtilDefsPackage theNet4jUtilDefsPackage = (Net4jUtilDefsPackage)EPackage.Registry.INSTANCE
+ .getEPackage(Net4jUtilDefsPackage.eNS_URI);
+
+ // Create type parameters
+
+ // Set bounds for type parameters
+
+ // Add supertypes to classes
+ testDefEClass.getESuperTypes().add(theNet4jUtilDefsPackage.getDef());
+
+ // Initialize classes and features; add operations and parameters
+ initEClass(testDefEClass, TestDef.class, "TestDef", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
+ initEReference(getTestDef_References(), theNet4jUtilDefsPackage.getDef(), null, "references", null, 0, -1, //$NON-NLS-1$
+ TestDef.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE,
+ IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getTestDef_Attribute(), ecorePackage.getEString(), "attribute", null, 0, 1, TestDef.class, //$NON-NLS-1$
+ !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ // Create resource
+ createResource(eNS_URI);
+ }
+
+} // DefsPackageImpl
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/TestDefImpl.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/TestDefImpl.java
index 0f1fde4db0..33bf707d41 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/TestDefImpl.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/TestDefImpl.java
@@ -1,236 +1,236 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.net4j.util.tests.defs.impl;
-
-import org.eclipse.net4j.util.defs.Def;
-import org.eclipse.net4j.util.defs.impl.DefImpl;
-import org.eclipse.net4j.util.tests.defs.TestDef;
-import org.eclipse.net4j.util.tests.defs.TestDefsPackage;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.impl.ENotificationImpl;
-import org.eclipse.emf.ecore.util.EObjectResolvingEList;
-
-import java.util.Collection;
-
-/**
- * <!-- begin-user-doc --> An implementation of the model object '<em><b>Test Def</b></em>'. <!-- end-user-doc -->
- * <p>
- * The following features are implemented:
- * <ul>
- * <li>{@link org.eclipse.net4j.util.tests.defs.impl.TestDefImpl#getReferences <em>References</em>}</li>
- * <li>{@link org.eclipse.net4j.util.tests.defs.impl.TestDefImpl#getAttribute <em>Attribute</em>}</li>
- * </ul>
- * </p>
- *
- * @generated
- */
-public class TestDefImpl extends DefImpl implements TestDef
-{
- /**
- * The cached value of the '{@link #getReferences() <em>References</em>}' reference list. <!-- begin-user-doc --> <!--
- * end-user-doc -->
- *
- * @see #getReferences()
- * @generated
- * @ordered
- */
- protected EList<Def> references;
-
- /**
- * The default value of the '{@link #getAttribute() <em>Attribute</em>}' attribute. <!-- begin-user-doc --> <!--
- * end-user-doc -->
- *
- * @see #getAttribute()
- * @generated
- * @ordered
- */
- protected static final String ATTRIBUTE_EDEFAULT = null;
-
- /**
- * The cached value of the '{@link #getAttribute() <em>Attribute</em>}' attribute. <!-- begin-user-doc --> <!--
- * end-user-doc -->
- *
- * @see #getAttribute()
- * @generated
- * @ordered
- */
- protected String attribute = ATTRIBUTE_EDEFAULT;
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- protected TestDefImpl()
- {
- super();
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- @Override
- protected EClass eStaticClass()
- {
- return TestDefsPackage.Literals.TEST_DEF;
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public EList<Def> getReferences()
- {
- if (references == null)
- {
- references = new EObjectResolvingEList<Def>(Def.class, this, TestDefsPackage.TEST_DEF__REFERENCES);
- }
- return references;
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public String getAttribute()
- {
- return attribute;
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public void setAttribute(String newAttribute)
- {
- String oldAttribute = attribute;
- attribute = newAttribute;
- if (eNotificationRequired())
- {
- eNotify(new ENotificationImpl(this, Notification.SET, TestDefsPackage.TEST_DEF__ATTRIBUTE, oldAttribute,
- attribute));
- }
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- @Override
- public Object eGet(int featureID, boolean resolve, boolean coreType)
- {
- switch (featureID)
- {
- case TestDefsPackage.TEST_DEF__REFERENCES:
- return getReferences();
- case TestDefsPackage.TEST_DEF__ATTRIBUTE:
- return getAttribute();
- }
- return super.eGet(featureID, resolve, coreType);
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- @SuppressWarnings("unchecked")
- @Override
- public void eSet(int featureID, Object newValue)
- {
- switch (featureID)
- {
- case TestDefsPackage.TEST_DEF__REFERENCES:
- getReferences().clear();
- getReferences().addAll((Collection<? extends Def>)newValue);
- return;
- case TestDefsPackage.TEST_DEF__ATTRIBUTE:
- setAttribute((String)newValue);
- return;
- }
- super.eSet(featureID, newValue);
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- @Override
- public void eUnset(int featureID)
- {
- switch (featureID)
- {
- case TestDefsPackage.TEST_DEF__REFERENCES:
- getReferences().clear();
- return;
- case TestDefsPackage.TEST_DEF__ATTRIBUTE:
- setAttribute(ATTRIBUTE_EDEFAULT);
- return;
- }
- super.eUnset(featureID);
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- @Override
- public boolean eIsSet(int featureID)
- {
- switch (featureID)
- {
- case TestDefsPackage.TEST_DEF__REFERENCES:
- return references != null && !references.isEmpty();
- case TestDefsPackage.TEST_DEF__ATTRIBUTE:
- return ATTRIBUTE_EDEFAULT == null ? attribute != null : !ATTRIBUTE_EDEFAULT.equals(attribute);
- }
- return super.eIsSet(featureID);
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- @Override
- public String toString()
- {
- if (eIsProxy())
- {
- return super.toString();
- }
-
- StringBuffer result = new StringBuffer(super.toString());
- result.append(" (attribute: ");
- result.append(attribute);
- result.append(')');
- return result.toString();
- }
-
- @Override
- protected Object createInstance()
- {
- return new String("TestDefStringInstance"); //$NON-NLS-1$
- }
-
-} // TestDefImpl
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.net4j.util.tests.defs.impl;
+
+import org.eclipse.net4j.util.defs.Def;
+import org.eclipse.net4j.util.defs.impl.DefImpl;
+import org.eclipse.net4j.util.tests.defs.TestDef;
+import org.eclipse.net4j.util.tests.defs.TestDefsPackage;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+import org.eclipse.emf.ecore.util.EObjectResolvingEList;
+
+import java.util.Collection;
+
+/**
+ * <!-- begin-user-doc --> An implementation of the model object '<em><b>Test Def</b></em>'. <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link org.eclipse.net4j.util.tests.defs.impl.TestDefImpl#getReferences <em>References</em>}</li>
+ * <li>{@link org.eclipse.net4j.util.tests.defs.impl.TestDefImpl#getAttribute <em>Attribute</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class TestDefImpl extends DefImpl implements TestDef
+{
+ /**
+ * The cached value of the '{@link #getReferences() <em>References</em>}' reference list. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @see #getReferences()
+ * @generated
+ * @ordered
+ */
+ protected EList<Def> references;
+
+ /**
+ * The default value of the '{@link #getAttribute() <em>Attribute</em>}' attribute. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @see #getAttribute()
+ * @generated
+ * @ordered
+ */
+ protected static final String ATTRIBUTE_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getAttribute() <em>Attribute</em>}' attribute. <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ *
+ * @see #getAttribute()
+ * @generated
+ * @ordered
+ */
+ protected String attribute = ATTRIBUTE_EDEFAULT;
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected TestDefImpl()
+ {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass()
+ {
+ return TestDefsPackage.Literals.TEST_DEF;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EList<Def> getReferences()
+ {
+ if (references == null)
+ {
+ references = new EObjectResolvingEList<Def>(Def.class, this, TestDefsPackage.TEST_DEF__REFERENCES);
+ }
+ return references;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public String getAttribute()
+ {
+ return attribute;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void setAttribute(String newAttribute)
+ {
+ String oldAttribute = attribute;
+ attribute = newAttribute;
+ if (eNotificationRequired())
+ {
+ eNotify(new ENotificationImpl(this, Notification.SET, TestDefsPackage.TEST_DEF__ATTRIBUTE, oldAttribute,
+ attribute));
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public Object eGet(int featureID, boolean resolve, boolean coreType)
+ {
+ switch (featureID)
+ {
+ case TestDefsPackage.TEST_DEF__REFERENCES:
+ return getReferences();
+ case TestDefsPackage.TEST_DEF__ATTRIBUTE:
+ return getAttribute();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public void eSet(int featureID, Object newValue)
+ {
+ switch (featureID)
+ {
+ case TestDefsPackage.TEST_DEF__REFERENCES:
+ getReferences().clear();
+ getReferences().addAll((Collection<? extends Def>)newValue);
+ return;
+ case TestDefsPackage.TEST_DEF__ATTRIBUTE:
+ setAttribute((String)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID)
+ {
+ switch (featureID)
+ {
+ case TestDefsPackage.TEST_DEF__REFERENCES:
+ getReferences().clear();
+ return;
+ case TestDefsPackage.TEST_DEF__ATTRIBUTE:
+ setAttribute(ATTRIBUTE_EDEFAULT);
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public boolean eIsSet(int featureID)
+ {
+ switch (featureID)
+ {
+ case TestDefsPackage.TEST_DEF__REFERENCES:
+ return references != null && !references.isEmpty();
+ case TestDefsPackage.TEST_DEF__ATTRIBUTE:
+ return ATTRIBUTE_EDEFAULT == null ? attribute != null : !ATTRIBUTE_EDEFAULT.equals(attribute);
+ }
+ return super.eIsSet(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public String toString()
+ {
+ if (eIsProxy())
+ {
+ return super.toString();
+ }
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (attribute: ");
+ result.append(attribute);
+ result.append(')');
+ return result.toString();
+ }
+
+ @Override
+ protected Object createInstance()
+ {
+ return new String("TestDefStringInstance"); //$NON-NLS-1$
+ }
+
+} // TestDefImpl
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/TestDefsFactoryImpl.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/TestDefsFactoryImpl.java
index 036e3220fe..ea5748708f 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/TestDefsFactoryImpl.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/TestDefsFactoryImpl.java
@@ -1,114 +1,114 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.net4j.util.tests.defs.impl;
-
-import org.eclipse.net4j.util.tests.defs.TestDef;
-import org.eclipse.net4j.util.tests.defs.TestDefsFactory;
-import org.eclipse.net4j.util.tests.defs.TestDefsPackage;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.impl.EFactoryImpl;
-import org.eclipse.emf.ecore.plugin.EcorePlugin;
-
-/**
- * <!-- begin-user-doc --> An implementation of the model <b>Factory</b>. <!-- end-user-doc -->
- *
- * @generated
- */
-public class TestDefsFactoryImpl extends EFactoryImpl implements TestDefsFactory
-{
- /**
- * Creates the default factory implementation. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public static TestDefsFactory init()
- {
- try
- {
- TestDefsFactory theTestDefsFactory = (TestDefsFactory)EPackage.Registry.INSTANCE
- .getEFactory("http://www.eclipse.org/NET4J/defs/tests/1.0.0");
- if (theTestDefsFactory != null)
- {
- return theTestDefsFactory;
- }
- }
- catch (Exception exception)
- {
- EcorePlugin.INSTANCE.log(exception);
- }
- return new TestDefsFactoryImpl();
- }
-
- /**
- * Creates an instance of the factory. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public TestDefsFactoryImpl()
- {
- super();
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- @Override
- public EObject create(EClass eClass)
- {
- switch (eClass.getClassifierID())
- {
- case TestDefsPackage.TEST_DEF:
- return createTestDef();
- default:
- throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
- }
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public TestDef createTestDef()
- {
- TestDefImpl testDef = new TestDefImpl();
- return testDef;
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public TestDefsPackage getTestDefsPackage()
- {
- return (TestDefsPackage)getEPackage();
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @deprecated
- * @generated
- */
- @Deprecated
- public static TestDefsPackage getPackage()
- {
- return TestDefsPackage.eINSTANCE;
- }
-
-} // TestDefsFactoryImpl
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.net4j.util.tests.defs.impl;
+
+import org.eclipse.net4j.util.tests.defs.TestDef;
+import org.eclipse.net4j.util.tests.defs.TestDefsFactory;
+import org.eclipse.net4j.util.tests.defs.TestDefsPackage;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.impl.EFactoryImpl;
+import org.eclipse.emf.ecore.plugin.EcorePlugin;
+
+/**
+ * <!-- begin-user-doc --> An implementation of the model <b>Factory</b>. <!-- end-user-doc -->
+ *
+ * @generated
+ */
+public class TestDefsFactoryImpl extends EFactoryImpl implements TestDefsFactory
+{
+ /**
+ * Creates the default factory implementation. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public static TestDefsFactory init()
+ {
+ try
+ {
+ TestDefsFactory theTestDefsFactory = (TestDefsFactory)EPackage.Registry.INSTANCE
+ .getEFactory("http://www.eclipse.org/NET4J/defs/tests/1.0.0");
+ if (theTestDefsFactory != null)
+ {
+ return theTestDefsFactory;
+ }
+ }
+ catch (Exception exception)
+ {
+ EcorePlugin.INSTANCE.log(exception);
+ }
+ return new TestDefsFactoryImpl();
+ }
+
+ /**
+ * Creates an instance of the factory. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public TestDefsFactoryImpl()
+ {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public EObject create(EClass eClass)
+ {
+ switch (eClass.getClassifierID())
+ {
+ case TestDefsPackage.TEST_DEF:
+ return createTestDef();
+ default:
+ throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public TestDef createTestDef()
+ {
+ TestDefImpl testDef = new TestDefImpl();
+ return testDef;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public TestDefsPackage getTestDefsPackage()
+ {
+ return (TestDefsPackage)getEPackage();
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @deprecated
+ * @generated
+ */
+ @Deprecated
+ public static TestDefsPackage getPackage()
+ {
+ return TestDefsPackage.eINSTANCE;
+ }
+
+} // TestDefsFactoryImpl
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/TestDefsPackageImpl.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/TestDefsPackageImpl.java
index d8ce288936..cccb2ae33a 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/TestDefsPackageImpl.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/impl/TestDefsPackageImpl.java
@@ -1,222 +1,222 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.net4j.util.tests.defs.impl;
-
-import org.eclipse.net4j.util.defs.Net4jUtilDefsPackage;
-import org.eclipse.net4j.util.tests.defs.TestDef;
-import org.eclipse.net4j.util.tests.defs.TestDefsFactory;
-import org.eclipse.net4j.util.tests.defs.TestDefsPackage;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.impl.EPackageImpl;
-
-/**
- * <!-- begin-user-doc --> An implementation of the model <b>Package</b>. <!-- end-user-doc -->
- *
- * @generated
- */
-public class TestDefsPackageImpl extends EPackageImpl implements TestDefsPackage
-{
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- private EClass testDefEClass = null;
-
- /**
- * Creates an instance of the model <b>Package</b>, registered with {@link org.eclipse.emf.ecore.EPackage.Registry
- * EPackage.Registry} by the package package URI value.
- * <p>
- * Note: the correct way to create the package is via the static factory method {@link #init init()}, which also
- * performs initialization of the package, or returns the registered package, if one already exists. <!--
- * begin-user-doc --> <!-- end-user-doc -->
- *
- * @see org.eclipse.emf.ecore.EPackage.Registry
- * @see org.eclipse.net4j.util.tests.defs.TestDefsPackage#eNS_URI
- * @see #init()
- * @generated
- */
- private TestDefsPackageImpl()
- {
- super(eNS_URI, TestDefsFactory.eINSTANCE);
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- private static boolean isInited = false;
-
- /**
- * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
- * <p>
- * This method is used to initialize {@link TestDefsPackage#eINSTANCE} when that field is accessed. Clients should not
- * invoke it directly. Instead, they should simply access that field to obtain the package. <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- *
- * @see #eNS_URI
- * @see #createPackageContents()
- * @see #initializePackageContents()
- * @generated
- */
- public static TestDefsPackage init()
- {
- if (isInited)
- {
- return (TestDefsPackage)EPackage.Registry.INSTANCE.getEPackage(TestDefsPackage.eNS_URI);
- }
-
- // Obtain or create and register package
- TestDefsPackageImpl theTestDefsPackage = (TestDefsPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof TestDefsPackageImpl ? EPackage.Registry.INSTANCE
- .get(eNS_URI) : new TestDefsPackageImpl());
-
- isInited = true;
-
- // Initialize simple dependencies
- Net4jUtilDefsPackage.eINSTANCE.eClass();
-
- // Create package meta-data objects
- theTestDefsPackage.createPackageContents();
-
- // Initialize created meta-data
- theTestDefsPackage.initializePackageContents();
-
- // Mark meta-data to indicate it can't be changed
- theTestDefsPackage.freeze();
-
- // Update the registry and return the package
- EPackage.Registry.INSTANCE.put(TestDefsPackage.eNS_URI, theTestDefsPackage);
- return theTestDefsPackage;
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public EClass getTestDef()
- {
- return testDefEClass;
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public EReference getTestDef_References()
- {
- return (EReference)testDefEClass.getEStructuralFeatures().get(0);
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public EAttribute getTestDef_Attribute()
- {
- return (EAttribute)testDefEClass.getEStructuralFeatures().get(1);
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public TestDefsFactory getTestDefsFactory()
- {
- return (TestDefsFactory)getEFactoryInstance();
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- private boolean isCreated = false;
-
- /**
- * Creates the meta-model objects for the package. This method is guarded to have no affect on any invocation but its
- * first. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public void createPackageContents()
- {
- if (isCreated)
- {
- return;
- }
- isCreated = true;
-
- // Create classes and their features
- testDefEClass = createEClass(TEST_DEF);
- createEReference(testDefEClass, TEST_DEF__REFERENCES);
- createEAttribute(testDefEClass, TEST_DEF__ATTRIBUTE);
- }
-
- /**
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- private boolean isInitialized = false;
-
- /**
- * Complete the initialization of the package and its meta-model. This method is guarded to have no affect on any
- * invocation but its first. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public void initializePackageContents()
- {
- if (isInitialized)
- {
- return;
- }
- isInitialized = true;
-
- // Initialize package
- setName(eNAME);
- setNsPrefix(eNS_PREFIX);
- setNsURI(eNS_URI);
-
- // Obtain other dependent packages
- Net4jUtilDefsPackage theNet4jUtilDefsPackage = (Net4jUtilDefsPackage)EPackage.Registry.INSTANCE
- .getEPackage(Net4jUtilDefsPackage.eNS_URI);
-
- // Create type parameters
-
- // Set bounds for type parameters
-
- // Add supertypes to classes
- testDefEClass.getESuperTypes().add(theNet4jUtilDefsPackage.getDef());
-
- // Initialize classes and features; add operations and parameters
- initEClass(testDefEClass, TestDef.class, "TestDef", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
- initEReference(getTestDef_References(), theNet4jUtilDefsPackage.getDef(), null, "references", null, 0, -1,
- TestDef.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE,
- IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEAttribute(getTestDef_Attribute(), ecorePackage.getEString(), "attribute", null, 0, 1, TestDef.class,
- !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
-
- // Create resource
- createResource(eNS_URI);
- }
-
-} // TestDefsPackageImpl
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.net4j.util.tests.defs.impl;
+
+import org.eclipse.net4j.util.defs.Net4jUtilDefsPackage;
+import org.eclipse.net4j.util.tests.defs.TestDef;
+import org.eclipse.net4j.util.tests.defs.TestDefsFactory;
+import org.eclipse.net4j.util.tests.defs.TestDefsPackage;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.impl.EPackageImpl;
+
+/**
+ * <!-- begin-user-doc --> An implementation of the model <b>Package</b>. <!-- end-user-doc -->
+ *
+ * @generated
+ */
+public class TestDefsPackageImpl extends EPackageImpl implements TestDefsPackage
+{
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ private EClass testDefEClass = null;
+
+ /**
+ * Creates an instance of the model <b>Package</b>, registered with {@link org.eclipse.emf.ecore.EPackage.Registry
+ * EPackage.Registry} by the package package URI value.
+ * <p>
+ * Note: the correct way to create the package is via the static factory method {@link #init init()}, which also
+ * performs initialization of the package, or returns the registered package, if one already exists. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see org.eclipse.emf.ecore.EPackage.Registry
+ * @see org.eclipse.net4j.util.tests.defs.TestDefsPackage#eNS_URI
+ * @see #init()
+ * @generated
+ */
+ private TestDefsPackageImpl()
+ {
+ super(eNS_URI, TestDefsFactory.eINSTANCE);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ private static boolean isInited = false;
+
+ /**
+ * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
+ * <p>
+ * This method is used to initialize {@link TestDefsPackage#eINSTANCE} when that field is accessed. Clients should not
+ * invoke it directly. Instead, they should simply access that field to obtain the package. <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @see #eNS_URI
+ * @see #createPackageContents()
+ * @see #initializePackageContents()
+ * @generated
+ */
+ public static TestDefsPackage init()
+ {
+ if (isInited)
+ {
+ return (TestDefsPackage)EPackage.Registry.INSTANCE.getEPackage(TestDefsPackage.eNS_URI);
+ }
+
+ // Obtain or create and register package
+ TestDefsPackageImpl theTestDefsPackage = (TestDefsPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof TestDefsPackageImpl ? EPackage.Registry.INSTANCE
+ .get(eNS_URI) : new TestDefsPackageImpl());
+
+ isInited = true;
+
+ // Initialize simple dependencies
+ Net4jUtilDefsPackage.eINSTANCE.eClass();
+
+ // Create package meta-data objects
+ theTestDefsPackage.createPackageContents();
+
+ // Initialize created meta-data
+ theTestDefsPackage.initializePackageContents();
+
+ // Mark meta-data to indicate it can't be changed
+ theTestDefsPackage.freeze();
+
+ // Update the registry and return the package
+ EPackage.Registry.INSTANCE.put(TestDefsPackage.eNS_URI, theTestDefsPackage);
+ return theTestDefsPackage;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EClass getTestDef()
+ {
+ return testDefEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EReference getTestDef_References()
+ {
+ return (EReference)testDefEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public EAttribute getTestDef_Attribute()
+ {
+ return (EAttribute)testDefEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public TestDefsFactory getTestDefsFactory()
+ {
+ return (TestDefsFactory)getEFactoryInstance();
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ private boolean isCreated = false;
+
+ /**
+ * Creates the meta-model objects for the package. This method is guarded to have no affect on any invocation but its
+ * first. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void createPackageContents()
+ {
+ if (isCreated)
+ {
+ return;
+ }
+ isCreated = true;
+
+ // Create classes and their features
+ testDefEClass = createEClass(TEST_DEF);
+ createEReference(testDefEClass, TEST_DEF__REFERENCES);
+ createEAttribute(testDefEClass, TEST_DEF__ATTRIBUTE);
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ private boolean isInitialized = false;
+
+ /**
+ * Complete the initialization of the package and its meta-model. This method is guarded to have no affect on any
+ * invocation but its first. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public void initializePackageContents()
+ {
+ if (isInitialized)
+ {
+ return;
+ }
+ isInitialized = true;
+
+ // Initialize package
+ setName(eNAME);
+ setNsPrefix(eNS_PREFIX);
+ setNsURI(eNS_URI);
+
+ // Obtain other dependent packages
+ Net4jUtilDefsPackage theNet4jUtilDefsPackage = (Net4jUtilDefsPackage)EPackage.Registry.INSTANCE
+ .getEPackage(Net4jUtilDefsPackage.eNS_URI);
+
+ // Create type parameters
+
+ // Set bounds for type parameters
+
+ // Add supertypes to classes
+ testDefEClass.getESuperTypes().add(theNet4jUtilDefsPackage.getDef());
+
+ // Initialize classes and features; add operations and parameters
+ initEClass(testDefEClass, TestDef.class, "TestDef", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEReference(getTestDef_References(), theNet4jUtilDefsPackage.getDef(), null, "references", null, 0, -1,
+ TestDef.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE,
+ IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getTestDef_Attribute(), ecorePackage.getEString(), "attribute", null, 0, 1, TestDef.class,
+ !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ // Create resource
+ createResource(eNS_URI);
+ }
+
+} // TestDefsPackageImpl
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/util/DefsAdapterFactory.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/util/DefsAdapterFactory.java
index c35abfbb1b..87a291a899 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/util/DefsAdapterFactory.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/util/DefsAdapterFactory.java
@@ -1,154 +1,154 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.net4j.util.tests.defs.util;
-
-import org.eclipse.net4j.util.defs.Def;
-import org.eclipse.net4j.util.tests.defs.DefsPackage;
-import org.eclipse.net4j.util.tests.defs.TestDef;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
-import org.eclipse.emf.ecore.EObject;
-
-/**
- * <!-- begin-user-doc --> The <b>Adapter Factory</b> for the model. It provides an adapter <code>createXXX</code>
- * method for each class of the model. <!-- end-user-doc -->
- *
- * @see org.eclipse.net4j.util.tests.defs.DefsPackage
- * @generated
- */
-public class DefsAdapterFactory extends AdapterFactoryImpl
-{
- /**
- * The cached model package. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- protected static DefsPackage modelPackage;
-
- /**
- * Creates an instance of the adapter factory. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public DefsAdapterFactory()
- {
- if (modelPackage == null)
- {
- modelPackage = DefsPackage.eINSTANCE;
- }
- }
-
- /**
- * Returns whether this factory is applicable for the type of the object. <!-- begin-user-doc --> This implementation
- * returns <code>true</code> if the object is either the model's package or is an instance object of the model. <!--
- * end-user-doc -->
- *
- * @return whether this factory is applicable for the type of the object.
- * @generated
- */
- @Override
- public boolean isFactoryForType(Object object)
- {
- if (object == modelPackage)
- {
- return true;
- }
- if (object instanceof EObject)
- {
- return ((EObject)object).eClass().getEPackage() == modelPackage;
- }
- return false;
- }
-
- /**
- * The switch that delegates to the <code>createXXX</code> methods. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- protected DefsSwitch<Adapter> modelSwitch = new DefsSwitch<Adapter>()
- {
- @Override
- public Adapter caseTestDef(TestDef object)
- {
- return createTestDefAdapter();
- }
-
- @Override
- public Adapter caseDef(Def object)
- {
- return createDefAdapter();
- }
-
- @Override
- public Adapter defaultCase(EObject object)
- {
- return createEObjectAdapter();
- }
- };
-
- /**
- * Creates an adapter for the <code>target</code>. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @param target
- * the object to adapt.
- * @return the adapter for the <code>target</code>.
- * @generated
- */
- @Override
- public Adapter createAdapter(Notifier target)
- {
- return modelSwitch.doSwitch((EObject)target);
- }
-
- /**
- * Creates a new adapter for an object of class '{@link org.eclipse.net4j.util.tests.defs.TestDef <em>Test Def</em>}'.
- * <!-- begin-user-doc --> This default implementation returns null so that we can easily ignore cases; it's useful to
- * ignore a case when inheritance will catch all the cases anyway. <!-- end-user-doc -->
- *
- * @return the new adapter.
- * @see org.eclipse.net4j.util.tests.defs.TestDef
- * @generated
- */
- public Adapter createTestDefAdapter()
- {
- return null;
- }
-
- /**
- * Creates a new adapter for an object of class '{@link org.eclipse.net4j.util.defs.Def <em>Def</em>}'. <!--
- * begin-user-doc --> This default implementation returns null so that we can easily ignore cases; it's useful to
- * ignore a case when inheritance will catch all the cases anyway. <!-- end-user-doc -->
- *
- * @return the new adapter.
- * @see org.eclipse.net4j.util.defs.Def
- * @generated
- */
- public Adapter createDefAdapter()
- {
- return null;
- }
-
- /**
- * Creates a new adapter for the default case. <!-- begin-user-doc --> This default implementation returns null. <!--
- * end-user-doc -->
- *
- * @return the new adapter.
- * @generated
- */
- public Adapter createEObjectAdapter()
- {
- return null;
- }
-
-} // DefsAdapterFactory
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.net4j.util.tests.defs.util;
+
+import org.eclipse.net4j.util.defs.Def;
+import org.eclipse.net4j.util.tests.defs.DefsPackage;
+import org.eclipse.net4j.util.tests.defs.TestDef;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc --> The <b>Adapter Factory</b> for the model. It provides an adapter <code>createXXX</code>
+ * method for each class of the model. <!-- end-user-doc -->
+ *
+ * @see org.eclipse.net4j.util.tests.defs.DefsPackage
+ * @generated
+ */
+public class DefsAdapterFactory extends AdapterFactoryImpl
+{
+ /**
+ * The cached model package. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected static DefsPackage modelPackage;
+
+ /**
+ * Creates an instance of the adapter factory. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public DefsAdapterFactory()
+ {
+ if (modelPackage == null)
+ {
+ modelPackage = DefsPackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Returns whether this factory is applicable for the type of the object. <!-- begin-user-doc --> This implementation
+ * returns <code>true</code> if the object is either the model's package or is an instance object of the model. <!--
+ * end-user-doc -->
+ *
+ * @return whether this factory is applicable for the type of the object.
+ * @generated
+ */
+ @Override
+ public boolean isFactoryForType(Object object)
+ {
+ if (object == modelPackage)
+ {
+ return true;
+ }
+ if (object instanceof EObject)
+ {
+ return ((EObject)object).eClass().getEPackage() == modelPackage;
+ }
+ return false;
+ }
+
+ /**
+ * The switch that delegates to the <code>createXXX</code> methods. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected DefsSwitch<Adapter> modelSwitch = new DefsSwitch<Adapter>()
+ {
+ @Override
+ public Adapter caseTestDef(TestDef object)
+ {
+ return createTestDefAdapter();
+ }
+
+ @Override
+ public Adapter caseDef(Def object)
+ {
+ return createDefAdapter();
+ }
+
+ @Override
+ public Adapter defaultCase(EObject object)
+ {
+ return createEObjectAdapter();
+ }
+ };
+
+ /**
+ * Creates an adapter for the <code>target</code>. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @param target
+ * the object to adapt.
+ * @return the adapter for the <code>target</code>.
+ * @generated
+ */
+ @Override
+ public Adapter createAdapter(Notifier target)
+ {
+ return modelSwitch.doSwitch((EObject)target);
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.net4j.util.tests.defs.TestDef <em>Test Def</em>}'.
+ * <!-- begin-user-doc --> This default implementation returns null so that we can easily ignore cases; it's useful to
+ * ignore a case when inheritance will catch all the cases anyway. <!-- end-user-doc -->
+ *
+ * @return the new adapter.
+ * @see org.eclipse.net4j.util.tests.defs.TestDef
+ * @generated
+ */
+ public Adapter createTestDefAdapter()
+ {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.net4j.util.defs.Def <em>Def</em>}'. <!--
+ * begin-user-doc --> This default implementation returns null so that we can easily ignore cases; it's useful to
+ * ignore a case when inheritance will catch all the cases anyway. <!-- end-user-doc -->
+ *
+ * @return the new adapter.
+ * @see org.eclipse.net4j.util.defs.Def
+ * @generated
+ */
+ public Adapter createDefAdapter()
+ {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for the default case. <!-- begin-user-doc --> This default implementation returns null. <!--
+ * end-user-doc -->
+ *
+ * @return the new adapter.
+ * @generated
+ */
+ public Adapter createEObjectAdapter()
+ {
+ return null;
+ }
+
+} // DefsAdapterFactory
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/util/DefsSwitch.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/util/DefsSwitch.java
index 741678837f..71f946b11a 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/util/DefsSwitch.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/util/DefsSwitch.java
@@ -1,162 +1,162 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.net4j.util.tests.defs.util;
-
-import org.eclipse.net4j.util.defs.Def;
-import org.eclipse.net4j.util.tests.defs.DefsPackage;
-import org.eclipse.net4j.util.tests.defs.TestDef;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-
-import java.util.List;
-
-/**
- * <!-- begin-user-doc --> The <b>Switch</b> for the model's inheritance hierarchy. It supports the call
- * {@link #doSwitch(EObject) doSwitch(object)} to invoke the <code>caseXXX</code> method for each class of the model,
- * starting with the actual class of the object and proceeding up the inheritance hierarchy until a non-null result is
- * returned, which is the result of the switch. <!-- end-user-doc -->
- *
- * @see org.eclipse.net4j.util.tests.defs.DefsPackage
- * @generated
- */
-public class DefsSwitch<T>
-{
- /**
- * The cached model package <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- protected static DefsPackage modelPackage;
-
- /**
- * Creates an instance of the switch. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public DefsSwitch()
- {
- if (modelPackage == null)
- {
- modelPackage = DefsPackage.eINSTANCE;
- }
- }
-
- /**
- * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @return the first non-null result returned by a <code>caseXXX</code> call.
- * @generated
- */
- public T doSwitch(EObject theEObject)
- {
- return doSwitch(theEObject.eClass(), theEObject);
- }
-
- /**
- * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @return the first non-null result returned by a <code>caseXXX</code> call.
- * @generated
- */
- protected T doSwitch(EClass theEClass, EObject theEObject)
- {
- if (theEClass.eContainer() == modelPackage)
- {
- return doSwitch(theEClass.getClassifierID(), theEObject);
- }
- else
- {
- List<EClass> eSuperTypes = theEClass.getESuperTypes();
- return eSuperTypes.isEmpty() ? defaultCase(theEObject) : doSwitch(eSuperTypes.get(0), theEObject);
- }
- }
-
- /**
- * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @return the first non-null result returned by a <code>caseXXX</code> call.
- * @generated
- */
- protected T doSwitch(int classifierID, EObject theEObject)
- {
- switch (classifierID)
- {
- case DefsPackage.TEST_DEF:
- {
- TestDef testDef = (TestDef)theEObject;
- T result = caseTestDef(testDef);
- if (result == null)
- {
- result = caseDef(testDef);
- }
- if (result == null)
- {
- result = defaultCase(theEObject);
- }
- return result;
- }
- default:
- return defaultCase(theEObject);
- }
- }
-
- /**
- * Returns the result of interpreting the object as an instance of '<em>Test Def</em>'. <!-- begin-user-doc --> This
- * implementation returns null; returning a non-null result will terminate the switch. <!-- end-user-doc -->
- *
- * @param object
- * the target of the switch.
- * @return the result of interpreting the object as an instance of '<em>Test Def</em>'.
- * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
- * @generated
- */
- public T caseTestDef(TestDef object)
- {
- return null;
- }
-
- /**
- * Returns the result of interpreting the object as an instance of '<em>Def</em>'. <!-- begin-user-doc --> This
- * implementation returns null; returning a non-null result will terminate the switch. <!-- end-user-doc -->
- *
- * @param object
- * the target of the switch.
- * @return the result of interpreting the object as an instance of '<em>Def</em>'.
- * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
- * @generated
- */
- public T caseDef(Def object)
- {
- return null;
- }
-
- /**
- * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. <!-- begin-user-doc --> This
- * implementation returns null; returning a non-null result will terminate the switch, but this is the last case
- * anyway. <!-- end-user-doc -->
- *
- * @param object
- * the target of the switch.
- * @return the result of interpreting the object as an instance of '<em>EObject</em>'.
- * @see #doSwitch(org.eclipse.emf.ecore.EObject)
- * @generated
- */
- public T defaultCase(EObject object)
- {
- return null;
- }
-
-} // DefsSwitch
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.net4j.util.tests.defs.util;
+
+import org.eclipse.net4j.util.defs.Def;
+import org.eclipse.net4j.util.tests.defs.DefsPackage;
+import org.eclipse.net4j.util.tests.defs.TestDef;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+
+import java.util.List;
+
+/**
+ * <!-- begin-user-doc --> The <b>Switch</b> for the model's inheritance hierarchy. It supports the call
+ * {@link #doSwitch(EObject) doSwitch(object)} to invoke the <code>caseXXX</code> method for each class of the model,
+ * starting with the actual class of the object and proceeding up the inheritance hierarchy until a non-null result is
+ * returned, which is the result of the switch. <!-- end-user-doc -->
+ *
+ * @see org.eclipse.net4j.util.tests.defs.DefsPackage
+ * @generated
+ */
+public class DefsSwitch<T>
+{
+ /**
+ * The cached model package <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected static DefsPackage modelPackage;
+
+ /**
+ * Creates an instance of the switch. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public DefsSwitch()
+ {
+ if (modelPackage == null)
+ {
+ modelPackage = DefsPackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the first non-null result returned by a <code>caseXXX</code> call.
+ * @generated
+ */
+ public T doSwitch(EObject theEObject)
+ {
+ return doSwitch(theEObject.eClass(), theEObject);
+ }
+
+ /**
+ * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the first non-null result returned by a <code>caseXXX</code> call.
+ * @generated
+ */
+ protected T doSwitch(EClass theEClass, EObject theEObject)
+ {
+ if (theEClass.eContainer() == modelPackage)
+ {
+ return doSwitch(theEClass.getClassifierID(), theEObject);
+ }
+ else
+ {
+ List<EClass> eSuperTypes = theEClass.getESuperTypes();
+ return eSuperTypes.isEmpty() ? defaultCase(theEObject) : doSwitch(eSuperTypes.get(0), theEObject);
+ }
+ }
+
+ /**
+ * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the first non-null result returned by a <code>caseXXX</code> call.
+ * @generated
+ */
+ protected T doSwitch(int classifierID, EObject theEObject)
+ {
+ switch (classifierID)
+ {
+ case DefsPackage.TEST_DEF:
+ {
+ TestDef testDef = (TestDef)theEObject;
+ T result = caseTestDef(testDef);
+ if (result == null)
+ {
+ result = caseDef(testDef);
+ }
+ if (result == null)
+ {
+ result = defaultCase(theEObject);
+ }
+ return result;
+ }
+ default:
+ return defaultCase(theEObject);
+ }
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>Test Def</em>'. <!-- begin-user-doc --> This
+ * implementation returns null; returning a non-null result will terminate the switch. <!-- end-user-doc -->
+ *
+ * @param object
+ * the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>Test Def</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseTestDef(TestDef object)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>Def</em>'. <!-- begin-user-doc --> This
+ * implementation returns null; returning a non-null result will terminate the switch. <!-- end-user-doc -->
+ *
+ * @param object
+ * the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>Def</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseDef(Def object)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. <!-- begin-user-doc --> This
+ * implementation returns null; returning a non-null result will terminate the switch, but this is the last case
+ * anyway. <!-- end-user-doc -->
+ *
+ * @param object
+ * the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>EObject</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject)
+ * @generated
+ */
+ public T defaultCase(EObject object)
+ {
+ return null;
+ }
+
+} // DefsSwitch
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/util/TestDefsAdapterFactory.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/util/TestDefsAdapterFactory.java
index 24345ee567..7546235903 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/util/TestDefsAdapterFactory.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/util/TestDefsAdapterFactory.java
@@ -1,154 +1,154 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.net4j.util.tests.defs.util;
-
-import org.eclipse.net4j.util.defs.Def;
-import org.eclipse.net4j.util.tests.defs.TestDef;
-import org.eclipse.net4j.util.tests.defs.TestDefsPackage;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
-import org.eclipse.emf.ecore.EObject;
-
-/**
- * <!-- begin-user-doc --> The <b>Adapter Factory</b> for the model. It provides an adapter <code>createXXX</code>
- * method for each class of the model. <!-- end-user-doc -->
- *
- * @see org.eclipse.net4j.util.tests.defs.TestDefsPackage
- * @generated
- */
-public class TestDefsAdapterFactory extends AdapterFactoryImpl
-{
- /**
- * The cached model package. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- protected static TestDefsPackage modelPackage;
-
- /**
- * Creates an instance of the adapter factory. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public TestDefsAdapterFactory()
- {
- if (modelPackage == null)
- {
- modelPackage = TestDefsPackage.eINSTANCE;
- }
- }
-
- /**
- * Returns whether this factory is applicable for the type of the object. <!-- begin-user-doc --> This implementation
- * returns <code>true</code> if the object is either the model's package or is an instance object of the model. <!--
- * end-user-doc -->
- *
- * @return whether this factory is applicable for the type of the object.
- * @generated
- */
- @Override
- public boolean isFactoryForType(Object object)
- {
- if (object == modelPackage)
- {
- return true;
- }
- if (object instanceof EObject)
- {
- return ((EObject)object).eClass().getEPackage() == modelPackage;
- }
- return false;
- }
-
- /**
- * The switch that delegates to the <code>createXXX</code> methods. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- protected TestDefsSwitch<Adapter> modelSwitch = new TestDefsSwitch<Adapter>()
- {
- @Override
- public Adapter caseTestDef(TestDef object)
- {
- return createTestDefAdapter();
- }
-
- @Override
- public Adapter caseDef(Def object)
- {
- return createDefAdapter();
- }
-
- @Override
- public Adapter defaultCase(EObject object)
- {
- return createEObjectAdapter();
- }
- };
-
- /**
- * Creates an adapter for the <code>target</code>. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @param target
- * the object to adapt.
- * @return the adapter for the <code>target</code>.
- * @generated
- */
- @Override
- public Adapter createAdapter(Notifier target)
- {
- return modelSwitch.doSwitch((EObject)target);
- }
-
- /**
- * Creates a new adapter for an object of class '{@link org.eclipse.net4j.util.tests.defs.TestDef <em>Test Def</em>}'.
- * <!-- begin-user-doc --> This default implementation returns null so that we can easily ignore cases; it's useful to
- * ignore a case when inheritance will catch all the cases anyway. <!-- end-user-doc -->
- *
- * @return the new adapter.
- * @see org.eclipse.net4j.util.tests.defs.TestDef
- * @generated
- */
- public Adapter createTestDefAdapter()
- {
- return null;
- }
-
- /**
- * Creates a new adapter for an object of class '{@link org.eclipse.net4j.util.defs.Def <em>Def</em>}'. <!--
- * begin-user-doc --> This default implementation returns null so that we can easily ignore cases; it's useful to
- * ignore a case when inheritance will catch all the cases anyway. <!-- end-user-doc -->
- *
- * @return the new adapter.
- * @see org.eclipse.net4j.util.defs.Def
- * @generated
- */
- public Adapter createDefAdapter()
- {
- return null;
- }
-
- /**
- * Creates a new adapter for the default case. <!-- begin-user-doc --> This default implementation returns null. <!--
- * end-user-doc -->
- *
- * @return the new adapter.
- * @generated
- */
- public Adapter createEObjectAdapter()
- {
- return null;
- }
-
-} // TestDefsAdapterFactory
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.net4j.util.tests.defs.util;
+
+import org.eclipse.net4j.util.defs.Def;
+import org.eclipse.net4j.util.tests.defs.TestDef;
+import org.eclipse.net4j.util.tests.defs.TestDefsPackage;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc --> The <b>Adapter Factory</b> for the model. It provides an adapter <code>createXXX</code>
+ * method for each class of the model. <!-- end-user-doc -->
+ *
+ * @see org.eclipse.net4j.util.tests.defs.TestDefsPackage
+ * @generated
+ */
+public class TestDefsAdapterFactory extends AdapterFactoryImpl
+{
+ /**
+ * The cached model package. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected static TestDefsPackage modelPackage;
+
+ /**
+ * Creates an instance of the adapter factory. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public TestDefsAdapterFactory()
+ {
+ if (modelPackage == null)
+ {
+ modelPackage = TestDefsPackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Returns whether this factory is applicable for the type of the object. <!-- begin-user-doc --> This implementation
+ * returns <code>true</code> if the object is either the model's package or is an instance object of the model. <!--
+ * end-user-doc -->
+ *
+ * @return whether this factory is applicable for the type of the object.
+ * @generated
+ */
+ @Override
+ public boolean isFactoryForType(Object object)
+ {
+ if (object == modelPackage)
+ {
+ return true;
+ }
+ if (object instanceof EObject)
+ {
+ return ((EObject)object).eClass().getEPackage() == modelPackage;
+ }
+ return false;
+ }
+
+ /**
+ * The switch that delegates to the <code>createXXX</code> methods. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected TestDefsSwitch<Adapter> modelSwitch = new TestDefsSwitch<Adapter>()
+ {
+ @Override
+ public Adapter caseTestDef(TestDef object)
+ {
+ return createTestDefAdapter();
+ }
+
+ @Override
+ public Adapter caseDef(Def object)
+ {
+ return createDefAdapter();
+ }
+
+ @Override
+ public Adapter defaultCase(EObject object)
+ {
+ return createEObjectAdapter();
+ }
+ };
+
+ /**
+ * Creates an adapter for the <code>target</code>. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @param target
+ * the object to adapt.
+ * @return the adapter for the <code>target</code>.
+ * @generated
+ */
+ @Override
+ public Adapter createAdapter(Notifier target)
+ {
+ return modelSwitch.doSwitch((EObject)target);
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.net4j.util.tests.defs.TestDef <em>Test Def</em>}'.
+ * <!-- begin-user-doc --> This default implementation returns null so that we can easily ignore cases; it's useful to
+ * ignore a case when inheritance will catch all the cases anyway. <!-- end-user-doc -->
+ *
+ * @return the new adapter.
+ * @see org.eclipse.net4j.util.tests.defs.TestDef
+ * @generated
+ */
+ public Adapter createTestDefAdapter()
+ {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.net4j.util.defs.Def <em>Def</em>}'. <!--
+ * begin-user-doc --> This default implementation returns null so that we can easily ignore cases; it's useful to
+ * ignore a case when inheritance will catch all the cases anyway. <!-- end-user-doc -->
+ *
+ * @return the new adapter.
+ * @see org.eclipse.net4j.util.defs.Def
+ * @generated
+ */
+ public Adapter createDefAdapter()
+ {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for the default case. <!-- begin-user-doc --> This default implementation returns null. <!--
+ * end-user-doc -->
+ *
+ * @return the new adapter.
+ * @generated
+ */
+ public Adapter createEObjectAdapter()
+ {
+ return null;
+ }
+
+} // TestDefsAdapterFactory
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/util/TestDefsSwitch.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/util/TestDefsSwitch.java
index c350c3cf11..2eecf1eb23 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/util/TestDefsSwitch.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/defs/util/TestDefsSwitch.java
@@ -1,162 +1,162 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.net4j.util.tests.defs.util;
-
-import org.eclipse.net4j.util.defs.Def;
-import org.eclipse.net4j.util.tests.defs.TestDef;
-import org.eclipse.net4j.util.tests.defs.TestDefsPackage;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-
-import java.util.List;
-
-/**
- * <!-- begin-user-doc --> The <b>Switch</b> for the model's inheritance hierarchy. It supports the call
- * {@link #doSwitch(EObject) doSwitch(object)} to invoke the <code>caseXXX</code> method for each class of the model,
- * starting with the actual class of the object and proceeding up the inheritance hierarchy until a non-null result is
- * returned, which is the result of the switch. <!-- end-user-doc -->
- *
- * @see org.eclipse.net4j.util.tests.defs.TestDefsPackage
- * @generated
- */
-public class TestDefsSwitch<T>
-{
- /**
- * The cached model package <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- protected static TestDefsPackage modelPackage;
-
- /**
- * Creates an instance of the switch. <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- public TestDefsSwitch()
- {
- if (modelPackage == null)
- {
- modelPackage = TestDefsPackage.eINSTANCE;
- }
- }
-
- /**
- * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @return the first non-null result returned by a <code>caseXXX</code> call.
- * @generated
- */
- public T doSwitch(EObject theEObject)
- {
- return doSwitch(theEObject.eClass(), theEObject);
- }
-
- /**
- * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @return the first non-null result returned by a <code>caseXXX</code> call.
- * @generated
- */
- protected T doSwitch(EClass theEClass, EObject theEObject)
- {
- if (theEClass.eContainer() == modelPackage)
- {
- return doSwitch(theEClass.getClassifierID(), theEObject);
- }
- else
- {
- List<EClass> eSuperTypes = theEClass.getESuperTypes();
- return eSuperTypes.isEmpty() ? defaultCase(theEObject) : doSwitch(eSuperTypes.get(0), theEObject);
- }
- }
-
- /**
- * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
- * <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @return the first non-null result returned by a <code>caseXXX</code> call.
- * @generated
- */
- protected T doSwitch(int classifierID, EObject theEObject)
- {
- switch (classifierID)
- {
- case TestDefsPackage.TEST_DEF:
- {
- TestDef testDef = (TestDef)theEObject;
- T result = caseTestDef(testDef);
- if (result == null)
- {
- result = caseDef(testDef);
- }
- if (result == null)
- {
- result = defaultCase(theEObject);
- }
- return result;
- }
- default:
- return defaultCase(theEObject);
- }
- }
-
- /**
- * Returns the result of interpreting the object as an instance of '<em>Test Def</em>'. <!-- begin-user-doc --> This
- * implementation returns null; returning a non-null result will terminate the switch. <!-- end-user-doc -->
- *
- * @param object
- * the target of the switch.
- * @return the result of interpreting the object as an instance of '<em>Test Def</em>'.
- * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
- * @generated
- */
- public T caseTestDef(TestDef object)
- {
- return null;
- }
-
- /**
- * Returns the result of interpreting the object as an instance of '<em>Def</em>'. <!-- begin-user-doc --> This
- * implementation returns null; returning a non-null result will terminate the switch. <!-- end-user-doc -->
- *
- * @param object
- * the target of the switch.
- * @return the result of interpreting the object as an instance of '<em>Def</em>'.
- * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
- * @generated
- */
- public T caseDef(Def object)
- {
- return null;
- }
-
- /**
- * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. <!-- begin-user-doc --> This
- * implementation returns null; returning a non-null result will terminate the switch, but this is the last case
- * anyway. <!-- end-user-doc -->
- *
- * @param object
- * the target of the switch.
- * @return the result of interpreting the object as an instance of '<em>EObject</em>'.
- * @see #doSwitch(org.eclipse.emf.ecore.EObject)
- * @generated
- */
- public T defaultCase(EObject object)
- {
- return null;
- }
-
-} // TestDefsSwitch
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.net4j.util.tests.defs.util;
+
+import org.eclipse.net4j.util.defs.Def;
+import org.eclipse.net4j.util.tests.defs.TestDef;
+import org.eclipse.net4j.util.tests.defs.TestDefsPackage;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+
+import java.util.List;
+
+/**
+ * <!-- begin-user-doc --> The <b>Switch</b> for the model's inheritance hierarchy. It supports the call
+ * {@link #doSwitch(EObject) doSwitch(object)} to invoke the <code>caseXXX</code> method for each class of the model,
+ * starting with the actual class of the object and proceeding up the inheritance hierarchy until a non-null result is
+ * returned, which is the result of the switch. <!-- end-user-doc -->
+ *
+ * @see org.eclipse.net4j.util.tests.defs.TestDefsPackage
+ * @generated
+ */
+public class TestDefsSwitch<T>
+{
+ /**
+ * The cached model package <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected static TestDefsPackage modelPackage;
+
+ /**
+ * Creates an instance of the switch. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public TestDefsSwitch()
+ {
+ if (modelPackage == null)
+ {
+ modelPackage = TestDefsPackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the first non-null result returned by a <code>caseXXX</code> call.
+ * @generated
+ */
+ public T doSwitch(EObject theEObject)
+ {
+ return doSwitch(theEObject.eClass(), theEObject);
+ }
+
+ /**
+ * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the first non-null result returned by a <code>caseXXX</code> call.
+ * @generated
+ */
+ protected T doSwitch(EClass theEClass, EObject theEObject)
+ {
+ if (theEClass.eContainer() == modelPackage)
+ {
+ return doSwitch(theEClass.getClassifierID(), theEObject);
+ }
+ else
+ {
+ List<EClass> eSuperTypes = theEClass.getESuperTypes();
+ return eSuperTypes.isEmpty() ? defaultCase(theEObject) : doSwitch(eSuperTypes.get(0), theEObject);
+ }
+ }
+
+ /**
+ * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the first non-null result returned by a <code>caseXXX</code> call.
+ * @generated
+ */
+ protected T doSwitch(int classifierID, EObject theEObject)
+ {
+ switch (classifierID)
+ {
+ case TestDefsPackage.TEST_DEF:
+ {
+ TestDef testDef = (TestDef)theEObject;
+ T result = caseTestDef(testDef);
+ if (result == null)
+ {
+ result = caseDef(testDef);
+ }
+ if (result == null)
+ {
+ result = defaultCase(theEObject);
+ }
+ return result;
+ }
+ default:
+ return defaultCase(theEObject);
+ }
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>Test Def</em>'. <!-- begin-user-doc --> This
+ * implementation returns null; returning a non-null result will terminate the switch. <!-- end-user-doc -->
+ *
+ * @param object
+ * the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>Test Def</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseTestDef(TestDef object)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>Def</em>'. <!-- begin-user-doc --> This
+ * implementation returns null; returning a non-null result will terminate the switch. <!-- end-user-doc -->
+ *
+ * @param object
+ * the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>Def</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseDef(Def object)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. <!-- begin-user-doc --> This
+ * implementation returns null; returning a non-null result will terminate the switch, but this is the last case
+ * anyway. <!-- end-user-doc -->
+ *
+ * @param object
+ * the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>EObject</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject)
+ * @generated
+ */
+ public T defaultCase(EObject object)
+ {
+ return null;
+ }
+
+} // TestDefsSwitch

Back to the top