Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/common/ConsoleOutputStreamTests.java')
-rwxr-xr-xbundles/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/common/ConsoleOutputStreamTests.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/common/ConsoleOutputStreamTests.java b/bundles/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/common/ConsoleOutputStreamTests.java
new file mode 100755
index 000000000..c1044ee8b
--- /dev/null
+++ b/bundles/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/common/ConsoleOutputStreamTests.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2011 SAP AG
+ * 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:
+ * Lazar Kirchev, SAP AG - initial contribution
+ ******************************************************************************/
+
+package org.eclipse.equinox.console.common;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.ByteArrayOutputStream;
+
+public class ConsoleOutputStreamTests {
+
+ private static final int DATA_LENGTH = 4;
+
+ @Test
+ public void testWrite() throws Exception {
+ ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
+ ConsoleOutputStream out = new ConsoleOutputStream(byteOut);
+ byte[] data = new byte[] { 'a', 'b', 'c', 'd' };
+ for (byte b : data) {
+ out.write(b);
+ }
+ out.flush();
+ byte[] res = byteOut.toByteArray();
+
+ Assert.assertNotNull("Bytes not written; result null", res);
+ Assert.assertFalse("Bytes not written; result empty", res.length == 0);
+
+ for (int i = 0; i < DATA_LENGTH; i++) {
+ Assert.assertEquals("Wrong char read. Position " + i + ", expected " + data[i] + ", read " + res[i], data[i], res[i]);
+ }
+ }
+}

Back to the top