Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2010-04-21 15:03:16 +0000
committerEike Stepper2010-04-21 15:03:16 +0000
commit74c29c47dd8c7180f5d9d2e341342de39fed01fb (patch)
treed020624e00c7a1dfcefbc7001b6701880e8c6cf0 /plugins
parente9c4dc88e587cd50c791cca7224217cae8809df9 (diff)
downloadcdo-74c29c47dd8c7180f5d9d2e341342de39fed01fb.tar.gz
cdo-74c29c47dd8c7180f5d9d2e341342de39fed01fb.tar.xz
cdo-74c29c47dd8c7180f5d9d2e341342de39fed01fb.zip
[256936] Support for Offline Mode
https://bugs.eclipse.org/bugs/show_bug.cgi?id=256936
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java14
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/StreamWrapperTest.java46
2 files changed, 57 insertions, 3 deletions
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 9687336dbc..5fe0cbf6ef 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
@@ -18,6 +18,7 @@ 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;
@@ -103,7 +104,7 @@ public class SignalTest extends AbstractProtocolTest
}
}
- public void _testCloseSocketChannel() throws Exception
+ public void testCloseSocketChannel() throws Exception
{
TestSignalProtocol protocol = null;
@@ -111,10 +112,17 @@ public class SignalTest extends AbstractProtocolTest
{
startTransport();
protocol = new TestSignalProtocol(getConnector());
+ final ILifecycle lifecycle = protocol;
closeSocketChannel((TCPConnector)getAcceptor().getAcceptedConnectors()[0]);
- sleep(1000); // TODO Better timeout for server build!
- assertEquals(false, protocol.isActive());
+ new PollingTimeOuter()
+ {
+ @Override
+ protected boolean successful()
+ {
+ return lifecycle.isActive();
+ }
+ }.assertNoTimeOut();
}
finally
{
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
new file mode 100644
index 0000000000..26cc4693d8
--- /dev/null
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/StreamWrapperTest.java
@@ -0,0 +1,46 @@
+/**
+ * Copyright (c) 2004 - 2010 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());
+ }
+}

Back to the top